zack 1 år sedan
förälder
incheckning
1b9e342b8c

+ 27 - 0
Core/Inc/ConfigMacros.h

@@ -94,7 +94,22 @@ do { \
 	refresh = true;\
 } while(0)
 
+#define RESET_4G_MODULE() \
+do { \
+	if(reset4Gmodule) { \
+		reset4Gmodule = false; \
+		HAL_Delay(1500); \
+		ML307A_Init(); \
+	} \
+} while(0)
 
+#define HANDLE_RETURN_INTERFACE() \
+do { \
+	if(returnInterface) { \
+		returnInterface = false; \
+		SET_MENU_STATUS(0, 0, 0, 0); \
+	} \
+} while(0)
 
 
 typedef struct
@@ -152,6 +167,18 @@ typedef enum {
     TxPower = 4
 } BtStep;
 
+typedef enum {
+    ATOK = 0,
+    CFUN = 1,
+    SIMH = 2,
+    CPIN = 3,
+    CEREG = 4,
+    MLB1 = 5,
+    MLB2 = 6,
+    MLB3 = 7,
+    MLB4 = 8,
+	ML307AStepReset = 9
+} ML307AStep;
 
 typedef enum {
     Default = 0,

+ 17 - 0
Core/Inc/keyboard.h

@@ -0,0 +1,17 @@
+#ifndef __KEYBOARD_H
+#define __KEYBOARD_H
+
+
+#include "main.h"
+
+
+
+
+void keyboard(void);
+
+
+
+
+
+#endif /*__KEYBOARD_H*/
+

+ 2 - 1
Core/Inc/ml307a.h

@@ -9,10 +9,11 @@ extern bool u4RecvFlag;
 extern uint8_t g_ML307A_8buf[2048]; 
 extern uint8_t g_ML307A_8buf_Down[2048];
 
+extern bool module4G_F;
 extern bool reset4Gmodule;
 
 void ML307A_Init(void);
-
+void loction_4G(void);
 
 #endif /*__ML307A_H*/
 

+ 10 - 18
Core/Src/freertos.c

@@ -28,8 +28,8 @@
 
 #include "key.h"
 #include "usart.h"
-void Jump_interface(Menu_table menu);
 extern Menu_table menu;
+void Jump_interface(Menu_table menu);
 /* USER CODE END Includes */
 
 /* Private typedef -----------------------------------------------------------*/
@@ -147,12 +147,14 @@ void StartScanKeyTask(void const * argument)
   for(;;)
   {
     osDelay(1);
-	updatekeystate(); 
-	modifyOledBmp();
-    Jump_interface(menu); 
-    OLED_Refresh(); 
-	open_close_lock();
-	workinfo_W();
+	updatekeystate(); 				//扫描键值
+	modifyOledBmp();				//修改锁图
+    Jump_interface(menu); 			//跳转界面
+    OLED_Refresh(); 				//刷新界面
+	open_close_lock();				//施解操作
+	//workinfo_W();
+	HANDLE_RETURN_INTERFACE();		//界面超时
+	RESET_4G_MODULE();				//4G启动(复位)
   }
   /* USER CODE END StartScanKeyTask */
 }
@@ -193,17 +195,7 @@ void StartTestTask(void const * argument)
   for(;;)
   {
     osDelay(1);
-	if(reset4Gmodule) { 
-		reset4Gmodule = false; 
-		HAL_Delay(1800);//等待4G启动
-        ML307A_Init(); 
-    }	
-	if(returnInterface)
-	{
-		returnInterface=false;
-		SET_MENU_STATUS(0,0,0,0);
-	}
-		  
+	loction_4G();
   }
   /* USER CODE END StartTestTask */
 }

+ 15 - 17
Core/Src/interface.c

@@ -1,5 +1,7 @@
 #include "interface.h"
 #include "bmp.h"
