Browse Source

Merge branch 'master' into DO360

Wendell 2 years ago
parent
commit
988e412397
63 changed files with 721 additions and 680 deletions
  1. 1 1
      EVSE/Modularization/UUpwr_PsuCommObj.c
  2. 110 4
      EVSE/Modularization/ocpp20/MessageHandler.c
  3. BIN
      EVSE/Projects/AW-CCS/Apps/CCS/SeccComm
  4. BIN
      EVSE/Projects/AW-CCS/Images/FactoryDefaultConfig.bin
  5. BIN
      EVSE/Projects/AW-CCS/Images/MLO
  6. BIN
      EVSE/Projects/AW-CCS/Images/am335x-evm.dtb
  7. BIN
      EVSE/Projects/AW-CCS/Images/ramdisk.gz
  8. BIN
      EVSE/Projects/AW-CCS/Images/u-boot-spl.bin
  9. BIN
      EVSE/Projects/AW-CCS/Images/u-boot.img
  10. BIN
      EVSE/Projects/AW-CCS/Images/zImage
  11. 5 5
      EVSE/Projects/DD360UCar/Apps/CSU/OCPP.c
  12. 4 4
      EVSE/Projects/DD360UCar/Apps/CSU/Primary.c
  13. 11 11
      EVSE/Projects/DD360UCar/Apps/CSU/RFID.c
  14. 147 111
      EVSE/Projects/DD360UCar/Apps/CSU/main.c
  15. 3 3
      EVSE/Projects/DD360UCar/Apps/CSU/main.h
  16. 1 0
      EVSE/Projects/DD360UCar/Apps/Config.h
  17. 0 1
      EVSE/Projects/DD360UCar/Apps/DataBase/DataBase.c
  18. 16 11
      EVSE/Projects/DD360UCar/Apps/ModuleDoComm/DoComm.c
  19. 18 11
      EVSE/Projects/DD360UCar/Apps/ModuleEvComm/Module_EvTxComm.c
  20. 5 5
      EVSE/Projects/DD360UCar/Apps/ModuleInternalComm/AcPlug.c
  21. 3 3
      EVSE/Projects/DD360UCar/Apps/ModuleInternalComm/FanBoard.c
  22. 4 4
      EVSE/Projects/DD360UCar/Apps/ModuleInternalComm/LEDlight.c
  23. 14 4
      EVSE/Projects/DD360UCar/Apps/ModuleInternalComm/Module_InternalComm.c
  24. 2 1
      EVSE/Projects/DD360UCar/Apps/ModuleInternalComm/Module_InternalComm.h
  25. 19 19
      EVSE/Projects/DD360UCar/Apps/ModuleInternalComm/RelayBoard.c
  26. 9 5
      EVSE/Projects/DD360UCar/Apps/ModuleLcmCtrl/Module_LcmControl.c
  27. 8 4
      EVSE/Projects/DD360UCar/Apps/ModulePrimary/Module_PrimaryComm.c
  28. 8 6
      EVSE/Projects/DD360UCar/Apps/ModulePsuComm/Module_PsuComm.c
  29. 4 4
      EVSE/Projects/DD360UCar/Apps/ModulePsuComm/Module_PsuComm.h
  30. 15 6
      EVSE/Projects/DD360UCar/Apps/OutputTask.c
  31. 1 1
      EVSE/Projects/DD360UCar/Apps/OutputTask.h
  32. 16 7
      EVSE/Projects/DD360UCar/Apps/ReadCmdline.c
  33. BIN
      EVSE/Projects/DD360UCar/Apps/UnsafetyOutputTask
  34. 3 3
      EVSE/Projects/DD360UCar/Apps/timeout.h
  35. BIN
      EVSE/Projects/DD360UCar/Images/ramdisk.gz
  36. BIN
      EVSE/Projects/DD360UCar/output/FactoryConfig
  37. BIN
      EVSE/Projects/DD360UCar/output/Module_ChkSysTask
  38. BIN
      EVSE/Projects/DD360UCar/output/Module_DoComm
  39. BIN
      EVSE/Projects/DD360UCar/output/Module_EvComm
  40. BIN
      EVSE/Projects/DD360UCar/output/Module_EventLogging
  41. BIN
      EVSE/Projects/DD360UCar/output/Module_InternalComm
  42. BIN
      EVSE/Projects/DD360UCar/output/Module_LcmControl
  43. BIN
      EVSE/Projects/DD360UCar/output/Module_PrimaryComm
  44. BIN
      EVSE/Projects/DD360UCar/output/Module_UpdateFW
  45. BIN
      EVSE/Projects/DD360UCar/output/ReadCmdline
  46. BIN
      EVSE/Projects/DD360UCar/output/UnsafetyOutputTask
  47. BIN
      EVSE/Projects/DD360UCar/output/main
  48. 37 16
      EVSE/Projects/DS60-120/Apps/main.c
  49. 29 22
      EVSE/Projects/define.h
  50. BIN
      EVSE/rootfs/root/Module_Payment_Bazel8
  51. BIN
      EVSE/rootfs/root/Module_Payment_Enegate
  52. BIN
      EVSE/rootfs/root/Module_PowerSharing
  53. 1 1
      board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/.version
  54. 1 1
      board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/dts/.am335x-evm.dtb.cmd
  55. 1 1
      board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/dts/.am335x-evm.dtb.d.dtc.tmp
  56. 1 2
      board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/dts/.am335x-evm.dtb.d.pre.tmp
  57. 61 136
      board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/dts/.am335x-evm.dtb.dts.tmp
  58. 84 55
      board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/dts/am335x-evm.dts
  59. 1 1
      board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/.am335x-evm.dtb.cmd
  60. 1 1
      board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/.am335x-evm.dtb.d.dtc.tmp
  61. 1 2
      board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/.am335x-evm.dtb.d.pre.tmp
  62. 31 137
      board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/.am335x-evm.dtb.dts.tmp
  63. 45 71
      board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/am335x-evm.dts

+ 1 - 1
EVSE/Modularization/UUpwr_PsuCommObj.c

@@ -1286,7 +1286,7 @@ void SetWalkInConfig(byte group, byte enable, byte sec)
 {
 	// 這階段可以做模塊高低壓設定、初始化一些設定
 	ShmUuPowerData._getCountIndexComp = LIB_STOP;
-	SetModuleVoltageMode(group, PSU_VOLTAGE_AUTO);
+	SetModuleVoltageMode(group, PSU_VOLTAGE_LOW);
 }
 
 void FlashLed(byte group, byte value)

+ 110 - 4
EVSE/Modularization/ocpp20/MessageHandler.c

@@ -7879,6 +7879,16 @@ void CheckSystemValue(void)
 		if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CSUMsg.bits[gun_index].NotifyEVChargingNeedsReq == ON))
 		{
 			sendNotifyEVChargingNeedsRequest(gun_index);
+			ShmOCPP20Data->CSUMsg.bits[gun_index].NotifyEVChargingNeedsReq = OFF;
+		}
+
+		//==========================================
+		// csu notify EV charging schedule request
+		//==========================================
+		if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CSUMsg.bits[gun_index].NotifyEVChargingScheduleReq == ON))
+		{
+			sendNotifyEVChargingScheduleRequest(gun_index);
+			ShmOCPP20Data->CSUMsg.bits[gun_index].NotifyEVChargingScheduleReq = OFF;
 		}
 
 		//==========================================
@@ -7955,6 +7965,7 @@ int sendAuthorizeRequest(int gun_index)
 	char tempdata[128]={0};
 	json_object *Authorize = json_object_new_object();
 	json_object *idToken = json_object_new_object();
+	json_object *iso15118CertificateHashData = json_object_new_array();
 
 	DEBUG_INFO("sendAuthorizeRequest...\n");
 	memset(&(ShmOCPP20Data->Authorize.Response_idTokenInfo),0,sizeof(struct IdTokenInfoType));
@@ -8034,6 +8045,27 @@ int sendAuthorizeRequest(int gun_index)
 
 	json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.idToken));
 	json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.type));
+
+	if(strcmp((char*)ShmOCPP20Data->Authorize.idToken.type, IdTokenEnumTypeStr[IdTokenType_eMAID]) == 0)
+	{
+		json_object *OCSPRequestDataType = json_object_new_object();
+		json_object_object_add(Authorize, "certificate", json_object_new_string((char*)ShmOCPP20Data->Authorize.certificate));
+		for(int idx=0; idx < 4; idx++)
+		{
+			if(strlen((char*)ShmOCPP20Data->Authorize.iso15118CertificateHashData[idx].responderURL) >= 7)
+			{
+				json_object_object_add(OCSPRequestDataType, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->Authorize.iso15118CertificateHashData[idx].hashAlgorithm));
+				json_object_object_add(OCSPRequestDataType, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->Authorize.iso15118CertificateHashData[idx].issuerNameHash));
+				json_object_object_add(OCSPRequestDataType, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->Authorize.iso15118CertificateHashData[idx].issuerKeyHash));
+				json_object_object_add(OCSPRequestDataType, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->Authorize.iso15118CertificateHashData[idx].serialNumber));
+				json_object_object_add(OCSPRequestDataType, "responderURL", json_object_new_string((char*)ShmOCPP20Data->Authorize.iso15118CertificateHashData[idx].responderURL));
+
+				json_object_array_add(iso15118CertificateHashData, OCSPRequestDataType);
+			}
+		}
+		json_object_object_add(Authorize, "iso15118CertificateHashData", iso15118CertificateHashData);
+	}
+
 	json_object_object_add(Authorize, "idToken", idToken);
 
 	random_uuid(guid);
@@ -17246,6 +17278,78 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 								isPeriodOverMax = TRUE;
 							}
 						}
+
+						if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff") != NULL)
+						{
+							if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "id") != NULL)
+							{
+								SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].salesTariff.id = json_object_get_int(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "id"));
+							}
+
+							if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffDescription") != NULL)
+							{
+								strcpy((char*)SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].salesTariff.salesTariffDescription, json_object_get_string(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffDescription")));
+							}
+
+							if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "numEPriceLevels") != NULL)
+							{
+								SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].salesTariff.numEPriceLevels = json_object_get_int(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "numEPriceLevels"));
+							}
+
+							if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry") != NULL)
+							{
+								int cntEntry = json_object_array_length(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"));
+
+								if(cntEntry<=1024)
+								{
+									for(int idxEntry=0; idxEntry<cntEntry; idxEntry++)
+									{
+										if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "ePriceLevel") != NULL)
+										{
+											SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].salesTariff.salesTariffEntry[idxEntry].ePriceLevel = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "ePriceLevel"));
+										}
+
+										if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "relativeTimeInterval") != NULL)
+										{
+											if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "relativeTimeInterval"), "start") != NULL)
+												SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].salesTariff.salesTariffEntry[idxEntry].relativeTimeInterval.start = json_object_get_int(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "relativeTimeInterval"), "start"));
+											if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "relativeTimeInterval"), "duration") != NULL)
+												SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].salesTariff.salesTariffEntry[idxEntry].relativeTimeInterval.duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "relativeTimeInterval"), "duration"));
+										}
+
+										if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "consumptionCost") != NULL)
+										{
+											uint8_t cntConCost = json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "consumptionCost"));
+											if(cntConCost<=3)
+											{
+												for(uint8_t idxConCost=0; idxConCost<cntConCost; idxConCost++)
+												{
+													if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "consumptionCost"),idxConCost), "startValue") != NULL)
+														SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].salesTariff.salesTariffEntry[idxEntry].consumptionCost[idxConCost].startValue = json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "consumptionCost"),idxConCost), "cost"));
+													if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "consumptionCost"),idxConCost), "cost") != NULL)
+													{
+														uint8_t cntCost = json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "consumptionCost"),idxConCost), "cost"));
+														if(cntConCost<=3)
+														{
+															for(uint8_t idxCost=0; idxCost<cntCost; idxCost++)
+															{
+																if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "consumptionCost"),idxConCost), "cost"), idxCost), "costKind") != NULL)
+																	strcpy((char*)SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].salesTariff.salesTariffEntry[idxEntry].consumptionCost[idxConCost].cost[idxCost].costKind, json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "consumptionCost"),idxConCost), "cost"), idxCost), "costKind")));
+																if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "consumptionCost"),idxConCost), "cost"), idxCost), "amount") != NULL)
+																	SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].salesTariff.salesTariffEntry[idxEntry].consumptionCost[idxConCost].cost[idxCost].amount = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "consumptionCost"),idxConCost), "cost"), idxCost), "amount"));
+																if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "consumptionCost"),idxConCost), "cost"), idxCost), "amountMultiplier") != NULL)
+																	SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].salesTariff.salesTariffEntry[idxEntry].consumptionCost[idxConCost].cost[idxCost].amountMultiplier = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "consumptionCost"),idxConCost), "cost"), idxCost), "amountMultiplier"));
+															}
+														}
+													}
+												}
+											}
+											SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].salesTariff.salesTariffEntry[idxEntry].ePriceLevel = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "salesTariff"), "salesTariffEntry"),idxEntry), "ePriceLevel"));
+										}
+									}
+								}
+							}
+						}
 					}
 				}
 				else
@@ -19596,8 +19700,10 @@ void handleNotifyEVChargingNeedsResponse(char *payload, int gun_index)
 	}
 	json_object_put(NotifyEVChargingNeeds);
 
-	ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
-	ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
+	//ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
+	//ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
+	ShmOCPP20Data->CSUMsg.bits[gun_index].NotifyEVChargingNeedsReq = OFF;
+	ShmOCPP20Data->CSUMsg.bits[gun_index].NotifyEVChargingNeedsConf = ON;
 }
 
 void handleNotifyEVChargingScheduleResponse(char *payload, int gun_index)
@@ -19615,8 +19721,8 @@ void handleNotifyEVChargingScheduleResponse(char *payload, int gun_index)
 	}
 	json_object_put(NotifyEVChargingSchedule);
 
-	ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleReq = OFF;
-	ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleConf = ON;
+	ShmOCPP20Data->CSUMsg.bits[gun_index].NotifyEVChargingScheduleReq = OFF;
+	ShmOCPP20Data->CSUMsg.bits[gun_index].NotifyEVChargingScheduleConf = ON;
 }
 
 void handleNotifyEventResponse(char *payload, int gun_index)

BIN
EVSE/Projects/AW-CCS/Apps/CCS/SeccComm


BIN
EVSE/Projects/AW-CCS/Images/FactoryDefaultConfig.bin


BIN
EVSE/Projects/AW-CCS/Images/MLO


BIN
EVSE/Projects/AW-CCS/Images/am335x-evm.dtb


BIN
EVSE/Projects/AW-CCS/Images/ramdisk.gz


BIN
EVSE/Projects/AW-CCS/Images/u-boot-spl.bin


BIN
EVSE/Projects/AW-CCS/Images/u-boot.img


BIN
EVSE/Projects/AW-CCS/Images/zImage


+ 5 - 5
EVSE/Projects/DD360UCar/Apps/CSU/OCPP.c

@@ -405,7 +405,7 @@ void ocpp_sub_set_remote_start_transaction_req(byte gunIndex, bool result)
         ShmOCPP20Data->CsMsg.bits[gunIndex].RequestStartTransactionReq = result;
     }
 }