+#include "keyboard.h"
+
 
 /**
   * @breaf 굶女땍屢긴좆
@@ -56,7 +58,6 @@ void LBinding(void);	//0x02
 void setLock(void);		//0x03
 void workSet(Menu_table menu); //0x04 0x05 0x06 0x07
 
-
 void Mac_slicing(void);	//0xA0 MAC학욥
 void Macbinding01_0F(void);	//0xA1
 void Macbinding10_1F(void);//0xA2
@@ -77,6 +78,8 @@ void Jump_interface(Menu_table menu)
 	{
 		case 0:
 			home(menu.home,L1bd,L2bd,L3bd,L4bd);
+			//keyboard();
+			//Mac_slicing();
 		break;
 		
 		case 1:
@@ -162,22 +165,22 @@ void Jump_interface(Menu_table menu)
 
 void Mac_slicing(void)//MAC학욥
 {
-    OLED_ShowString(8, 0,(unsigned char*)"> MacSlicing <", 16, 0);
-	OLED_ShowString(0,20,(unsigned char*)"MAC:0001-000F",16,1);
-	OLED_ShowString(0,35,(unsigned char*)"MAC:0010-001F",16,1);
+    OLED_ShowString(19, 0,(unsigned char*)"> Mac Choose <", 12, 0);
+	OLED_ShowString(0,11,(unsigned char*)"MAC:0001-000F",16,1);
+	OLED_ShowString(0,26,(unsigned char*)"MAC:0010-001F",16,1);
 	if(menu.up==1)
 	{	
-		OLED_ShowString(110,20,(unsigned char*)"<-",16,0);
+		OLED_ShowString(110,11,(unsigned char*)"<-",16,0);
 	}
 	else
 	{	
-		OLED_ShowString(110,35,(unsigned char*)"<-",16,0);
+		OLED_ShowString(110,26,(unsigned char*)"<-",16,0);
 	}
 }
 
-void clearSn(void)
+void clearSn(void)//헌왕곬땍斤口
 {
-	//헌왕곬땍斤口
+	
 	OLED_ShowChinese(10,25,35,16,1);
 	OLED_ShowChinese(30,25,36,16,1);
 	OLED_ShowChinese(50,25,37,16,1);
@@ -186,7 +189,7 @@ void clearSn(void)
 	OLED_ShowChinese(110,25,40,16,1);
 }
 
-void setLock(void)
+void setLock(void)//꾸鱗꽉데
 {
 	OLED_ShowString(20,2,(unsigned char*)"L 1",16,1);
 	OLED_ShowChinese(50,2,20,14,1);//꾸
@@ -219,17 +222,15 @@ void setLock(void)
 	}
 }
 
-void workSet(Menu_table menu)
+void workSet(Menu_table menu)//嘉썩룐썹충
 {
-	OLED_ShowString(4,8,(unsigned char*)"SN:",16,1);
-	OLED_ShowString(0,8,(unsigned char*)"LOCKNAME:",12,1);
+	//OLED_ShowString(4,8,(unsigned char*)"SN:",16,1);
+	OLED_ShowString(0,8,(unsigned char*)"LOCK_SN:",12,1);
 	OLED_ShowChinese(55,12,0,18,1);//嘉
 	OLED_ShowChinese(75,12,1,18,1);//룐
 	OLED_ShowChinese(55,40,2,18,1);//썩
 	OLED_ShowChinese(75,40,3,18,1);//룐
 
-
-	
 	if(menu.current==4)
 	{
 		OLED_ShowString(0,30,(unsigned char*)menu.SN1name,16,0);
@@ -1256,6 +1257,3 @@ void home(uint32_t L_s, bool L1bd, bool L2bd, bool L3bd, bool L4bd)
 		}
 	}
 }
-
-
-

+ 40 - 0
Core/Src/keyboard.c

@@ -0,0 +1,40 @@
+#include "keyboard.h"
+
+
+
+
+
+void keyboard(void)
+{
+	
+	OLED_ShowString(19,0,(unsigned char*)" >DtuKeyboard< ",12,0);   
+	
+	OLED_ShowString(5,17,(unsigned char*)"0",16,1);     
+	OLED_ShowString(20,17,(unsigned char*)"1",16,1);     
+	OLED_ShowString(35,17,(unsigned char*)"2",16,1);    
+	OLED_ShowString(50,17,(unsigned char*)"3",16,1);    
+	OLED_ShowString(65,17,(unsigned char*)"4",16,1);    
+	OLED_ShowString(80,17,(unsigned char*)"5",16,1);    
+	
+	OLED_ShowString(5,32,(unsigned char*)"6",16,1);   
+	OLED_ShowString(20,32,(unsigned char*)"7",16,1);    
+	OLED_ShowString(35,32,(unsigned char*)"8",16,1);    
+	OLED_ShowString(50,32,(unsigned char*)"9",16,1);  
+	OLED_ShowString(65,32,(unsigned char*)"A",16,1);    
+	OLED_ShowString(80,32,(unsigned char*)"B",16,1);   
+	
+	
+	OLED_ShowString(5,47,(unsigned char*)"C",16,1);     
+	OLED_ShowString(20,47,(unsigned char*)"D",16,1);  
+	OLED_ShowString(35,47,(unsigned char*)"E",16,1);     
+	OLED_ShowString(50,47,(unsigned char*)"F",16,1);     
+	
+}
+
+
+
+
+
+
+
+

+ 2 - 3
Core/Src/main.c

@@ -45,9 +45,9 @@
 /* Private macro -------------------------------------------------------------*/
 /* USER CODE BEGIN PM */
 
+extern bool refresh;
 extern Menu_table menu;
 extern BtFrame btframe;
-extern bool refresh;
 extern TipsFlag tipsflag;
 /* USER CODE END PM */
 
@@ -122,7 +122,7 @@ int main(void)
   MBA32A_Init();
 #endif
 #if open4G==1
-  //reset4Gmodule = true;//ML307A_Init();
+  reset4Gmodule = true;//ML307A_Init();
 #endif
   /* USER CODE END 2 */
 
@@ -280,7 +280,6 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
   if (htim->Instance == TIM1) {
     HAL_IncTick();
   }
-
   /* USER CODE BEGIN Callback 1 */
 	//ι¿´ÃŹ·
 	TOGGLE_WDI_PIN(&htim2);

+ 11 - 10
Core/Src/mba32a.c

@@ -6,13 +6,13 @@
 extern UART_HandleTypeDef huart5;
 extern Menu_table menu;	
 
-BtFrame btframe;
-uint8_t resetcount_bt=0;
-uint16_t resetFlag16=0;
 BtStep btstep;
-uint16_t u5length=0;
+BtFrame btframe;
 bool resetBTmodule = false;
+uint16_t u5length=0;
 uint16_t displayNum=0;
+uint16_t resetFlag16=0;
+uint8_t resetcount_bt=0;
 uint16_t 	bt_dataLength=0;				//bt接收有效数据长度
 uint8_t 	bt_error_num=0;					//bt接收的错误事件
 uint32_t 	bt_serial_num=0;				//bt接收的流水号
@@ -167,6 +167,8 @@ void MBA32A_Init(void)
 
 	menu.current=0;//回到初始
 	refresh=true;
+
+	
 }
 
 
@@ -176,13 +178,12 @@ void MBA32A_Init(void)
 /**
   * @breaf 串口发送命令子函数
   */
-
-
 void USART_SendString(UART_HandleTypeDef *huart,char *str)
 {
-	printf("\r\nCMD:\t");
-	HAL_UART_Transmit(huart, (uint8_t*)str, strlen(str), 0xFFFF);
-    HAL_UART_Transmit(&huart3, (uint8_t*)str, strlen(str), 0xFFFF);
+	printf("\r\nAT_CMD:\t");
+	HAL_UART_Transmit(huart, (uint8_t*)str, strlen(str), 0xFFFF);		//工作信息串口发送
+    HAL_UART_Transmit(&huart1, (uint8_t*)str, strlen(str), 0xFFFF);		//485打印log
+    //HAL_UART_Transmit(&huart3, (uint8_t*)str, strlen(str), 0xFFFF);	//TTL打印log
 	
 }
 /**
@@ -534,7 +535,7 @@ void open_close_lock(void)
 		S2 = read_flash_16(Sn2StatusAddr);
 		S3 = read_flash_16(Sn3StatusAddr);
 		S4 = read_flash_16(Sn4StatusAddr);
-		HAL_Delay(100);
+		HAL_Delay(50);
 		menu.enter=3;
         refresh = true;
     }

+ 153 - 44
Core/Src/ml307a.c

@@ -2,75 +2,165 @@
 #include "mba32a.h"
 #include "usart.h"
 
-
-uint8_t u4length=0;
-uint8_t resetcount_4g=0;
+ML307AStep ml307astep;
 bool u4RecvFlag = false;
 bool ml307aFail = false;
+bool reset4Gmodule = false;
+bool module4G_F = false;
+uint8_t u4length=0;
+uint8_t resetcount_4g=0;
 uint8_t g_ML307A_8buf[2048]={0}; 
 uint8_t g_ML307A_8buf_Down[2048]={0}; 
-bool reset4Gmodule = false;
-
+uint8_t MLBSLOCcount = 0;
 extern UART_HandleTypeDef huart3;
 extern UART_HandleTypeDef huart4;
 
-uint8_t sendCmd_4G(char *pCmd, char *pRes, uint32_t timeOut, uint8_t sendNum);
+extern Menu_table menu;	
 void ML307AReset(void);
-	
+uint8_t sendCmd_4G(char *pCmd, char *pRes, uint32_t timeOut, uint8_t sendNum);
+
+uint8_t ML307A_JD[13]={0}; 
+uint8_t ML307A_WD[13]={0}; 
+
 
+void loction_4G(void);
+/**
+  * @breaf 4G初始化
+  */
 void ML307A_Init(void)
 {
 	
-	printf("\t###02\t4G_init%d...\r\n",resetcount_4g); \
-	if(strstr((const char *)g_ML307A_8buf_Down, "+MATREADY") != NULL)
+	printf("\t###02\t4G_init%d...\r\n",resetcount_4g); 
+	switch(ml307astep)
 	{
-		memset(g_ML307A_8buf_Down,0,15);
-		printf("#4G模块上电");
-		HAL_Delay(150);
-		if(!sendCmd_4G("AT\r\n","OK",1,1))
+		case ATOK:
 		{
-			ml307aFail=true;
-			printf("4G模组异常!\r\n");
-		}	
-		if (ml307aFail)
+			if (sendCmd_4G("AT\r\n", "OK", 1, 2)) 
+			{
+				printf("------->%s",g_ML307A_8buf_Down);
+				printf("#4G模组正常\r\n");
+				ml307astep++;
+			}
+			else
+			{
+				ml307astep = ML307AStepReset;
+			}
+		}
+		case CFUN:
 		{
-			printf("#4G模块初始化Fail");
+			if (sendCmd_4G("AT+CFUN=1\r\n", "OK", 1, 2)) 
+			{
+				printf("------->%s",g_ML307A_8buf_Down);
+				printf("#4G模组CFUN正常\r\n");
+				ml307astep++;
+			}
+			else
+			{
+				ml307astep = ML307AStepReset;
+			}
 		}
-		else
+		case SIMH:
 		{
-			if (sendCmd_4G("AT+CPIN?\r\n", "+CME ERROR: 10", 1, 1)) // 00检测是否有SIM卡 <+CPIN: READY\r\nOK>
+			if (sendCmd_4G("AT+MCFG=\"simhot\",1\r\n", "OK", 1, 2)) 
 			{
-				printf("\tERROR!-->未检测到SIM卡\r\n");
-				OLED_ShowString(42,50,(unsigned char*)" NO_SIM ",12,0);
+				printf("------->%s",g_ML307A_8buf_Down);
+				printf("#4G模组热插拔开启\r\n");
+				ml307astep++;
 			}
 			else
 			{
-				HAL_Delay(200);
-				if (sendCmd_4G("AT+CPIN?\r\n", "+CME ERROR: 13", 1, 1))
-				{
-					printf("\tERROR!-->SIM失败\r\n");
-					OLED_ShowString(35,45,(unsigned char*)" SIM_Fail ",12,0);
-				}
-				else
-				{
-					sendCmd_4G("AT+CSQ\r\n", 		"ERROR", 1, 1);// 01查询信号值(信号强度,误码率) <+CSQ: 26,99\r\nOK>
-					sendCmd_4G("AT+CEREG?\r\n", 	"ERROR", 1, 1);// 02查询附着成功(驻网:<*,@> @为1或5表示附着成功) <+CEREG: 0,1\r\nOK>
-					//sendCmd_4G("AT+MIPCALL?\r\n", 	"ERROR", 1, 1);// 03查询PDP激活状态 <+MIPCALL: 1,1,"10.94.99.162"\r\nOK>
-					//sendCmd_4G("AT+MQTTCFG=?\r\n",	"ERROR", 1, 1);// 04查询MQTT
-					printf("init_success\r\n");
-				}
+				ml307astep = ML307AStepReset;
 			}
+		}
+		case CPIN:
+		{
+			if (sendCmd_4G("AT+CPIN?\r\n", "+CPIN: READY", 1, 5)) 
+			{
+				printf("------->%s",g_ML307A_8buf_Down);
+				printf("#4G模组状态正常\r\n");
+				ml307astep++;
+			}
+			else
+			{
+				ml307astep = ML307AStepReset;
+			}
+		}		
+		case CEREG:
+		{
+			if (sendCmd_4G("AT+CEREG?\r\n", "+CEREG: 0,1", 1, 2)) 
+			{
+				printf("------->%s",g_ML307A_8buf_Down);
+				printf("#4G模组附着正常\r\n");
+				printf("#4G模组初始化完成\r\n");
+				ml307astep++;
+				
+				//break;
+			}	
+			else
+			{
+				ml307astep = ML307AStepReset;
+			}
+			module4G_F=true;
+			break;
+		}	
+//		case MLB1:
+//		{
+//			if (sendCmd_4G("AT+MLBSCFG=\"method\",40\r\n", "OK", 1, 1)) 
+//			{
+//				printf("------->%s",g_ML307A_8buf_Down);
+//				ml307astep++;
+//			}
+//			else
+//			{
+//				ml307astep = ML307AStepReset;
+//			}
+//		}
+//		
+//		case MLB2:
+//		{
+//			if(!sendCmd_4G("AT+MLBSCFG=\"pid\"\r\n", "Not referenced", 1, 1))
+//			{
+//				HAL_Delay(500);
+//				printf("------->%s",g_ML307A_8buf_Down);
+//				ml307astep++;
+//				
+//			}
+//		
+//		}
+//		
+//		case MLB3:
+//		{
+//			if (sendCmd_4G("AT+MLBSCFG=\"nearbtsen\",1\r\n", "OK", 1, 1)) 
+//			{
+//				printf("------->%s",g_ML307A_8buf_Down);
+//				memset(g_ML307A_8buf_Down,0,u4length);
+//				ml307astep++;
+//			}
+//			else
+//			{
+//				ml307astep = ML307AStepReset;
+//			}
+//			module4G_F=true;
+//			break;
+//		}
 
+		
+		case ML307AStepReset:
+		{
+			ml307astep = ATOK;
+			ML307AReset();
 		}
-	}
-	else
-	{
-		ML307AReset();
+		
+		
 	}
 	
+//	menu.current=0;//回到初始
+//	refresh=true;
 }
 