-
+/*
 void ocpp_chk_remoteStart_cmd()
 {
     if (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == _OFFLINE_POLICY_NO_CHARGING)
@@ -422,7 +422,7 @@ void ocpp_chk_remoteStart_cmd()
                     ShmSysConfigAndInfo->SysInfo.OrderCharging = YES;
                     //ShmSysConfigAndInfo->SysInfo.OrderCharging = DEFAULT_AC_INDEX;
                     //ShmOCPP16Data->CsMsg.bits[ShmSysConfigAndInfo->SysConfig.TotalConnectorCount + ac_index].RemoteStartTransactionReq = NO;
-                    DetectPluginStart();
+                    DetectPluginStart(ac_index);
                     return;
                 }
                 ocpp_sub_set_remote_start_transaction_req(acDirIndex, NO);
@@ -473,7 +473,7 @@ void ocpp_chk_remoteStart_cmd()
                 chargingInfo[dcIndex]->RemoteStartFlag = YES;
                 ShmSysConfigAndInfo->SysInfo.OrderCharging = YES;
                 //ShmSysConfigAndInfo->SysInfo.OrderCharging = gun_index;
-                DetectPluginStart();
+                DetectPluginStart(dcIndex);
             }
             ocpp_sub_set_remote_start_transaction_req(dcIndex + threeGunIndex, NO);
         } else if (chargingInfo[scheduleIndex]->schedule.isTriggerStart) {
@@ -481,13 +481,13 @@ void ocpp_chk_remoteStart_cmd()
                     chargingInfo[scheduleIndex]->SystemStatus == S_RESERVATION) {
                 chargingInfo[scheduleIndex]->RemoteStartFlag = YES;
                 ShmSysConfigAndInfo->SysInfo.OrderCharging = YES;
-                DetectPluginStart();
+                DetectPluginStart(dcIndex);
             }
             chargingInfo[scheduleIndex]->schedule.isTriggerStart = NO;
         }
     }
 }
-
+*/
 void ocpp_chk_update_cmd()
 {
     if (ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16) {

+ 4 - 4
EVSE/Projects/DD360UCar/Apps/CSU/Primary.c

@@ -45,7 +45,7 @@ void EnterAuthorizePage(uint8_t gunIndex)
 {
     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
     log_info("Select Gun(%d) in Authorizing",gunIndex);
-    ClearDetectPluginFlag();
+    ClearDetectPluginFlag(gunIndex);
     ChangeGunSelectByIndex(gunIndex);
     confirmSelGun(gunIndex);
     ChangeLCM(_LCM_START_SCAN);
@@ -131,7 +131,7 @@ void showConfirmStopPage(uint8_t gunIndex)
 void CheckLeftButton()
 {
     DcCommonInfo* ShmDcCommonData = (DcCommonInfo*)GetShmDcCommonData();
-    uint8_t gunIndex = 0;
+
     pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(LEFT_GUN_NUM);
     switch (pSysInfo->SystemPage) {
         case _LCM_VIEW:
@@ -208,7 +208,6 @@ void CheckLeftButton()
 }
 void CheckRightButton()
 {
-    uint8_t gunIndex = 0;
     DcCommonInfo* ShmDcCommonData = (DcCommonInfo*)GetShmDcCommonData();
     pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(RIGHT_GUN_NUM);
     switch (pSysInfo->SystemPage) {
@@ -243,8 +242,9 @@ void CheckRightButton()
             ReturnAuthorize();
             break;
         case _LCM_WAIT_PLUGIN:
-            if (pSysInfo->CurGunSelected == RIGHT_GUN_NUM)
+            if (pSysInfo->CurGunSelected == RIGHT_GUN_NUM) {
                 ReturnIDLE(RIGHT_GUN_NUM);
+            }
         	break;
         case _LCM_LINK_ERROR:
             if (pSysInfo->CurGunSelected == RIGHT_GUN_NUM) {

+ 11 - 11
EVSE/Projects/DD360UCar/Apps/CSU/RFID.c

@@ -124,16 +124,16 @@ bool RfidStopCharging(void)
 }
 static void UserScanFunction(void)
 {
-    bool idleReq = false;
-    uint8_t i = 0;
-    uint8_t stopReq = NO_DEFINE;
-    char value[32] = {0};
-    static uint8_t _authorizeIndex = NO_DEFINE;
+    //bool idleReq = false;
+    //uint8_t i = 0;
+    //uint8_t stopReq = NO_DEFINE;
+    //char value[32] = {0};
+    //static uint8_t _authorizeIndex = NO_DEFINE;
     struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
     struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
-    struct ChargingInfoData *pAcChargingInfo =  (struct ChargingInfoData *)GetAcChargingInfoData(0);
+    //struct ChargingInfoData *pAcChargingInfo =  (struct ChargingInfoData *)GetAcChargingInfoData(0);
     struct ChargingInfoData *pDcChargingInfo = NULL;
-    GunIndexInfo *pGunIndexInfo = (GunIndexInfo *)GetGunIndexInfo();
+    //GunIndexInfo *pGunIndexInfo = (GunIndexInfo *)GetGunIndexInfo();
 
     // 當前非驗證的狀態
     if (IsAuthorizingMode()) {
@@ -275,7 +275,7 @@ void AuthorizeToCharge()
                 if (!pDcChargingInfo->ConnectorPlugIn)
                     pSysInfo->SystemPage = _LCM_WAIT_PLUGIN;
                 log_info("Wait Gun(%d) plugin",pSysInfo->CurGunSelected);
-                DetectPluginStart();
+                DetectPluginStart(pSysInfo->CurGunSelected);
                 log_info("Gun(%d) Balance: %f",pSysInfo->CurGunSelected,
                         ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance);
             } else {
@@ -295,7 +295,7 @@ void ScannerCardProcess(void)
     struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
     struct WARNING_CODE_INFO *pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
 
-    if (!isDetectPlugin() && pSysInfo->SystemPage == _LCM_START_SCAN &&
+    if (!isDetectPlugin(pSysInfo->CurGunSelected) && pSysInfo->SystemPage == _LCM_START_SCAN &&
             pSysWarning->Level != WARN_LV_ER /*&&
             pSysConfig->AuthorisationMode == AUTH_MODE_ENABLE*/) {
         isCardScan = true;
@@ -308,8 +308,8 @@ void ScannerCardProcess(void)
     } else if (pSysInfo->SystemPage == _LCM_START_AUTHORIZE_FAIL) {
         StartSystemTimeoutDet(Timeout_VerifyFail);
         isCardScan = false;
-    } else if (pSysInfo->SystemPage == _LCM_WAIT_PLUGIN) {
-        StartSystemTimeoutDet(Timeout_WaitPlug);
+    //} else if (pSysInfo->SystemPage == _LCM_WAIT_PLUGIN) {
+    //    StartSystemTimeoutDet(Timeout_WaitPlug);
     } else {
         isCardScan = false;
     }

+ 147 - 111
EVSE/Projects/DD360UCar/Apps/CSU/main.c

@@ -88,12 +88,12 @@ char* DebugVersion = "V2.09.00";      // Software debug version
 bool isDb_ready;
 
 //------------------------------------------------------------------------------
-void ClearDetectPluginFlag();
+void ClearDetectPluginFlag(int gunIndex);
 
 long long DiffTimebWithNow(struct timeb ST);
 uint8_t DetectBitValue(uint8_t _byte, uint8_t _bit);
 void SetBitValue(uint8_t *_byte, uint8_t _bit, uint8_t value);
-unsigned long GetTimeoutValue(struct timeval _sour_time);
+unsigned long GetTimeoutValue(struct timespec _start_time);
 void GetClockTime(struct timespec *_now_time, void *null);
 unsigned long GetClockTimeoutValue(struct timespec _start_time);
 void gpio_set_value(unsigned int gpio, unsigned int value);
@@ -758,19 +758,39 @@ static void checkEvBoardAlarmState(uint8_t gunType)
     }
 }
 
-unsigned long GetTimeoutValue(struct timeval _sour_time)
+unsigned long GetSecTimeoutValue(struct timespec _start_time)
 {
-    struct timeval _end_time;
-    gettimeofday(&_end_time, NULL);
+    struct timespec ts_end;
+    unsigned long ret = 0;
+
+    clock_gettime(CLOCK_MONOTONIC, &ts_end);
 
-    return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
+    ret = ((unsigned long)(ts_end.tv_sec - _start_time.tv_sec) * 1000) + ((unsigned long)((ts_end.tv_nsec / 1000000) - (_start_time.tv_nsec / 1000000)));
+    /*
+    printf("\r\n TimeInterval: %ld.%09ld - %ld.%09ld = %ld.%03ld ms",
+        ts_end.tv_sec, ts_end.tv_nsec,  _start_time.tv_sec, _start_time.tv_nsec,
+        (ret / 1000), (ret % 1000));
+    */
+    ret /= 1000;
+
+    return ret;
 }
 
 void GetClockTime(struct timespec *_now_time, void *null)
 {
     clock_gettime(CLOCK_MONOTONIC, _now_time);
 }
+unsigned long GetTimeoutValue(struct timespec _start_time)
+{
+    struct timespec ts_end;
+    unsigned long ret = 0;
 
+    clock_gettime(CLOCK_MONOTONIC, &ts_end);
+
+    ret = ((unsigned long)(ts_end.tv_sec - _start_time.tv_sec) * 1000000) + ((unsigned long)((ts_end.tv_nsec / 1000) - (_start_time.tv_nsec / 1000)));
+
+    return ret;
+}
 // return value unit: 1us
 unsigned long GetClockTimeoutValue(struct timespec _start_time)
 {
@@ -1201,7 +1221,7 @@ int Initialization(void)
     ClearAuthorizedFlag();
 
     // 初始化插槍驗證的 Flag
-    ClearDetectPluginFlag();
+    ClearDetectPluginFlag(pSysInfo->CurGunSelected);
 
     for (count = 0; count < pSysConfig->TotalConnectorCount; count++) {
         pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(count);
@@ -1347,34 +1367,30 @@ bool isEvBoardNormalStopChargeFlag(uint8_t gunIndex)
 //===============================================
 // 掃描插槍狀況
 //===============================================
-void ClearDetectPluginFlag(void)
+void ClearDetectPluginFlag(int gunIndex)
 {
-    uint8_t gunIndex = 0;
-    pSysInfo->WaitForPlugit = NO;
+    pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(gunIndex);
 
-    //DS60-120 add
-    for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
-        pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
-        /*
-        if (pDcChargingInfo->RemoteStartFlag == YES) {
-            pDcChargingInfo->RemoteStartFlag = NO;
-        }
-        */
+    if (pDcChargingInfo->RemoteStartFlag == YES) {
+        pDcChargingInfo->RemoteStartFlag = NO;
     }
+    ShmDcCommonData->pGunInfo[gunIndex].WaitForPlugit = NO;
+
 
     if (pSysInfo->OrderCharging != NO_DEFINE) {
         pSysInfo->OrderCharging = NO_DEFINE;
     }
 }
 
-void DetectPluginStart()
+void DetectPluginStart(int gunIndex)
 {
-    pSysInfo->WaitForPlugit = YES;
+    //pSysInfo->WaitForPlugit = YES;
+    ShmDcCommonData->pGunInfo[gunIndex].WaitForPlugit = YES;
 }
 
-bool isDetectPlugin()
+bool isDetectPlugin(int gunIndex)
 {
-    if (pSysInfo->WaitForPlugit == YES) {
+    if (ShmDcCommonData->pGunInfo[gunIndex].WaitForPlugit == YES) {
         return true;
     }
 
@@ -1469,7 +1485,7 @@ bool isEvGunLocked_ccs(uint8_t gunIndex)
 
 uint8_t isPrechargeStatus_ccs(uint8_t gunIndex)
 {
-    uint8_t result = 0x00;
+
     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
 
     return ShmCcsData->V2GMessage_DIN70121[pDcChargingInfo->type_index].PresentMsgFlowStatus;
@@ -1529,7 +1545,7 @@ void _AutoReturnTimeout(void)
         pDcChargingInfo->SystemStatus = S_ALARM;
         //pSysInfo->SystemPage = _LCM_ERROR;
         pSysInfo->SystemPage = _LCM_MAINTAIN;
-        ClearDetectPluginFlag();
+        ClearDetectPluginFlag(pSysInfo->CurGunSelected);
     } else if (pSysInfo->SystemPage ==_LCM_START_AUTHORIZE_FAIL) {
         pSysInfo->SystemPage = _LCM_START_SCAN;
         StartSystemTimeoutDet(Timeout_ReturnViewPage);
@@ -1566,16 +1582,17 @@ void _AuthorizedTimeout(void)
     //}
 }
 
-void _DetectPlugInTimeout(void)
+void _DetectPlugInTimeout(int gunIndex)
 {
     log_info("*********** _DetectPlugInTimeout *********** ");
     strcpy((char *)pSysConfig->UserId, "");
-    StopSystemTimeoutDet();
-    pSysInfo->SystemPage = _LCM_LINK_ERROR;
-    StartSystemTimeoutDet(Timeout_ReturnViewPage);
-    ClearDetectPluginFlag();
-	//setChargerMode(pSysInfo->CurGunSelected, S_TERMINATING);
-    //systemPageRestoreInit();
+
+    //pSysInfo->SystemPage = _LCM_LINK_ERROR;
+    //StartSystemTimeoutDet(Timeout_ReturnViewPage);
+    ClearDetectPluginFlag(gunIndex);
+	setChargerMode(gunIndex, S_IDLE);
+    if (pSysInfo->CurGunSelected == gunIndex)
+        systemPageRestoreInit();
 }
 
 void _DetectEvChargingEnableTimeout(uint8_t gunIndex)
@@ -2458,7 +2475,7 @@ void StartGunInfoTimeoutDet(uint8_t gunIndex, uint8_t flag)
 
     if (gunIndex < pSysConfig->TotalConnectorCount) {
         if (pDcChargingInfo->TimeoutFlag != flag) {
-            gettimeofday(&pDcChargingInfo->TimeoutTimer, NULL);
+            GetClockTime(&pDcChargingInfo->ConnectorTimeout, NULL);
             //log_info("Set Gun%d Timeout Flag %d", gunIndex,flag);
         }
         pDcChargingInfo->TimeoutFlag = flag;
@@ -2498,7 +2515,7 @@ void CreateTimeoutFork(void)
 
     timeoutPid = fork();
     if (timeoutPid == 0) {
-        gettimeofday(&_cmdSubPriority_time, NULL);
+        GetClockTime(&_cmdSubPriority_time, NULL);
         CheckConnectionTimeout();
 
         //log_info("Timeout Fork Child's PID is %d", getpid());
@@ -2506,7 +2523,7 @@ void CreateTimeoutFork(void)
         while (1) {
             if ((GetTimeoutValue(_cmdSubPriority_time) / 1000) > 5000) {
                 CheckConnectionTimeout();
-                gettimeofday(&_cmdSubPriority_time, NULL);
+                GetClockTime(&_cmdSubPriority_time, NULL);
             }
             //if (pSysInfo->SystemTimeoutFlag != 0)
             //log_info("Timeout ***********SystemTimeoutFlag = %d(%d) ********",pSysInfo->SystemTimeoutFlag,
@@ -2581,13 +2598,6 @@ void CreateTimeoutFork(void)
                 }
                 break;
 
-            case Timeout_WaitPlug:
-                if (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL >= _connectionTimeout) {
-                    _DetectPlugInTimeout();
-
-                    //destroySelGun(pSysInfo->CurGunSelected);
-                }
-                break;
 /*
             case Timeout_ReturnToChargingGunDet:
                 if (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL >= RETURN_TO_CHARGING_PAGE) {
@@ -2623,17 +2633,17 @@ void CreateTimeoutFork(void)
                 /*
                 if (pDcChargingInfo->TimeoutFlag != 0)
                 log_info("Timeout ***********GunTimeoutFlag = %d(%d) ********",pDcChargingInfo->TimeoutFlag,
-                        GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL);
+                        GetTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL);
                         */
                 switch (pDcChargingInfo->TimeoutFlag) {
                 case Timeout_EVCCID_Link:
-                if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= EVCCID_LINK_TIMEOUT) {
+                if (GetTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL >= EVCCID_LINK_TIMEOUT) {
                     _evccidlinktimeout(gunIndex);
                 	}
                 break;
 
                 case Timeout_Preparing:
-                    if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= GUN_PREPARE_TIMEOUT) {
+                    if (GetTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL >= GUN_PREPARE_TIMEOUT) {
                         _PrepareTimeout(gunIndex);
                         StopGunInfoTimeoutDet(gunIndex);
                         destroySelGun(gunIndex); //jerry add
@@ -2641,7 +2651,7 @@ void CreateTimeoutFork(void)
                     break;
 
                 case Timeout_EvChargingDet:
-                    if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= GUN_EV_WAIT_TIMEOUT) {
+                    if (GetTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL >= GUN_EV_WAIT_TIMEOUT) {
                         _DetectEvChargingEnableTimeout(gunIndex);
                         StopGunInfoTimeoutDet(gunIndex);
                         destroySelGun(gunIndex); //jerry add
@@ -2649,7 +2659,7 @@ void CreateTimeoutFork(void)
                     break;
 
                 case Timeout_EvseChargingDet:
-                    if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= GUN_EVSE_WAIT_TIMEOUT) {
+                    if (GetTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL >= GUN_EVSE_WAIT_TIMEOUT) {
                         _DetectEvseChargingEnableTimeout(gunIndex);
                         StopGunInfoTimeoutDet(gunIndex);
                         destroySelGun(gunIndex); //jerry add
@@ -2657,14 +2667,14 @@ void CreateTimeoutFork(void)
                     break;
 
                 case Timeout_EvseCompleteDet:
-                    if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= GUN_COMP_WAIT_TIMEOUT) {
+                    if (GetTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL >= GUN_COMP_WAIT_TIMEOUT) {
                         StopGunInfoTimeoutDet(gunIndex);
                         destroySelGun(gunIndex); //jerry add
                     }
                     break;
 
                 case Timeout_ForCcsPrechargeDet:
-                    if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= GUN_PRECHARGING_TIMEOUT) {
+                    if (GetTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL >= GUN_PRECHARGING_TIMEOUT) {
                         _CcsPrechargeTimeout(gunIndex);
                         StopGunInfoTimeoutDet(gunIndex);
                         destroySelGun(gunIndex); //jerry add
@@ -2672,7 +2682,7 @@ void CreateTimeoutFork(void)
                     break;
                     /*
                 case Timeout_SelectGun: //Jerry add
-                    if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= SEL_GUN_TIMEOUT) {
+                    if (GetTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL >= SEL_GUN_TIMEOUT) {
                         log_info("Timeout_SelectGun");
                         StopGunInfoTimeoutDet(gunIndex);
                         destroySelGun(gunIndex); //jerry add
@@ -2680,21 +2690,21 @@ void CreateTimeoutFork(void)
                     break;
                     */
                 case Timeout_PlugOut:
-                    if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= PLUGOUT_TIMEOUT) {
+                    if (GetTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL >= PLUGOUT_TIMEOUT) {
                         StopGunInfoTimeoutDet(gunIndex);
                         destroySelGun(gunIndex); //jerry add
                         setChargerMode(gunIndex, S_IDLE);
                     }
                     break;
                 case Timeout_GunAuthorizePage:
-                    if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= GUN_AUTHORIZE_PAGE) {
+                    if (GetTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL >= GUN_AUTHORIZE_PAGE) {
                         StopGunInfoTimeoutDet(gunIndex);
                         destroySelGun(gunIndex); //jerry add
                         pDcChargingInfo->SystemStatus = S_IDLE;
                     }
                     break;
                 case Timeout_Terminating:
-                    if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= TERMINATING_TIMEOUT) {
+                    if (GetTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL >= TERMINATING_TIMEOUT) {
                         StopGunInfoTimeoutDet(gunIndex);
                         pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(gunIndex);
 
@@ -2703,6 +2713,14 @@ void CreateTimeoutFork(void)
                         setChargerMode(gunIndex, S_COMPLETE);
                     }
                     break;
+
+                case Timeout_WaitPlug:
+                    if (GetTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL >= _connectionTimeout) {
+                        StopGunInfoTimeoutDet(gunIndex);
+                        _DetectPlugInTimeout(gunIndex);
+                        destroySelGun(gunIndex);
+                    }
+                    break;
                 }
             }
             sleep(1);
@@ -2860,36 +2878,35 @@ void OcppRemoteStartChk()
 {
     if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_NO_CHARGING) {
 
-    } else if (!isDetectPlugin()) {
+    } else {
         // 如果有 AC 槍,則固定是第 2 把槍,所以索引固定為 1
         uint8_t acDirIndex = pSysConfig->AcConnectorCount;
+        if (!isDetectPlugin(acDirIndex)) {
+            for (uint8_t ac_index = 0; ac_index < pSysConfig->AcConnectorCount; ac_index++) {
+                pAcChargingInfo = (struct ChargingInfoData*)GetAcChargingInfoData(ac_index);
 
-        for (uint8_t ac_index = 0; ac_index < pSysConfig->AcConnectorCount; ac_index++) {
-            pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(ac_index);
-
-            if (ShmOCPP16Data->CsMsg.bits[acDirIndex].RemoteStartTransactionReq == YES) {
-                if (pAcChargingInfo->SystemStatus == S_IDLE ||
+                if (ShmOCPP16Data->CsMsg.bits[acDirIndex].RemoteStartTransactionReq == YES) {
+                    if (pAcChargingInfo->SystemStatus == S_IDLE ||
                         pAcChargingInfo->SystemStatus == S_RESERVATION) {
+                        ShmOCPP16Data->CsMsg.bits[acDirIndex].RemoteStartTransactionReq = NO;
+                        pAcChargingInfo->RemoteStartFlag = YES;
+                        pSysInfo->OrderCharging = YES;
+                        //pSysInfo->OrderCharging = DEFAULT_AC_INDEX;
+                        ShmOCPP16Data->CsMsg.bits[pSysConfig->TotalConnectorCount + ac_index].RemoteStartTransactionReq = NO;
+                        DetectPluginStart(acDirIndex);
+                        return;
+                    }
                     ShmOCPP16Data->CsMsg.bits[acDirIndex].RemoteStartTransactionReq = NO;
-                    pAcChargingInfo->RemoteStartFlag = YES;
-                    pSysInfo->OrderCharging = YES;
-                    //pSysInfo->OrderCharging = DEFAULT_AC_INDEX;
-                    ShmOCPP16Data->CsMsg.bits[pSysConfig->TotalConnectorCount + ac_index].RemoteStartTransactionReq = NO;
-                    DetectPluginStart();
-                    return;
                 }
-                ShmOCPP16Data->CsMsg.bits[acDirIndex].RemoteStartTransactionReq = NO;
             }
         }
-
-        uint8_t threeGunIndex = 0;
-        uint8_t dcIndex = 0;
-        bool isGunUsingStatus = false;
-        bool _remotestarting = false;
+        //uint8_t threeGunIndex = 0;
+        //uint8_t dcIndex = 0;
+        //bool isGunUsingStatus = false;
 
         for (uint8_t _index = 0; _index < pSysConfig->TotalConnectorCount; _index++) {
-            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
-
+            pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(_index);
+            /*
             // 如果有 AC 槍,且 DC 槍也有兩把
             if (acDirIndex == 1 && _index == 1) {
                 threeGunIndex = 1;
@@ -2903,7 +2920,7 @@ void OcppRemoteStartChk()
                 isGunUsingStatus = true;
             }
             if (pDcChargingInfo->RemoteStartFlag == YES) {
-            	_remotestarting = true;
+                //_remotestarting = true;
             }
         }
 
@@ -2920,24 +2937,26 @@ void OcppRemoteStartChk()
         if (dcIndex == 0) {
             threeGunIndex = 0;
         }
+        */
+            pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(_index);
 
-        pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(dcIndex);
-
-        if (ShmOCPP16Data->CsMsg.bits[dcIndex + threeGunIndex].RemoteStartTransactionReq == YES &&
-        		!_remotestarting ) {
-            if (pDcChargingInfo->SystemStatus == S_IDLE ||
-            		pDcChargingInfo->SystemStatus == S_AUTHORIZING ||
+            if (ShmOCPP16Data->CsMsg.bits[_index].RemoteStartTransactionReq == YES &&
+                !isDetectPlugin(_index)) {
+                if (pDcChargingInfo->SystemStatus == S_IDLE ||
+                    pDcChargingInfo->SystemStatus == MODE_AUTHORIZING ||
                     pDcChargingInfo->SystemStatus == S_RESERVATION) {
-                pDcChargingInfo->RemoteStartFlag = YES;
-                pSysInfo->OrderCharging = YES;
-                //pDcChargingInfo->SystemStatus = S_AUTHORIZING;
-                //pSysInfo->OrderCharging = gunIndex;
-                ShmOCPP16Data->CsMsg.bits[dcIndex + threeGunIndex].RemoteStartTransactionReq = NO;
-                DetectPluginStart();
-                setSelGunWaitToAuthor(dcIndex);
-                log_info("Ocpp Remote Start Pass");
+                    pDcChargingInfo->RemoteStartFlag = YES;
+                    //ShmDcCommonData->is_RemoteStart[_index] = TRUE;
+                    //pSysInfo->OrderCharging = YES;
+                    //pDcChargingInfo->SystemStatus = S_AUTHORIZING;
+                    //pSysInfo->OrderCharging = gunIndex;
+                    ShmOCPP16Data->CsMsg.bits[_index].RemoteStartTransactionReq = NO;
+                    DetectPluginStart(_index);
+                    setSelGunWaitToAuthor(_index);
+                    log_info("Ocpp Remote Start Gun%d Pass", _index);
+                }
+                ShmOCPP16Data->CsMsg.bits[_index].RemoteStartTransactionReq = NO;
             }
-            ShmOCPP16Data->CsMsg.bits[dcIndex + threeGunIndex].RemoteStartTransactionReq = NO;
         }
     }
 }
@@ -3110,7 +3129,6 @@ void ChangeStartOrStopDateTime(uint8_t isStart, uint8_t gunIndex)
 }
 void GetChargeTranscationDateTime(uint8_t gunIndex)
 {
-    char cmdBuf[32];
     struct timeb csuTime;
     struct tm* tmCSU;
 
@@ -3827,7 +3845,7 @@ void ResetIdleData(uint8_t gunIndex)
     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
     ShmOCPP16Data = (struct OCPP16Data *)GetShmOCPP16Data();
     ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
-
+    float powerconsumption = ShmDcCommonData->pGunInfo[gunIndex].PowerConsumption;
     pDcChargingInfo->PresentChargedDuration = 0;
     pDcChargingInfo->RemainChargingDuration = 0;
     pDcChargingInfo->PresentChargingVoltage = 0;//DS60-120 add
@@ -3841,11 +3859,13 @@ void ResetIdleData(uint8_t gunIndex)
     ShmDcCommonData->isIntoCharge[gunIndex] = FALSE;
     ShmDcCommonData->finalcost_flag[gunIndex] = FALSE;
 
-    ClearDetectPluginFlag();
+    ClearDetectPluginFlag(gunIndex);
     //Jerry add
     memset(&ShmSelectGunInfo->PricesInfo[gunIndex], 0, sizeof(PricesInfo));
     memset(&ShmDcCommonData->pGunInfo[gunIndex], 0, sizeof(GunInfo));
-    DB_Get_PowerConsumption(gunIndex);
+
+    ShmDcCommonData->pGunInfo[gunIndex].PowerConsumption = powerconsumption;
+
     ShmSelectGunInfo->PricesInfo[gunIndex].Balance = FAIL_BALANCE_PRICES;
     destroySelGun(gunIndex);
     ResetDetAlarmStatus(gunIndex); //recovery OVP status code
@@ -3874,7 +3894,7 @@ void CheckErrorCode(uint8_t gunIndex)
             systemPageRestoreInit();
         }
     }
-    ClearDetectPluginFlag();
+    ClearDetectPluginFlag(gunIndex);
     if (pDcChargingInfo->SystemStatus != S_FAULT)
     {
         UpdateErrorCodeToOcpp(gunIndex);
@@ -3939,7 +3959,6 @@ int main(void)
     bool isModelNameMatch = true;
     uint8_t _ocppProfileChkFlag;
     uint8_t gunIndex = 0;
-    uint8_t isplugin[2] = {0};
     if (CreateAllCsuShareMemory() == FAIL) {
         log_error("create share memory error");
         return FAIL;
@@ -4058,16 +4077,15 @@ int main(void)
 
     CheckFwSlotStatusLog();
     //AdjustChargerCurrent();
-    gettimeofday(&_cmdMainPriority_time, NULL);
+    GetClockTime(&_cmdMainPriority_time, NULL);
 
-    GunIndexInfo *pGunIndexInfo = (GunIndexInfo *)GetGunIndexInfo();
+    //GunIndexInfo *pGunIndexInfo = (GunIndexInfo *)GetGunIndexInfo();
 
     CheckTaskAlive();
 
     CreateWatchdog();
-    int is_idle = TRUE;
-    time_t ShowEVStatusTimer[2] = { 0 };
-    int EVStatus[2];
+    int is_prepare0 = FALSE;
+    int is_prepare1 = FALSE;
     pSysInfo->OTPTemp = GUN_OTP_VALUE;
     pSysInfo->OTPTempR = GUN_OTP_RECOVERY;
 
@@ -4115,26 +4133,42 @@ int main(void)
                 }
                 checkGunOTPState(gunIndex); //check gun OTP
             }
-            gettimeofday(&_cmdMainPriority_time, NULL);
+            GetClockTime(&_cmdMainPriority_time, NULL);
         }
 
         gEvBoardErr.GunErrMessage = 0; //清除系統執行中的錯誤訊息
         gChillerTempErr.TempErrMsg = 0;//清除系統執行中的錯誤訊息
-        is_idle = TRUE;
+        is_prepare0 = FALSE;
+        is_prepare1 = FALSE;
         for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
             pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
             // 重新收集各槍的錯誤狀態
             collectError(gunIndex);
             checkEvBoardAlarmState(pDcChargingInfo->Type);
-            if ((pDcChargingInfo->SystemStatus >= S_REASSIGN_CHECK &&
-                pDcChargingInfo->SystemStatus <= S_COMPLETE) ||
+            if ((pDcChargingInfo->SystemStatus >= S_AUTHORIZING &&
+                pDcChargingInfo->SystemStatus <= S_PREPARING_FOR_EVSE) ||
                 pDcChargingInfo->SystemStatus == S_CCS_PRECHARGE_ST0 ||
                 pDcChargingInfo->SystemStatus == S_CCS_PRECHARGE_ST1) {
-                is_idle = FALSE;
+                (gunIndex == LEFT_GUN_NUM) ? (is_prepare0 = TRUE) : (is_prepare1 = TRUE);
             }
-
         }
-
+        // 檢查是否有槍處於Preparing & precharging 狀態
+        if (is_prepare0 && !is_prepare1) {
+            pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(RIGHT_GUN_NUM);
+            if (pDcChargingInfo->SystemStatus != S_AUTHORIZING)
+                pSysInfo->CurGunSelected = LEFT_GUN_NUM;
+            else if (pDcChargingInfo->SystemStatus == S_AUTHORIZING) {
+                pSysInfo->CurGunSelected = RIGHT_GUN_NUM;
+            }
+        } else if (!is_prepare0 && is_prepare1) {
+            pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(LEFT_GUN_NUM);
+            if (pDcChargingInfo->SystemStatus != S_AUTHORIZING)
+                pSysInfo->CurGunSelected = RIGHT_GUN_NUM;
+            else if (pDcChargingInfo->SystemStatus == S_AUTHORIZING) {
+                pSysInfo->CurGunSelected = LEFT_GUN_NUM;
+            }
+        }
+        ////////////////////////////////////////
         checkChillerAlarmState();
 
         // 確認當前錯誤 Level = 2 ?
@@ -4243,7 +4277,8 @@ CheckStatus:
                 // 隨插即充
                 //autoStartCharging(gunIndex);
 
-                if (isDetectPlugin() && pSysInfo->SystemPage != _LCM_LINK_ERROR) {
+                if (isDetectPlugin(gunIndex) && pSysInfo->SystemPage != _LCM_LINK_ERROR) {
+                    StartGunInfoTimeoutDet(gunIndex, Timeout_WaitPlug);
                     // 卡號驗證成功後,等待充電槍插入充電車
                     if (pDcChargingInfo->RemoteStartFlag == YES) {
                         if (pDcChargingInfo->ConnectorPlugIn == YES &&
@@ -4256,7 +4291,7 @@ CheckStatus:
                             setChargerMode(gunIndex, MODE_REASSIGN_CHECK);
                             StopGunInfoTimeoutDet(gunIndex);
                             strcpy((char *)pDcChargingInfo->StartUserId, "");
-                            ClearDetectPluginFlag();
+                            ClearDetectPluginFlag(gunIndex);
                             continue;
                         }
                     } else if (pSysInfo->OrderCharging == NO_DEFINE) {
@@ -4279,7 +4314,7 @@ CheckStatus:
                             // 當前操作的槍號,進入 Preparing
                             setChargerMode(gunIndex, MODE_REASSIGN_CHECK);
                             StopGunInfoTimeoutDet(gunIndex);
-                            ClearDetectPluginFlag();
+                            ClearDetectPluginFlag(gunIndex);
                             continue;
                         }
                     }
@@ -4321,7 +4356,7 @@ CheckStatus:
 
                 if (ShmPsuData->SystemPresentPsuQuantity > 0 &&
                         ShmPsuData->SystemAvailablePower > 10 &&
-                        GetTimeoutValue(pDcChargingInfo->TimeoutTimer) >= 1000000) {
+                        GetTimeoutValue(pDcChargingInfo->ConnectorTimeout) >= 1000000) {
                     setChargerMode(gunIndex, MODE_PREPARE_FOR_EV);
                 }
 
@@ -4458,7 +4493,8 @@ CheckStatus:
                     ftime(&startChargingTime[gunIndex]);
                     strcpy((char *)ShmOCPP16Data->StartTransaction[gunIndex].ResponseIdTagInfo.Status, ""); //DS60-120 add
                     ChangeStartOrStopDateTime(YES, gunIndex);
-                    pSysInfo->SystemPage = _LCM_VIEW;
+                    if (pSysInfo->CurGunSelected == gunIndex)
+                        pSysInfo->SystemPage = _LCM_VIEW;
                     ShmDcCommonData->isIntoCharge[gunIndex] = TRUE;
                 }
 

+ 3 - 3
EVSE/Projects/DD360UCar/Apps/CSU/main.h

@@ -65,8 +65,8 @@
 //} LedConfig;
 
 //------------------------------------------------------------------------------
-bool isDetectPlugin(void);
-void _DetectPlugInTimeout(void);
+bool isDetectPlugin(int gunIndex);
+void _DetectPlugInTimeout(int gunIndex);
 void _evccidlinktimeout(uint8_t gunIndex);
 void StartSystemTimeoutDet(uint8_t flag);
 void StopSystemTimeoutDet(void);
@@ -78,7 +78,7 @@ void AuthorizingStart(void);
 bool IsAuthorizingMode(void);
 bool isAuthorizedComplete(void);
 void ClearAuthorizedFlag(void);
-void ClearDetectPluginFlag(void);
+void ClearDetectPluginFlag(int gunIndex);
 
 void ChargingAlarmProcess(uint8_t gunIndex);
 void StopChargingProcessByString(uint8_t level);

+ 1 - 0
EVSE/Projects/DD360UCar/Apps/Config.h

@@ -420,6 +420,7 @@ typedef struct StGunInfo {
     char ChargeStopTime[32];
     char ChargeDuration[32];
     uint8_t withChiller;      //是否有水冷機
+    uint8_t WaitForPlugit;    // 等待插槍FLAG
 } GunInfo;
 
 typedef struct Psu_VersionInfo{

+ 0 - 1
EVSE/Projects/DD360UCar/Apps/DataBase/DataBase.c

@@ -319,7 +319,6 @@ int DB_Get_PowerConsumption(uint8_t gunIndex)
             for (int idxRow = 1; idxRow <= rows; idxRow++) {
                 ShmDcCommonData->pGunInfo[gunIndex].PowerConsumption = atof(rs[(idxRow * cols) + 2]);
                 log_info("Query connector-%d PowerConsumption: %s", gunIndex, rs[(idxRow * cols) + 2]);
-                
             }
         } else {
             log_info("Query connector-%d fail, set default value to operactive.", gunIndex);

+ 16 - 11
EVSE/Projects/DD360UCar/Apps/ModuleDoComm/DoComm.c

@@ -61,7 +61,8 @@ static unsigned int LedIntensity = 0;
 static int TimeZoneOffset = 0;
 int RxLen;
 char Rxdata[1024];
-uint8_t _isplugin;
+
+uint8_t _isplugin[2] = { 0 };
 //------------------------------------------------------------------------------
 static void removeFaultCodeToBuf(uint8_t *Code);
 static void addFaultCodeToBuf(uint8_t *Code);
@@ -500,6 +501,7 @@ static int qrCodeUrlInfoHandle(uint8_t *data)
     struct timeb SeqEndTime;
     struct tm *tm;
     char _setTime[50];
+    int is_idle = TRUE;
     uint8_t cmdBuf[128];
     if ((char *)&data[0] == '\0') {
         log_error("QR code date error");
@@ -519,13 +521,16 @@ static int qrCodeUrlInfoHandle(uint8_t *data)
 
     //copy QR code string
     memset(ShmDcCommonData->QRCodeString, '\0', sizeof(ShmDcCommonData->QRCodeString));
-    //printf("data =  %s", data);
-    //len =
 
+    // 充電槍IDLE時才更新系統時間
+    for (int i = 0; i < pSysConfig->TotalConnectorCount; i++) {
+        pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(i);
+        if (pDcChargingInfo->SystemStatus != S_IDLE)
+            is_idle = FALSE;
+    }
     string2ByteArray((char *)data, (uint8_t *)ShmDcCommonData->QRCodeString);
     string2Date((char*)data, (uint8_t*)_setTime);
-    //printf("SystemId =  %s", pSysConfig->SystemId);
-    if (!timecmp(localTime, _setTime)) {
+    if (!timecmp(localTime, _setTime) && is_idle) {
         //log_info("Set Timer:%s Time Zone:%d", _setTime,ShmDcCommonData->TZOffset);
         sprintf((char*)cmdBuf, "date -u -s \"%s\" >> /dev/null &", _setTime);
         system((char*)cmdBuf);
@@ -1773,13 +1778,13 @@ static int readChargingTimeStamp(int fd, uint8_t id)
 
     return ret;
 }
-static int writeWaitPlugItState(int fd, uint8_t id)
+static int writeWaitPlugItState(int fd, uint8_t id, uint8_t gunIndex)
 {
     int ret = PASS;
-    uint8_t data[2] = {pSysInfo->WaitForPlugit, 0};
-    if (_isplugin != pSysInfo->WaitForPlugit) {
-        log_info("Wait for plug:%s", pSysInfo->WaitForPlugit == 0 ? "disable" : "enable");
-        _isplugin = pSysInfo->WaitForPlugit;
+    uint8_t data[2] = { ShmDcCommonData->pGunInfo[gunIndex].WaitForPlugit, 0 };
+    if (_isplugin[gunIndex] != ShmDcCommonData->pGunInfo[gunIndex].WaitForPlugit) {
+        //log_info("Wait Gun%d for plug:%s", gunIndex, ShmDcCommonData->pGunInfo[gunIndex].WaitForPlugit == 0 ? "disable" : "enable");
+        _isplugin[gunIndex] = ShmDcCommonData->pGunInfo[gunIndex].WaitForPlugit;
     }
     //printf("WaitForPlugit = %d", pSysInfo->WaitForPlugit);
 
@@ -2786,7 +2791,7 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
         if (DiffTimeb(gRegTimeUp[plugNum][REG_WAIT_PLUG_IT_STATE], AuthNowTime) > (LOOP_RETRY_TIME / 10) ||
                 DiffTimeb(gRegTimeUp[plugNum][REG_WAIT_PLUG_IT_STATE], AuthNowTime) < 0
            ) {
-            writeWaitPlugItState(fd, gunID);
+            writeWaitPlugItState(fd, gunID, plugNum);
             ftime(&gRegTimeUp[plugNum][REG_WAIT_PLUG_IT_STATE]);
         }
         /*

+ 18 - 11
EVSE/Projects/DD360UCar/Apps/ModuleEvComm/Module_EvTxComm.c

@@ -67,13 +67,20 @@ int GetCanFd(void)
 {
     return CanFd;
 }
-
-uint32_t GetTimeoutValue(struct timeval _sour_time)
+void GetClockTime(struct timespec* _now_time, void* null)
+{
+    clock_gettime(CLOCK_MONOTONIC, _now_time);
+}
+unsigned long GetTimeoutValue(struct timespec _start_time)
 {
-    struct timeval _end_time;
-    gettimeofday(&_end_time, NULL);
+    struct timespec ts_end;
+    unsigned long ret = 0;
+
+    clock_gettime(CLOCK_MONOTONIC, &ts_end);
+
+    ret = ((unsigned long)(ts_end.tv_sec - _start_time.tv_sec) * 1000000) + ((unsigned long)((ts_end.tv_nsec / 1000) - (_start_time.tv_nsec / 1000)));
 
-    return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
+    return ret;
 }
 
 int InitCanBus(void)
@@ -693,8 +700,8 @@ int main(int argc, char *argv[])
     uint32_t _timeBuf = 0;
     uint32_t chargingTime[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY] = {0};
     float maxVol, maxCur;
-    struct timeval _chk_ratingPower_timeout[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
-    struct timeval _chk_chademo_permission_timeout[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
+    struct timespec _chk_ratingPower_timeout[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
+    struct timespec _chk_chademo_permission_timeout[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
     time_t rtc = {0};
     struct ChargingInfoData *pDcChargingInfo = NULL;
     struct timeb waitChargingTime;
@@ -792,17 +799,17 @@ int main(int argc, char *argv[])
                     if (pSysInfo->PageIndex == _LCM_WAIT_PLUGIN) {
                         if (!chkChademoPermission[gunIndex]) {
                             chkChademoPermission[gunIndex] = true;
-                            gettimeofday(&_chk_chademo_permission_timeout[gunIndex], NULL);
+                            GetClockTime(&_chk_chademo_permission_timeout[gunIndex], NULL);
                             SendCommunicationOnly(gunIndex);
                         } else {
                             _timeBuf = GetTimeoutValue(_chk_chademo_permission_timeout[gunIndex]);
 
                             if (_timeBuf < 0) {
-                                gettimeofday(&_chk_chademo_permission_timeout[gunIndex], NULL);
+                                GetClockTime(&_chk_chademo_permission_timeout[gunIndex], NULL);
                             } else {
                                 if (_timeBuf / 1000 > 10000) {
                                     SendCommunicationOnly(gunIndex);
-                                    gettimeofday(&_chk_chademo_permission_timeout[gunIndex], NULL);
+                                    GetClockTime(&_chk_chademo_permission_timeout[gunIndex], NULL);
                                 }
                             }
                         }
@@ -943,7 +950,7 @@ int main(int argc, char *argv[])
                     GetEvBatteryInfo(gunIndex, pDcChargingInfo->Evboard_id);
                 }
 
-                gettimeofday(&_chk_ratingPower_timeout[gunIndex], NULL);
+                GetClockTime(&_chk_ratingPower_timeout[gunIndex], NULL);
                 break;
 
             case S_PREPARING_FOR_EVSE:

+ 5 - 5
EVSE/Projects/DD360UCar/Apps/ModuleInternalComm/AcPlug.c

@@ -25,8 +25,8 @@ static struct OCPP16Data *ShmOCPP16Data = NULL;
 
 static int Uart5Fd = 0;
 
-static struct timeval  _ac_charging_comp;
-static struct timeval  _ac_preparing;
+static struct timespec  _ac_charging_comp;
+static struct timespec  _ac_preparing;
 static struct timeb    _ac_startChargingTime;
 static struct timeb    _ac_endChargingTime;
 
@@ -414,7 +414,7 @@ void AcPlugTask(int uartFD)
                 if (pSysInfo->OrderCharging != NO_DEFINE) {
                     pSysInfo->OrderCharging = NO_DEFINE;
                 }
-                gettimeofday(&_ac_preparing, NULL);
+                GetClockTime(&_ac_preparing, NULL);
             }
 
             if (GetChargingEnergy() == PASS) {
@@ -464,7 +464,7 @@ void AcPlugTask(int uartFD)
         case S_TERMINATING: {
             if (isModeChange()) {
                 ChangeStartOrStopDateTime(NO);
-                gettimeofday(&_ac_charging_comp, NULL);
+                GetClockTime(&_ac_charging_comp, NULL);
             }
 
             SetLegacyReq(NO);
@@ -475,7 +475,7 @@ void AcPlugTask(int uartFD)
         break;
         case S_COMPLETE: {
             if (isModeChange()) {
-                gettimeofday(&_ac_charging_comp, NULL);
+                GetClockTime(&_ac_charging_comp, NULL);
                 ftime(&_ac_endChargingTime);
                 if (strcmp((char *)pAcChargingInfo->StartDateTime, "") != EQUAL) {
                     // AC 固定為第2把槍

+ 3 - 3
EVSE/Projects/DD360UCar/Apps/ModuleInternalComm/FanBoard.c

@@ -22,7 +22,7 @@ static struct FanModuleData *ShmFanModuleData = NULL;
 static struct PsuData *ShmPsuData = NULL;
 
 static int Uart5Fd = 0;
-static struct timeval gFanBoardRunTimer;
+static struct timespec gFanBoardRunTimer;
 
 static uint16_t _setFanSpeed = 0;
 static uint16_t fanSpeedSmoothValue = 500;
@@ -229,7 +229,7 @@ static void fanBoardPorcess(void)
             GetFanSpeedByFunction();
             GetFanSpeed();
             pSysInfo->SystemFanRotaSpeed = _setFanSpeed;
-            gettimeofday(&gFanBoardRunTimer, NULL);
+            GetClockTime(&gFanBoardRunTimer, NULL);
 
             ShmFanModuleData->SetFan1Speed = ShmFanModuleData->TestFanSpeed;
             ShmFanModuleData->SetFan2Speed = ShmFanModuleData->TestFanSpeed;
@@ -252,7 +252,7 @@ static void fanBoardSelfTest(void)
     SetModelName_Fan();
     SetRtcData_Fan();
     sleep(1);
-    gettimeofday(&gFanBoardRunTimer, NULL);
+    GetClockTime(&gFanBoardRunTimer, NULL);
 }
 
 void FanBoardTask(int uartFD)

+ 4 - 4
EVSE/Projects/DD360UCar/Apps/ModuleInternalComm/LEDlight.c

@@ -27,7 +27,7 @@ static int Uart5Fd = 0;
 static Led_Color cur_led_color = {COLOR_MIN_LV};
 static Led_Color led_color;
 
-static struct timeval _led_priority_time;
+static struct timespec _led_priority_time;
 
 //------------------------------------------------------------------------------
 static bool IsNoneMatchLedColor(void)
@@ -255,7 +255,7 @@ static void LEDBoardProcess(void)
         //    SetLedColor(pDcChargingInfo0, pDcChargingInfo1);
         //}
         SetLedColor();
-        gettimeofday(&_led_priority_time, NULL);
+        GetClockTime(&_led_priority_time, NULL);
     }
 }
 
@@ -269,7 +269,7 @@ static void LEDBoardSelfTest(void)
 #if defined DD360 ||defined DD360Audi
     GetFwAndHwVersion_Led();
     sleep(1);
-    gettimeofday(&_led_priority_time, NULL);
+    GetClockTime(&_led_priority_time, NULL);
 
     return;
 #endif //defined DD360 || defined DD360Audi
@@ -278,7 +278,7 @@ static void LEDBoardSelfTest(void)
     if (pSysInfo->SelfTestSeq <= _STEST_PSU_CAP) {
         GetFwAndHwVersion_Led();
         sleep(1);
-        gettimeofday(&_led_priority_time, NULL);
+        GetClockTime(&_led_priority_time, NULL);
     } else {
         // 自檢階段沒有問到版號
         if (pAlarmCode->AlarmEvents.bits.LedboardStestFail == NO) {

+ 14 - 4
EVSE/Projects/DD360UCar/Apps/ModuleInternalComm/Module_InternalComm.c

@@ -11,6 +11,7 @@
 #include <sys/timeb.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
+#include <time.h>
 
 #include "../Config.h"
 #include "../Log/log.h"
@@ -38,12 +39,21 @@ int DiffTimeb(struct timeb ST, struct timeb ET)
     return (StopTime - StartTime);
 }
 
-uint32_t GetTimeoutValue(struct timeval _sour_time)
+void GetClockTime(struct timespec* _now_time, void* null)
 {
-    struct timeval _end_time;
-    gettimeofday(&_end_time, NULL);
+    clock_gettime(CLOCK_MONOTONIC, _now_time);
+}
+
+unsigned long GetTimeoutValue(struct timespec _start_time)
+{
+    struct timespec ts_end;
+    unsigned long ret = 0;
+
+    clock_gettime(CLOCK_MONOTONIC, &ts_end);
+
+    ret = ((unsigned long)(ts_end.tv_sec - _start_time.tv_sec) * 1000000) + ((unsigned long)((ts_end.tv_nsec / 1000) - (_start_time.tv_nsec / 1000)));
 
-    return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
+    return ret;
 }
 
 static int Init485ComPort(void)

+ 2 - 1
EVSE/Projects/DD360UCar/Apps/ModuleInternalComm/Module_InternalComm.h

@@ -104,7 +104,8 @@ typedef struct StPreCharginState {
 } PreChargingState;
 
 //------------------------------------------------------------------------------
-uint32_t GetTimeoutValue(struct timeval _sour_time);
+unsigned long GetTimeoutValue(struct timespec _start_time);
+void GetClockTime(struct timespec* _now_time, void* null);
 int DiffTimeb(struct timeb ST, struct timeb ET);
 
 #endif /* _MODULE_INTERNAL_COMM_H_ */

+ 19 - 19
EVSE/Projects/DD360UCar/Apps/ModuleInternalComm/RelayBoard.c

@@ -29,13 +29,13 @@ static struct FanModuleData *ShmFanModuleData = NULL;
 static Relay outputRelay = {0};
 static Relay regRelay = {0};
 static int Uart5Fd = 0;
-static struct timeval gFanBoardRunTimer;
+static struct timespec gFanBoardRunTimer;
 static uint16_t _setFanSpeed = 0;
 static uint16_t fanSpeedSmoothValue = 500;
 
 static Led_Color cur_led_color = {COLOR_MIN_LV};
 static Led_Color led_color;
-static struct timeval _led_priority_time;
+static struct timespec _led_priority_time;
 
 //static bool _isRelayWelding[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 //static struct timeval _checkRelayWeldingTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
@@ -44,26 +44,26 @@ static struct timeval _led_priority_time;
 //static struct timeval _checkOutputNoneMatchTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 
 static bool _isOvpChkTimeFlag[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY]; //DS60-120 add
-static struct timeval _checkOutputVolProtectTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY]; //DS60-120 add
+static struct timespec _checkOutputVolProtectTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY]; //DS60-120 add
 
 static void SetLedColor(void);
-static struct timeval _close_ac_contactor;
+static struct timespec _close_ac_contactor;
 
 //------------------------------------------------------------------------------
 static void RunForceStopProcess(void)
 {
     static bool isCriticalStop = NO;
-    static struct timeval  _psuCriticalStop;
+    static struct timespec  _psuCriticalStop;
     uint32_t _timebuf;
 
     if (isCriticalStop == NO) {
         isCriticalStop = YES;
-        gettimeofday(&_psuCriticalStop, NULL);
+        GetClockTime(&_psuCriticalStop, NULL);
     } else {
         _timebuf = GetTimeoutValue(_psuCriticalStop);
 
         if (_timebuf < 0) {
-            gettimeofday(&_psuCriticalStop, NULL);
+            GetClockTime(&_psuCriticalStop, NULL);
         } else {
             if (_timebuf / 1000 >= (FORCE_STOP_TIME * 1000)) {
                 isCriticalStop = NO;
@@ -83,11 +83,11 @@ static void StopCheckRelayInfo(uint8_t _chkIndex)
 static void StartCheckRelayInfo(uint8_t _chkIndex, uint8_t toState)
 {
     // SMR1 *2 + SMR2 * 2 + Parallel * 2
-    static struct timeval lastCheckRelayStateTimer[6] = {0};
+    static struct timespec lastCheckRelayStateTimer[6] = {0};
     //uint8_t *pCheckRelayState = (uint8_t *)ShmDcCommonData->CheckRelayStatus[_chkIndex];
 
     if (ShmDcCommonData->CheckRelayStatus[_chkIndex] == STOP) {
-        gettimeofday(&lastCheckRelayStateTimer[_chkIndex], NULL);
+        GetClockTime(&lastCheckRelayStateTimer[_chkIndex], NULL);
         ShmDcCommonData->CheckRelayStatus[_chkIndex] = START;
     } else {
         if ((GetTimeoutValue(lastCheckRelayStateTimer[_chkIndex]) / 1000000) >= 1) {
@@ -97,7 +97,7 @@ static void StartCheckRelayInfo(uint8_t _chkIndex, uint8_t toState)
             } else {
                 ShmDcCommonData->CheckRelayStatus[_chkIndex] = RELAY_STATUS_ERROR_WELDING;
             }
-            gettimeofday(&lastCheckRelayStateTimer[_chkIndex], NULL);
+            GetClockTime(&lastCheckRelayStateTimer[_chkIndex], NULL);
         }
     }
 }
@@ -372,7 +372,7 @@ void CheckOutputPowerOverCarReq(uint8_t index)
         if (fireV >= (carV + (carV * 0.02))) {
             if (!_isOvpChkTimeFlag[index]) {
                 if ((pDcChargingInfo->PresentChargingVoltage * 10) >= VOUT_MIN_VOLTAGE * 10) {
-                    gettimeofday(&_checkOutputVolProtectTimer[index], NULL);
+                    GetClockTime(&_checkOutputVolProtectTimer[index], NULL);
                     _isOvpChkTimeFlag[index] = YES;
                 }
             } else {
@@ -476,7 +476,7 @@ void CheckAcInputOvpStatus(uint8_t index)
 //                ((pDcChargingInfo->PresentChargingVoltage * 10) > pDcChargingInfo->FireChargingVoltage + 300)) {
 //            if (!_isOutputNoneMatch[index]) {
 //                _isOutputNoneMatch[index] = YES;
-//                gettimeofday(&_checkOutputNoneMatchTimer[index], NULL);
+//                GetClockTime(&_checkOutputNoneMatchTimer[index], NULL);
 //            } else {
 //                if ((GetTimeoutValue(_checkOutputNoneMatchTimer[index]) / 1000) >= 5000) {
 //                    /*log_info("[Module_InternalComm]CheckOutputVolNoneMatchFire NG (%d) : pre = %f, fire = %f ",
@@ -1400,7 +1400,7 @@ static void fanBoardSelfTest(void)
     SetModelName_Fan();
     SetRtcData_Fan();
     sleep(1);
-    gettimeofday(&gFanBoardRunTimer, NULL);
+    GetClockTime(&gFanBoardRunTimer, NULL);
     ShmDcCommonData->FanDisconnectTime = time((time_t*)NULL);
 }
 
@@ -1420,7 +1420,7 @@ static void fanBoardPorcess(void)
             //GetFanSpeedByFunction();
             GetFanSpeed();
             pSysInfo->SystemFanRotaSpeed = _setFanSpeed;
-            gettimeofday(&gFanBoardRunTimer, NULL);
+            GetClockTime(&gFanBoardRunTimer, NULL);
             /*
             ShmFanModuleData->SetFan1Speed = ShmFanModuleData->TestFanSpeed;
             ShmFanModuleData->SetFan2Speed = ShmFanModuleData->TestFanSpeed;
@@ -1681,7 +1681,7 @@ static void LEDBoardSelfTest(void)
 #if defined DD360 ||defined DD360Audi || defined DD360UCar
     GetFwAndHwVersion_Led();
     sleep(1);
-    gettimeofday(&_led_priority_time, NULL);
+    GetClockTime(&_led_priority_time, NULL);
 
     return;
 #endif //defined DD360 || defined DD360Audi
@@ -1690,7 +1690,7 @@ static void LEDBoardSelfTest(void)
     if (pSysInfo->SelfTestSeq <= _STEST_PSU_CAP) {
         GetFwAndHwVersion_Led();
         sleep(1);
-        gettimeofday(&_led_priority_time, NULL);
+        GetClockTime(&_led_priority_time, NULL);
     } else {
         // 自檢階段沒有問到版號
         if (pAlarmCode->AlarmEvents.bits.LedboardStestFail == NO) {
@@ -1720,7 +1720,7 @@ static void LEDBoardProcess(void)
         //    SetLedColor(pDcChargingInfo0, pDcChargingInfo1);
         //}
         SetLedColor();
-        gettimeofday(&_led_priority_time, NULL);
+        GetClockTime(&_led_priority_time, NULL);
     }
 }
 
@@ -1843,7 +1843,7 @@ void RelayBoardTask(int uartFD)
                              pDcChargingInfo->SystemStatus <= S_COMPLETE) ||
                             (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
                              pDcChargingInfo->SystemStatus <= S_CCS_PRECHARGE_ST1) ||
-                            pSysInfo->WaitForPlugit == YES ||
+                             ShmDcCommonData->pGunInfo[i].WaitForPlugit == YES ||
                             (pSysInfo->PageIndex >=  _LCM_START_AUTHORIZING &&
                              pSysInfo->PageIndex <= _LCM_WAIT_PLUGIN)
                        ) {
@@ -1889,7 +1889,7 @@ void RelayBoardTask(int uartFD)
                     outputRelay.relay_event.bits.AC_Contactor = YES;
                 } else {
                     if (!isStopChargingCount) {
-                        gettimeofday(&_close_ac_contactor, NULL);
+                        GetClockTime(&_close_ac_contactor, NULL);
                         isStopChargingCount = true;
                     } else {
                         if ((outputRelay.relay_event.bits.AC_Contactor == YES &&

+ 9 - 5
EVSE/Projects/DD360UCar/Apps/ModuleLcmCtrl/Module_LcmControl.c

@@ -900,19 +900,23 @@ void ShowCountDownTimer()
     else
         DisplayValueToLcm(_Count_Down_Time, (uint8_t *)value, sizeof(value));
 }
-unsigned long GetTimeoutValue(struct timeval _sour_time)
+unsigned long GetTimeoutValue(struct timespec _start_time)
 {
-    struct timeval _end_time;
-    gettimeofday(&_end_time, NULL);
+    struct timespec ts_end;
+    unsigned long ret = 0;
+
+    clock_gettime(CLOCK_MONOTONIC, &ts_end);
+
+    ret = ((unsigned long)(ts_end.tv_sec - _start_time.tv_sec) * 1000000) + ((unsigned long)((ts_end.tv_nsec / 1000) - (_start_time.tv_nsec / 1000)));
 
-    return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
+    return ret;
 }
 void ShowGunCountDownTimer()
 {
     int min,sec;
     uint8_t value[10] = {0};
     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
-    int tm = 120 - (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL);
+    int tm = 120 - (GetTimeoutValue(pDcChargingInfo->ConnectorTimeout) / uSEC_VAL);
     // GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL
     min = tm/60;
     sec = tm%60;

+ 8 - 4
EVSE/Projects/DD360UCar/Apps/ModulePrimary/Module_PrimaryComm.c

@@ -393,12 +393,16 @@ int InitComPort()
     return fd;
 }
 
-unsigned long GetTimeoutValue(struct timeval _sour_time)
+unsigned long GetTimeoutValue(struct timespec _start_time)
 {
-    struct timeval _end_time;
-    gettimeofday(&_end_time, NULL);
+    struct timespec ts_end;
+    unsigned long ret = 0;
 
-    return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
+    clock_gettime(CLOCK_MONOTONIC, &ts_end);
+
+    ret = ((unsigned long)(ts_end.tv_sec - _start_time.tv_sec) * 1000000) + ((unsigned long)((ts_end.tv_nsec / 1000) - (_start_time.tv_nsec / 1000)));
+
+    return ret;
 }
 
 static bool IsPrimaryProcessNeedPause(void)

+ 8 - 6
EVSE/Projects/DD360UCar/Apps/ModulePsuComm/Module_PsuComm.c

@@ -39,14 +39,16 @@ int StoreLogMsg(const char *fmt, ...);
 #define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
 #define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
 
-unsigned long GetTimeoutValue(struct timeval _sour_time);
-
-unsigned long GetTimeoutValue(struct timeval _sour_time)
+unsigned long GetTimeoutValue(struct timespec _start_time)
 {
-	struct timeval _end_time;
-	gettimeofday(&_end_time, NULL);
+	struct timespec ts_end;
+	unsigned long ret = 0;
+
+	clock_gettime(CLOCK_MONOTONIC, &ts_end);
+
+	ret = ((unsigned long)(ts_end.tv_sec - _start_time.tv_sec) * 1000000) + ((unsigned long)((ts_end.tv_nsec / 1000) - (_start_time.tv_nsec / 1000)));
 
-	return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
+	return ret;
 }
 
 int StoreLogMsg(const char *fmt, ...)

+ 4 - 4
EVSE/Projects/DD360UCar/Apps/ModulePsuComm/Module_PsuComm.h

@@ -40,11 +40,11 @@ unsigned char _gunCount;
 struct ChargingInfoData *chargingInfo[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 bool isStartOutputSwitch[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 
-struct timeval _cmdSubPriority_time;
-struct timeval _derating_time;
-struct timeval _max_time;
+struct timespec _cmdSubPriority_time;
+struct timespec _derating_time;
+struct timespec _max_time;
 
-struct timeval _test_time;
+struct timespec _test_time;
 
 bool isCharging = false;
 bool isWaitingAver = false;

+ 15 - 6
EVSE/Projects/DD360UCar/Apps/OutputTask.c

@@ -36,12 +36,21 @@ int InitComPort()
 	return fd;
 }
 
-unsigned long GetTimeoutValue(struct timeval _sour_time)
+void GetClockTime(struct timespec* _now_time, void* null)
 {
-	struct timeval _end_time;
-	gettimeofday(&_end_time, NULL);
+	clock_gettime(CLOCK_MONOTONIC, _now_time);
+}
+
+unsigned long GetTimeoutValue(struct timespec _start_time)
+{
+	struct timespec ts_end;
+	unsigned long ret = 0;
+
+	clock_gettime(CLOCK_MONOTONIC, &ts_end);
+
+	ret = ((unsigned long)(ts_end.tv_sec - _start_time.tv_sec) * 1000000) + ((unsigned long)((ts_end.tv_nsec / 1000) - (_start_time.tv_nsec / 1000)));
 
-	return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
+	return ret;
 }
 
 void ShowMainMsg()
@@ -263,7 +272,7 @@ int main(void)
 	}
 
 	sleep(5);
-	gettimeofday(&_cmdSubPriority_time, NULL);
+	GetClockTime(&_cmdSubPriority_time, NULL);
 	VOLTAGE = 0.0;
 	CURRENT = 0.0;
 
@@ -347,7 +356,7 @@ int main(void)
 			{
 				printf("Step 1 : GetModuleCount...... \n");
 				GetModuleCount(SYSTEM_CMD);
-				gettimeofday(&_cmdSubPriority_time, NULL);
+				GetClockTime(&_cmdSubPriority_time, NULL);
 			}
 		}
 		else if (time < 5000)

+ 1 - 1
EVSE/Projects/DD360UCar/Apps/OutputTask.h

@@ -56,7 +56,7 @@ int Uart1Fd = -1;
 char *priPortName = "/dev/ttyS1";
 
 bool libInitialize = false;
-struct timeval _cmdSubPriority_time;
+struct timespec _cmdSubPriority_time;
 
 unsigned char Button1 = RELEASE;
 unsigned char Button2 = RELEASE;

+ 16 - 7
EVSE/Projects/DD360UCar/Apps/ReadCmdline.c

@@ -65,7 +65,7 @@
 //------------------------------------------------------------------------------
 uint8_t _curAutoRunCount = 0;
 uint8_t _usingAutoRun = 0;
-struct timeval _autoTime;
+struct timespec _autoTime;
 
 static struct SysConfigData *pSysConfig = NULL;
 static struct SysInfoData *pSysInfo = NULL;
@@ -180,12 +180,21 @@ static uint8_t readCmdKey(uint8_t state)
     return YES;
 }
 
-unsigned long GetTimeoutValue(struct timeval _sour_time)
+void GetClockTime(struct timespec* _now_time, void* null)
 {
-    struct timeval _end_time;
-    gettimeofday(&_end_time, NULL);
+    clock_gettime(CLOCK_MONOTONIC, _now_time);
+}
+
+unsigned long GetTimeoutValue(struct timespec _start_time)
+{
+    struct timespec ts_end;
+    unsigned long ret = 0;
+
+    clock_gettime(CLOCK_MONOTONIC, &ts_end);
+
+    ret = ((unsigned long)(ts_end.tv_sec - _start_time.tv_sec) * 1000000) + ((unsigned long)((ts_end.tv_nsec / 1000) - (_start_time.tv_nsec / 1000)));
 
-    return (_end_time.tv_sec - _sour_time.tv_sec);
+    return ret;
 }
 
 void RunStatusProc(char *v1, char *v2)
@@ -819,7 +828,7 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
                     pDcChargingInfo->EvBatterytargetCurrent = _Current;
                 } else {
                     _curAutoRunCount = 0;
-                    gettimeofday(&_autoTime, NULL);
+                    GetClockTime(&_autoTime, NULL);
                 }
 
                 pDcChargingInfo->EvBatterySoc = 50;
@@ -841,7 +850,7 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
                     if (_curAutoRunCount >= AUTORUN_CYCLE_COUNT) {
                         pDcChargingInfo->SystemStatus = S_TERMINATING;
                     } else {
-                        gettimeofday(&_autoTime, NULL);
+                        GetClockTime(&_autoTime, NULL);
                     }
                 } else {
                     pDcChargingInfo->EvBatterytargetVoltage = 0;

BIN
EVSE/Projects/DD360UCar/Apps/UnsafetyOutputTask


+ 3 - 3
EVSE/Projects/DD360UCar/Apps/timeout.h

@@ -58,12 +58,12 @@ enum Timeout_flag {
 
 //------------------------------------------------------------------------------
 // for timeout fork
-struct timeval _cmdSubPriority_time;
+struct timespec _cmdSubPriority_time;
 unsigned short _connectionTimeout;
 
 // for main
-struct timeval _cmdMainPriority_time;
-struct timeval _toAverage_time;
+struct timespec _cmdMainPriority_time;
+struct timespec _toAverage_time;
 //uint8_t _ocppProfileChkFlag;
 
 #endif /* TIMEOUT_H_ */

BIN
EVSE/Projects/DD360UCar/Images/ramdisk.gz


BIN
EVSE/Projects/DD360UCar/output/FactoryConfig


BIN
EVSE/Projects/DD360UCar/output/Module_ChkSysTask


BIN
EVSE/Projects/DD360UCar/output/Module_DoComm


BIN
EVSE/Projects/DD360UCar/output/Module_EvComm


BIN
EVSE/Projects/DD360UCar/output/Module_EventLogging


BIN
EVSE/Projects/DD360UCar/output/Module_InternalComm


BIN
EVSE/Projects/DD360UCar/output/Module_LcmControl


BIN
EVSE/Projects/DD360UCar/output/Module_PrimaryComm


BIN
EVSE/Projects/DD360UCar/output/Module_UpdateFW


BIN
EVSE/Projects/DD360UCar/output/ReadCmdline


BIN
EVSE/Projects/DD360UCar/output/UnsafetyOutputTask


BIN
EVSE/Projects/DD360UCar/output/main


+ 37 - 16
EVSE/Projects/DS60-120/Apps/main.c

@@ -58,6 +58,7 @@
 #define		SYSTEM_MIN_VOL		80
 #define 	MIN_OUTPUT_CUR		0
 #define		AC_OUTPUT_VOL		220
+#define 	NO_RESERVE			-1
 
 #define		NO_DEFINE			255
 #define 	DEFAULT_AC_INDEX	2
@@ -651,7 +652,7 @@ bool CheckWebConfigChargingSOC(byte gunIndex)
 
 	if (ShmSysConfigAndInfo->SysConfig.MaxChargingSoc > 0)
 	{
-		if (chargingInfo[gunIndex]->EvBatterySoc >= ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy)
+		if (chargingInfo[gunIndex]->EvBatterySoc >= ShmSysConfigAndInfo->SysConfig.MaxChargingSoc)
 			result = true;
 	}
 
@@ -2881,6 +2882,8 @@ void ReleaseSysAlarmCode(byte gunIndex)
 	else if (gunIndex == 1)
 		ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AbnormalVoltageOnOutputLine_2 = NO;
 
+	ResetChargerAlarmCode(gunIndex, "023984");
+
 	if (chargingInfo[gunIndex]->Type == _Type_Chademo)
 	{
 		ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaGfdTrip = NO;
@@ -3977,7 +3980,7 @@ bool AddGunInfoByConnector(byte typeValue, byte slots)
 
 				// AC 固定 index
 				ac_chargingInfo[_acgunIndex]->Index = DEFAULT_AC_INDEX;
-				ac_chargingInfo[_acgunIndex]->ReservationId = -1;
+				ac_chargingInfo[_acgunIndex]->ReservationId = NO_RESERVE;
 				ac_chargingInfo[_acgunIndex]->SystemStatus = SYS_MODE_BOOTING;
 				ac_chargingInfo[_acgunIndex]->Type = _Type_AC;
 				ac_chargingInfo[_acgunIndex]->IsAvailable = YES;
@@ -4002,7 +4005,7 @@ bool AddGunInfoByConnector(byte typeValue, byte slots)
 			{
 				chargingInfo[_gunIndex] = &ShmSysConfigAndInfo->SysInfo.ChademoChargingData[_chademoIndex];
 				chargingInfo[_gunIndex]->Index = _gunIndex;
-				chargingInfo[_gunIndex]->ReservationId = -1;
+				chargingInfo[_gunIndex]->ReservationId = NO_RESERVE;
 				chargingInfo[_gunIndex]->slotsIndex = slots;
 				chargingInfo[_gunIndex]->SystemStatus = SYS_MODE_BOOTING;
 				chargingInfo[_gunIndex]->Type = _Type_Chademo;
@@ -4036,7 +4039,7 @@ bool AddGunInfoByConnector(byte typeValue, byte slots)
 				chargingInfo[_gunIndex] = &ShmSysConfigAndInfo->SysInfo.CcsChargingData[_ccsIndex];
 
 				chargingInfo[_gunIndex]->Index = _gunIndex;
-				chargingInfo[_gunIndex]->ReservationId = -1;
+				chargingInfo[_gunIndex]->ReservationId = NO_RESERVE;
 				chargingInfo[_gunIndex]->slotsIndex = slots;
 				chargingInfo[_gunIndex]->SystemStatus = SYS_MODE_BOOTING;
 				chargingInfo[_gunIndex]->Type = _Type_CCS;
@@ -4068,7 +4071,7 @@ bool AddGunInfoByConnector(byte typeValue, byte slots)
 				chargingInfo[_gunIndex] = &ShmSysConfigAndInfo->SysInfo.GbChargingData[_gb_Index];
 
 				chargingInfo[_gunIndex]->Index = _gunIndex;
-				chargingInfo[_gunIndex]->ReservationId = -1;
+				chargingInfo[_gunIndex]->ReservationId = NO_RESERVE;
 				chargingInfo[_gunIndex]->slotsIndex = slots;
 				chargingInfo[_gunIndex]->SystemStatus = SYS_MODE_BOOTING;
 				chargingInfo[_gunIndex]->Type = _Type_GB;
@@ -5661,7 +5664,7 @@ void ocpp_ac_chk_reserved_cmd()
 				PRINTF_FUNC ( "***************ChkOcppStatus : (AC) OcppReservedStatus******************** \n" );
 				PRINTF_FUNC ( "ReservationId = %d \n", ShmOCPP16Data->ReserveNow [hasDc].ReservationId );
 				PRINTF_FUNC ( "***********ChkOcppStatus : (AC) Cancel OcppReservedStatus End**************** \n" );
-				ac_chargingInfo [0]->ReservationId = -1;
+				ac_chargingInfo [0]->ReservationId = NO_RESERVE;
 				ac_chargingInfo [0]->SystemStatus = SYS_MODE_IDLE;
 
 				strcpy ( (char *) ShmDcCommonData->_reserved_ac_UserId[0], "" );
@@ -5699,7 +5702,7 @@ void ocpp_ac_chk_reserved_cmd()
 				PRINTF_FUNC ( "***************ChkOcppStatus : (AC) OcppReservedStatus******************** \n" );
 				PRINTF_FUNC ( "ReservationId = %d \n", ShmOCPP20Data->ReserveNow [hasDc].id );
 				PRINTF_FUNC ( "***********ChkOcppStatus : (AC) Cancel OcppReservedStatus End**************** \n" );
-				ac_chargingInfo [0]->ReservationId = -1;
+				ac_chargingInfo [0]->ReservationId = NO_RESERVE;
 				ac_chargingInfo [0]->SystemStatus = SYS_MODE_IDLE;
 
 				strcpy ( (char *) ShmDcCommonData->_reserved_UserId, "" );
@@ -6095,7 +6098,7 @@ void ocpp_chk_reserved_cmd(byte gunIndex)
 				PRINTF_FUNC("***************ChkOcppStatus : OcppReservedStatus******************** \n");
 				PRINTF_FUNC("ReservationId = %d \n", ShmOCPP16Data->ReserveNow[gunIndex + acDirIndex].ReservationId);
 				PRINTF_FUNC("***********ChkOcppStatus : Cancel OcppReservedStatus End**************** \n");
-				chargingInfo[gunIndex]->ReservationId = -1;
+				chargingInfo[gunIndex]->ReservationId = NO_RESERVE;
 				chargingInfo[gunIndex]->SystemStatus = SYS_MODE_IDLE;
 
 				strcpy((char *)ShmDcCommonData->_reserved_UserId[gunIndex], "");
@@ -6133,7 +6136,7 @@ void ocpp_chk_reserved_cmd(byte gunIndex)
 				PRINTF_FUNC("***************ChkOcppStatus : OcppReservedStatus******************** \n");
 				PRINTF_FUNC("ReservationId = %d \n", ShmOCPP20Data->ReserveNow[gunIndex + acDirIndex].id);
 				PRINTF_FUNC("***********ChkOcppStatus : Cancel OcppReservedStatus End**************** \n");
-				chargingInfo[gunIndex]->ReservationId = -1;
+				chargingInfo[gunIndex]->ReservationId = NO_RESERVE;
 				chargingInfo[gunIndex]->SystemStatus = SYS_MODE_IDLE;
 
 				strcpy((char *)ShmDcCommonData->_reserved_UserId[gunIndex], "");
@@ -9394,10 +9397,11 @@ int main(void)
 	}
 	else
 	{
-		for (byte gun_index = 0; gun_index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; gun_index++)
-		{
-			SetChargerMode(gun_index, SYS_MODE_IDLE);
-		}
+		//lwmark
+//		for (byte gun_index = 0; gun_index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; gun_index++)
+//		{
+//			SetChargerMode(gun_index, SYS_MODE_IDLE);
+//		}
 
 		SetupRebootCount(0);
 	}
@@ -9427,12 +9431,22 @@ int main(void)
 		DB_Reboot_Record(localDb);
 	}
 
+	//lwmark
+	for (int _index = 0; _index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; _index ++)
+	{
+		if (chargingInfo [_index]->IsAvailable == NO)
+			SetChargerMode ( _index, SYS_MODE_MAINTAIN );
+		else
+			SetChargerMode ( _index, SYS_MODE_IDLE );
+	}
+
 	if (NetworkDB_Open(networkDb) != PASS)
 	{
 		PRINTF_FUNC("NetworkDB_Open fail. \n");
 	}
 
 	ChangeLcmByIndex(_LCM_IDLE);
+
 	sleep(1);
 	CreateRfidFork();
 	sleep(1);
@@ -9693,13 +9707,17 @@ int main(void)
 						if (chargingInfo[gun_index]->SystemStatus == SYS_MODE_IDLE)
 						{
 							PRINTF_FUNC("================= SYS_MODE_IDLE (%x) ================  \n", gun_index);
-							chargingInfo[gun_index]->ReservationId = -1;
+							chargingInfo[gun_index]->ReservationId = NO_RESERVE;
 						}
 						else if (chargingInfo[gun_index]->SystemStatus == SYS_MODE_RESERVATION)
 						{
 							PRINTF_FUNC("================= SYS_MODE_RESERVATION (%x) ================  \n", gun_index);
 							PRINTF_FUNC("================= Id : %s ================  \n", ShmDcCommonData->_reserved_UserId[gun_index]);
 						}
+						else if (chargingInfo[gun_index]->SystemStatus == SYS_MODE_MAINTAIN)
+						{
+							PRINTF_FUNC("================= SYS_MODE_MAINTAIN (%x) ================  \n", gun_index);
+						}
 						chargingInfo[gun_index]->PresentChargedDuration = 0;
 						chargingInfo[gun_index]->RemainChargingDuration = 0;
 						chargingInfo[gun_index]->PresentChargingVoltage = 0;
@@ -9735,7 +9753,9 @@ int main(void)
 					if (chargingInfo[gun_index]->deratingByConnOtp.deratingIndex != 0)
 						chargingInfo[gun_index]->deratingByConnOtp.deratingIndex = 0;
 
-					if (chargingInfo[gun_index]->IsAvailable == NO)
+					//lwmark
+					if (chargingInfo [gun_index]->IsAvailable == NO &&
+							chargingInfo[gun_index]->SystemStatus != SYS_MODE_MAINTAIN)
 					{
 						SetChargerMode(gun_index, SYS_MODE_MAINTAIN);
 					}
@@ -9764,7 +9784,8 @@ int main(void)
 								SetChargerMode(gun_index, SYS_MODE_IDLE);
 							}
 
-							CcidAuthorizationProcessing(gun_index);
+							if (chargingInfo[gun_index]->ReservationId == NO_RESERVE)
+								CcidAuthorizationProcessing(gun_index);
 
 							//
 							{

+ 29 - 22
EVSE/Projects/define.h

@@ -5140,7 +5140,7 @@ struct DCChargingParametersType
 struct AdditionalInfoType
 {
 	unsigned char	additionalIdToken[37];						// Required. This field specifies the additional IdToken.
-	unsigned char	type[50];									// Required. This defines the type of the additionalIdToken. This is a custom type, so the implementation needs to be agreed upon by all involved parties.
+	unsigned char	type[51];									// Required. This defines the type of the additionalIdToken. This is a custom type, so the implementation needs to be agreed upon by all involved parties.
 };
 
 struct APNType
@@ -5168,13 +5168,14 @@ struct GroupIdTokenType
 {
 	unsigned char idToken[37];									// Required. IdToken is case insensitive. Might hold the hidden id of an RFID tag, but can for example also contain a UUID.
 	unsigned char type[16];										// Required. Enumeration of possible idToken types.
+	//struct AdditionalInfoType additionalInfo[10];               // Optional. AdditionalInfo can be used to send extra information which can be validated by the CSMS in addition to the regular authorization with IdToken.
 };
 
 struct MessageContentType
 {
 	unsigned char format[8];									// Required. Format of the message.
-	unsigned char	language[8];								// Optional. Message language identifier. Contains a language code as defined in [RFC5646].
-	unsigned char content[512];									// Required. Message contents.
+	unsigned char	language[9];								// Optional. Message language identifier. Contains a language code as defined in [RFC5646].
+	unsigned char content[513];									// Required. Message contents.
 };
 
 struct IdTokenInfoType
@@ -5182,9 +5183,9 @@ struct IdTokenInfoType
 	unsigned char status[32];									// Required. Current status of the ID Token.
 	unsigned char cacheExpiryDateTime[28];						// Optional. Date and Time after which the token must be considered invalid.
 	short int	chargingPriority;								// Optional. Priority from a business point of view. Default priority is 0, The range is from -9 to 9. Higher values indicate a higher priority.
-	unsigned char language1[8];									// Optional. Preferred user interface language of identifier user. Contains a language code as defined in [RFC5646].
+	unsigned char language1[9];									// Optional. Preferred user interface language of identifier user. Contains a language code as defined in [RFC5646].
 	unsigned int evseId[100];									// Optional. Only used when the IdToken is only valid for one or more specific EVSEs, not for the entire Charging Station.
-	unsigned char language2[8];									// Optional. Second preferred user interface language of identifier user. Don’t use when language1 is omitted, has to be different from language1.
+	unsigned char language2[9];									// Optional. Second preferred user interface language of identifier user. Don’t use when language1 is omitted, has to be different from language1.
 	struct GroupIdTokenType groupIdToken;						// Optional. This contains the group identifier.
 	struct MessageContentType personalMessage;					// Optional. Personal message that can be shown to the EV Driver and can be used for tariff information, user greetings etc.
 };
@@ -5242,6 +5243,7 @@ struct CostTypeOCPP
 {
 	unsigned char costKind[36];									// Required. The kind of cost referred to in the message element amount
 	int amount;													// Required. The estimated or actual cost per kWh
+	int amountMultiplier;                                       // Optional. Values: -3..3, The amountMultiplier defines the exponent to base 10 (dec). The final value is determined by: amount * 10 ^ amountMultiplier
 };
 
 struct ConsumptionCostTypeOCPP
@@ -5481,10 +5483,10 @@ struct NetworkConnectionProfileType
 struct OCSPRequestDataType
 {
 	unsigned char hashAlgorithm[8];									// Required. Used algorithms for the hashes provided.
-	unsigned char issuerNameHash[128];								// Required. hashed value of the IssuerName.
-	unsigned char issuerKeyHash[128];								// Required. Hashed value of the issuers public key
-	unsigned char serialNumber[40];									// Required. The serial number of the certificate.
-	unsigned char responderURL[512];								// Required. This contains the responder URL (Case insensitive).
+	unsigned char issuerNameHash[129];								// Required. hashed value of the IssuerName.
+	unsigned char issuerKeyHash[129];								// Required. Hashed value of the issuers public key
+	unsigned char serialNumber[41];									// Required. The serial number of the certificate.
+	unsigned char responderURL[513];								// Required. This contains the responder URL (Case insensitive).
 };
 
 struct ReportDataType
@@ -5551,6 +5553,7 @@ struct StatusInfoType
  */
 struct Authorize_20
 {
+	unsigned char certificate[5601];                                // Optional. The X.509 certificated presented by EV for authorization.
 	struct IdTokenType idToken;										// Required. This contains the identifier that needs to be authorized.
 	struct OCSPRequestDataType iso15118CertificateHashData[4];		// Optional. Contains the information needed to verify the EV Contract Certificate via OCSP.
 	unsigned char Response_certificateStatus[32];					// Optional. Certificate status information. - if all certificates are valid: return 'Accepted'. - if one of the certificates was revoked, return 'CertificateRevoked'.
@@ -5668,11 +5671,11 @@ struct FirmwareStatusNotification_20
 
 struct Get15118EVCertificate_20
 {
-	unsigned char iso15118SchemaVersion[50];						// Required. Schema version currently used for the 15118 session between EV and Charging Station. Needed for parsing of the EXI stream by the CSMS.
+	unsigned char iso15118SchemaVersion[51];						// Required. Schema version currently used for the 15118 session between EV and Charging Station. Needed for parsing of the EXI stream by the CSMS.
 	unsigned char action[16];										// Required. Defines whether certificate needs to be installed or updated.
-	unsigned char exiRequest[5600];									// Required. Raw CertificateInstallationReq request from EV, Base64 encoded.
+	unsigned char exiRequest[5601];									// Required. Raw CertificateInstallationReq request from EV, Base64 encoded.
 	unsigned char Response_status[16];								// Required. Indicates whether the message was processed properly.
-	unsigned char Response_exiResponse[5600];						// Required. Raw CertificateInstallationRes response for the EV, Base64 encoded.
+	unsigned char Response_exiResponse[5601];						// Required. Raw CertificateInstallationRes response for the EV, Base64 encoded.
 };
 
 struct GetBaseReport_20
@@ -5833,6 +5836,7 @@ struct NotifyEVChargingNeeds_20
 	unsigned int evseId;											// Required. Defines the EVSE and connector to which the EV is connected. EvseId may not be 0.
 	struct ChargingNeedsType chargingNeeds;							// Required. The characteristics of the energy delivery required.
 	unsigned char Response_status[16];								// Required. Returns whether the CSMS has been able to process the message successfully. It does not imply that the evChargingNeeds can be met with the current charging profile.
+	struct StatusInfoType Response_statusInfo;                      // Optional. Detailed status information.
 };
 
 struct NotifyEVChargingSchedule_20
@@ -5841,6 +5845,7 @@ struct NotifyEVChargingSchedule_20
 	unsigned int evseId;											// Required. The charging schedule contained in this notification applies to an EVSE. EvseId must be > 0.
 	struct ChargingScheduleType chargingSchedule;					// Required. Planned energy consumption of the EV over time. Always relative to timeBase.
 	unsigned char Response_status[16];								// Required. Returns whether the CSMS has been able to process the message successfully. It does not imply any approval of the charging schedule.
+	struct StatusInfoType Response_statusInfo;                      // Optional. Detailed status information.
 };
 
 struct NotifyEvent_20
@@ -5963,6 +5968,7 @@ struct SetChargingProfile_20
 	struct ChargingProfileType chargingProfile;						// Required. The charging profile to be set at the Charging Station.
 	unsigned char Response_status[16];								// Required. Returns whether the Charging Station has been able to process the message successfully. This does not guarantee the schedule will be followed to the letter. There might be other constraints the Charging Station may need to take into account.
 	unsigned char guid[37];											// Save guid from server request
+	struct StatusInfoType Response_statusInfo;                      // Optional. Detailed status information.
 };
 
 struct SetDisplayMessage_20
@@ -6135,8 +6141,8 @@ struct OCPP20Data
 			unsigned char NotifyDisplayMessagesReq :1;
 			unsigned char NotifyDisplayMessagesConf :1;
 
-			unsigned char NotifyEVChargingScheduleReq :1;
-			unsigned char NotifyEVChargingScheduleConf :1;
+			unsigned char NotifyCustomerInformationReq :1;
+			unsigned char NotifyCustomerInformationConf :1;
 			unsigned char NotifyEventReq :1;
 			unsigned char NotifyEventConf :1;
 			unsigned char NotifyMonitoringReportReq :1;
@@ -6150,8 +6156,8 @@ struct OCPP20Data
 			unsigned char SecurityEventNotificationConf :1;
 			unsigned char SignCertificateReq :1;
 			unsigned char SignCertificateConf :1;
-            unsigned char NotifyCustomerInformationReq :1;  //bit 6
-            unsigned char NotifyCustomerInformationConf :1; //bit 7
+            unsigned char :1; //bit 6
+            unsigned char :1; //bit 7
 
 		} bits;
 	} SpMsg;
@@ -6278,12 +6284,13 @@ struct OCPP20Data
 		{
 			//CSUMsgValue[0]
 			unsigned char ChargingProfileReq:1;	//bit 0,
-			unsigned char ChargingProfileConf:1;	//bit 0,
-            unsigned char ClearedChargingLimitReq :1;
-            unsigned char ClearedChargingLimitConf :1;
-            unsigned char NotifyEVChargingNeedsReq :1;
-            unsigned char NotifyEVChargingNeedsConf :1;
-            unsigned char :2;   //bit 1,2,3,4,5,6,7 , reserved
+			unsigned char ChargingProfileConf:1; //bit 1
+            unsigned char ClearedChargingLimitReq :1; //bit 2
+            unsigned char ClearedChargingLimitConf :1; //bit 3
+            unsigned char NotifyEVChargingNeedsReq :1; //bit 4
+            unsigned char NotifyEVChargingNeedsConf :1; //bit 5
+            unsigned char NotifyEVChargingScheduleReq:1; //bit 6
+            unsigned char NotifyEVChargingScheduleConf:1; //bit 7
 		} bits[CONNECTOR_QUANTITY];
 	}CSUMsg;
 

BIN
EVSE/rootfs/root/Module_Payment_Bazel8


BIN
EVSE/rootfs/root/Module_Payment_Enegate


BIN
EVSE/rootfs/root/Module_PowerSharing


+ 1 - 1
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/.version

@@ -1 +1 @@
-43
+44

+ 1 - 1
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/dts/.am335x-evm.dtb.cmd

@@ -8,8 +8,8 @@ deps_arch/arm/boot/dts/am335x-evm.dtb := \
   arch/arm/boot/dts/include/dt-bindings/pinctrl/am33xx.h \
   arch/arm/boot/dts/include/dt-bindings/pinctrl/omap.h \
   arch/arm/boot/dts/include/dt-bindings/interrupt-controller/irq.h \
-  arch/arm/boot/dts/tps65910.dtsi \
   arch/arm/boot/dts/am33xx-clocks.dtsi \
+  arch/arm/boot/dts/tps65217.dtsi \
 
 arch/arm/boot/dts/am335x-evm.dtb: $(deps_arch/arm/boot/dts/am335x-evm.dtb)
 

+ 1 - 1
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/dts/.am335x-evm.dtb.d.dtc.tmp

@@ -1 +1 @@
-arch/arm/boot/dts/am335x-evm.dtb: arch/arm/boot/dts/.am335x-evm.dtb.dts.tmp arch/arm/boot/dts/am33xx-clocks.dtsi
+arch/arm/boot/dts/am335x-evm.dtb: arch/arm/boot/dts/.am335x-evm.dtb.dts.tmp arch/arm/boot/dts/am33xx-clocks.dtsi arch/arm/boot/dts/tps65217.dtsi

+ 1 - 2
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/dts/.am335x-evm.dtb.d.pre.tmp

@@ -3,5 +3,4 @@ am335x-evm.o: arch/arm/boot/dts/am335x-evm.dts \
  arch/arm/boot/dts/include/dt-bindings/gpio/gpio.h \
  arch/arm/boot/dts/include/dt-bindings/pinctrl/am33xx.h \
  arch/arm/boot/dts/include/dt-bindings/pinctrl/omap.h \
- arch/arm/boot/dts/include/dt-bindings/interrupt-controller/irq.h \
- arch/arm/boot/dts/tps65910.dtsi
+ arch/arm/boot/dts/include/dt-bindings/interrupt-controller/irq.h

+ 61 - 136
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/dts/.am335x-evm.dtb.dts.tmp

@@ -1159,7 +1159,7 @@
 
  cpus {
   cpu@0 {
-   cpu0-supply = <&vdd1_reg>;
+   cpu0-supply = <&dcdc2_reg>;
   };
  };
 
@@ -1203,7 +1203,11 @@
    0x1B0 (((1 << 3)) | 7)
    0x1B4 (((1 << 5) | (1 << 3)) | 7)
 
+   0x060 (((1 << 3)) | 7)
+   0x06C (((1 << 3)) | 7)
 
+
+   0x088 (((1 << 5) | (1 << 3)) | 7)
    0x08C (((1 << 3)) | 7)
    0x0A0 (((1 << 3)) | 7)
    0x0A4 (((1 << 3)) | 7)
@@ -1213,7 +1217,11 @@
    0x0B4 (((1 << 3)) | 7)
    0x0E8 (((1 << 5) | (1 << 3)) | 7)
    0x0E0 (((1 << 3)) | 7)
+   0x0EC (((1 << 3)) | 7)
+
 
+   0x1A0 (((1 << 3)) | 7)
+   0x1A4 (((1 << 3)) | 7)
    0x1A8 (((1 << 3)) | 7)
   >;
  };
@@ -1259,7 +1267,7 @@
    0x164 (0 | 1)
   >;
  };
-# 136 "arch/arm/boot/dts/am335x-evm.dts"
+# 144 "arch/arm/boot/dts/am335x-evm.dts"
  clkout2_pin: pinmux_clkout2_pin {
   pinctrl-single,pins = <
    0x1b4 (0 | 3)
@@ -1383,7 +1391,15 @@
    0x17C (((1 << 5)) | 2)
   >;
  };
-# 280 "arch/arm/boot/dts/am335x-evm.dts"
+# 287 "arch/arm/boot/dts/am335x-evm.dts"
+ spi1_pins: spi1_pins {
+                pinctrl-single,pins = <
+                        ((((0x990)) & 0xffff) - (0x0800)) (((1 << 5) | (1 << 4)) | 3)
+                        ((((0x994)) & 0xffff) - (0x0800)) (((1 << 5) | (1 << 4)) | 3)
+                        ((((0x998)) & 0xffff) - (0x0800)) (((1 << 4)) | 3)
+                        ((((0x99C)) & 0xffff) - (0x0800)) (((1 << 4)) | 3)
+                >;
+        };
 };
 
 
@@ -1415,7 +1431,7 @@
 
  status = "okay";
 };
-# 319 "arch/arm/boot/dts/am335x-evm.dts"
+# 334 "arch/arm/boot/dts/am335x-evm.dts"
 &i2c0 {
  pinctrl-names = "default";
  pinctrl-0 = <&i2c0_pins>;
@@ -1423,8 +1439,8 @@
  status = "okay";
  clock-frequency = <400000>;
 
- tps: tps@2d {
-  reg = <0x2d>;
+ tps: tps@24 {
+  reg = <0x24>;
  };
 
 
@@ -1479,14 +1495,14 @@
 &elm {
  status = "okay";
 };
-# 403 "arch/arm/boot/dts/am335x-evm.dts"
+# 418 "arch/arm/boot/dts/am335x-evm.dts"
 &gpmc {
  status = "okay";
  pinctrl-names = "default", "sleep";
  pinctrl-0 = <&nandflash_pins_default>;
  pinctrl-1 = <&nandflash_pins_sleep>;
 
- ranges = <0 0 0x08000000 0x80000000>;
+ ranges = <0 0 0x08000000 0x40000000>;
  nand@0,0 {
   compatible = "ti,omap2-nand";
   reg = <0 0 4>;
@@ -1580,165 +1596,58 @@
   };
   partition@13 {
    label = "Storage";
-   reg = <0x0A200000 0x75E00000>;
+   reg = <0x0A200000 0x35E00000>;
   };
  };
 };
 
-# 1 "arch/arm/boot/dts/tps65910.dtsi" 1
-# 14 "arch/arm/boot/dts/tps65910.dtsi"
-&tps {
- compatible = "ti,tps65910";
-
- regulators {
-  #address-cells = <1>;
-  #size-cells = <0>;
-
-  vrtc_reg: regulator@0 {
-   reg = <0>;
-   regulator-compatible = "vrtc";
-  };
-
-  vio_reg: regulator@1 {
-   reg = <1>;
-   regulator-compatible = "vio";
-  };
-
-  vdd1_reg: regulator@2 {
-   reg = <2>;
-   regulator-compatible = "vdd1";
-  };
-
-  vdd2_reg: regulator@3 {
-   reg = <3>;
-   regulator-compatible = "vdd2";
-  };
-
-  vdd3_reg: regulator@4 {
-   reg = <4>;
-   regulator-compatible = "vdd3";
-  };
-
-  vdig1_reg: regulator@5 {
-   reg = <5>;
-   regulator-compatible = "vdig1";
-  };
-
-  vdig2_reg: regulator@6 {
-   reg = <6>;
-   regulator-compatible = "vdig2";
-  };
-
-  vpll_reg: regulator@7 {
-   reg = <7>;
-   regulator-compatible = "vpll";
-  };
-
-  vdac_reg: regulator@8 {
-   reg = <8>;
-   regulator-compatible = "vdac";
-  };
-
-  vaux1_reg: regulator@9 {
-   reg = <9>;
-   regulator-compatible = "vaux1";
-  };
-
-  vaux2_reg: regulator@10 {
-   reg = <10>;
-   regulator-compatible = "vaux2";
-  };
-
-  vaux33_reg: regulator@11 {
-   reg = <11>;
-   regulator-compatible = "vaux33";
-  };
-
-  vmmc_reg: regulator@12 {
-   reg = <12>;
-   regulator-compatible = "vmmc";
-  };
-
-  vbb_reg: regulator@13 {
-   reg = <13>;
-   regulator-compatible = "vbb";
-  };
- };
-};
-# 509 "arch/arm/boot/dts/am335x-evm.dts" 2
+/include/ "tps65217.dtsi"
 
 &tps {
- vcc1-supply = <&vbat>;
- vcc2-supply = <&vbat>;
- vcc3-supply = <&vbat>;
- vcc4-supply = <&vbat>;
- vcc5-supply = <&vbat>;
- vcc6-supply = <&vbat>;
- vcc7-supply = <&vbat>;
- vccio-supply = <&vbat>;
+# 543 "arch/arm/boot/dts/am335x-evm.dts"
+ ti,pmic-shutdown-controller;
 
  regulators {
-  vrtc_reg: regulator@0 {
-   regulator-always-on;
-  };
-
-  vio_reg: regulator@1 {
+  dcdc1_reg: regulator@0 {
+   regulator-name = "vdds_dpr";
    regulator-always-on;
   };
 
-  vdd1_reg: regulator@2 {
+  dcdc2_reg: regulator@1 {
 
    regulator-name = "vdd_mpu";
-   regulator-min-microvolt = <912500>;
-   regulator-max-microvolt = <1378000>;
+   regulator-min-microvolt = <1100000>;
+   regulator-max-microvolt = <1351500>;
    regulator-boot-on;
    regulator-always-on;
   };
 
-  vdd2_reg: regulator@3 {
+  dcdc3_reg: regulator@2 {
 
    regulator-name = "vdd_core";
-   regulator-min-microvolt = <912500>;
+   regulator-min-microvolt = <925000>;
    regulator-max-microvolt = <1150000>;
    regulator-boot-on;
    regulator-always-on;
   };
 
-  vdd3_reg: regulator@4 {
-   regulator-always-on;
-  };
-
-  vdig1_reg: regulator@5 {
+  ldo1_reg: regulator@3 {
+   regulator-name = "vio,vrtc,vdds";
    regulator-always-on;
   };
 
-  vdig2_reg: regulator@6 {
+  ldo2_reg: regulator@4 {
+   regulator-name = "vdd_3v3aux";
    regulator-always-on;
   };
 
-  vpll_reg: regulator@7 {
+  ldo3_reg: regulator@5 {
+   regulator-name = "vdd_1v8";
    regulator-always-on;
   };
 
-  vdac_reg: regulator@8 {
-   regulator-always-on;
-  };
-
-  vaux1_reg: regulator@9 {
-   regulator-always-on;
-  };
-
-  vaux2_reg: regulator@10 {
-   regulator-always-on;
-  };
-
-  vaux33_reg: regulator@11 {
-   regulator-always-on;
-  };
-
-  vmmc_reg: regulator@12 {
-   regulator-min-microvolt = <1800000>;
-   regulator-max-microvolt = <3300000>;
+  ldo4_reg: regulator@6 {
+   regulator-name = "vdd_3v3a";
    regulator-always-on;
   };
  };
@@ -1764,7 +1673,7 @@
   phy-mode = "mii";
 
 };
-# 615 "arch/arm/boot/dts/am335x-evm.dts"
+# 620 "arch/arm/boot/dts/am335x-evm.dts"
 &tscadc {
  status = "okay";
 
@@ -1781,7 +1690,7 @@
 
 &mmc1 {
  status = "okay";
- vmmc-supply = <&vmmc_reg>;
+ vmmc-supply = <&ldo4_reg>;
  bus-width = <4>;
  pinctrl-names = "default";
  pinctrl-0 = <&mmc1_pins_default>;
@@ -1811,3 +1720,19 @@
  pinctrl-names = "default";
  pinctrl-0 = <&dcan0_pins_default>;
 };
+# 681 "arch/arm/boot/dts/am335x-evm.dts"
+&spi1 {
+        status = "okay";
+        pinctrl-names = "default";
+        pinctrl-0 = <&spi1_pins>;
+        qca7000@0 {
+                compatible = "qca,qca7000";
+                reg = <0>;
+                interrupt-parent = <&gpio2>;
+                interrupts = <0 1>;
+                spi-cpha;
+                spi-cpol;
+                spi-max-frequency = <10000000>;
+                qca,legacy-mode = <0>;
+        };
+};

+ 84 - 55
board-support/linux-4.9.59+gitAUTOINC+a75d8e9305-ga75d8e9305/arch/arm/boot/dts/am335x-evm.dts

@@ -25,7 +25,7 @@
 
 	cpus {
 		cpu@0 {
-			cpu0-supply = <&vdd1_reg>;
+			cpu0-supply = <&dcdc2_reg>;
 		};
 	};
 
@@ -68,8 +68,12 @@
 			0x144 (PIN_INPUT | MUX_MODE7)    			/* RMII1_REF_CLK		=>	GPIO0_29 */	/*USB 0 OCP detection*/
 			0x1B0 (PIN_OUTPUT | MUX_MODE7)			/*XDMA_EVENT_INTR0	=>	GPIO0_19 */	/*AM_RFID_RST*/
 			0x1B4 (PIN_INPUT | MUX_MODE7)			/*XDMA_EVENT_INTR1	=>	GPIO0_20 */	/*AM_RFID_ICC*/
-			/** GPIO 1 */			
+			/** GPIO 1 */		
+			0x060 (PIN_OUTPUT | MUX_MODE7)			/*GPIO1_24*/
+			0x06C (PIN_OUTPUT | MUX_MODE7)			/* (V17) gpmc_a11.gpio1[27] */
+
 			/** GPIO 2 */
+			0x088 (PIN_INPUT | MUX_MODE7)   		/* CCS=>GPMC_CSn3.GPIO2_0*/
 			0x08C (PIN_OUTPUT | MUX_MODE7)			/*GPMC_CLK	=>	GPIO2_1*/	/*Speaker*/
 			0x0A0 (PIN_OUTPUT | MUX_MODE7)			/*LCD_DATA0	=>	GPIO2_6*/	/*Panel LED control-BB_LEDR1*/
 			0x0A4 (PIN_OUTPUT | MUX_MODE7)			/*LCD_DATA1	=>	GPIO2_7*/	/*Panel LED control-BB_LEDG1*/
@@ -79,7 +83,11 @@
 			0x0B4 (PIN_OUTPUT | MUX_MODE7)			/*LCD_DATA5	=>	GPIO2_11*/	/*Panel LED control-BB_LEDB2*/
 			0x0E8 (PIN_INPUT | MUX_MODE7)			/*LCD_PCLK	=>	GPIO2_24*/	/*communication board proximity*/
 			0x0E0 (PIN_OUTPUT | MUX_MODE7)			/*LCD_VSYNC	=>	GPIO2_22*/	/*Breath LED*/
+			0x0EC (PIN_OUTPUT | MUX_MODE7)			/* CCSEthernet-Reset=>LCD_AC_BIAS_EN.GPIO2_25*/
+			
 			/** GPIO 3 */
+			0x1A0 (PIN_OUTPUT | MUX_MODE7)                  /* MCASP0_AXR1  =>      GPIO3_18 */     /*control 4G reset pin*/
+			0x1A4 (PIN_OUTPUT | MUX_MODE7)			/* MCASP0_FSR.GPIO3_19 */
 			0x1A8 (PIN_OUTPUT | MUX_MODE7)			/* MCASP0_AXR1	=>	GPIO3_20 */	/*control MCU to output CP PWM*/
 		>;
 	};
@@ -274,9 +282,16 @@
 		pinctrl-single,pins =< 
 			0x0A4 (PIN_OUTPUT | MUX_MODE3)	/* LCD_DATA1.eHRPWM2B */
 		>;                
-    };	
-	 
+    	};	 
 #endif  
+	spi1_pins: spi1_pins {
+                pinctrl-single,pins = <
+                        AM33XX_IOPAD(0x990, PIN_INPUT_PULLUP | MUX_MODE3) /* MCASP0_ACLKX.AM_SPI1_SCLK */
+                        AM33XX_IOPAD(0x994, PIN_INPUT_PULLUP | MUX_MODE3) /* MCASP0_FSX.AM_SPI1_D0 */
+                        AM33XX_IOPAD(0x998, PIN_OUTPUT_PULLUP | MUX_MODE3) /* MCASP0_AXR0.AM_SPI1_D1 */
+                        AM33XX_IOPAD(0x99C, PIN_OUTPUT_PULLUP | MUX_MODE3) /* MCASP0_AHCLKR.AM_SPI1_CS0 */
+                >;
+        };
 };
 
 
@@ -323,8 +338,8 @@
 	status = "okay";
 	clock-frequency = <400000>;
 
-	tps: tps@2d {
-		reg = <0x2d>;
+	tps: tps@24 {
+		reg = <0x24>;
 	};
 
 /*	rtc0: rtc@51 {
@@ -406,7 +421,7 @@
 	pinctrl-0 = <&nandflash_pins_default>;
 	pinctrl-1 = <&nandflash_pins_sleep>;
 	/*ranges = <0 0 0x08000000 0x10000000>;*/	/* CS0: NAND */
-	ranges = <0 0 0x08000000 0x80000000>;	/*+++ vern,NAND,20181030 ---*/
+	ranges = <0 0 0x08000000 0x40000000>;	/*+++ vern,NAND,20181030 ---*/
 	nand@0,0 {
 		compatible = "ti,omap2-nand";
 		reg = <0 0 4>; /* CS0, offset 0, IO size 4 */
@@ -500,85 +515,74 @@
 		};
 		partition@13 {
 			label = "Storage";
-			reg = <0x0A200000 0x75E00000>;
+			reg = <0x0A200000 0x35E00000>;
 		};
 	};
 };
 
-#include "tps65910.dtsi"
+/include/ "tps65217.dtsi"
 
 &tps {
-	vcc1-supply = <&vbat>;
-	vcc2-supply = <&vbat>;
-	vcc3-supply = <&vbat>;
-	vcc4-supply = <&vbat>;
-	vcc5-supply = <&vbat>;
-	vcc6-supply = <&vbat>;
-	vcc7-supply = <&vbat>;
-	vccio-supply = <&vbat>;
+	/*
+	 * Configure pmic to enter OFF-state instead of SLEEP-state ("RTC-only
+	 * mode") at poweroff.  Most BeagleBone versions do not support RTC-only
+	 * mode and risk hardware damage if this mode is entered.
+	 *
+	 * For details, see linux-omap mailing list May 2015 thread
+	 *	[PATCH] ARM: dts: am335x-bone* enable pmic-shutdown-controller
+	 * In particular, messages:
+	 *	http://www.spinics.net/lists/linux-omap/msg118585.html
+	 *	http://www.spinics.net/lists/linux-omap/msg118615.html
+	 *
+	 * You can override this later with
+	 *	&tps {  /delete-property/ ti,pmic-shutdown-controller;  }
+	 * if you want to use RTC-only mode and made sure you are not affected
+	 * by the hardware problems. (Tip: double-check by performing a current
+	 * measurement after shutdown: it should be less than 1 mA.)
+	 */
+	ti,pmic-shutdown-controller;
 
 	regulators {
-		vrtc_reg: regulator@0 {
+		dcdc1_reg: regulator@0 {
+			regulator-name = "vdds_dpr";
 			regulator-always-on;
 		};
 
-		vio_reg: regulator@1 {
-			regulator-always-on;
-		};
-
-		vdd1_reg: regulator@2 {
-			/* VDD_MPU voltage limits 0.95V - 1.325V with +/-4% tolerance */
+		dcdc2_reg: regulator@1 {
+			/* VDD_MPU voltage limits 0.95V - 1.26V with +/-4% tolerance */
 			regulator-name = "vdd_mpu";
-			regulator-min-microvolt = <912500>;
-			regulator-max-microvolt = <1378000>;
+			regulator-min-microvolt = <1100000>;
+			regulator-max-microvolt = <1351500>;
 			regulator-boot-on;
 			regulator-always-on;
 		};
 
-		vdd2_reg: regulator@3 {
+		dcdc3_reg: regulator@2 {
 			/* VDD_CORE voltage limits 0.95V - 1.1V with +/-4% tolerance */
 			regulator-name = "vdd_core";
-			regulator-min-microvolt = <912500>;
+			regulator-min-microvolt = <925000>;
 			regulator-max-microvolt = <1150000>;
 			regulator-boot-on;
 			regulator-always-on;
 		};
 
-		vdd3_reg: regulator@4 {
-			regulator-always-on;
-		};
-
-		vdig1_reg: regulator@5 {
+		ldo1_reg: regulator@3 {
+			regulator-name = "vio,vrtc,vdds";
 			regulator-always-on;
 		};
 
-		vdig2_reg: regulator@6 {
+		ldo2_reg: regulator@4 {
+			regulator-name = "vdd_3v3aux";
 			regulator-always-on;
 		};
 
-		vpll_reg: regulator@7 {
+		ldo3_reg: regulator@5 {
+			regulator-name = "vdd_1v8";
 			regulator-always-on;
 		};
 
-		vdac_reg: regulator@8 {
-			regulator-always-on;
-		};
-
-		vaux1_reg: regulator@9 {
-			regulator-always-on;
-		};
-
-		vaux2_reg: regulator@10 {
-			regulator-always-on;
-		};
-
-		vaux33_reg: regulator@11 {
-			regulator-always-on;
-		};
-
-		vmmc_reg: regulator@12 {
-			regulator-min-microvolt = <1800000>;
-			regulator-max-microvolt = <3300000>;
+		ldo4_reg: regulator@6 {
+			regulator-name = "vdd_3v3a";
 			regulator-always-on;
 		};
 	};
@@ -604,6 +608,7 @@
  	phy-mode = "mii";
 
 };
+
 #if 0
 &cpsw_emac1 {
 	phy_id = <&davinci_mdio>, <2>;
@@ -628,7 +633,7 @@
 
 &mmc1 {
 	status = "okay";
-	vmmc-supply = <&vmmc_reg>;
+	vmmc-supply = <&ldo4_reg>;
 	bus-width = <4>;
 	pinctrl-names = "default";
 	pinctrl-0 = <&mmc1_pins_default>;
@@ -665,3 +670,27 @@
 	pinctrl-0 = <&dcan1_pins_default>;
 };
 #endif
+
+/*
+The QCA7000 acts as a SPI slave and uses Mode 3: CPOL=1, CPHA=1.
+SPI data width is 8 bit. The SPI CLK period should not be less than 83.3 ns
+The SPI should be used in burst mode, meaning that the chip select is held low during a complete SPI message.
+ Note: The SPI lines between Host CPU and QCA7000 should be kept as short as possible.
+
+*/
+&spi1 {
+        status = "okay";
+        pinctrl-names = "default";
+        pinctrl-0 = <&spi1_pins>;
+        qca7000@0 {
+                compatible = "qca,qca7000";
+                reg = <0>;
+                interrupt-parent = <&gpio2>; /* GPIO2_0 */
+                interrupts = <0 1>;                     /* GPIO2_0 */
+                spi-cpha;                                        /* SPI mode: CPHA=1 */
+                spi-cpol;                                        /* SPI mode: CPOL=1 */
+                spi-max-frequency = <10000000>;  /* freq: 10MHz */
+                qca,legacy-mode = <0>;            /* Burst mode */
+        };
+};
+

+ 1 - 1
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/.am335x-evm.dtb.cmd

@@ -8,8 +8,8 @@ deps_arch/arm/dts/am335x-evm.dtb := \
   arch/arm/dts/include/dt-bindings/pinctrl/omap.h \
   arch/arm/dts/skeleton.dtsi \
   arch/arm/dts/include/dt-bindings/interrupt-controller/irq.h \
-  arch/arm/dts/tps65910.dtsi \
   arch/arm/dts/am33xx-clocks.dtsi \
+  arch/arm/dts/tps65217.dtsi \
 
 arch/arm/dts/am335x-evm.dtb: $(deps_arch/arm/dts/am335x-evm.dtb)
 

+ 1 - 1
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/.am335x-evm.dtb.d.dtc.tmp

@@ -1 +1 @@
-arch/arm/dts/am335x-evm.dtb: arch/arm/dts/.am335x-evm.dtb.dts.tmp arch/arm/dts/am33xx-clocks.dtsi
+arch/arm/dts/am335x-evm.dtb: arch/arm/dts/.am335x-evm.dtb.dts.tmp arch/arm/dts/am33xx-clocks.dtsi arch/arm/dts/tps65217.dtsi

+ 1 - 2
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/.am335x-evm.dtb.d.pre.tmp

@@ -3,5 +3,4 @@
  arch/arm/dts/include/dt-bindings/pinctrl/am33xx.h \
  arch/arm/dts/include/dt-bindings/pinctrl/omap.h \
  arch/arm/dts/skeleton.dtsi \
- arch/arm/dts/include/dt-bindings/interrupt-controller/irq.h \
- arch/arm/dts/tps65910.dtsi
+ arch/arm/dts/include/dt-bindings/interrupt-controller/irq.h

+ 31 - 137
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/.am335x-evm.dtb.dts.tmp

@@ -925,7 +925,7 @@
 
  cpus {
   cpu@0 {
-   cpu0-supply = <&vdd1_reg>;
+   cpu0-supply = <&dcdc2_reg>;
   };
  };
 
@@ -1067,9 +1067,10 @@
   pinctrl-single,pins = <
    0x54 (0 | 7)
    0x58 (0 | 7)
+   0x60 (0 | 7)
    0x64 (((1 << 5)) | 7)
    0x68 (((1 << 5)) | 7)
-   0x6c (((1 << 5)) | 7)
+   0x6c (0 | 7)
   >;
  };
 
@@ -1197,7 +1198,7 @@
    0x14c (((1 << 5)) | 7)
   >;
  };
-# 304 "<stdin>"
+# 305 "<stdin>"
  mmc1_pins_default: pinmux_mmc1_pins {
   pinctrl-single,pins = <
    0x0F0 (((1 << 5) | (1 << 4)) | 0)
@@ -1261,7 +1262,7 @@
    0xec (((1 << 3)) | 0)
   >;
  };
-# 377 "<stdin>"
+# 378 "<stdin>"
  dcan1_pins_default: dcan1_pins_default {
   pinctrl-single,pins = <
    0x168 (((1 << 3)) | 2)
@@ -1291,8 +1292,8 @@
  status = "okay";
  clock-frequency = <400000>;
 
- tps: tps@2d {
-  reg = <0x2d>;
+ tps: tps@24 {
+  reg = <0x24>;
  };
 };
 
@@ -1376,9 +1377,9 @@
   status = "okay";
 
 
-  AVDD-supply = <&vaux2_reg>;
-  IOVDD-supply = <&vaux2_reg>;
-  DRVDD-supply = <&vaux2_reg>;
+  AVDD-supply = <&ldo2_reg>;
+  IOVDD-supply = <&ldo2_reg>;
+  DRVDD-supply = <&ldo2_reg>;
   DVDD-supply = <&vbat>;
  };
 };
@@ -1406,7 +1407,7 @@
  pinctrl-names = "default";
  pinctrl-0 = <&nandflash_pins_s0>;
 
- ranges = <0 0 0x08000000 0x80000000>;
+ ranges = <0 0 0x08000000 0x40000000>;
  nand@0,0 {
   reg = <0 0 4>;
   ti,nand-ecc-opt = "bch16";
@@ -1495,165 +1496,58 @@
   };
   partition@13 {
    label = "Storage";
-   reg = <0x0A200000 0x75E00000>;
+   reg = <0x0A200000 0x35E00000>;
   };
  };
 };
 
-# 1 "./arch/arm/dts/tps65910.dtsi" 1
-# 14 "./arch/arm/dts/tps65910.dtsi"
-&tps {
- compatible = "ti,tps65910";
-
- regulators {
-  #address-cells = <1>;
-  #size-cells = <0>;
-
-  vrtc_reg: regulator@0 {
-   reg = <0>;
-   regulator-compatible = "vrtc";
-  };
-
-  vio_reg: regulator@1 {
-   reg = <1>;
-   regulator-compatible = "vio";
-  };
-
-  vdd1_reg: regulator@2 {
-   reg = <2>;
-   regulator-compatible = "vdd1";
-  };
-
-  vdd2_reg: regulator@3 {
-   reg = <3>;
-   regulator-compatible = "vdd2";
-  };
+/include/ "tps65217.dtsi"
 
-  vdd3_reg: regulator@4 {
-   reg = <4>;
-   regulator-compatible = "vdd3";
-  };
-
-  vdig1_reg: regulator@5 {
-   reg = <5>;
-   regulator-compatible = "vdig1";
-  };
-
-  vdig2_reg: regulator@6 {
-   reg = <6>;
-   regulator-compatible = "vdig2";
-  };
-
-  vpll_reg: regulator@7 {
-   reg = <7>;
-   regulator-compatible = "vpll";
-  };
-
-  vdac_reg: regulator@8 {
-   reg = <8>;
-   regulator-compatible = "vdac";
-  };
-
-  vaux1_reg: regulator@9 {
-   reg = <9>;
-   regulator-compatible = "vaux1";
-  };
-
-  vaux2_reg: regulator@10 {
-   reg = <10>;
-   regulator-compatible = "vaux2";
-  };
-
-  vaux33_reg: regulator@11 {
-   reg = <11>;
-   regulator-compatible = "vaux33";
-  };
-
-  vmmc_reg: regulator@12 {
-   reg = <12>;
-   regulator-compatible = "vmmc";
-  };
-
-  vbb_reg: regulator@13 {
-   reg = <13>;
-   regulator-compatible = "vbb";
-  };
- };
-};
-# 616 "<stdin>" 2
-# 633 "<stdin>"
 &tps {
- vcc1-supply = <&vbat>;
- vcc2-supply = <&vbat>;
- vcc3-supply = <&vbat>;
- vcc4-supply = <&vbat>;
- vcc5-supply = <&vbat>;
- vcc6-supply = <&vbat>;
- vcc7-supply = <&vbat>;
- vccio-supply = <&vbat>;
+# 636 "<stdin>"
+ ti,pmic-shutdown-controller;
 
  regulators {
-  vrtc_reg: regulator@0 {
-   regulator-always-on;
-  };
-
-  vio_reg: regulator@1 {
+  dcdc1_reg: regulator@0 {
+   regulator-name = "vdds_dpr";
    regulator-always-on;
   };
 
-  vdd1_reg: regulator@2 {
+  dcdc2_reg: regulator@1 {
 
    regulator-name = "vdd_mpu";
-   regulator-min-microvolt = <912500>;
-   regulator-max-microvolt = <1312500>;
+   regulator-min-microvolt = <1100000>;
+   regulator-max-microvolt = <1325000>;
    regulator-boot-on;
    regulator-always-on;
   };
 
-  vdd2_reg: regulator@3 {
+  dcdc3_reg: regulator@2 {
 
    regulator-name = "vdd_core";
-   regulator-min-microvolt = <912500>;
+   regulator-min-microvolt = <925000>;
    regulator-max-microvolt = <1150000>;
    regulator-boot-on;
    regulator-always-on;
   };
 
-  vdd3_reg: regulator@4 {
-   regulator-always-on;
-  };
-
-  vdig1_reg: regulator@5 {
-   regulator-always-on;
-  };
-
-  vdig2_reg: regulator@6 {
-   regulator-always-on;
-  };
-
-  vpll_reg: regulator@7 {
-   regulator-always-on;
-  };
-
-  vdac_reg: regulator@8 {
-   regulator-always-on;
-  };
-
-  vaux1_reg: regulator@9 {
+  ldo1_reg: regulator@3 {
+   regulator-name = "vio,vrtc,vdds";
    regulator-always-on;
   };
 
-  vaux2_reg: regulator@10 {
+  ldo2_reg: regulator@4 {
+   regulator-name = "vdd_3v3aux";
    regulator-always-on;
   };
 
-  vaux33_reg: regulator@11 {
+  ldo3_reg: regulator@5 {
+   regulator-name = "vdd_1v8";
    regulator-always-on;
   };
 
-  vmmc_reg: regulator@12 {
-   regulator-min-microvolt = <1800000>;
-   regulator-max-microvolt = <3300000>;
+  ldo4_reg: regulator@6 {
+   regulator-name = "vdd_3v3a";
    regulator-always-on;
   };
  };
@@ -1700,7 +1594,7 @@
 
 &mmc1 {
  status = "okay";
- vmmc-supply = <&vmmc_reg>;
+ vmmc-supply = <&ldo4_reg>;
  bus-width = <4>;
  pinctrl-names = "default";
  pinctrl-0 = <&mmc1_pins_default>;

+ 45 - 71
board-support/u-boot-2017.01+gitAUTOINC+340fb36f04-g340fb36f04/arch/arm/dts/am335x-evm.dts

@@ -21,7 +21,7 @@
 
 	cpus {
 		cpu@0 {
-			cpu0-supply = <&vdd1_reg>;
+			cpu0-supply = <&dcdc2_reg>;
 		};
 	};
 
@@ -163,9 +163,10 @@
 		pinctrl-single,pins = <
 			0x54 (PIN_OUTPUT_PULLDOWN | MUX_MODE7)	/* gpmc_a5.gpio1_21 */
 			0x58 (PIN_OUTPUT_PULLDOWN | MUX_MODE7)	/* gpmc_a6.gpio1_22 */
+			0x60 (PIN_OUTPUT_PULLDOWN | MUX_MODE7)  /* gpmc_a8.gpio1_24 */
 			0x64 (PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_a9.gpio1_25 */
 			0x68 (PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_a10.gpio1_26 */
-			0x6c (PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_a11.gpio1_27 */
+			0x6c (PIN_OUTPUT_PULLDOWN | MUX_MODE7)	/* gpmc_a11.gpio1_27 */
 		>;
 	};
 
@@ -403,8 +404,8 @@
 	status = "okay";
 	clock-frequency = <400000>;
 
-	tps: tps@2d {
-		reg = <0x2d>;
+	tps: tps@24 {
+		reg = <0x24>;
 	};
 };
 
@@ -488,9 +489,9 @@
 		status = "okay";
 
 		/* Regulators */
-		AVDD-supply = <&vaux2_reg>;
-		IOVDD-supply = <&vaux2_reg>;
-		DRVDD-supply = <&vaux2_reg>;
+		AVDD-supply = <&ldo2_reg>;
+		IOVDD-supply = <&ldo2_reg>;
+		DRVDD-supply = <&ldo2_reg>;
 		DVDD-supply = <&vbat>;
 	};
 };
@@ -518,7 +519,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&nandflash_pins_s0>;
 	/*ranges = <0 0 0x08000000 0x1000000>;*/	/* CS0: 16MB for NAND */
-	ranges = <0 0 0x08000000 0x80000000>;	/*+++ vern,NAND,20181030 ---*/
+	ranges = <0 0 0x08000000 0x40000000>;	/*+++ vern,NAND,20181030 ---*/
 	nand@0,0 {
 		reg = <0 0 4>; /* CS0, offset 0, IO size 4 */
 		ti,nand-ecc-opt = "bch16";
@@ -607,101 +608,74 @@
 		};
 		partition@13 {
 			label = "Storage";
-			reg = <0x0A200000 0x75E00000>;
+			reg = <0x0A200000 0x35E00000>;
 		};
 	};
 };
 
-#include "tps65910.dtsi"
-#if 0
-&mcasp1 {
-		pinctrl-names = "default";
-		pinctrl-0 = <&am335x_evm_audio_pins>;
-
-		status = "okay";
+/include/ "tps65217.dtsi"
 
-		op-mode = <0>;          /* MCASP_IIS_MODE */
-		tdm-slots = <2>;
-		/* 4 serializers */
-		serial-dir = <  /* 0: INACTIVE, 1: TX, 2: RX */
-			0 0 1 2
-		>;
-		tx-num-evt = <32>;
-		rx-num-evt = <32>;
-};
-#endif
 &tps {
-	vcc1-supply = <&vbat>;
-	vcc2-supply = <&vbat>;
-	vcc3-supply = <&vbat>;
-	vcc4-supply = <&vbat>;
-	vcc5-supply = <&vbat>;
-	vcc6-supply = <&vbat>;
-	vcc7-supply = <&vbat>;
-	vccio-supply = <&vbat>;
+	/*
+	 * Configure pmic to enter OFF-state instead of SLEEP-state ("RTC-only
+	 * mode") at poweroff.  Most BeagleBone versions do not support RTC-only
+	 * mode and risk hardware damage if this mode is entered.
+	 *
+	 * For details, see linux-omap mailing list May 2015 thread
+	 *	[PATCH] ARM: dts: am335x-bone* enable pmic-shutdown-controller
+	 * In particular, messages:
+	 *	http://www.spinics.net/lists/linux-omap/msg118585.html
+	 *	http://www.spinics.net/lists/linux-omap/msg118615.html
+	 *
+	 * You can override this later with
+	 *	&tps {  /delete-property/ ti,pmic-shutdown-controller;  }
+	 * if you want to use RTC-only mode and made sure you are not affected
+	 * by the hardware problems. (Tip: double-check by performing a current
+	 * measurement after shutdown: it should be less than 1 mA.)
+	 */
+	ti,pmic-shutdown-controller;
 
 	regulators {
-		vrtc_reg: regulator@0 {
+		dcdc1_reg: regulator@0 {
+			regulator-name = "vdds_dpr";
 			regulator-always-on;
 		};
 
-		vio_reg: regulator@1 {
-			regulator-always-on;
-		};
-
-		vdd1_reg: regulator@2 {
+		dcdc2_reg: regulator@1 {
 			/* VDD_MPU voltage limits 0.95V - 1.26V with +/-4% tolerance */
 			regulator-name = "vdd_mpu";
-			regulator-min-microvolt = <912500>;
-			regulator-max-microvolt = <1312500>;
+			regulator-min-microvolt = <1100000>;
+			regulator-max-microvolt = <1325000>;
 			regulator-boot-on;
 			regulator-always-on;
 		};
 
-		vdd2_reg: regulator@3 {
+		dcdc3_reg: regulator@2 {
 			/* VDD_CORE voltage limits 0.95V - 1.1V with +/-4% tolerance */
 			regulator-name = "vdd_core";
-			regulator-min-microvolt = <912500>;
+			regulator-min-microvolt = <925000>;
 			regulator-max-microvolt = <1150000>;
 			regulator-boot-on;
 			regulator-always-on;
 		};
 
-		vdd3_reg: regulator@4 {
-			regulator-always-on;
-		};
-
-		vdig1_reg: regulator@5 {
-			regulator-always-on;
-		};
-
-		vdig2_reg: regulator@6 {
-			regulator-always-on;
-		};
-
-		vpll_reg: regulator@7 {
-			regulator-always-on;
-		};
-
-		vdac_reg: regulator@8 {
-			regulator-always-on;
-		};
-
-		vaux1_reg: regulator@9 {
+		ldo1_reg: regulator@3 {
+			regulator-name = "vio,vrtc,vdds";
 			regulator-always-on;
 		};
 
-		vaux2_reg: regulator@10 {
+		ldo2_reg: regulator@4 {
+			regulator-name = "vdd_3v3aux";
 			regulator-always-on;
 		};
 
-		vaux33_reg: regulator@11 {
+		ldo3_reg: regulator@5 {
+			regulator-name = "vdd_1v8";
 			regulator-always-on;
 		};
 
-		vmmc_reg: regulator@12 {
-			regulator-min-microvolt = <1800000>;
-			regulator-max-microvolt = <3300000>;
+		ldo4_reg: regulator@6 {
+			regulator-name = "vdd_3v3a";
 			regulator-always-on;
 		};
 	};
@@ -748,7 +722,7 @@
 
 &mmc1 {
 	status = "okay";
-	vmmc-supply = <&vmmc_reg>;
+	vmmc-supply = <&ldo4_reg>;
 	bus-width = <4>;
 	pinctrl-names = "default";
 	pinctrl-0 = <&mmc1_pins_default>;