-
+/**
+  * @breaf 4G发送串口命令
+  */
 uint8_t sendCmd_4G(char *pCmd, char *pRes, uint32_t timeOut, uint8_t sendNum)
 {
     uint8_t i = 0;
@@ -78,9 +168,10 @@ uint8_t sendCmd_4G(char *pCmd, char *pRes, uint32_t timeOut, uint8_t sendNum)
     for(i = 0; i < sendNum; i++)
 	{
         time = timeOut * 10;
+		memset(g_ML307A_8buf_Down,0,u4length);
         USART_SendString(&huart4, pCmd);
-		HAL_Delay(50);
-		printf("------->%s",g_ML307A_8buf_Down);
+		HAL_Delay(700);
+
         while(time--)
 		{
 			if(strstr((const char *)g_ML307A_8buf_Down, pRes) != NULL)             // 如果检索到关键词
@@ -103,6 +194,7 @@ uint8_t sendCmd_4G(char *pCmd, char *pRes, uint32_t timeOut, uint8_t sendNum)
 void ML307AReset(void)
 {
 	reset4Gmodule=true;
+	module4G_F=false;
 	resetcount_4g+=1;
 	printf("4G Module_Reset\n");    
 	HAL_GPIO_WritePin(GPIOA, GPIO_PIN_1, GPIO_PIN_RESET);
@@ -112,4 +204,21 @@ void ML307AReset(void)
 
 
 
-
+void loction_4G(void)
+{
+	MLBSLOCcount+=1;
+	if(module4G_F)
+	{
+		//定位状态码、精度、纬度、定位精度、具体位置信息	
+		//sendCmd_4G("AT+MLBSLOC\r\n", "OK", 1, 1);
+		{//MQTT 测试
+		sendCmd_4G("AT+MQTTCFG=?\r\n", "OK", 1, 1);
+		HAL_Delay(10000);
+		printf("%s",g_ML307A_8buf_Down);
+		}
+		
+		//AL_Delay(5000);
+		//printf("------->%s",g_ML307A_8buf_Down);
+		memset(g_ML307A_8buf_Down,0,u4length);
+	}
+}

+ 2 - 1
Core/Src/rtc.c

@@ -61,7 +61,8 @@ if(HAL_RTCEx_BKUPRead(&hrtc,RTC_BKP_DR1)!= 0x5051)
 		
   /* USER CODE END Check_RTC_BKUP */
 
-  /** Initialize RTC and set the Time and Date */
+  /** Initialize RTC and set the Time and Date
+  */
   sTime.Hours = 0x13;
   sTime.Minutes = 0x0;
   sTime.Seconds = 0x0;

+ 18 - 3
Core/Src/stm32f1xx_it.c

@@ -435,12 +435,27 @@ void UART4_IRQHandler(void)
 		u4RecvFlag = true;
 		u4length = recvLength;
 		
-//		memcpy(g_ML307A_8buf, &recvBuff[2], recvLength);	
-//		memcpy(g_ML307A_8buf_Down, g_ML307A_8buf, recvLength);	
+		memset(g_ML307A_8buf,0,1024);
+		memset(g_ML307A_8buf_Down,0,1024);
 
-		memcpy(g_ML307A_8buf_Down,  &recvBuff[2], recvLength);	
 		
+//		if(module4G_F)
+//		{
+//			//memcpy(g_ML307A_8buf_Down, &recvBuff[16], 24);	
+//		}
+//		else
+//		{
+//			memcpy(g_ML307A_8buf, &recvBuff[2], recvLength);	
+//			memcpy(g_ML307A_8buf_Down, g_ML307A_8buf, recvLength);	
+//		}
 		
+			memcpy(g_ML307A_8buf, recvBuff, recvLength);	
+			memcpy(g_ML307A_8buf_Down, g_ML307A_8buf, recvLength);	
+		
+		
+		
+		//memset(g_ML307A_8buf,0,recvLength);
+		//memcpy(g_ML307A_8buf_Down,  &recvBuff[2], recvLength);	
 		HAL_UART_Receive_DMA(&huart4, recvBuff, 2048);		//重新打开DMA接收,不然只能接收一次数据
 	 }
 

+ 1 - 1
Core/Src/tim.c

@@ -83,7 +83,7 @@ void MX_TIM3_Init(void)
 
   /* USER CODE END TIM3_Init 1 */
   htim3.Instance = TIM3;
-  htim3.Init.Prescaler = 5000-1;
+  htim3.Init.Prescaler = 8000-1;
   htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
   htim3.Init.Period = 8000-1;
   htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;

+ 2 - 1
Core/Src/usart.c

@@ -621,7 +621,8 @@ PUTCHAR_PROTOTYPE
   *	@brief printf全局打印
   */
 
-  HAL_UART_Transmit(&huart3, (uint8_t *)&ch, 1, 0xFFFF);
+  HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF);//485串口打印
+  //HAL_UART_Transmit(&huart3, (uint8_t *)&ch, 1, 0xFFFF);//TTL测试打印
   return ch;
 }
 

+ 408 - 0
Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c

@@ -0,0 +1,408 @@
+/**
+  ******************************************************************************
+  * @file    system_stm32f1xx.c
+  * @author  MCD Application Team
+  * @brief   CMSIS Cortex-M3 Device Peripheral Access Layer System Source File.
+  * 
+  * 1.  This file provides two functions and one global variable to be called from 
+  *     user application:
+  *      - SystemInit(): Setups the system clock (System clock source, PLL Multiplier
+  *                      factors, AHB/APBx prescalers and Flash settings). 
+  *                      This function is called at startup just after reset and 
+  *                      before branch to main program. This call is made inside
+  *                      the "startup_stm32f1xx_xx.s" file.
+  *
+  *      - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
+  *                                  by the user application to setup the SysTick 
+  *                                  timer or configure other parameters.
+  *                                     
+  *      - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
+  *                                 be called whenever the core clock is changed
+  *                                 during program execution.
+  *
+  * 2. After each device reset the HSI (8 MHz) is used as system clock source.
+  *    Then SystemInit() function is called, in "startup_stm32f1xx_xx.s" file, to
+  *    configure the system clock before to branch to main program.
+  *
+  * 4. The default value of HSE crystal is set to 8 MHz (or 25 MHz, depending on
+  *    the product used), refer to "HSE_VALUE". 
+  *    When HSE is used as system clock source, directly or through PLL, and you
+  *    are using different crystal you have to adapt the HSE value to your own
+  *    configuration.
+  *        
+  ******************************************************************************
+  * @attention
+  *
+  * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
+  * All rights reserved.</center></h2>
+  *
+  * This software component is licensed by ST under BSD 3-Clause license,
+  * the "License"; You may not use this file except in compliance with the
+  * License. You may obtain a copy of the License at:
+  *                        opensource.org/licenses/BSD-3-Clause
+  *
+  ******************************************************************************
+  */
+
+/** @addtogroup CMSIS
+  * @{
+  */
+
+/** @addtogroup stm32f1xx_system
+  * @{
+  */  
+  
+/** @addtogroup STM32F1xx_System_Private_Includes
+  * @{
+  */
+
+#include "stm32f1xx.h"
+
+/**
+  * @}
+  */
+
+/** @addtogroup STM32F1xx_System_Private_TypesDefinitions
+  * @{
+  */
+
+/**
+  * @}
+  */
+
+/** @addtogroup STM32F1xx_System_Private_Defines
+  * @{
+  */
+
+#if !defined  (HSE_VALUE) 
+  #define HSE_VALUE               8000000U /*!< Default value of the External oscillator in Hz.
+                                                This value can be provided and adapted by the user application. */
+#endif /* HSE_VALUE */
+
+#if !defined  (HSI_VALUE)
+  #define HSI_VALUE               8000000U /*!< Default value of the Internal oscillator in Hz.
+                                                This value can be provided and adapted by the user application. */
+#endif /* HSI_VALUE */
+
+/*!< Uncomment the following line if you need to use external SRAM  */ 
+#if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG)
+/* #define DATA_IN_ExtSRAM */
+#endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */
+
+/* Note: Following vector table addresses must be defined in line with linker
+         configuration. */
+/*!< Uncomment the following line if you need to relocate the vector table
+     anywhere in Flash or Sram, else the vector table is kept at the automatic
+     remap of boot address selected */
+/* #define USER_VECT_TAB_ADDRESS */
+
+#if defined(USER_VECT_TAB_ADDRESS)
+/*!< Uncomment the following line if you need to relocate your vector Table
+     in Sram else user remap will be done in Flash. */
+/* #define VECT_TAB_SRAM */
+#if defined(VECT_TAB_SRAM)
+#define VECT_TAB_BASE_ADDRESS   SRAM_BASE       /*!< Vector Table base address field.
+                                                     This value must be a multiple of 0x200. */
+#define VECT_TAB_OFFSET         0x00000000U     /*!< Vector Table base offset field.
+                                                     This value must be a multiple of 0x200. */
+#else
+#define VECT_TAB_BASE_ADDRESS   FLASH_BASE      /*!< Vector Table base address field.
+                                                     This value must be a multiple of 0x200. */
+#define VECT_TAB_OFFSET         0x00000000U     /*!< Vector Table base offset field.
+                                                     This value must be a multiple of 0x200. */
+#endif /* VECT_TAB_SRAM */
+#endif /* USER_VECT_TAB_ADDRESS */
+
+/******************************************************************************/
+
+/**
+  * @}
+  */
+
+/** @addtogroup STM32F1xx_System_Private_Macros
+  * @{
+  */
+
+/**
+  * @}
+  */
+
+/** @addtogroup STM32F1xx_System_Private_Variables
+  * @{
+  */
+
+  /* This variable is updated in three ways:
+      1) by calling CMSIS function SystemCoreClockUpdate()
+      2) by calling HAL API function HAL_RCC_GetHCLKFreq()
+      3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency 
+         Note: If you use this function to configure the system clock; then there
+               is no need to call the 2 first functions listed above, since SystemCoreClock
+               variable is updated automatically.
+  */
+uint32_t SystemCoreClock = 16000000;
+const uint8_t AHBPrescTable[16U] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
+const uint8_t APBPrescTable[8U] =  {0, 0, 0, 0, 1, 2, 3, 4};
+
+/**
+  * @}
+  */
+
+/** @addtogroup STM32F1xx_System_Private_FunctionPrototypes
+  * @{
+  */
+
+#if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG)
+#ifdef DATA_IN_ExtSRAM
+  static void SystemInit_ExtMemCtl(void); 
+#endif /* DATA_IN_ExtSRAM */
+#endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */
+
+/**
+  * @}
+  */
+
+/** @addtogroup STM32F1xx_System_Private_Functions
+  * @{
+  */
+
+/**
+  * @brief  Setup the microcontroller system
+  *         Initialize the Embedded Flash Interface, the PLL and update the 
+  *         SystemCoreClock variable.
+  * @note   This function should be used only after reset.
+  * @param  None
+  * @retval None
+  */
+void SystemInit (void)
+{
+#if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG)
+  #ifdef DATA_IN_ExtSRAM
+    SystemInit_ExtMemCtl(); 
+  #endif /* DATA_IN_ExtSRAM */
+#endif 
+
+  /* Configure the Vector Table location -------------------------------------*/
+#if defined(USER_VECT_TAB_ADDRESS)
+  SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */
+#endif /* USER_VECT_TAB_ADDRESS */
+}
+
+/**
+  * @brief  Update SystemCoreClock variable according to Clock Register Values.
+  *         The SystemCoreClock variable contains the core clock (HCLK), it can
+  *         be used by the user application to setup the SysTick timer or configure
+  *         other parameters.
+  *           
+  * @note   Each time the core clock (HCLK) changes, this function must be called
+  *         to update SystemCoreClock variable value. Otherwise, any configuration
+  *         based on this variable will be incorrect.         
+  *     
+  * @note   - The system frequency computed by this function is not the real 
+  *           frequency in the chip. It is calculated based on the predefined 
+  *           constant and the selected clock source:
+  *             
+  *           - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
+  *                                              
+  *           - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
+  *                          
+  *           - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) 
+  *             or HSI_VALUE(*) multiplied by the PLL factors.
+  *         
+  *         (*) HSI_VALUE is a constant defined in stm32f1xx.h file (default value
+  *             8 MHz) but the real value may vary depending on the variations
+  *             in voltage and temperature.   
+  *    
+  *         (**) HSE_VALUE is a constant defined in stm32f1xx.h file (default value
+  *              8 MHz or 25 MHz, depending on the product used), user has to ensure
+  *              that HSE_VALUE is same as the real frequency of the crystal used.
+  *              Otherwise, this function may have wrong result.
+  *                
+  *         - The result of this function could be not correct when using fractional
+  *           value for HSE crystal.
+  * @param  None
+  * @retval None
+  */
+void SystemCoreClockUpdate (void)
+{
+  uint32_t tmp = 0U, pllmull = 0U, pllsource = 0U;
+
+#if defined(STM32F105xC) || defined(STM32F107xC)
+  uint32_t prediv1source = 0U, prediv1factor = 0U, prediv2factor = 0U, pll2mull = 0U;
+#endif /* STM32F105xC */
+
+#if defined(STM32F100xB) || defined(STM32F100xE)
+  uint32_t prediv1factor = 0U;
+#endif /* STM32F100xB or STM32F100xE */
+    
+  /* Get SYSCLK source -------------------------------------------------------*/
+  tmp = RCC->CFGR & RCC_CFGR_SWS;
+  
+  switch (tmp)
+  {
+    case 0x00U:  /* HSI used as system clock */
+      SystemCoreClock = HSI_VALUE;
+      break;
+    case 0x04U:  /* HSE used as system clock */
+      SystemCoreClock = HSE_VALUE;
+      break;
+    case 0x08U:  /* PLL used as system clock */
+
+      /* Get PLL clock source and multiplication factor ----------------------*/
+      pllmull = RCC->CFGR & RCC_CFGR_PLLMULL;
+      pllsource = RCC->CFGR & RCC_CFGR_PLLSRC;
+      
+#if !defined(STM32F105xC) && !defined(STM32F107xC)      
+      pllmull = ( pllmull >> 18U) + 2U;
+      
+      if (pllsource == 0x00U)
+      {
+        /* HSI oscillator clock divided by 2 selected as PLL clock entry */
+        SystemCoreClock = (HSI_VALUE >> 1U) * pllmull;
+      }
+      else
+      {
+ #if defined(STM32F100xB) || defined(STM32F100xE)
+       prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1U;
+       /* HSE oscillator clock selected as PREDIV1 clock entry */
+       SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; 
+ #else
+        /* HSE selected as PLL clock entry */
+        if ((RCC->CFGR & RCC_CFGR_PLLXTPRE) != (uint32_t)RESET)
+        {/* HSE oscillator clock divided by 2 */
+          SystemCoreClock = (HSE_VALUE >> 1U) * pllmull;
+        }
+        else
+        {
+          SystemCoreClock = HSE_VALUE * pllmull;
+        }
+ #endif
+      }
+#else
+      pllmull = pllmull >> 18U;
+      
+      if (pllmull != 0x0DU)
+      {
+         pllmull += 2U;
+      }
+      else
+      { /* PLL multiplication factor = PLL input clock * 6.5 */
+        pllmull = 13U / 2U; 
+      }
+            
+      if (pllsource == 0x00U)
+      {
+        /* HSI oscillator clock divided by 2 selected as PLL clock entry */
+        SystemCoreClock = (HSI_VALUE >> 1U) * pllmull;
+      }
+      else
+      {/* PREDIV1 selected as PLL clock entry */
+        
+        /* Get PREDIV1 clock source and division factor */
+        prediv1source = RCC->CFGR2 & RCC_CFGR2_PREDIV1SRC;
+        prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1U;
+        
+        if (prediv1source == 0U)
+        { 
+          /* HSE oscillator clock selected as PREDIV1 clock entry */
+          SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull;          
+        }
+        else
+        {/* PLL2 clock selected as PREDIV1 clock entry */
+          
+          /* Get PREDIV2 division factor and PLL2 multiplication factor */
+          prediv2factor = ((RCC->CFGR2 & RCC_CFGR2_PREDIV2) >> 4U) + 1U;
+          pll2mull = ((RCC->CFGR2 & RCC_CFGR2_PLL2MUL) >> 8U) + 2U; 
+          SystemCoreClock = (((HSE_VALUE / prediv2factor) * pll2mull) / prediv1factor) * pllmull;                         
+        }
+      }
+#endif /* STM32F105xC */ 
+      break;
+
+    default:
+      SystemCoreClock = HSI_VALUE;
+      break;
+  }
+  
+  /* Compute HCLK clock frequency ----------------*/
+  /* Get HCLK prescaler */
+  tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4U)];
+  /* HCLK clock frequency */
+  SystemCoreClock >>= tmp;  
+}
+
+#if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG)
+/**
+  * @brief  Setup the external memory controller. Called in startup_stm32f1xx.s 
+  *          before jump to __main
+  * @param  None
+  * @retval None
+  */ 
+#ifdef DATA_IN_ExtSRAM
+/**
+  * @brief  Setup the external memory controller. 
+  *         Called in startup_stm32f1xx_xx.s/.c before jump to main.
+  *         This function configures the external SRAM mounted on STM3210E-EVAL
+  *         board (STM32 High density devices). This SRAM will be used as program
+  *         data memory (including heap and stack).
+  * @param  None
+  * @retval None
+  */ 
+void SystemInit_ExtMemCtl(void) 
+{
+  __IO uint32_t tmpreg;
+  /*!< FSMC Bank1 NOR/SRAM3 is used for the STM3210E-EVAL, if another Bank is 
+    required, then adjust the Register Addresses */
+
+  /* Enable FSMC clock */
+  RCC->AHBENR = 0x00000114U;
+
+  /* Delay after an RCC peripheral clock enabling */
+  tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_FSMCEN);
+  
+  /* Enable GPIOD, GPIOE, GPIOF and GPIOG clocks */
+  RCC->APB2ENR = 0x000001E0U;
+  
+  /* Delay after an RCC peripheral clock enabling */
+  tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPDEN);
+
+  (void)(tmpreg);
+  
+/* ---------------  SRAM Data lines, NOE and NWE configuration ---------------*/
+/*----------------  SRAM Address lines configuration -------------------------*/
+/*----------------  NOE and NWE configuration --------------------------------*/  
+/*----------------  NE3 configuration ----------------------------------------*/
+/*----------------  NBL0, NBL1 configuration ---------------------------------*/
+  
+  GPIOD->CRL = 0x44BB44BBU;  
+  GPIOD->CRH = 0xBBBBBBBBU;
+
+  GPIOE->CRL = 0xB44444BBU;  
+  GPIOE->CRH = 0xBBBBBBBBU;
+
+  GPIOF->CRL = 0x44BBBBBBU;  
+  GPIOF->CRH = 0xBBBB4444U;
+
+  GPIOG->CRL = 0x44BBBBBBU;  
+  GPIOG->CRH = 0x444B4B44U;
+   
+/*----------------  FSMC Configuration ---------------------------------------*/  
+/*----------------  Enable FSMC Bank1_SRAM Bank ------------------------------*/
+  
+  FSMC_Bank1->BTCR[4U] = 0x00001091U;
+  FSMC_Bank1->BTCR[5U] = 0x00110212U;
+}
+#endif /* DATA_IN_ExtSRAM */
+#endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */
+
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */
+  
+/**
+  * @}
+  */    
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 3682 - 0
MDK-ARM/dtu.uvguix.Administrator


+ 74 - 57
MDK-ARM/dtu.uvoptx

@@ -165,6 +165,11 @@
           <WinNumber>1</WinNumber>
           <ItemText>enterInterface_time</ItemText>
         </Ww>
+        <Ww>
+          <count>3</count>
+          <WinNumber>1</WinNumber>
+          <ItemText>g_ML307A_8buf_Down</ItemText>
+        </Ww>
       </WatchWindow1>
       <MemoryWindow1>
         <Mm>
@@ -315,8 +320,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>../Core/Src/main.c</PathWithFileName>
-      <FilenameWithoutPath>main.c</FilenameWithoutPath>
+      <PathWithFileName>..\Core\Src\ml307a.c</PathWithFileName>
+      <FilenameWithoutPath>ml307a.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -327,8 +332,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>../Core/Src/gpio.c</PathWithFileName>
-      <FilenameWithoutPath>gpio.c</FilenameWithoutPath>
+      <PathWithFileName>..\Core\Src\dtuaes.c</PathWithFileName>
+      <FilenameWithoutPath>dtuaes.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -339,8 +344,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>../Core/Src/freertos.c</PathWithFileName>
-      <FilenameWithoutPath>freertos.c</FilenameWithoutPath>
+      <PathWithFileName>..\Core\Src\keyboard.c</PathWithFileName>
+      <FilenameWithoutPath>keyboard.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -351,8 +356,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>../Core/Src/can.c</PathWithFileName>
-      <FilenameWithoutPath>can.c</FilenameWithoutPath>
+      <PathWithFileName>../Core/Src/main.c</PathWithFileName>
+      <FilenameWithoutPath>main.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -363,8 +368,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>../Core/Src/dma.c</PathWithFileName>
-      <FilenameWithoutPath>dma.c</FilenameWithoutPath>
+      <PathWithFileName>../Core/Src/gpio.c</PathWithFileName>
+      <FilenameWithoutPath>gpio.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -375,8 +380,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>../Core/Src/rtc.c</PathWithFileName>
-      <FilenameWithoutPath>rtc.c</FilenameWithoutPath>
+      <PathWithFileName>../Core/Src/freertos.c</PathWithFileName>
+      <FilenameWithoutPath>freertos.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -387,8 +392,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>../Core/Src/spi.c</PathWithFileName>
-      <FilenameWithoutPath>spi.c</FilenameWithoutPath>
+      <PathWithFileName>../Core/Src/can.c</PathWithFileName>
+      <FilenameWithoutPath>can.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -399,8 +404,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>../Core/Src/tim.c</PathWithFileName>
-      <FilenameWithoutPath>tim.c</FilenameWithoutPath>
+      <PathWithFileName>../Core/Src/dma.c</PathWithFileName>
+      <FilenameWithoutPath>dma.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -411,8 +416,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>../Core/Src/usart.c</PathWithFileName>
-      <FilenameWithoutPath>usart.c</FilenameWithoutPath>
+      <PathWithFileName>../Core/Src/rtc.c</PathWithFileName>
+      <FilenameWithoutPath>rtc.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -423,8 +428,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>../Core/Src/stm32f1xx_it.c</PathWithFileName>
-      <FilenameWithoutPath>stm32f1xx_it.c</FilenameWithoutPath>
+      <PathWithFileName>../Core/Src/spi.c</PathWithFileName>
+      <FilenameWithoutPath>spi.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -435,8 +440,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>../Core/Src/stm32f1xx_hal_msp.c</PathWithFileName>
-      <FilenameWithoutPath>stm32f1xx_hal_msp.c</FilenameWithoutPath>
+      <PathWithFileName>../Core/Src/tim.c</PathWithFileName>
+      <FilenameWithoutPath>tim.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -447,8 +452,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>../Core/Src/stm32f1xx_hal_timebase_tim.c</PathWithFileName>
-      <FilenameWithoutPath>stm32f1xx_hal_timebase_tim.c</FilenameWithoutPath>
+      <PathWithFileName>../Core/Src/usart.c</PathWithFileName>
+      <FilenameWithoutPath>usart.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -459,8 +464,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\Core\Src\ml307a.c</PathWithFileName>
-      <FilenameWithoutPath>ml307a.c</FilenameWithoutPath>
+      <PathWithFileName>../Core/Src/stm32f1xx_it.c</PathWithFileName>
+      <FilenameWithoutPath>stm32f1xx_it.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -471,8 +476,20 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\Core\Src\dtuaes.c</PathWithFileName>
-      <FilenameWithoutPath>dtuaes.c</FilenameWithoutPath>
+      <PathWithFileName>../Core/Src/stm32f1xx_hal_msp.c</PathWithFileName>
+      <FilenameWithoutPath>stm32f1xx_hal_msp.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>2</GroupNumber>
+      <FileNumber>20</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>../Core/Src/stm32f1xx_hal_timebase_tim.c</PathWithFileName>
+      <FilenameWithoutPath>stm32f1xx_hal_timebase_tim.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -486,7 +503,7 @@
     <RteFlg>0</RteFlg>
     <File>
       <GroupNumber>3</GroupNumber>
-      <FileNumber>20</FileNumber>
+      <FileNumber>21</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -498,7 +515,7 @@
     </File>
     <File>
       <GroupNumber>3</GroupNumber>
-      <FileNumber>21</FileNumber>
+      <FileNumber>22</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -510,7 +527,7 @@
     </File>
     <File>
       <GroupNumber>3</GroupNumber>
-      <FileNumber>22</FileNumber>
+      <FileNumber>23</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -522,7 +539,7 @@
     </File>
     <File>
       <GroupNumber>3</GroupNumber>
-      <FileNumber>23</FileNumber>
+      <FileNumber>24</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -534,7 +551,7 @@
     </File>
     <File>
       <GroupNumber>3</GroupNumber>
-      <FileNumber>24</FileNumber>
+      <FileNumber>25</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -546,7 +563,7 @@
     </File>
     <File>
       <GroupNumber>3</GroupNumber>
-      <FileNumber>25</FileNumber>
+      <FileNumber>26</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -558,7 +575,7 @@
     </File>
     <File>
       <GroupNumber>3</GroupNumber>
-      <FileNumber>26</FileNumber>
+      <FileNumber>27</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -570,7 +587,7 @@
     </File>
     <File>
       <GroupNumber>3</GroupNumber>
-      <FileNumber>27</FileNumber>
+      <FileNumber>28</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -582,7 +599,7 @@
     </File>
     <File>
       <GroupNumber>3</GroupNumber>
-      <FileNumber>28</FileNumber>
+      <FileNumber>29</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -594,7 +611,7 @@
     </File>
     <File>
       <GroupNumber>3</GroupNumber>
-      <FileNumber>29</FileNumber>
+      <FileNumber>30</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -606,7 +623,7 @@
     </File>
     <File>
       <GroupNumber>3</GroupNumber>
-      <FileNumber>30</FileNumber>
+      <FileNumber>31</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -618,7 +635,7 @@
     </File>
     <File>
       <GroupNumber>3</GroupNumber>
-      <FileNumber>31</FileNumber>
+      <FileNumber>32</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -630,7 +647,7 @@
     </File>
     <File>
       <GroupNumber>3</GroupNumber>
-      <FileNumber>32</FileNumber>
+      <FileNumber>33</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -642,7 +659,7 @@
     </File>
     <File>
       <GroupNumber>3</GroupNumber>
-      <FileNumber>33</FileNumber>
+      <FileNumber>34</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -654,7 +671,7 @@
     </File>
     <File>
       <GroupNumber>3</GroupNumber>
-      <FileNumber>34</FileNumber>
+      <FileNumber>35</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -666,7 +683,7 @@
     </File>
     <File>
       <GroupNumber>3</GroupNumber>
-      <FileNumber>35</FileNumber>
+      <FileNumber>36</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -678,7 +695,7 @@
     </File>
     <File>
       <GroupNumber>3</GroupNumber>
-      <FileNumber>36</FileNumber>
+      <FileNumber>37</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -690,7 +707,7 @@
     </File>
     <File>
       <GroupNumber>3</GroupNumber>
-      <FileNumber>37</FileNumber>
+      <FileNumber>38</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -710,7 +727,7 @@
     <RteFlg>0</RteFlg>
     <File>
       <GroupNumber>4</GroupNumber>
-      <FileNumber>38</FileNumber>
+      <FileNumber>39</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -730,7 +747,7 @@
     <RteFlg>0</RteFlg>
     <File>
       <GroupNumber>5</GroupNumber>
-      <FileNumber>39</FileNumber>
+      <FileNumber>40</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -742,7 +759,7 @@
     </File>
     <File>
       <GroupNumber>5</GroupNumber>
-      <FileNumber>40</FileNumber>
+      <FileNumber>41</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -754,7 +771,7 @@
     </File>
     <File>
       <GroupNumber>5</GroupNumber>
-      <FileNumber>41</FileNumber>
+      <FileNumber>42</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -766,7 +783,7 @@
     </File>
     <File>
       <GroupNumber>5</GroupNumber>
-      <FileNumber>42</FileNumber>
+      <FileNumber>43</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -778,7 +795,7 @@
     </File>
     <File>
       <GroupNumber>5</GroupNumber>
-      <FileNumber>43</FileNumber>
+      <FileNumber>44</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -790,7 +807,7 @@
     </File>
     <File>
       <GroupNumber>5</GroupNumber>
-      <FileNumber>44</FileNumber>
+      <FileNumber>45</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -802,7 +819,7 @@
     </File>
     <File>
       <GroupNumber>5</GroupNumber>
-      <FileNumber>45</FileNumber>
+      <FileNumber>46</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -814,7 +831,7 @@
     </File>
     <File>
       <GroupNumber>5</GroupNumber>
-      <FileNumber>46</FileNumber>
+      <FileNumber>47</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -826,7 +843,7 @@
     </File>
     <File>
       <GroupNumber>5</GroupNumber>
-      <FileNumber>47</FileNumber>
+      <FileNumber>48</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
@@ -838,7 +855,7 @@
     </File>
     <File>
       <GroupNumber>5</GroupNumber>
-      <FileNumber>48</FileNumber>
+      <FileNumber>49</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>

+ 15 - 10
MDK-ARM/dtu.uvprojx

@@ -414,6 +414,21 @@
               <FileType>1</FileType>
               <FilePath>..\Core\Src\mba32a.c</FilePath>
             </File>
+            <File>
+              <FileName>ml307a.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Core\Src\ml307a.c</FilePath>
+            </File>
+            <File>
+              <FileName>dtuaes.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Core\Src\dtuaes.c</FilePath>
+            </File>
+            <File>
+              <FileName>keyboard.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Core\Src\keyboard.c</FilePath>
+            </File>
             <File>
               <FileName>main.c</FileName>
               <FileType>1</FileType>
@@ -627,16 +642,6 @@
               <FileType>1</FileType>
               <FilePath>../Core/Src/stm32f1xx_hal_timebase_tim.c</FilePath>
             </File>
-            <File>
-              <FileName>ml307a.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\Core\Src\ml307a.c</FilePath>
-            </File>
-            <File>
-              <FileName>dtuaes.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\Core\Src\dtuaes.c</FilePath>
-            </File>
           </Files>
         </Group>
         <Group>

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1917 - 1917
Output/dtu.hex


+ 3 - 2
Output/dtu.lnp

@@ -4,6 +4,9 @@
 "..\output\key.o"
 "..\output\oled.o"
 "..\output\mba32a.o"
+"..\output\ml307a.o"
+"..\output\dtuaes.o"
+"..\output\keyboard.o"
 "..\output\main.o"
 "..\output\gpio.o"
 "..\output\freertos.o"
@@ -16,8 +19,6 @@
 "..\output\stm32f1xx_it.o"
 "..\output\stm32f1xx_hal_msp.o"
 "..\output\stm32f1xx_hal_timebase_tim.o"
-"..\output\ml307a.o"
-"..\output\dtuaes.o"
 "..\output\stm32f1xx_hal_gpio_ex.o"
 "..\output\stm32f1xx_hal_can.o"
 "..\output\stm32f1xx_hal.o"

+ 1 - 1
dtu.ioc

@@ -388,7 +388,7 @@ TIM2.Period=8000-1
 TIM2.Prescaler=10-1
 TIM3.IPParameters=Period,Prescaler
 TIM3.Period=8000-1
-TIM3.Prescaler=5000-1
+TIM3.Prescaler=8000-1
 UART4.BaudRate=115200
 UART4.IPParameters=VirtualMode,BaudRate
 UART4.VirtualMode=Asynchronous