Index: fw/hal/jinghongling/inc/HalBt.h
===================================================================
--- /YC3121_SDK/fw/hal/jinghongling/inc/HalBt.h	(revision 732)
+++ /YC3121_SDK/fw/hal/jinghongling/inc/HalBt.h	(working copy)
@@ -1,25 +1,35 @@
-#include "yc3121.h"
-#include "halBasics.h"
+/*******************************************************************************
+文件名: halIFLASH.h
+描  述:
+版  权: 1.0
+作  者: YJK
+--------------------------------------------------------------------------------
+备  注: -
+--------------------------------------------------------------------------------
+修改记录:
+日期		版本	修改人		修改内容
+2010/11/10	1.0		YJK			创建
+*******************************************************************************/
+#ifndef __HALBT_H__
+#define __HALBT_H__
 
-#define MAC_ADDR_LEN 17
-#define MAX_devNAME 33
+#include "halCommon.h"
 
-//Bluetooth device
-typedef struct 
-{
-	char BtMAC[MAC_ADDR_LEN + 1];
-	char BtName[MAX_devNAME + 1]; // for scan
-	char Channel[3]; // for opush
-}BT_devICE;
+#ifdef __cplusplus
+    extern "C" {
+#endif
 
+// 宏定义
 
+// 类/结构声明
+
+// 全局函数声明
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
 
-s32 HalBtOpen(void);
-s32 HalBtClose(void);
-s32 HalBtSet (s8 *cdevName, s8 *cPin);
-s32 HalBtSetMac(u8 *pucMac);
-s32 HalBtGetStatus(u8 *pucStatus);
-s32 HalBtSendData(u8 *ucSendBuf, u32 uiSendLen);
-s32 HalBtRecvData(u8 *ucRecvBuf, u32 uiRecvLen);
-s32 halBtRfCtrl(u8 ucMode);
-s32 halBtRfSet(u8 ucRfValue);
Index: fw/hal/jinghongling/inc/HalIcc.h
===================================================================
--- /YC3121_SDK/fw/hal/jinghongling/inc/HalIcc.h	(revision 732)
+++ /YC3121_SDK/fw/hal/jinghongling/inc/HalIcc.h	(working copy)
@@ -1,55 +1,189 @@
-#ifndef _HAL_ICC
-#define _HAL_ICC
-#include "yc3121.h"
-#include "yc_7816.h"
-#include "yc_7816_comm.h"
-#include "yc_7816_T0.h"
-#include "yc_7816_T1.h"
-#include "halBasics.h"
-
-#define     ICC_USERCARD         0x00        // 鍗婂煁鍗″骇
-#define     ICC_SAM1             0x01        // SAM鍗″骇1
-#define     ICC_SAM2             0x02        // SAM鍗″骇2
-#define     ICC_SAM3             0x03        // SAM鍗″骇3
-#define     ICC_SAM4             0x04        // SAM鍗″骇4
-
-// ICC鍗￠氫俊鍙傛暟
-#define     ICC_VOL_5V            0x05        //  5V鍗
-#define     ICC_VOL_3V            0x03        //  3V鍗
-#define     ICC_VOL_1_8V          0x01        //  1.8V鍗
-
-#define     ICC_ISO               0x00        // 绗﹀悎ISO7816瑙勮寖
-#define     ICC_EMV               0x01        // 绗﹀悎EMV v4.1瑙勮寖
-
-#define     ICC_9600              0x01        // 9600BPS鍗＄墖
-#define     ICC_19200             0x02        // 19200BPS鍗＄墖
-#define     ICC_38400             0x03        // 38400BPS鍗＄墖
-
-//  杩斿洖鍊煎畾涔
-#define     ICC_SUCCESS          0x00      // 鍗℃搷浣滄垚鍔
-#define     ICC_TIMEOUT          	0x01      // 鍗¤秴鏃跺搷搴
-#define     ICC_COMMERR         0x02      // 鍗￠氫俊閿欒(濂囧伓閿欐垨LRC閿)
-#define     ICC_RESPERR          0x03      // 鍗＄墖杩斿洖淇℃伅閿欒
-#define     ICC_CARDOUT          0x04      // 鍗′笉鍦ㄤ綅
-#define     ICC_NOPOWER          0x05      // 鍗℃湭涓婄數
-#define     ICC_ERRORSLOT        0x06      // 鍗″骇閿欒
-#define     ICC_ERRPARA          0x07      // 鍙傛暟閿欒
-#define     ICC_ERROR           0x08      // IC鍗℃ā鍧楅敊璇
-
-
-s32 HalIccOpen(u8 ucCardSlot);
-s32 HalIccClose(u8 u8CardSlot);
-s32 HalvIccDetect(u8 ucCardSlot);
-s32 HalIccPowerUp(u8 ucCardSlot, u32 *puiAtrLen, u8 *pucAtrData);
-s32 HalIccPowerDown(u8 ucCardSlot);
-s32 HalIccExchangeAPDU(u8 ucCardSlot, u8 *pucSend,u8 uiSendLen,u8 *pucResp,u32 *puiRespLen);
-s32 HalSleCardRead(u32 uiAddr, u8 *pucRecData,u32 uiLen);
-s32 HalSleCardWrite (u32 uiAddr,u8 *pucDataIn,u32 uiLen);
-s32 HalSleCardReadStatus(u32 uiAddr, u8 *pucStatus);
-s32 HalSleCardCheckData(u32 uiAddr, u8 ucData);
+/*******************************************************************************
+文件名: HalIcc.h
+描  述: HalIc的头文件
+版  权: 1.0
+作  者: Cyclie
+--------------------------------------------------------------------------------
+备  注: <多线程是否安全>、<异常时是否安全>、<其它说明>
+--------------------------------------------------------------------------------
+修改记录:
+日期		版本	修改人		修改内容
+2019/11/07	1.0		Cyclie		创建
+*******************************************************************************/
+#ifndef __HALIC_H__       // 防止.h被重复引用
+#define __HALIC_H__
 
-void HalICCTest(void);
+#include "halCommon.h"       // 引用当前工程中的头文件
 
-uint16_t ISO7816_LoopBack2(void);
+#ifdef __cplusplus
+    extern "C" {
+#endif
+
+//宏定义
+
+// 卡座号
+#define HAL_ICC_USERCARD		0x00        // 半埋卡座
+#define HAL_ICC_SAM1			0x01        // SAM卡座1
+#define HAL_ICC_SAM2			0x02        // SAM卡座2
+
+// ICC卡通信参数
+
+// 卡支持电压
+#define HAL_ICC_VOL_5V          0x05        // 5V卡
+#define HAL_ICC_VOL_3V          0x03        // 3V卡
+#define HAL_ICC_VOL_1_8V        0x01        // 1.8V卡
+
+#define HAL_ICC_ISO		        0x00        // 符合ISO7816规范
+#define HAL_ICC_EMV			    0x01        // 符合EMV v4.1规范
+
+#define HAL_ICC_9600			0x01        // 9600BPS卡片
+#define HAL_ICC_19200			0x02        // 19200BPS卡片
+#define HAL_ICC_38400			0x03        // 38400BPS卡片
+
+// 返回值定义
+#define ICC_SUCCESS             0x00 // 卡操作成功
+#define ICC_TIMEOUT          	0x01 // 卡响应超时
+#define ICC_COMMERR             0x02 // 卡通信错误(奇偶错或LRC错)
+#define ICC_RESPERR             0x03 // 卡片返回信息错误
+#define ICC_CARDOUT             0x04 // 卡不在位
+#define ICC_NOPOWER             0x05 // 卡未上电
+#define ICC_ERRORSLOT           0x06 // 卡座错误
+#define ICC_ERRPARA             0x07 // 参数错误
+#define ICC_ERROR               0x08 // IC卡模块错误
+
+// IC Error Code
+#define HAL_IC_OK             0       // 成功
+#define HAL_IC_FAILED         -1      // 失败
+#define	IccInitError					0x5001	//初始化失败
+#define	IccDetectError					0x5002	//检测卡不在位
+#define	IccPowerupVoltageInvalidError	0x5003	//无效电压
+#define	IccPowerupInterruptedError		0x5004	//启动中断
+#define	IccPowerupATRTimeoutErr			0x5005	//ATR超时
+#define	IccPowerupATRInvalidErr			0x5006	//ATR无效
+#define	IccPowerupATRcrcFailureErr		0x5007	//ATR CRC故障
+#define	IccProtocolUnsupportedErr		0x5008	//协议不支持
+#define	IccInvalidSlotErr				0x5009	//无效的位置
+#define	IccReceiveTimeoutErr			0x500a	//接收超时
+#define	IccReceiveParityErr				0x500b	//接收奇偶检验错
+#define	IccReceiveLRCErr				0x500c	//LRC错误
+#define	IccReceiveCRCErr				0x500d	//CRC错误
+#define	IccReceiveSequenceNumErr		0x500e	//接收序列号错误
+#define	IccSetIFSDFailureErr			0x500f	//设置IFSD失败
+#define	IccReceiveInvalidErr			0x5010	//接收错误
+#define	IccPowerupATREAErr				0x5011	//ATR EA错误
+#define	IccPowerupATRTSErr				0x5012	//ATR TS错误
+#define	IccTransmitParityErr			0x5013	//传输奇偶检验错
+#define	IccOtherErr						0x5014	//其他错误
+#define	IccApduRecvLengthErr			0x5015	//apdu返回数据长度错误
+#define	IccWByteTimeout					0x5016	//IC卡操作超时
+#define	IccRByteTimeout					0x5017	//IC卡操作超时
+#define	IccCWTErr						0x5018	//其他错误
+
+// 类/结构声明
+
+// 全局函数声明
+/*******************************************************************************
+函数功能: 对应卡座上电
+输入参数: ucCardSlot            卡座号
+输出参数: None
+返回值  : HalIc Error Code
+--------------------------------------------------------------------------------
+备注    : Electrify to appointed card slot, and reset card, return the
+          responsive content of card No command could be done before card
+          initialization successful.
+--------------------------------------------------------------------------------
+修改信息: 20191107 Cyclie 创建
+*******************************************************************************/
+extern s32 halIccOpen(u8 ucCardSlot);
+
+/*******************************************************************************
+函数功能: 对应卡座下电
+输入参数: ucCardSlot            卡座号
+输出参数: None
+返回值  : HalIc Error Code
+--------------------------------------------------------------------------------
+备注    : 请看本模块宏定义
+--------------------------------------------------------------------------------
+修改信息: 20191107 Cyclie 创建
+*******************************************************************************/
+extern s32 halIccClose(u8 ucCardSlot);
+
+/*******************************************************************************
+函数功能: set the basic parameters
+输入参数: ucCardSlot            卡座号
+          iCardVol              卡支持电压
+          iCardType             支持卡片规范
+          iBaudrate             支持波特率
+          iIsPPS                是否支持PPS
+输出参数: None
+返回值  : HalIc Error Code
+--------------------------------------------------------------------------------
+备注    : 请看本模块宏定义
+--------------------------------------------------------------------------------
+修改信息: 20191107 Cyclie 创建
+*******************************************************************************/
+extern s32 halIccSetPara(u8 ucCardSlot, s32 iCardVol, s32 iCardType, s32 iBaudrate, s32 iIsPPS);
+
+/*******************************************************************************
+函数功能: detect the ic card
+输入参数: ucCardSlot            卡座号
+输出参数: None
+返回值  : HalIc Error Code
+--------------------------------------------------------------------------------
+备注    : 请看本模块宏定义
+--------------------------------------------------------------------------------
+修改信息: 20191111 Cyclie 创建
+*******************************************************************************/
+extern s32 halIccDetect(u8 ucCardSlot);
+
+/*******************************************************************************
+函数功能: 对指定卡座的IC卡执行上电操作
+输入参数: ucCardSlot            卡座号
+输出参数: piAtrLen	            卡片返回的ATR数据长度
+          pucAtrData            卡片返回的ATR数据
+返回值  : HalIc Error Code
+--------------------------------------------------------------------------------
+备注    : 请看本模块宏定义
+--------------------------------------------------------------------------------
+修改信息: 20191111 Cyclie 创建
+*******************************************************************************/
+extern s32 halIccPowerUp(u8 ucCardSlot, u32 *puiAtrLen, u8 *pucAtrData);
+
+/*******************************************************************************
+函数功能: 对IC卡执行下电操作
+输入参数: ucCardSlot            卡座号
+输出参数: None
+返回值  : HalIc Error Code
+--------------------------------------------------------------------------------
+备注    : 请看本模块宏定义
+--------------------------------------------------------------------------------
+修改信息: 20191111 Cyclie 创建
+*******************************************************************************/
+extern s32 halIccPowerDown(u8 ucCardSlot);
+
+/*******************************************************************************
+函数功能: 对指定卡座的IC卡进行数据交换
+输入参数: ucCardSlot            卡座号
+          pucSend               终端发送的APDU命令包
+          uiSendLen             发送的APDU命令包长度
+输出参数: pucResp               卡片返回的APDU响应包
+          puiRespLen            卡片返回的APDU响应包长度
+返回值  : HalIc Error Code
+--------------------------------------------------------------------------------
+备注    : uiSendLen             lc + 5
+          pucSend               cmd[4] + lc[1] + Data[Lc]
+--------------------------------------------------------------------------------
+修改信息: 20191111 Cyclie 创建
+*******************************************************************************/
+extern s32 halIccExchangeAPDU(u8 ucCardSlot, u8 *pucSend, u8 uiSendLen, u8 *pucResp, u32 *puiRespLen);
+
+#ifdef __cplusplus
+    }
+#endif
 
 #endif
+
+
+
+
+
Index: fw/hal/jinghongling/inc/HalMag.h
===================================================================
--- /YC3121_SDK/fw/hal/jinghongling/inc/HalMag.h	(revision 732)
+++ /YC3121_SDK/fw/hal/jinghongling/inc/HalMag.h	(working copy)
@@ -1,17 +1,156 @@
-#ifndef _HAL_MSR
-#define _HAL_MSR
+/*******************************************************************************
+文件名: halMag.h
+描  述: HalMag的头文件
+版  权: 1.0
+作  者: Cyclie
+--------------------------------------------------------------------------------
+备  注: <多线程是否安全>、<异常时是否安全>、<其它说明>
+--------------------------------------------------------------------------------
+修改记录:
+日期		版本	修改人		修改内容
+2019/11/07	1.0		Cyclie		创建
+*******************************************************************************/
+#ifndef __HAL_MAG_H__       // 防止.h被重复引用
+#define __HAL_MAG_H__
 
-#include "..\core\yc3121.h"
-#include "..\sdk\yc_adc.h"
-#include "..\sdk\yc_msr\yc_msr.h"
-#include "halBasics.h"
+#include "halCommon.h"       // 引用当前工程中的头文件
 
+#ifdef __cplusplus
+    extern "C" {
+#endif
+
+//宏定义
+#define MAG_READ_IRQ				(0x01)		//磁条卡读卡数据是否在中断读取(=1 在中断，=0 查询到有卡标志再读取)
+#define MAG_DETECT_MODE_IT			(0xA0)		//磁条卡检卡ADC采用中断方式
+#define MAG_DETECT_MODE_POLL		(0xA1)		//磁条卡检卡ADC采用轮询方式
+#define MAG_DETECT_ING				(0xA2)		//磁条卡检卡中
+#define MAG_DETECT_FINISH			(0xA3)		//磁条卡检卡完成
+
+#define MAG_ADC_HIGH  				(0xA4)		//adc值高于阈值
+#define MAG_ADC_NOISE  				(0xA5)		//adc值在噪声范围内
+#define MAG_ADC_LOW  				(0xA6)		//adc值低于阈值
+
+#define CD1_LOW_NORMAL			    (1450)	 	// 1磁道的低阈值
+#define CD1_HIGH_NORMAL			    (2200)		// 1磁道的高阈值
+
+#define CD2_LOW_NORMAL			    (1000)		// 2磁道的低阈值
+#define CD2_HIGH_NORMAL			    (2200)		// 2磁道的高阈值
+
+#define CD3_LOW_NORMAL			    (1450)		// 3磁道的低阈值
+#define CD3_HIGH_NORMAL			    (2200)		// 3磁道的高阈值
+
+// Mag Error Code
+#define HAL_MAG_OK                  0       // 成功
+#define HAL_MAG_FAILED              -1      // 失败
+#define HAL_MAG_SWIP_YES			(0xA801)//有刷卡
+#define HAL_MAG_SWIP_NO				(0xA802)//无刷卡
+#define HAL_MAG_TRACK_1				(0xA803)//只有1磁道有有效数据,2 3磁道无有效数据
+#define HAL_MAG_TRACK_2				(0xA804)//只有2磁道有有效数据,1 3磁道无有效数据
+#define HAL_MAG_TRACK_3				(0xA805)//只有3磁道有有效数据,1 2磁道无有效数据
+#define HAL_MAG_TRACK_12		    (0xA806)//只有3磁道无有效数据,1 2磁道有有效数据
+#define HAL_MAG_TRACK_13			(0xA807)//只有2磁道无有效数据,1 3磁道有有效数据
+#define HAL_MAG_TRACK_23			(0xA808)//只有1磁道无有效数据,2 3磁道有有效数据
+#define HAL_MAG_TRACK_123			(0xA809)// 1 2 3磁道都有有效数据
+#define HAL_MAG_TRACK_NULL			(0xA80A)// 1 2 3磁道都无有效数据
+
+//类/结构声明
+
+//全局函数声明
+/*******************************************************************************
+函数功能: 磁卡阅读器初始化
+输入参数: 无
+输出参数: 无
+返回值:   HAL_OK        打开成功
+          HAL_ERROR     打开失败
+--------------------------------------------------------------------------------
+备注  :   无
+--------------------------------------------------------------------------------
+修改信息: 2019/12/21    jqdeng      创建
+*******************************************************************************/
+extern s32 halMagInit(void);
+
+/*******************************************************************************
+函数功能: 打开磁卡阅读器
+输入参数: None
+输出参数: None
+返回值  : HalMag Error Code
+--------------------------------------------------------------------------------
+备注    : 读磁卡数据采用中断方式工作，一旦打开磁卡阅读器，即使不调用读取函数，
+          只要刷卡，磁头一样能读入磁卡数据，因此在不需要使用磁卡阅读器时，
+          最好将磁卡阅读器关闭。
+--------------------------------------------------------------------------------
+修改信息: 20191111 Cyclie 创建
+*******************************************************************************/
+extern s32 halMagOpen(void);
+
+/*******************************************************************************
+函数功能: 关闭磁卡阅读器
+输入参数: None
+输出参数: None
+返回值  : HalMag Error Code
+--------------------------------------------------------------------------------
+备注    :
+--------------------------------------------------------------------------------
+修改信息: 20191111 Cyclie 创建
+*******************************************************************************/
+extern s32 halMagClose(void);
 
-s32 HalMagOpen(void);
-s32 HalMagClose(void);
-void HalMagReset(void);
-s32 HalMagSwiped(void);
-s32 HalMagRead(s8 *cTrack1, s8 *cTrack2, s8 *cTrack3);
-void  test_halmag();
+/*******************************************************************************
+函数功能: 复位磁头，并清除磁卡缓冲区数据
+输入参数: None
+输出参数: None
+返回值  : None
+--------------------------------------------------------------------------------
+备注    : 在磁头已上电的情况下，该函数复位磁头，清除磁卡缓冲区数据；
+          在磁头没有上电的情况下，只清除磁卡缓冲区数据。为确保磁头读入的数据是最
+          新的数据，在循环检测是否刷卡之前，最好调用该函数一次，以清除磁卡缓冲数据。
+--------------------------------------------------------------------------------
+修改信息: 20191111 Cyclie 创建
+*******************************************************************************/
+extern void halMagReset(void);
 
+/*******************************************************************************
+函数功能: 检查是否刷卡
+输入参数: None
+输出参数: None
+返回值  : HalMag Error Code
+--------------------------------------------------------------------------------
+备注    : 不管是否刷卡，该函数都会立即返回
+--------------------------------------------------------------------------------
+修改信息: 20191111 Cyclie 创建
+*******************************************************************************/
+extern s32 halMagSwiped(void);
+
+/*******************************************************************************
+函数功能: 读取磁卡缓冲区的1、2、3磁道的数据
+输入参数: None
+输出参数: cTrack1           存放1磁道数据的指针 [应用层缓冲区要设为256]
+          cTrack2           存放2磁道数据的指针 [应用层缓冲区要设为256]
+          cTrack3           存放3磁道数据的指针 [应用层缓冲区要设为256]
+返回值  : HalMag Error Code
+--------------------------------------------------------------------------------
+备注    : 与magSwiped函数配合使用。如果不需要某磁道数据，
+          可以将该磁道对应的指针置为NULL，这时将不会输出该磁道的数据。
+          返回的磁道数据不包含开始符、结束符和LRC符。
+          一般读取符合ISO7812标准的磁卡时：
+            track1的空间为79字节
+            track2的空间为40字节
+            track3的空间为107字节
+--------------------------------------------------------------------------------
+修改信息: 20191111 Cyclie 创建
+*******************************************************************************/
+extern s32 halMagRead(s8 *cTrack1, s8 *cTrack2, s8 *cTrack3);
+
+extern void magIRQHandler(void);
+
+#ifdef __cplusplus
+    }
 #endif
+
+#endif
+
+
+
+
+
+
Index: fw/hal/jinghongling/inc/halAdc.h
===================================================================
--- /YC3121_SDK/fw/hal/jinghongling/inc/halAdc.h	(revision 732)
+++ /YC3121_SDK/fw/hal/jinghongling/inc/halAdc.h	(working copy)
@@ -1,42 +1,105 @@
-#ifndef _HAL_ADC_H_
-#define _HAL_ADC_H_
+/*******************************************************************************
+文件名: <halAdc.h>
+描  述: adc接口及相关宏定义
+版  权:
+作  者: czz
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改记录: 创建
+日期			修改人			修改内容
+2019.11.5		czz				创建
+2019.11.7       czz				修改
+*******************************************************************************/
+#ifndef __HAL_ADC_H__
+#define __HAL_ADC_H__
 
-#include "yc3121.h"
+#include "halCommon.h"
 #include "yc_adc.h"
-#include "halBasics.h"
 
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+// 宏定义
+#define		HAL_CHARGE_FULL  0x00 //充电完成，电充满
+#define		HAL_CHARGE_ING   0x01 //充电中
+#define		HAL_CHARGE_NULL  0x02 //充电断开，未充电
+
+// 类/结构声明
 typedef enum
 {
-	ADC_PHASE_0 = ADC_GPIO,
-	ADC_PHASE_1,
-	ADC_PHASE_2,
-	ADC_PHASE_30,
-} E_ADC_PHASE_NUM; //
+    ADC_PHASE_0,
+    ADC_PHASE_1,
+    ADC_PHASE_2,
+    ADC_PHASE_30,
+    ADC_PHASE_31,
+    ADC_PHASE_32,
+    ADC_PHASE_33,
+    ADC_PHASE_MAX,
+} E_ADC_PHASE_NUM;
 
 typedef enum
 {
-	ADC_CH_OFF = 0,
-	ADC_CH_0 = 1,
-	ADC_CH_1 = 2,
-	ADC_CH_2 = 3,
-	ADC_CH_3 = 4,
-	ADC_CH_4 = 5,
-	ADC_CH_5 = 6,
-	ADC_CH_6 = 7,
-	ADC_CH_7 = 8,
-	ADC_CH_8 = 9,
-	ADC_CH_01 = 0, // differ adc channel_0 and adc channel_1
-	ADC_CH_23 = 1, // differ adc channel_2 and adc channel_3
-	ADC_CH_45 = 2, // differ adc channel_4 and adc channel_5
-	ADC_CH_67 = 3, // differ adc channel_6 and adc channel_7
-	ADC_CH_MAX,
-}E_ADC_CH; // adc channel
-
-void halAdcInit(void) ;
-u32 halAdcPhaseSelect(E_ADC_PHASE_NUM ePhase, E_ADC_CH eChn);
-u32 halAdcStart(void);
-u32 halAdcStop(void);
-int halAdcReadData(E_ADC_PHASE_NUM ucPhase, u16* data);
+    ADC_CH_OFF  =  0,
+    ADC_CH_0  =  1,
+    ADC_CH_1  =  2,
+    ADC_CH_2  =  3,
+    ADC_CH_3  =  4,
+    ADC_CH_4  =  5,
+    ADC_CH_5  =  6,
+    ADC_CH_6  =  7,
+    ADC_CH_7  =  8,
+    ADC_CH_8  =  9,
+    ADC_CH_9  =  0x0a,
+    ADC_CH_01  =  0x0b,  // differ adc channel_0 and adc channel_1
+    ADC_CH_23  =  0x0c,  // differ adc channel_2 and adc channel_3
+    ADC_CH_45  =  0x0d,  // differ adc channel_4 and adc channel_5
+    ADC_CH_67  =  0x0e,  // differ adc channel_6 and adc channel_7
+    ADC_CH_MAX,
+}E_ADC_CH;               // adc channel
+
+typedef enum
+{
+    ADC_BATTERY_VAL,
+    ADC_CHRG_STATUS,
+    ADC_PRN_TEMPERATURE,
+    ADC_TP_INT,
+    ADC_PRN_CHECK_PAPER,
+} E_ADC_MODE;
+
+// 全局函数声明
+extern u8 gucBatteryAdc2MagAdcTime;
+extern void halAdcInit(void);
+extern s32 halAdcPhaseSelectt(E_ADC_PHASE_NUM ePhase, E_ADC_CH eChn);
+extern s32 halAdcDmaOutEnable(u8 ucMask);
+extern s32 halAdcStart(void);
+extern s32 halAdcStop(void);
+extern s32 halAdcReadData(E_ADC_PHASE_NUM ePhase, u16* usdata);
+extern s32 halAdcMonitCfg(E_ADC_PHASE_NUM ePhase, s16 unthrs, u32 uicomp, u32 uien);
+extern s32 halAdcMonitStart(void);
+extern s32 halAdcMonitStop(void);
+
+/*******************************************************************************
+函数功能: 获取电池电量、CHRG_STATUS、打印机温度检测、TP_INT 、检纸
+输入参数: eMode : 通道选择
+输出参数: punValue : 获取的对应通道adc值
+返回值  : HAL_OK
+          HAL_ERROR
+--------------------------------------------------------------------------------
+备注    :
+1.当模式为 ADC_BATTERY_VAL & ADC_CHRG_STATUS时，调用要求至少间隔每1s调用1次；(影响刷卡)
+2.当模式为 ADC_BATTERY_VAL & ADC_CHRG_STATUS时，退出会判断是否要恢复刷卡adc配置；
+--------------------------------------------------------------------------------
+修改信息: 2019.12.21    jqdeng    创建
+*******************************************************************************/
+extern s32 halAdcGetData(E_ADC_MODE eMode, u16 *punValue);
+
+extern s32 halAdcReset(void);
+
+#ifdef __cplusplus
+}
+#endif
 
 #endif
 
Index: fw/hal/jinghongling/inc/halCommon.h
===================================================================
--- /YC3121_SDK/fw/hal/jinghongling/inc/halCommon.h	(revision 732)
+++ /YC3121_SDK/fw/hal/jinghongling/inc/halCommon.h	(working copy)
@@ -1,19 +1,20 @@
 /*******************************************************************************
-文件名: <halCommon.h>
-描  述: 数据类型重命名
-版  权:
-作  者: jqdeng
+文件名: HalCommon.h
+描  述: HalCommon的头文件
+版  权: 1.0
+作  者: Cyclie
 --------------------------------------------------------------------------------
-备注  :
+备  注: <多线程是否安全>、<异常时是否安全>、<其它说明>
 --------------------------------------------------------------------------------
-修改记录: 创建
-日期			修改人			修改内容
-2019.11.12			jqdeng				创建
+修改记录:
+日期		版本	修改人		修改内容
+2019/11/07	1.0		Cyclie		创建
 *******************************************************************************/
-#ifndef __HAL_COMMON_H__
-#define __HAL_COMMON_H__
+#ifndef __HALCOMMON_H__ // 防止.h被重复引用
+#define __HALCOMMON_H__
 
 #include <stdint.h>
+#include "yc3121.h"
 
 #ifdef __cplusplus
     extern "C" {
@@ -51,22 +52,149 @@
 typedef unsigned long long	u64;
 #endif
 
+//typedef enum {FALSE = 0, TRUE = !FALSE} bool;
+//typedef enum {HAL_FALSE = 0, HAL_TRUE = !HAL_FALSE} bool;
 
-
-typedef enum {HAL_FALSE = 0, HAL_TRUE = !HAL_FALSE} bool;
-
-#define NULL				0
-
-#define HAL_OK                 	(0)
-#define HAL_ERROR              	(-1)
-#define HAL_PARAMERR          	(-2)
-#define HAL_TIMEOUT            	(-3)
-
-#define HAL_ON                  (0x01)
-#define HAL_OFF                 (0x00)
-
-#define HAL_Success				(0x00)
-
+#undef TRUE
+#undef FALSE
+#define TRUE     1
+#define FALSE    0
+
+#define HAL_FALSE  			(0)
+#define HAL_TRUE  			(1)
+
+#ifndef NULL
+#define NULL				(0)
+#endif
+
+#define SYS_RELEASE     	(0xA0) // 正式版本
+#define SYS_DEBUG       	(0xA1) // 调试版本(不操作仿真两个口)
+
+#define SYS_MODE        	SYS_RELEASE
+
+// 宏定义
+#define HAL_OK              (0)
+#define HAL_ERROR           (-1)
+#define HAL_PARAMERR        (-2)
+#define HAL_TIMEOUT         (-3)
+#define HAL_HWSPIERR        (-4)
+
+#define HAL_ON               (0x01)
+#define HAL_OFF              (0x00)
+#define HAL_NULL			  0
+
+#define HAL_Success		     (0x00)
+#define HAL_SUCCESS			 (0)
+#define HAL_FAILED		     (-1)
+
+#define HAL_MAG_OPEN_FLAG		(0x00000001) // 磁卡检测开启标志
+#define HAL_ICC_OPEN_FLAG		(0x00000002) // IC卡检测开启标志
+#define HAL_RFID_OPEN_FLAG		(0x00000004) // 非接卡检测开启标志
+
+// 中断编号
+/* ---------------------  SC300 Processor Exceptions Numbers  --------------------- */
+#define  HAL_INTR_NonMaskableInt    = -14,      /*!< 2 Non Maskable Interrupt                                      */
+#define  HAL_INTR_HardFault         = -13,      /*!< 4 Hardfault Interrupt                                         */
+#define  HAL_INTR_MemoryManagement  = -12,      /*!< 4 SC300 Memory Management Interrupt                           */
+#define  HAL_INTR_BusFault         	= -11,      /*!< 5 SC300 Bus Fault Interrupt                                   */
+#define  HAL_INTR_UsageFault        = -10,      /*!< 6 SC300 Usage Fault Interrupt                                 */
+#define  HAL_INTR_SVCall            = -5,       /*!< 11 SC300 SV Call Interrupt                                    */
+#define  HAL_INTR_DebugMonitor      = -4,       /*!< 12 SC300 Debug Monitor Interrupt                              */
+#define  HAL_INTR_PendSV           	= -2,       /*!< 14 SC300 Pend SV Interrupt                                    */
+#define  HAL_INTR_SysTick          = -1,       /*!< 15 SC300 System Tick Interrupt                                */
+/* ---------------------  ARMSC300 Specific Interrupt Numbers  -------------------- */
+#define HAL_INTR_RCC		0
+#define HAL_INTR_DMA		3
+#define HAL_INTR_AHBMMU		4
+#define HAL_INTR_MPU	    7
+#define HAL_INTR_SM4		10
+#define HAL_INTR_AES     	11
+#define HAL_INTR_DES		12
+#define HAL_INTR_PKE	    13
+#define HAL_INTR_EGS	    15
+#define HAL_INTR_TRNG	    17
+#define HAL_INTR_FD2	    18
+#define HAL_INTR_FD3	    19
+#define HAL_INTR_VB_SENSOR	20
+#define HAL_INTR_ASH	    21
+#define HAL_INTR_WWDT		22
+#define HAL_INTR_TIMER1		23
+#define HAL_INTR_TIMER2     24
+#define HAL_INTR_TIMER3		25
+#define HAL_INTR_TIMER4		26
+#define HAL_INTR_TIMER5		27
+#define HAL_INTR_TIMER6		28
+#define HAL_INTR_FLASH1		33
+#define HAL_INTR_GPIO		36
+#define HAL_INTR_SPI1       37
+#define HAL_INTR_SPI2		38
+#define HAL_INTR_SPI3		39
+#define HAL_INTR_UART1		40
+#define HAL_INTR_UART2		41
+#define HAL_INTR_UART3		42
+#define HAL_INTR_I2C        44
+#define HAL_INTR_ISO7816M1	45
+#define HAL_INTR_ISO7816M2	46
+#define HAL_INTR_ISO7816M3	47
+#define HAL_INTR_PWM1		48
+#define HAL_INTR_PWM2		49
+#define HAL_INTR_DCMI		50
+#define HAL_INTR_USB		51
+#define HAL_INTR_UART4    	52
+#define HAL_INTR_ADC		53
+#define HAL_INTR_ISO7816S	54
+#define HAL_INTR_SWP 		55
+#define HAL_INTR_FSP		57
+#define HAL_INTR_EXTI0_15	64
+#define HAL_INTR_EXTI16_31	65
+#define HAL_INTR_EXTI32_47	66
+#define HAL_INTR_EXTI48_63	67
+#define HAL_INTR_EXTI64_79	68
+#define HAL_INTR_EXTI80		69
+#define HAL_INTR_EXTI81		70
+#define HAL_INTR_EXTI82		71
+#define HAL_INTR_EXTI83		72
+#define HAL_INTR_EXTI84		73
+#define HAL_INTR_EXTI85		74
+
+#define HAL_WWDT_LOAD_VALUE     (0x0FFFFFFF)
+
+// 类/结构声明
+
+// 全局变量声明
+extern volatile u8 gucCardOpenFlag;
+extern volatile u8 gucPkeRamBuf[4096]; // 加密协处理器使用的4K内存RAM
+
+// 全局函数声明
+extern void halPrintf(char *fmt, ...);
+extern void halPrintfWithTitle(u8 *pucData, u16 unLen, s8 *pcName);
+extern u32 halGetSysTick(void);
+extern void halDelayMs(u32 uiMs);
+extern void halDelayUs(u32 uiUs);
+extern void halClkCoreFreqSet(u32 uiFreq);
+extern void halInitInterrupt(void);
+extern void halEnableIrq(u32 uiID);
+extern void halDisableIrq(u32 id);
+extern void halGetMcuID(u8 *pucMcdID);
+extern void halNvicSetPriority(u8 ucIRQn, u8 ucPriority);
+extern s32 halGetPwrKeyState(void);
+extern s32 halSysPwrOff(void);
+extern void halSysReset(void);
+extern s32 halSysReadHalVer(s8 *pcVersion);
+extern s32 halSysClkInit(void);
+extern void halSysIrq(u8 ucMode);
+extern void halSysTickHandler(void);
+extern void systickIntHandler(void);
+extern void halClearPendingIrq(u32 uiID);
+extern s32 halWdtOpen(u32 uiLoadVal);
+extern s32 halWdtIsr(void);
+extern s32 halWdtClose(void);
+extern s32 halWdtFeed(u32 uiLoadVal);
+extern void halSoftDelayUs(u32 uiTimeUs);
+extern void halSoftDelayMs(u32 uiTimeMs);
+extern void testSoftDelay(u8 ucMode);
+extern void halClearPendingIrq(u32 uiID);
+extern s32 halReadHalVer(s8 *pszVersion);
 
 #ifdef __cplusplus
     }
@@ -74,3 +202,5 @@
 
 #endif
 
+
+
Index: fw/hal/jinghongling/inc/halGpio.h
===================================================================
--- /YC3121_SDK/fw/hal/jinghongling/inc/halGpio.h	(revision 732)
+++ /YC3121_SDK/fw/hal/jinghongling/inc/halGpio.h	(working copy)
@@ -14,25 +14,13 @@
 #ifndef __HAL_GPIO_H__
 #define __HAL_GPIO_H__
 
-#include "yc3121.h"
-#include "yc_gpio.h"
 #include "halCommon.h"
-#include "halBasics.h"
 
 #ifdef __cplusplus
     extern "C" {
 #endif
 
-
-// GPIO Group
-#define HAL_GPIOA						(0x01)	//第一组GPIO
-#define HAL_GPIOB						(0x02)	//第二组GPIO
-#define HAL_GPIOC						(0x03)	//第三组GPIO
-#define HAL_GPIOD						(0x04)	//第四组GPIO
-#define HAL_GPIOE						(0x05)	//第五组GPIO
-
-
-// GPIO Pin
+// Define
 #define HAL_GPIO_PIN_0				((uint16_t)0x0001)
 #define HAL_GPIO_PIN_1				((uint16_t)0x0002)
 #define HAL_GPIO_PIN_2				((uint16_t)0x0004)
@@ -51,38 +39,121 @@
 #define HAL_GPIO_PIN_15				((uint16_t)0x8000)
 #define HAL_GPIO_PIN_All			((uint16_t)0xFFFF)
 
+#define HAL_GPIOA					(0x01)	//第一组GPIO
+#define HAL_GPIOB					(0x02)	//第二组GPIO
+#define HAL_GPIOC					(0x03)	//第三组GPIO
+#define HAL_GPIOD					(0x04)	//第四组GPIO
+#define HAL_GPIOE					(0x05)	//第五组GPIO
+
+//初始化模式
+#define HAL_GPIO_MODE_IN			(0x00000000UL)  //输入模式
+#define HAL_GPIO_MODE_OUT			(0x00000001UL)  //输出模式
+
+//复用
+#define HAL_GPIO_AFR_FUNCTION1		(0x00000000UL)  //复用第一功能
+#define HAL_GPIO_AFR_FUNCTION2		(0x00000001UL)  //复用第二功能
+#define HAL_GPIO_AFR_FUNCTION3	    (0x00000002UL)  //复用第三功能
+#define HAL_GPIO_AFR_FUNCTION4	    (0x00000003UL)	//复用第四功能
+
+//引脚复用功能
+#define HAL_GPIO_MODE_AF			(0x00000002UL)	        //复用模式
+#define HAL_GPIO_Mode_AF_OD			HAL_GPIO_MODE_AF		//复用开漏输出模式
+#define HAL_GPIO_Mode_AF_PP			HAL_GPIO_MODE_AF		//复用推挽输出模式
 
-// GPIO State
+// GPIO 状态
 #define HAL_GPIO_RESET			    (0X00) // IO低电平
 #define HAL_GPIO_SET			    (0X01) // IO高电平
 
+// 机型
+#define HAL_H60_A                   (0x53)
+#define HAL_HM600                   (0x14)
+
+// Pin Function Type
+// Lcd
+#define HAL_GPIO_LCD_CS             (0x00)
+#define HAL_GPIO_LCD_RST            (0x01)
+#define HAL_GPIO_LCD_BL             (0x02)
+#define HAL_GPIO_LCD_AO             (0x03)
+// Nfc
+#define HAL_GPIO_NFC_SLEEP      	(0x10)
+#define HAL_GPIO_NFC_RST        	(0x11)
+#define HAL_GPIO_NFC_STANDBY    	(0x12)
+
+// Prn
+#define HAL_GPIO_PRN_MTA1           (0x20)
+#define HAL_GPIO_PRN_MTA2           (0x21)
+#define HAL_GPIO_PRN_MTB1           (0x22)
+#define HAL_GPIO_PRN_MTB2           (0x23)
+#define HAL_GPIO_PRN_LAT            (0x24)
+#define HAL_GPIO_PRN_PWR            (0x25)
+#define HAL_GPIO_PRN_STB            (0x26)
+// Led
+#define HAL_GPIO_LED_GREEN          (0x30)
+#define HAL_GPIO_LED_RED            (0x31)
+#define HAL_GPIO_LED_YELLOW         (0x32)
+#define HAL_GPIO_LED_BLUE           (0x33)
+// Sys
+#define HAL_GPIO_SYS_PWR            (0x40)
+#define HAL_GPIO_SYS_DETECT         (0x41) // InPut
+// Beep
+#define HAL_GPIO_BEEP               (0x50)
+// Tp
+#define HAL_GPIO_TP_CS              (0x60)
+// WiFi
+#define HAL_GPIO_WIFI_TX            (0x70)
+#define HAL_GPIO_WIFI_RX            (0x71)
+#define HAL_GPIO_WIFI_PWR           (0x72)
+// Wnet
+#define HAL_GPIO_WNET_PWR           (0x80)
+#define HAL_GPIO_WNET_RST           (0x81)
+#define HAL_GPIO_WNET_TX            (0x82)
+#define HAL_GPIO_WNET_RX            (0x83)
+// Key
+#define HAL_GPIO_KEY0               (0x90) // InPut & OutPut
+#define HAL_GPIO_KEY1               (0x91) // InPut & OutPut
+#define HAL_GPIO_KEY2               (0x92) // InPut & OutPut
+#define HAL_GPIO_KEY3               (0x93) // InPut & OutPut
+#define HAL_GPIO_KEY4               (0x94) // InPut & OutPut
+#define HAL_GPIO_KEY5               (0x95) // InPut & OutPut
+// Usb
+#define HAL_GPIO_USB_DETECT         (0xA0) // InPut
 
-
+// Class/structure declaration
 typedef enum
 {
-	HAL_INT_RISING = 1,
+    HAL_INT_RISING = 1,
     HAL_INT_FALLING,
     HAL_INT_DUAL,
     HAL_INT_LOW,
     HAL_INT_HIGH
-} E_GPIO_INT_MODE; // GPhal interrupt type
+} E_GPIO_INT_MODE; // GPIO interrupt type
 
 typedef enum
 {
-	HAL_GPIO_INPUT,
+    HAL_GPIO_INPUT,
     HAL_GPIO_OUTPUT,
     HAL_SIG_INPUT,
     HAL_SIG_OUTPUT
-} E_GPIO_PIN_MODE; // GPhal mode
+} E_GPIO_PIN_MODE; // GPIO mode
+
+typedef enum
+ {
+    HAL_GPIO_NOPULL,
+    HAL_GPIO_PULLUP,
+    HAL_GPIO_PULLDN,
+    HAL_GPIO_DEFAULT
+} E_GPIO_PULL_MODE; // GPIO PULL
 
 typedef enum
 {
-	HAL_GPIO_NOPULL,
-	HAL_GPIO_PULLUP,
-	HAL_GPIO_PULLDN,
-	HAL_GPIO_DEFAULT
-} E_GPIO_PULL_MODE; // GPhal PULL
+  HAL_PIN_RESET = 0,
+  HAL_PIN_SET = 1
+}E_GPIO_PinState;
+
+typedef void(*gpioIsr)(void);
+extern gpioIsr pfnGpioIsr;
 
+// Global function declaration
 extern void halGpioInit(u32 uiGpio, u32 uiGpioPin, E_GPIO_PIN_MODE eMode, E_GPIO_PULL_MODE ePull);
 extern s32 halGpioIntDisable(u32 uiGpioIndex,u32 uiGpioPin);
 extern s32 halGpioIntEnable(u32 uiGpioIndex,u32 uiGpioPin);
@@ -91,9 +162,24 @@
 extern s32 halGpioWritePin(u32 uiGpioIndex,u32 uiGpioPin,u8 ucBit);
 extern s32 halIoMuxSetMode(u32 uiGpioIndex,u32 uiGpioPin,u8 ucMuxMode);
 extern s32 halGpioWakeupCfg(u32 uiGpioIndex,u32 uiGpioPin,u8 ucEn);
+extern void halVbatGpioInit(u32 uiVbatGpioIndex, unsigned char ucIntControl);
+extern u32 halVbatIoReadPin(u32 uiGpioPin);
+extern void halSpiSetPrintio(void);
+extern void setVbatIo(u8 mode);
+extern s32 halClearGpioIT(u32 uiGpio);
+extern u32 halGetGpioIT(u32 uiGpio);
+extern void testGpio(void);
+extern void gpioPB13set(u8 ucMode);
+extern void gpioPB14set(u8 ucMode);
+extern s32 halGpioFixedConfig(u8 ucDevType, u8 ucFuncType);
+extern s32 halGpioFixedPinSet(u8 ucDevType, u8 ucFuncType, u8 ucBit);
+extern u32 halGpioFixedPinGetVal(u8 ucDevType, u8 ucFuncType);
+extern void halSleepIoConfig(u8 ucDevType);
 
 #ifdef __cplusplus
     }
 #endif
 
 #endif
+
+
Index: fw/hal/jinghongling/inc/halI2c.h
===================================================================
--- /YC3121_SDK/fw/hal/jinghongling/inc/halI2c.h	(revision 732)
+++ /YC3121_SDK/fw/hal/jinghongling/inc/halI2c.h	(working copy)
@@ -1,7 +1,45 @@
-#include "yc3121.h"
-#include "yc_iic.h"
-#include "halBasics.h"
-
-int halI2CConfig(u32 index, u32 speed);
-int halI2CSend(u32 uiIndex,u32 uiAddr,u8 *puBuf ,u32 uiLen);
-int halI2CRecv(u32 uiIndex,u32 uiAddr,u8 *pubuf, u32 uiLen);
+/*******************************************************************************
+文件名: halI2c.h
+描  述:
+版  权: 1.0
+作  者: YJK
+--------------------------------------------------------------------------------
+备  注: -
+--------------------------------------------------------------------------------
+修改记录:
+日期		版本	修改人		修改内容
+2019/11/13	1.0		YJK			创建
+*******************************************************************************/
+#ifndef __HALI2C_H__        // 防止重复引用
+#define __HALI2C_H__
+
+#include "halCommon.h"
+
+#ifdef __cplusplus
+    extern "C" {
+#endif
+
+// 宏定义
+#define Hal_IIC1    1
+#define Hal_IIC2    2
+
+#define HAL_DATA_WRITE_DIR 0
+#define HAL_DATA_READ_DIR  1
+
+#define HAL_IIC_OK     0
+
+// 类/结构声明
+
+
+// 全局函数声明
+s32 halI2CConfig(u32 uiIndex, u32 uiSpeed);
+s32 halI2CSend(u32 uiIndex,u32 uiAddr,u8 *pucBuf ,u32 uiLen);
+s32 halI2CRecv(u32 uiIndex,u32 uiAddr,u8 *pucBuf, u32 uiLen);
+
+#ifdef __cplusplus
+    }
+#endif
+
+#endif
+
+
Index: fw/hal/jinghongling/inc/halIFlash.h
===================================================================
--- /YC3121_SDK/fw/hal/jinghongling/inc/halIFlash.h	(revision 732)
+++ /YC3121_SDK/fw/hal/jinghongling/inc/halIFlash.h	(working copy)
@@ -1,14 +1,93 @@
-#ifndef _HAL_IFLASH
-#define _HAL_IFLASH
-#include "yc3121.h"
-#include "yc_qspi.h"
-#include "halBasics.h"
+/*******************************************************************************
+文件名: halIflash.h
+描  述:
+版  权: 1.0
+作  者: YJK
+--------------------------------------------------------------------------------
+备  注: -
+--------------------------------------------------------------------------------
+修改记录:
+日期		版本	修改人		修改内容
+2010/11/10	1.0		YJK			创建
+*******************************************************************************/
+#ifndef __HALIFLASH_H__
+#define __HALIFLASH_H__
 
+#include "halCommon.h"     // 引用标准库的头文件
 
-//u32 halIflashInit(void)//when power on,flash always be initialized.
-int halIflashErase(u32 addr);
+#ifdef __cplusplus
+    extern "C" {
+#endif
+
+// 宏定义
+//内部flash(0x7001 ~ 0x8000)
+#define FlashSuccess				0	//操作成功
+#define FlashFailure				(-1)	//操作成功
+
+#define FlashErasePageTimeout		0x7001	//页面擦除超时
+#define FlashErasePageError			0x7002	//页面擦除失败
+#define FlashDoubleWordTimeout		0x7003	//双字编程超时
+#define FlashDoubleWordError		0x7004	//双字编程错误
+#define FlashCompareError			0x7005	//数据对比错误
+#define FlashWritePageError			0x7006	//页面写入失败
+#define FlashAddreeError			0x7007	//Flash地址出错
+#define WriteMkeyIndexError			0x7008	//主密钥索引写入失败
+#define ReadMkeyIndexError			0x7009	//获取主密钥索引失败
+#define ReadMkeyModeError			0x700a	//获取主密钥加密模式失败
+#define MKeyIndexError				0x700b	//密钥索引值出错
+#define MKeyLenError				0x700c	//密钥长度出错
+#define MKeyModeError				0x700d	//密钥模式出错
+#define MKeyWriteError				0x700e	//写入密钥出错
+#define WriteMkeyModeError			0x700f	//写密钥加密模式出错
+#define WriteSnKeyError				0x7010	//写入sn密钥失败
+#define WriteTDataError				0x7011	//写入传输数据出错
+#define WriteTKeyLenError			0x7012	//写入传输密钥数据长度出错
+#define WriteTKeyModeError			0x7013	//写入传输密钥模式出错
+#define WriteTKeyError				0x7013	//写入传输密钥数据出错
+#define WriteTUSnError				0x7014	//写入TUSN出错
+#define WKeyIndexError				0x7015	//工作密钥索引出错
+#define WKeyLenError				0x7016	//工作密钥长度出错
+#define WKeyModeError				0x7017	//工作密钥模式出错
+#define WKeyWrtieError				0x7018	//工作密钥写入失败
+
+//全局函数声明
+extern s32 halIFlashInit(void);
 
-int halIflash_write(u32 uiAddr,u8 *pucData, u32 uiDataLen);
+/*******************************************************************************
+函数功能: 页擦除
+输入参数: uiAddress 要被擦除的页起始地址
+          uiPageNum 要擦除的页数
+输出参数: 无
+返回值:   =0 成功
+          其他 失败
+--------------------------------------------------------------------------------
+备注  :   无
+--------------------------------------------------------------------------------
+修改信息: 2019/11/10    YJK      创建
+*******************************************************************************/
+extern s32 halIFlashErasePage(u32 uiAddress, u32 uiPageNum);
+extern s32 halIFlashErase(u32 uiAddr);
+extern s32 halIFlashWrite(u32 uiAddr,u8 *pucData, u32 uiDataLen);
+
+/*******************************************************************************
+函数功能: 从IFLASH读取数据
+输入参数: uiAddr        偏移地址
+          uiDataLen     读取的数据长度
+输出参数: pucData       读到的数据
+返回值  : >=0  实际读取的数据长度
+          <0  失败
+--------------------------------------------------------------------------------
+备注    :
+--------------------------------------------------------------------------------
+修改信息: 2019/11/10 YJK 创建
+          20200113 Cyclie 修改 返回值
+*******************************************************************************/
+extern s32 halIFlashRead(u32 uiAddr,u8 *pucData, u32 uiDataLen);
+extern void testIFlash(void);
+
+#ifdef __cplusplus
+    }
+#endif
 
-int halIflash_read(u32 uiAddr,u8 *pucData, u32 uiDataLen);
 #endif
+
Index: fw/hal/jinghongling/inc/halPwm.h
===================================================================
--- /YC3121_SDK/fw/hal/jinghongling/inc/halPwm.h	(revision 732)
+++ /YC3121_SDK/fw/hal/jinghongling/inc/halPwm.h	(working copy)
@@ -1,20 +1,53 @@
-#include "yc3121.h"
-#include "yc_timer.h"
-#include "halBasics.h"
+/*******************************************************************************
+文件名: halPwm.h
+描  述: PWM头文件
+版  权: 1.0
+作  者: YJK
+--------------------------------------------------------------------------------
+备  注: -
+--------------------------------------------------------------------------------
+修改记录:
+日期		版本	修改人		修改内容
+2019/11/1	1.0		YJK			创建
+2020/1/1	1.0		Czz			修改
+*******************************************************************************/
+#ifndef __HALPWM_H__        // 防止hal_iccard.h被重复引用
+#define __HALPWM_H__
 
-typedef enum 
+#include "halCommon.h"    // 引用标准库的头文件
+
+#ifdef __cplusplus
+    extern "C" {
+#endif
+
+typedef enum
 {
-PWM0=0,
-PWM1,
-PWM2,
-PWM3,
-PWM4,
-PWM5,
-PWM6,
-PWM7,
-PWM8,
-}E_PWM_INDEX;
+    HAL_PWM1 = 1,
+    HAL_PWM2,
+}E_PWM_INDEX;    //结构体/类声明
+
+typedef struct
+{
+    u16 unPwm1Max;
+    u16 unPwm2Max;
+}T_PWM_MAX_MS; // PWM执行的时间，一个变量对应一组PWM(单位10ms)
+
+//全局函数声明
+extern T_PWM_MAX_MS gtPwmMaxMs;
 
-void halPwmInit(void);
+//全局dev调用函数声明
+void halPwmInit(E_PWM_INDEX eIndex);    
 void halPwmConfig(E_PWM_INDEX eIndex,u32 uiUs,u32 uiDuty,u8 ucType);
-void halPwmSwitch(E_PWM_INDEX eIndex,u32 ucIsOn);
+extern void halPwmSwitch(E_PWM_INDEX eIndex,u8 ucIsOn);
+extern s32 halPwmSetTimeout(E_PWM_INDEX eIndex, u16 un10MsCnt);
+extern s32 halPwmGetTimeout(T_PWM_MAX_MS *tTimeLeft);
+extern void testPwm(void);
+extern void pwmMsCntDecrease(void);
+
+#ifdef __cplusplus
+    }
+#endif
+
+
+#endif
+
Index: fw/hal/jinghongling/inc/halSpi.h
===================================================================
--- /YC3121_SDK/fw/hal/jinghongling/inc/halSpi.h	(revision 732)
+++ /YC3121_SDK/fw/hal/jinghongling/inc/halSpi.h	(working copy)
@@ -2,42 +2,47 @@
 文件名: <halSpi.h>
 描  述: spi接口及相关宏定义
 版  权:
-作  者: jqdeng
+作  者: czz
 --------------------------------------------------------------------------------
 备注  :
 --------------------------------------------------------------------------------
 修改记录: 创建
 日期			修改人			修改内容
-2019.11.15      jqdeng				创建
+2019.11.11      czz				创建
 *******************************************************************************/
 #ifndef __HAL_SPI_H__
 #define __HAL_SPI_H__
 
+#include "halCommon.h"
+
 #ifdef __cplusplus
  extern "C" {
 #endif
 
-#include "yc3121.h"
-#include "yc_spi.h"
-#include "halCommon.h"
-#include "halBasics.h"
-
 typedef enum
 {
-	spi0 = SPI0,
-	spi1
+	HAL_SPI0,
+	HAL_SPI1,
+	HAL_SPI2,
+	HAL_SPI3,
 }E_SPI_INDEX;
 
-
 extern s32 halSpiConfig(E_SPI_INDEX eIndex, u32 uiSpeed, u8 ucDataBits, u8 ucMode);
 extern s32 halSpiSend(E_SPI_INDEX eIndex,u8 *pucBuf, u32 uiLen);
 extern s32 halSpiRecv(E_SPI_INDEX eIndex,u8 *pucBuf, u32 uiLen);
-
+extern void testSpi(void);
 
 #ifdef __cplusplus
-    }
+}
 #endif
 
 #endif
 
 
+
+
+
+
+
+
+
Index: fw/hal/jinghongling/inc/halTimer.h
===================================================================
--- /YC3121_SDK/fw/hal/jinghongling/inc/halTimer.h	(revision 732)
+++ /YC3121_SDK/fw/hal/jinghongling/inc/halTimer.h	(working copy)
@@ -1,42 +1,111 @@
-#include "yc_uart.h"
-#include "halBasics.h"
-#include "yc_systick.h"
+/*******************************************************************************
+文件名: HalTime.h
+描  述: HalTime的头文件
+版  权: 1.0
+作  者: Cyclie
+--------------------------------------------------------------------------------
+备  注: <多线程是否安全>、<异常时是否安全>、<其它说明>
+--------------------------------------------------------------------------------
+修改记录:
+日期		版本	修改人		修改内容
+2019/11/07	1.0		Cyclie		创建
+*******************************************************************************/
+#ifndef __HALTIME_H__       // 防止.h被重复引用
+#define __HALTIME_H__
+
+#include "halCommon.h"       // 引用当前工程中的头文件
+
+#ifdef __cplusplus
+    extern "C" {
+#endif
+		
+#define TIMER_RELOAD_1MS        (48000) //总计1MS
+		
+//宏定义
+// 定时器编号
+#define HAL_TIME1	                1
+#define HAL_TIME2	                2
+#define HAL_TIME3	                3
+#define HAL_TIME4	                4
+#define HAL_TIME5	                5
+#define HAL_TIME6	                6
+
+// 定时器状态
+#define HAL_TIM_STATE_RESET         0x00U       /*!< Peripheral not yet initialized or disabled  */
+#define HAL_TIM_STATE_READY         0x01U       /*!< Peripheral Initialized and ready for use    */
+#define HAL_TIM_STATE_BUSY          0x02U       /*!< An internal process is ongoing              */
+#define HAL_TIM_STATE_OVER_FLOW     0x03U       /*!< Timeout state                               */
+
+// 定时器区间大小
+#define HAL_TIM_SIZE_16BIT			(0x00UL)    /*!< Selects 16 bit Counter default*/
+#define HAL_TIM_SIZE_32BIT			(0x01UL)    /*!< Selects 32 bit Counter */
+
+// 时钟分频
+#define HAL_TIM_PRESCLAR_NOT_DIV	(0x00UL)	/*!< The 0 stages of prescale,clock is divided 1,default*/
+#define HAL_TIM_PRESCLAR_DIV_16		(0x04UL)	/*!< The 4 stages of prescale,clock is divided 16,default*/
+#define HAL_TIM_PRESCLAR_DIV_256	(0x08UL)	/*!<The 8 stages of prescale,clock is divided 256,default*/
+
+// 定时器模式
+#define HAL_TIM_MODE_CONTINUITY_NO_RELOAD	(0x00UL)	/*!< The Counter warps after reaching its zero value,and continues to count down from the maximum value. this is the default mode.*/
+#define HAL_TIM_MODE_CONTINUITY_RELOAD		(0x01UL)	/*!< The Counter generates an interrupt at a constant interval,relaoding the original value after wrapping past zero*/
+#define HAL_TIM_MODE_SINGEL					(0x02UL)	/*!< The Counter generates an interrupt once,when the counter reaches 0,it halts until you reprogram it,you can do this using one of follower:
+														 Clear the one shot count bit in the contral register,in which case the count proceeds according to the selection of Free-running or periodic mode
+														 Write a new value to the Load value register*/
+
+#define HAL_TIM_DIVISION            5
+
+// Time Error Code
+#define HAL_TIME_OK                 0       // 成功
+#define HAL_TIME_FAILED             -1      // 失败
+#define HAL_TIME_ERRPARA            -2      // 参数错误
 
-typedef enum
+//类/结构声明
+typedef struct
 {
-	SYS_TM_PERhalD, // GTMR0_0 systick
-	SYS_TM_1, // GTMR0_1
-	SYS_TM_2, // GTMR0_2
-	SYS_TM_3, // GTMR0_3
-	SYS_TM_4, // GTMR1_0
-	SYS_TM_5, // GTMR1_1
-	SYS_TM_6, // GTMR1_2
-	SYS_TM_7, // GTMR1_3
-	SYS_TM_MAX,
-} SYS_TIMER_ID; // timer id
+    u32 perhald;
+    u32 mode;
+	void (*handler)(void);  /* interrupt handler Functhaln pointer */
+	u32 prhalr;             /*timer's interrupt prhalrity  1~6*/
+	s32 index;              /* timer id number */
+}T_TIMER_PARAM;
+
+
+//全局函数声明
+extern s32 testTime(void);
+extern void halTimeIRQHandler(u32 uiTimeID);
+extern void halTimeSetState(u32 uiTimeID, u8 ucState);
+extern u8 halTimeGetState(u32 uiTimeID);
+extern s32 halTimerInit(u32 uiTimeID);
+extern s32 halTimerDeInit(u32 uiTimeID);
+extern s32 halTimerConfig(u32 uiTimeID, u16 usPresclar, u8 ucCounterMode, u8 ucSizeMode);
+extern s32 halSetTimer(u32 uiTimeID, u32 uiTimeout);
+extern s32 halGetTimer(u32 uiTimeID);
+extern s32 halTimerStart(u32 uiTimeID);
+extern s32 halTimerStartIT(u32 uiTimeID);
+extern s32 halTimerStartIT(u32 uiTimeID);
+
+/*******************************************************************************
+函数功能: Stop the timer
+输入参数: uiTimeID          Timer number
+输出参数: None
+返回值  : HalTime Error Code
+--------------------------------------------------------------------------------
+备注    :
+--------------------------------------------------------------------------------
+修改信息: 20191107 Cyclie 创建
+*******************************************************************************/
+extern s32 halTimerStop(u32 uiTimeID);
+
+#ifdef __cplusplus
+    }
+#endif
+
+#endif
+
+
 
 
-typedef struct
-{
-u32 perhald;
-u32 mode;
-	void (*handler)(void); /* interrupt handler Functhaln pointer */
-	u32 prhalr; /*timer's interrupt prhalrity0~7*/
-	int index; /* timer id number */
- }ST_TM_PARAM; 
 
 
-typedef struct 
-{
-	u32 starttime;
-	u32 timeout;
-}ST_Timer_UNIT; 
 
 
-void hal_TimerInit(void);
-void hal_TimerConfig(ST_TM_PARAM *tmr);
-void hal_TimerStart(u32 index);
-void hal_TimerStop(u32 index);
-int hal_TimerGet(u32 index);
-void hal_TimerLeft(ST_Timer_UNIT *timer);
-int hal_GetSysTick(void);
Index: fw/hal/jinghongling/inc/halTrng.h
===================================================================
--- /YC3121_SDK/fw/hal/jinghongling/inc/halTrng.h	(revision 732)
+++ /YC3121_SDK/fw/hal/jinghongling/inc/halTrng.h	(working copy)
@@ -1,11 +1,62 @@
-#include "yc3121.h"
-#include "yc_trng.h"
-#include "halBasics.h"
-
-
-void hal_RandomInint(void);
-void hal_GetRandom(u8 *random,u32 len);
+/*******************************************************************************
+文件名: HalRandom.h
+描  述: HalRandom的头文件
+版  权: 1.0
+作  者: Cyclie
+--------------------------------------------------------------------------------
+备  注: <多线程是否安全>、<异常时是否安全>、<其它说明>
+--------------------------------------------------------------------------------
+修改记录:
+日期		版本	修改人		修改内容
+2019/11/07	1.0		Cyclie		创建
+*******************************************************************************/
+#ifndef __HALRANDOM_H__       // 防止.h被重复引用
+#define __HALRANDOM_H__
+
+#include "halCommon.h"       // 引用当前工程中的头文件
+
+#ifdef __cplusplus
+    extern "C" {
+#endif
+
+//宏定义
+// Random Error Code
+#define HAL_RANDOM_OK             0       // 成功
+#define HAL_RANDOM_FAILED         -1      // 失败
+
+//类/结构声明
+
+//全局函数声明
+/*******************************************************************************
+函数功能: Random number initialization
+输入参数: None
+输出参数: None
+返回值  : HalRandom Error Code
+--------------------------------------------------------------------------------
+备注    :
+--------------------------------------------------------------------------------
+修改信息: 20191107 Cyclie 创建
+*******************************************************************************/
+extern s32 halRandomInit(void);
+
+/*******************************************************************************
+函数功能: Get random data
+输入参数: len               random data byte len
+输出参数: random            random data
+返回值  : HalRandom Error Code
+--------------------------------------------------------------------------------
+备注    :
+--------------------------------------------------------------------------------
+修改信息: 20191107 Cyclie 创建
+          20191224 jqdeng 修改
+*******************************************************************************/
+extern s32 halGetRandom(u8 *pucRandom,u32 uilen);
+
+#ifdef __cplusplus
+    }
+#endif
 
+#endif
 
 
 
Index: fw/hal/jinghongling/inc/halUart.h
===================================================================
--- /YC3121_SDK/fw/hal/jinghongling/inc/halUart.h	(revision 732)
+++ /YC3121_SDK/fw/hal/jinghongling/inc/halUart.h	(working copy)
@@ -1,62 +1,84 @@
 /*******************************************************************************
-文件名: halUart.h
-描  述: 串口相关宏定义
+文件名: hal_uart.h
+描  述:
 版  权: 1.0
-作  者: jqdeng
+作  者: YJK
 --------------------------------------------------------------------------------
 备  注: -
 --------------------------------------------------------------------------------
 修改记录:
 日期		版本	修改人		修改内容
-2010/11/1	1.0		jqdeng			创建
+2010/11/1	1.0		YJK			创建
 *******************************************************************************/
-#ifndef __HALUART_H__
+#ifndef __HALUART_H__        // 防止hal_iccard.h被重复引用
 #define __HALUART_H__
 
-
-#include "yc3121.h"
-#include "yc_uart.h"
 #include "halCommon.h"
-#include "halBasics.h"
 
 #ifdef __cplusplus
     extern "C" {
 #endif
 
-//结构体/类声明
+#define HAL_DEBUG_UART          UART_PT2 // 调试串口 UART_PT2 UART_PT0
+
+// 宏定义
+#define HAL_UART_OK         0
+#define FIFO_MAX_SIZE   (255) // 128 >> 255
+
+// 结构体/类声明
+typedef struct
+{
+    u8 ucBuff[FIFO_MAX_SIZE];
+    u8 ucIndex;
+    u8 ucLen;
+} T_LOOP_FIFO;
+
 typedef enum
 {
 	UART_PT0 = 0,
-	UART_PT1 = 1,
-	UART_PT2 = 2,
-	UART_PT3 = 3,
-}E_UART_INDEX;// uart index
+	UART_PT1,
+	UART_PT2,
+	UART_PT3
+}E_UART_INDEX;
 
 typedef enum
 {
-	UART_DATA_8_BITS = Databits_8b,
-	UART_DATA_9_BITS = Databits_9b
-}E_UART_DATA_BIT;// data bits
+	UART_DATA_5_BITS  =  0,
+	UART_DATA_6_BITS,
+	UART_DATA_7_BITS,
+	UART_DATA_8_BITS,
+}E_UART_DATA_BIT;
 
 typedef enum
 {
-	UART_STOP_BITS_1 = StopBits_1,
-	UART_STOP_BITS_2 = StopBits_2,
-}E_UART_STOP_BIT;// sotp bits
+	UART_STOP_BITS_1  =   0,
+	UART_STOP_BITS_1_5,
+	UART_STOP_BITS_2
+}E_UART_STOP_BIT;
 
 typedef enum
 {
-	UART_PARITY_DISABLE = Parity_None,
-	UART_PARITY_EVEN = Parity_Even,
-	UART_PARITY_ODD = Parity_Odd
-}E_PARITY_TYPE; // parity type
+    UART_PARITY_DISABLE  =  0,
+	UART_PARITY_EVEN,
+	UART_PARITY_ODD
+}E_PARITY_TYPE;
+
+// 变量外部声明
+extern T_LOOP_FIFO tUart1Fifo;
+//extern T_LOOP_FIFO tUart2Fifo;
+extern T_LOOP_FIFO tUart3Fifo;
+//extern T_LOOP_FIFO tUart4Fifo;
+
 
-//全局函数声明
+// 全局函数声明
+extern void uartFifoIn(u8 ucData, T_LOOP_FIFO *ptFifo);
 extern s32 halUartOpen(E_UART_INDEX eChannel, u32 uiBaud, E_UART_DATA_BIT eDataBit,  E_PARITY_TYPE eParity, E_UART_STOP_BIT eStopBit);
 extern s32 halUartSend(E_UART_INDEX eChannel, u8 *pucBuf, u32 uiLen);
 extern s32 halUartRecv(E_UART_INDEX eChannel, u8 *pucBuf, u32 uiLen);
 extern s32 halUartClose(E_UART_INDEX eChannel);
 extern s32 halUartFlush(E_UART_INDEX eChannel);
+extern void uartIntHandler(E_UART_INDEX eChannel);
+extern void testUart(E_UART_INDEX eChannel);
 
 
 #ifdef __cplusplus
@@ -66,4 +88,3 @@
 
 #endif
 
-
Index: fw/hal/jinghongling/make/YC3121_hal.uvoptx
===================================================================
--- /YC3121_SDK/fw/hal/jinghongling/make/YC3121_hal.uvoptx	(revision 732)
+++ /YC3121_SDK/fw/hal/jinghongling/make/YC3121_hal.uvoptx	(working copy)
@@ -171,7 +171,7 @@
 
   <Group>
     <GroupName>lib</GroupName>
-    <tvExp>1</tvExp>
+    <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
     <RteFlg>0</RteFlg>
@@ -199,26 +199,26 @@
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
-  </Group>
-
-  <Group>
-    <GroupName>lib_sdk</GroupName>
-    <tvExp>1</tvExp>
-    <tvExpOptDlg>0</tvExpOptDlg>
-    <cbSel>0</cbSel>
-    <RteFlg>0</RteFlg>
     <File>
-      <GroupNumber>2</GroupNumber>
+      <GroupNumber>1</GroupNumber>
       <FileNumber>3</FileNumber>
-      <FileType>4</FileType>
+      <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_crypt\crypt.lib</PathWithFileName>
-      <FilenameWithoutPath>crypt.lib</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\core\bt_code.c</PathWithFileName>
+      <FilenameWithoutPath>bt_code.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
+  </Group>
+
+  <Group>
+    <GroupName>lib_sdk</GroupName>
+    <tvExp>1</tvExp>
+    <tvExpOptDlg>0</tvExpOptDlg>
+    <cbSel>0</cbSel>
+    <RteFlg>0</RteFlg>
     <File>
       <GroupNumber>2</GroupNumber>
       <FileNumber>4</FileNumber>
@@ -262,8 +262,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_usb\libraries\SCPU_USB_Device_Library\class\ccid\usbd_ccid_if.c</PathWithFileName>
-      <FilenameWithoutPath>usbd_ccid_if.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_usb\libraries\SCPU_USB_Device_Library\core\usbd_core.c</PathWithFileName>
+      <FilenameWithoutPath>usbd_core.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -274,8 +274,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_usb\libraries\SCPU_USB_Device_Library\class\ccid\usbd_ccid_core.c</PathWithFileName>
-      <FilenameWithoutPath>usbd_ccid_core.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_usb\libraries\SCPU_USB_Device_Library\core\usbd_ioreq.c</PathWithFileName>
+      <FilenameWithoutPath>usbd_ioreq.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -286,8 +286,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_usb\libraries\SCPU_USB_Device_Library\class\ccid\usbd_ccid_cmd.c</PathWithFileName>
-      <FilenameWithoutPath>usbd_ccid_cmd.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_usb\libraries\SCPU_USB_Device_Library\core\usbd_req.c</PathWithFileName>
+      <FilenameWithoutPath>usbd_req.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -298,8 +298,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_usb\libraries\SCPU_USB_Device_Library\core\usbd_core.c</PathWithFileName>
-      <FilenameWithoutPath>usbd_core.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_usb\scpu_usb_ccid_Device_Demo\usbd_usr.c</PathWithFileName>
+      <FilenameWithoutPath>usbd_usr.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -310,8 +310,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_usb\libraries\SCPU_USB_Device_Library\core\usbd_ioreq.c</PathWithFileName>
-      <FilenameWithoutPath>usbd_ioreq.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_usb\scpu_usb_ccid_Device_Demo\usbd_desc.c</PathWithFileName>
+      <FilenameWithoutPath>usbd_desc.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -322,8 +322,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_usb\libraries\SCPU_USB_Device_Library\core\usbd_req.c</PathWithFileName>
-      <FilenameWithoutPath>usbd_req.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_adc.c</PathWithFileName>
+      <FilenameWithoutPath>yc_adc.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -334,8 +334,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_usb\scpu_usb_ccid_Device_Demo\usbd_usr.c</PathWithFileName>
-      <FilenameWithoutPath>usbd_usr.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_bt.c</PathWithFileName>
+      <FilenameWithoutPath>yc_bt.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -346,8 +346,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_usb\scpu_usb_ccid_Device_Demo\usbd_desc.c</PathWithFileName>
-      <FilenameWithoutPath>usbd_desc.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_dma.c</PathWithFileName>
+      <FilenameWithoutPath>yc_dma.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -358,8 +358,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_usb\scpu_usb_ccid_Device_Demo\usb_main.c</PathWithFileName>
-      <FilenameWithoutPath>usb_main.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_DTM.c</PathWithFileName>
+      <FilenameWithoutPath>yc_DTM.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -370,8 +370,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_usb\scpu_usb_ccid_Device_Demo\sc_itf.c</PathWithFileName>
-      <FilenameWithoutPath>sc_itf.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_exti.c</PathWithFileName>
+      <FilenameWithoutPath>yc_exti.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -382,8 +382,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_adc.c</PathWithFileName>
-      <FilenameWithoutPath>yc_adc.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_gpio.c</PathWithFileName>
+      <FilenameWithoutPath>yc_gpio.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -394,8 +394,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_bt.c</PathWithFileName>
-      <FilenameWithoutPath>yc_bt.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_iic.c</PathWithFileName>
+      <FilenameWithoutPath>yc_iic.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -406,8 +406,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_dma.c</PathWithFileName>
-      <FilenameWithoutPath>yc_dma.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_ipc.c</PathWithFileName>
+      <FilenameWithoutPath>yc_ipc.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -418,8 +418,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_DTM.c</PathWithFileName>
-      <FilenameWithoutPath>yc_DTM.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_lcd.c</PathWithFileName>
+      <FilenameWithoutPath>yc_lcd.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -430,8 +430,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_exti.c</PathWithFileName>
-      <FilenameWithoutPath>yc_exti.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_lpm.c</PathWithFileName>
+      <FilenameWithoutPath>yc_lpm.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -442,8 +442,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_gpio.c</PathWithFileName>
-      <FilenameWithoutPath>yc_gpio.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_otp.c</PathWithFileName>
+      <FilenameWithoutPath>yc_otp.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -454,8 +454,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_iic.c</PathWithFileName>
-      <FilenameWithoutPath>yc_iic.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_rtc.c</PathWithFileName>
+      <FilenameWithoutPath>yc_rtc.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -466,8 +466,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_ipc.c</PathWithFileName>
-      <FilenameWithoutPath>yc_ipc.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_spi.c</PathWithFileName>
+      <FilenameWithoutPath>yc_spi.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -478,8 +478,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_lcd.c</PathWithFileName>
-      <FilenameWithoutPath>yc_lcd.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_ssc.c</PathWithFileName>
+      <FilenameWithoutPath>yc_ssc.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -490,8 +490,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_lpm.c</PathWithFileName>
-      <FilenameWithoutPath>yc_lpm.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_sysctrl.c</PathWithFileName>
+      <FilenameWithoutPath>yc_sysctrl.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -502,8 +502,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_otp.c</PathWithFileName>
-      <FilenameWithoutPath>yc_otp.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_systick.c</PathWithFileName>
+      <FilenameWithoutPath>yc_systick.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -514,8 +514,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_qspi.c</PathWithFileName>
-      <FilenameWithoutPath>yc_qspi.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_rand.c</PathWithFileName>
+      <FilenameWithoutPath>yc_rand.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -526,8 +526,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_rtc.c</PathWithFileName>
-      <FilenameWithoutPath>yc_rtc.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_timer.c</PathWithFileName>
+      <FilenameWithoutPath>yc_timer.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -538,8 +538,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_spi.c</PathWithFileName>
-      <FilenameWithoutPath>yc_spi.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_trng.c</PathWithFileName>
+      <FilenameWithoutPath>yc_trng.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -550,8 +550,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_ssc.c</PathWithFileName>
-      <FilenameWithoutPath>yc_ssc.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_uart.c</PathWithFileName>
+      <FilenameWithoutPath>yc_uart.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -562,20 +562,20 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_sysctrl.c</PathWithFileName>
-      <FilenameWithoutPath>yc_sysctrl.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_wdt.c</PathWithFileName>
+      <FilenameWithoutPath>yc_wdt.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
     <File>
       <GroupNumber>2</GroupNumber>
       <FileNumber>33</FileNumber>
-      <FileType>1</FileType>
+      <FileType>4</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_systick.c</PathWithFileName>
-      <FilenameWithoutPath>yc_systick.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_msr\yc_msr.lib</PathWithFileName>
+      <FilenameWithoutPath>yc_msr.lib</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -586,32 +586,32 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_rand.c</PathWithFileName>
-      <FilenameWithoutPath>yc_rand.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_nfc\yc_nfc_common.c</PathWithFileName>
+      <FilenameWithoutPath>yc_nfc_common.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
     <File>
       <GroupNumber>2</GroupNumber>
       <FileNumber>35</FileNumber>
-      <FileType>1</FileType>
+      <FileType>4</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_timer.c</PathWithFileName>
-      <FilenameWithoutPath>yc_timer.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_crypt\yc_crypt.lib</PathWithFileName>
+      <FilenameWithoutPath>yc_crypt.lib</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
     <File>
       <GroupNumber>2</GroupNumber>
       <FileNumber>36</FileNumber>
-      <FileType>1</FileType>
+      <FileType>4</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_trng.c</PathWithFileName>
-      <FilenameWithoutPath>yc_trng.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_qspi.lib</PathWithFileName>
+      <FilenameWithoutPath>yc_qspi.lib</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -622,8 +622,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_uart.c</PathWithFileName>
-      <FilenameWithoutPath>yc_uart.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_nfc\yc_emv_contactless_l1.c</PathWithFileName>
+      <FilenameWithoutPath>yc_emv_contactless_l1.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -634,8 +634,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_wdt.c</PathWithFileName>
-      <FilenameWithoutPath>yc_wdt.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_7816\yc_7816.c</PathWithFileName>
+      <FilenameWithoutPath>yc_7816.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -646,44 +646,44 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\bt_code.c</PathWithFileName>
-      <FilenameWithoutPath>bt_code.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_7816\yc_7816_T0.c</PathWithFileName>
+      <FilenameWithoutPath>yc_7816_T0.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
     <File>
       <GroupNumber>2</GroupNumber>
       <FileNumber>40</FileNumber>
-      <FileType>4</FileType>
+      <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_msr\yc_msr.lib</PathWithFileName>
-      <FilenameWithoutPath>yc_msr.lib</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_7816\yc_7816_T1.c</PathWithFileName>
+      <FilenameWithoutPath>yc_7816_T1.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
     <File>
       <GroupNumber>2</GroupNumber>
       <FileNumber>41</FileNumber>
-      <FileType>4</FileType>
+      <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_7816\yc_7816.lib</PathWithFileName>
-      <FilenameWithoutPath>yc_7816.lib</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_usb\scpu_usb_hid_Device_Demo\usb_main.c</PathWithFileName>
+      <FilenameWithoutPath>usb_main.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
     <File>
       <GroupNumber>2</GroupNumber>
       <FileNumber>42</FileNumber>
-      <FileType>4</FileType>
+      <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_nfc\yc_nfc.lib</PathWithFileName>
-      <FilenameWithoutPath>yc_nfc.lib</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_chrg.c</PathWithFileName>
+      <FilenameWithoutPath>yc_chrg.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -694,8 +694,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\lib\Librarier\sdk\yc_nfc\yc_nfc_common.c</PathWithFileName>
-      <FilenameWithoutPath>yc_nfc_common.c</FilenameWithoutPath>
+      <PathWithFileName>..\lib\Librarier\sdk\yc_usb\libraries\SCPU_USB_Device_Library\class\HID\usbd_hid_core.c</PathWithFileName>
+      <FilenameWithoutPath>usbd_hid_core.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -735,7 +735,7 @@
 
   <Group>
     <GroupName>HalApp</GroupName>
-    <tvExp>1</tvExp>
+    <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
     <RteFlg>0</RteFlg>
@@ -774,7 +774,7 @@
   </Group>
 
   <Group>
-    <GroupName>HalBasics</GroupName>
+    <GroupName>HalBt</GroupName>
     <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
@@ -786,15 +786,15 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\src\HalBasics\halBasics.c</PathWithFileName>
-      <FilenameWithoutPath>halBasics.c</FilenameWithoutPath>
+      <PathWithFileName>..\src\HalBt\HalBt.c</PathWithFileName>
+      <FilenameWithoutPath>HalBt.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
   </Group>
 
   <Group>
-    <GroupName>HalGpio</GroupName>
+    <GroupName>HalCommon</GroupName>
     <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
@@ -806,15 +806,15 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\src\HalGpio\halGpio.c</PathWithFileName>
-      <FilenameWithoutPath>halGpio.c</FilenameWithoutPath>
+      <PathWithFileName>..\src\HalCommon\halCommon.c</PathWithFileName>
+      <FilenameWithoutPath>halCommon.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
   </Group>
 
   <Group>
-    <GroupName>HalIFlash</GroupName>
+    <GroupName>HalEncrypt</GroupName>
     <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
@@ -826,15 +826,15 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\src\HalIFlash\halIFlash.c</PathWithFileName>
-      <FilenameWithoutPath>halIFlash.c</FilenameWithoutPath>
+      <PathWithFileName>..\src\HalEncrypt\halEncrypt.c</PathWithFileName>
+      <FilenameWithoutPath>halEncrypt.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
   </Group>
 
   <Group>
-    <GroupName>HalI2c</GroupName>
+    <GroupName>HalExFlash</GroupName>
     <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
@@ -846,15 +846,15 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\src\HalI2c\halI2c.c</PathWithFileName>
-      <FilenameWithoutPath>halI2c.c</FilenameWithoutPath>
+      <PathWithFileName>..\src\HalExFlash\halExFlash.c</PathWithFileName>
+      <FilenameWithoutPath>halExFlash.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
   </Group>
 
   <Group>
-    <GroupName>HalPwm</GroupName>
+    <GroupName>HalGpio</GroupName>
     <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
@@ -866,15 +866,15 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\src\HalPwm\halPwm.c</PathWithFileName>
-      <FilenameWithoutPath>halPwm.c</FilenameWithoutPath>
+      <PathWithFileName>..\src\HalGpio\halGpio.c</PathWithFileName>
+      <FilenameWithoutPath>halGpio.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
   </Group>
 
   <Group>
-    <GroupName>HalSpi</GroupName>
+    <GroupName>HalI2c</GroupName>
     <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
@@ -886,15 +886,15 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\src\HalSpi\halSpi.c</PathWithFileName>
-      <FilenameWithoutPath>halSpi.c</FilenameWithoutPath>
+      <PathWithFileName>..\src\HalI2c\halI2c.c</PathWithFileName>
+      <FilenameWithoutPath>halI2c.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
   </Group>
 
   <Group>
-    <GroupName>HalTimer</GroupName>
+    <GroupName>HalIcc</GroupName>
     <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
@@ -906,15 +906,15 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\src\HalTimer\halTimer.c</PathWithFileName>
-      <FilenameWithoutPath>halTimer.c</FilenameWithoutPath>
+      <PathWithFileName>..\src\HalIcc\HalIcc.c</PathWithFileName>
+      <FilenameWithoutPath>HalIcc.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
   </Group>
 
   <Group>
-    <GroupName>HalTrng</GroupName>
+    <GroupName>HalIFlash</GroupName>
     <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
@@ -926,15 +926,15 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\src\HalTrng\halTrng.c</PathWithFileName>
-      <FilenameWithoutPath>halTrng.c</FilenameWithoutPath>
+      <PathWithFileName>..\src\HalIFlash\halIFlash.c</PathWithFileName>
+      <FilenameWithoutPath>halIFlash.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
   </Group>
 
   <Group>
-    <GroupName>HalUart</GroupName>
+    <GroupName>HalInt</GroupName>
     <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
@@ -946,15 +946,15 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\src\Haluart\halUart.c</PathWithFileName>
-      <FilenameWithoutPath>halUart.c</FilenameWithoutPath>
+      <PathWithFileName>..\src\HalInt\halInt.c</PathWithFileName>
+      <FilenameWithoutPath>halInt.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
   </Group>
 
   <Group>
-    <GroupName>HalMag</GroupName>
+    <GroupName>HalKeyboard</GroupName>
     <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
@@ -966,15 +966,15 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\src\HalMag\HalMag.c</PathWithFileName>
-      <FilenameWithoutPath>HalMag.c</FilenameWithoutPath>
+      <PathWithFileName>..\src\HalKeyboard\halKeyboard.c</PathWithFileName>
+      <FilenameWithoutPath>halKeyboard.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
   </Group>
 
   <Group>
-    <GroupName>HalIcc</GroupName>
+    <GroupName>HalMag</GroupName>
     <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
@@ -986,15 +986,15 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\src\HalIC\HalIcc.c</PathWithFileName>
-      <FilenameWithoutPath>HalIcc.c</FilenameWithoutPath>
+      <PathWithFileName>..\src\HalMag\HalMag.c</PathWithFileName>
+      <FilenameWithoutPath>HalMag.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
   </Group>
 
   <Group>
-    <GroupName>HalBt</GroupName>
+    <GroupName>HalNfc</GroupName>
     <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
@@ -1006,15 +1006,15 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\src\HalBt\HalBt.c</PathWithFileName>
-      <FilenameWithoutPath>HalBt.c</FilenameWithoutPath>
+      <PathWithFileName>..\src\HalNfc\halNfc.c</PathWithFileName>
+      <FilenameWithoutPath>halNfc.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
   </Group>
 
   <Group>
-    <GroupName>HalEncrypt</GroupName>
+    <GroupName>HalPwm</GroupName>
     <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
@@ -1026,16 +1026,16 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\src\HalEncrypt\hal_encrypt.c</PathWithFileName>
-      <FilenameWithoutPath>hal_encrypt.c</FilenameWithoutPath>
+      <PathWithFileName>..\src\HalPwm\halPWM.c</PathWithFileName>
+      <FilenameWithoutPath>halPWM.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
   </Group>
 
   <Group>
-    <GroupName>HalNFC</GroupName>
-    <tvExp>1</tvExp>
+    <GroupName>HalRtc</GroupName>
+    <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
     <RteFlg>0</RteFlg>
@@ -1046,8 +1046,148 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\src\HalNFC\yc_nfc_hal.c</PathWithFileName>
-      <FilenameWithoutPath>yc_nfc_hal.c</FilenameWithoutPath>
+      <PathWithFileName>..\src\HalRtc\halRtc.c</PathWithFileName>
+      <FilenameWithoutPath>halRtc.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+  </Group>
+
+  <Group>
+    <GroupName>HalSecurity</GroupName>
+    <tvExp>0</tvExp>
+    <tvExpOptDlg>0</tvExpOptDlg>
+    <cbSel>0</cbSel>
+    <RteFlg>0</RteFlg>
+    <File>
+      <GroupNumber>20</GroupNumber>
+      <FileNumber>62</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\src\HalSecurity\halSecurity.c</PathWithFileName>
+      <FilenameWithoutPath>halSecurity.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+  </Group>
+
+  <Group>
+    <GroupName>HalSleep</GroupName>
+    <tvExp>0</tvExp>
+    <tvExpOptDlg>0</tvExpOptDlg>
+    <cbSel>0</cbSel>
+    <RteFlg>0</RteFlg>
+    <File>
+      <GroupNumber>21</GroupNumber>
+      <FileNumber>63</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\src\HalSleep\halSleep.c</PathWithFileName>
+      <FilenameWithoutPath>halSleep.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+  </Group>
+
+  <Group>
+    <GroupName>HalSpi</GroupName>
+    <tvExp>0</tvExp>
+    <tvExpOptDlg>0</tvExpOptDlg>
+    <cbSel>0</cbSel>
+    <RteFlg>0</RteFlg>
+    <File>
+      <GroupNumber>22</GroupNumber>
+      <FileNumber>64</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\src\HalSpi\halSpi.c</PathWithFileName>
+      <FilenameWithoutPath>halSpi.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+  </Group>
+
+  <Group>
+    <GroupName>HalTimer</GroupName>
+    <tvExp>0</tvExp>
+    <tvExpOptDlg>0</tvExpOptDlg>
+    <cbSel>0</cbSel>
+    <RteFlg>0</RteFlg>
+    <File>
+      <GroupNumber>23</GroupNumber>
+      <FileNumber>65</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\src\HalTimer\halTimer.c</PathWithFileName>
+      <FilenameWithoutPath>halTimer.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+  </Group>
+
+  <Group>
+    <GroupName>HalTrng</GroupName>
+    <tvExp>0</tvExp>
+    <tvExpOptDlg>0</tvExpOptDlg>
+    <cbSel>0</cbSel>
+    <RteFlg>0</RteFlg>
+    <File>
+      <GroupNumber>24</GroupNumber>
+      <FileNumber>66</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\src\HalTrng\halTrng.c</PathWithFileName>
+      <FilenameWithoutPath>halTrng.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+  </Group>
+
+  <Group>
+    <GroupName>HalUart</GroupName>
+    <tvExp>0</tvExp>
+    <tvExpOptDlg>0</tvExpOptDlg>
+    <cbSel>0</cbSel>
+    <RteFlg>0</RteFlg>
+    <File>
+      <GroupNumber>25</GroupNumber>
+      <FileNumber>67</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\src\HalUart\halUart.c</PathWithFileName>
+      <FilenameWithoutPath>halUart.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+  </Group>
+
+  <Group>
+    <GroupName>HalUsb</GroupName>
+    <tvExp>0</tvExp>
+    <tvExpOptDlg>0</tvExpOptDlg>
+    <cbSel>0</cbSel>
+    <RteFlg>0</RteFlg>
+    <File>
+      <GroupNumber>26</GroupNumber>
+      <FileNumber>68</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\src\HalUsb\halUsb.c</PathWithFileName>
+      <FilenameWithoutPath>halUsb.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
Index: fw/hal/jinghongling/make/YC3121_hal.uvprojx
===================================================================
--- /YC3121_SDK/fw/hal/jinghongling/make/YC3121_hal.uvprojx	(revision 732)
+++ /YC3121_SDK/fw/hal/jinghongling/make/YC3121_hal.uvprojx	(working copy)
@@ -338,7 +338,7 @@
               <MiscControls></MiscControls>
               <Define>__USEKEILCOMPILE__</Define>
               <Undefine></Undefine>
-              <IncludePath>..\inc;..\lib\Librarier\core;..\lib\Librarier\sdk;..\lib\Librarier\sdk\yc_7816;..\lib\Librarier\sdk\yc_msr;..\lib\Librarier\sdk\yc_usb;..\lib\Librarier\sdk\yc_usb\libraries;..\lib\Librarier\sdk\yc_usb\libraries\harward_Der;..\lib\Librarier\sdk\yc_usb\libraries\SCPU_USB_Device_Library;..\lib\Librarier\sdk\yc_usb\libraries\SCPU_USB_Device_Library\class;..\lib\Librarier\sdk\yc_usb\libraries\SCPU_USB_Device_Library\class\ccid;..\lib\Librarier\sdk\yc_usb\libraries\SCPU_USB_Device_Library\core;..\lib\Librarier\sdk\yc_usb\scpu_usb_ccid_Device_Demo;..\lib;..\lib\Librarier\sdk\yc_crypt;..\lib\Librarier\sdk\yc_nfc</IncludePath>
+              <IncludePath>..\inc;..\lib\Librarier\core;..\lib\Librarier\sdk;..\lib\Librarier\sdk\yc_7816;..\lib\Librarier\sdk\yc_msr;..\lib\Librarier\sdk\yc_usb;..\lib\Librarier\sdk\yc_usb\libraries;..\lib\Librarier\sdk\yc_usb\libraries\harward_Der;..\lib\Librarier\sdk\yc_usb\libraries\SCPU_USB_Device_Library;..\lib\Librarier\sdk\yc_usb\libraries\SCPU_USB_Device_Library\class;..\lib\Librarier\sdk\yc_usb\libraries\SCPU_USB_Device_Library\class\HID;..\lib\Librarier\sdk\yc_usb\libraries\SCPU_USB_Device_Library\core;..\lib\Librarier\sdk\yc_usb\scpu_usb_hid_Device_Demo;..\lib;..\lib\Librarier\sdk\yc_crypt;..\lib\Librarier\sdk\yc_nfc</IncludePath>
             </VariousControls>
           </Cads>
           <Aads>
@@ -392,17 +392,17 @@
               <FileType>1</FileType>
               <FilePath>..\lib\Librarier\core\system.c</FilePath>
             </File>
+            <File>
+              <FileName>bt_code.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\lib\Librarier\core\bt_code.c</FilePath>
+            </File>
           </Files>
         </Group>
         <Group>
           <GroupName>lib_sdk</GroupName>
           <Files>
             <File>
-              <FileName>crypt.lib</FileName>
-              <FileType>4</FileType>
-              <FilePath>..\lib\Librarier\sdk\yc_crypt\crypt.lib</FilePath>
-            </File>
-            <File>
               <FileName>usb_core.c</FileName>
               <FileType>1</FileType>
               <FilePath>..\lib\Librarier\sdk\yc_usb\libraries\harward_Der\usb_core.c</FilePath>
@@ -418,21 +418,6 @@
               <FilePath>..\lib\Librarier\sdk\yc_usb\libraries\harward_Der\Usb_dcd_init.c</FilePath>
             </File>
             <File>
-              <FileName>usbd_ccid_if.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\lib\Librarier\sdk\yc_usb\libraries\SCPU_USB_Device_Library\class\ccid\usbd_ccid_if.c</FilePath>
-            </File>
-            <File>
-              <FileName>usbd_ccid_core.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\lib\Librarier\sdk\yc_usb\libraries\SCPU_USB_Device_Library\class\ccid\usbd_ccid_core.c</FilePath>
-            </File>
-            <File>
-              <FileName>usbd_ccid_cmd.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\lib\Librarier\sdk\yc_usb\libraries\SCPU_USB_Device_Library\class\ccid\usbd_ccid_cmd.c</FilePath>
-            </File>
-            <File>
               <FileName>usbd_core.c</FileName>
               <FileType>1</FileType>
               <FilePath>..\lib\Librarier\sdk\yc_usb\libraries\SCPU_USB_Device_Library\core\usbd_core.c</FilePath>
@@ -458,16 +443,6 @@
               <FilePath>..\lib\Librarier\sdk\yc_usb\scpu_usb_ccid_Device_Demo\usbd_desc.c</FilePath>
             </File>
             <File>
-              <FileName>usb_main.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\lib\Librarier\sdk\yc_usb\scpu_usb_ccid_Device_Demo\usb_main.c</FilePath>
-            </File>
-            <File>
-              <FileName>sc_itf.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\lib\Librarier\sdk\yc_usb\scpu_usb_ccid_Device_Demo\sc_itf.c</FilePath>
-            </File>
-            <File>
               <FileName>yc_adc.c</FileName>
               <FileType>1</FileType>
               <FilePath>..\lib\Librarier\sdk\yc_adc.c</FilePath>
@@ -523,11 +498,6 @@
               <FilePath>..\lib\Librarier\sdk\yc_otp.c</FilePath>
             </File>
             <File>
-              <FileName>yc_qspi.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\lib\Librarier\sdk\yc_qspi.c</FilePath>
-            </File>
-            <File>
               <FileName>yc_rtc.c</FileName>
               <FileType>1</FileType>
               <FilePath>..\lib\Librarier\sdk\yc_rtc.c</FilePath>
@@ -578,29 +548,59 @@
               <FilePath>..\lib\Librarier\sdk\yc_wdt.c</FilePath>
             </File>
             <File>
-              <FileName>bt_code.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\lib\bt_code.c</FilePath>
-            </File>
-            <File>
               <FileName>yc_msr.lib</FileName>
               <FileType>4</FileType>
               <FilePath>..\lib\Librarier\sdk\yc_msr\yc_msr.lib</FilePath>
             </File>
             <File>
-              <FileName>yc_7816.lib</FileName>
+              <FileName>yc_nfc_common.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\lib\Librarier\sdk\yc_nfc\yc_nfc_common.c</FilePath>
+            </File>
+            <File>
+              <FileName>yc_crypt.lib</FileName>
               <FileType>4</FileType>
-              <FilePath>..\lib\Librarier\sdk\yc_7816\yc_7816.lib</FilePath>
+              <FilePath>..\lib\Librarier\sdk\yc_crypt\yc_crypt.lib</FilePath>
             </File>
             <File>
-              <FileName>yc_nfc.lib</FileName>
+              <FileName>yc_qspi.lib</FileName>
               <FileType>4</FileType>
-              <FilePath>..\lib\Librarier\sdk\yc_nfc\yc_nfc.lib</FilePath>
+              <FilePath>..\lib\Librarier\sdk\yc_qspi.lib</FilePath>
             </File>
             <File>
-              <FileName>yc_nfc_common.c</FileName>
+              <FileName>yc_emv_contactless_l1.c</FileName>
               <FileType>1</FileType>
-              <FilePath>..\lib\Librarier\sdk\yc_nfc\yc_nfc_common.c</FilePath>
+              <FilePath>..\lib\Librarier\sdk\yc_nfc\yc_emv_contactless_l1.c</FilePath>
+            </File>
+            <File>
+              <FileName>yc_7816.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\lib\Librarier\sdk\yc_7816\yc_7816.c</FilePath>
+            </File>
+            <File>
+              <FileName>yc_7816_T0.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\lib\Librarier\sdk\yc_7816\yc_7816_T0.c</FilePath>
+            </File>
+            <File>
+              <FileName>yc_7816_T1.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\lib\Librarier\sdk\yc_7816\yc_7816_T1.c</FilePath>
+            </File>
+            <File>
+              <FileName>usb_main.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\lib\Librarier\sdk\yc_usb\scpu_usb_hid_Device_Demo\usb_main.c</FilePath>
+            </File>
+            <File>
+              <FileName>yc_chrg.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\lib\Librarier\sdk\yc_chrg.c</FilePath>
+            </File>
+            <File>
+              <FileName>usbd_hid_core.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\lib\Librarier\sdk\yc_usb\libraries\SCPU_USB_Device_Library\class\HID\usbd_hid_core.c</FilePath>
             </File>
           </Files>
         </Group>
@@ -640,12 +640,93 @@
           </Files>
         </Group>
         <Group>
-          <GroupName>HalBasics</GroupName>
+          <GroupName>HalBt</GroupName>
           <Files>
             <File>
-              <FileName>halBasics.c</FileName>
+              <FileName>HalBt.c</FileName>
               <FileType>1</FileType>
-              <FilePath>..\src\HalBasics\halBasics.c</FilePath>
+              <FilePath>..\src\HalBt\HalBt.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>HalCommon</GroupName>
+          <Files>
+            <File>
+              <FileName>halCommon.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\src\HalCommon\halCommon.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>HalEncrypt</GroupName>
+          <Files>
+            <File>
+              <FileName>halEncrypt.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\src\HalEncrypt\halEncrypt.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>HalExFlash</GroupName>
+          <Files>
+            <File>
+              <FileName>halExFlash.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\src\HalExFlash\halExFlash.c</FilePath>
             </File>
           </Files>
         </Group>
@@ -660,6 +741,77 @@
           </Files>
         </Group>
         <Group>
+          <GroupName>HalI2c</GroupName>
+          <Files>
+            <File>
+              <FileName>halI2c.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\src\HalI2c\halI2c.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>HalIcc</GroupName>
+          <Files>
+            <File>
+              <FileName>HalIcc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\src\HalIcc\HalIcc.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
+            </File>
+          </Files>
+        </Group>
+        <Group>
           <GroupName>HalIFlash</GroupName>
           <Files>
             <File>
@@ -670,112 +822,336 @@
           </Files>
         </Group>
         <Group>
-          <GroupName>HalI2c</GroupName>
+          <GroupName>HalInt</GroupName>
           <Files>
             <File>
-              <FileName>halI2c.c</FileName>
+              <FileName>halInt.c</FileName>
               <FileType>1</FileType>
-              <FilePath>..\src\HalI2c\halI2c.c</FilePath>
+              <FilePath>..\src\HalInt\halInt.c</FilePath>
             </File>
           </Files>
         </Group>
         <Group>
-          <GroupName>HalPwm</GroupName>
+          <GroupName>HalKeyboard</GroupName>
           <Files>
             <File>
-              <FileName>halPwm.c</FileName>
+              <FileName>halKeyboard.c</FileName>
               <FileType>1</FileType>
-              <FilePath>..\src\HalPwm\halPwm.c</FilePath>
+              <FilePath>..\src\HalKeyboard\halKeyboard.c</FilePath>
             </File>
           </Files>
         </Group>
         <Group>
-          <GroupName>HalSpi</GroupName>
+          <GroupName>HalMag</GroupName>
           <Files>
             <File>
-              <FileName>halSpi.c</FileName>
+              <FileName>HalMag.c</FileName>
               <FileType>1</FileType>
-              <FilePath>..\src\HalSpi\halSpi.c</FilePath>
+              <FilePath>..\src\HalMag\HalMag.c</FilePath>
             </File>
           </Files>
         </Group>
         <Group>
-          <GroupName>HalTimer</GroupName>
+          <GroupName>HalNfc</GroupName>
           <Files>
             <File>
-              <FileName>halTimer.c</FileName>
+              <FileName>halNfc.c</FileName>
               <FileType>1</FileType>
-              <FilePath>..\src\HalTimer\halTimer.c</FilePath>
+              <FilePath>..\src\HalNfc\halNfc.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
             </File>
           </Files>
         </Group>
         <Group>
-          <GroupName>HalTrng</GroupName>
+          <GroupName>HalPwm</GroupName>
           <Files>
             <File>
-              <FileName>halTrng.c</FileName>
+              <FileName>halPWM.c</FileName>
               <FileType>1</FileType>
-              <FilePath>..\src\HalTrng\halTrng.c</FilePath>
+              <FilePath>..\src\HalPwm\halPWM.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>HalRtc</GroupName>
+          <Files>
+            <File>
+              <FileName>halRtc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\src\HalRtc\halRtc.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>HalSecurity</GroupName>
+          <Files>
+            <File>
+              <FileName>halSecurity.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\src\HalSecurity\halSecurity.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
             </File>
           </Files>
         </Group>
         <Group>
-          <GroupName>HalUart</GroupName>
+          <GroupName>HalSleep</GroupName>
           <Files>
             <File>
-              <FileName>halUart.c</FileName>
+              <FileName>halSleep.c</FileName>
               <FileType>1</FileType>
-              <FilePath>..\src\Haluart\halUart.c</FilePath>
+              <FilePath>..\src\HalSleep\halSleep.c</FilePath>
             </File>
           </Files>
         </Group>
         <Group>
-          <GroupName>HalMag</GroupName>
+          <GroupName>HalSpi</GroupName>
           <Files>
             <File>
-              <FileName>HalMag.c</FileName>
+              <FileName>halSpi.c</FileName>
               <FileType>1</FileType>
-              <FilePath>..\src\HalMag\HalMag.c</FilePath>
+              <FilePath>..\src\HalSpi\halSpi.c</FilePath>
             </File>
           </Files>
         </Group>
         <Group>
-          <GroupName>HalIcc</GroupName>
+          <GroupName>HalTimer</GroupName>
           <Files>
             <File>
-              <FileName>HalIcc.c</FileName>
+              <FileName>halTimer.c</FileName>
               <FileType>1</FileType>
-              <FilePath>..\src\HalIC\HalIcc.c</FilePath>
+              <FilePath>..\src\HalTimer\halTimer.c</FilePath>
+              <FileOption>
+                <CommonProperty>
+                  <UseCPPCompiler>2</UseCPPCompiler>
+                  <RVCTCodeConst>0</RVCTCodeConst>
+                  <RVCTZI>0</RVCTZI>
+                  <RVCTOtherData>0</RVCTOtherData>
+                  <ModuleSelection>0</ModuleSelection>
+                  <IncludeInBuild>0</IncludeInBuild>
+                  <AlwaysBuild>2</AlwaysBuild>
+                  <GenerateAssemblyFile>2</GenerateAssemblyFile>
+                  <AssembleAssemblyFile>2</AssembleAssemblyFile>
+                  <PublicsOnly>2</PublicsOnly>
+                  <StopOnExitCode>11</StopOnExitCode>
+                  <CustomArgument></CustomArgument>
+                  <IncludeLibraryModules></IncludeLibraryModules>
+                  <ComprImg>1</ComprImg>
+                </CommonProperty>
+                <FileArmAds>
+                  <Cads>
+                    <interw>2</interw>
+                    <Optim>0</Optim>
+                    <oTime>2</oTime>
+                    <SplitLS>2</SplitLS>
+                    <OneElfS>2</OneElfS>
+                    <Strict>2</Strict>
+                    <EnumInt>2</EnumInt>
+                    <PlainCh>2</PlainCh>
+                    <Ropi>2</Ropi>
+                    <Rwpi>2</Rwpi>
+                    <wLevel>0</wLevel>
+                    <uThumb>2</uThumb>
+                    <uSurpInc>2</uSurpInc>
+                    <uC99>2</uC99>
+                    <uGnu>2</uGnu>
+                    <useXO>2</useXO>
+                    <v6Lang>0</v6Lang>
+                    <v6LangP>0</v6LangP>
+                    <vShortEn>2</vShortEn>
+                    <vShortWch>2</vShortWch>
+                    <v6Lto>2</v6Lto>
+                    <v6WtE>2</v6WtE>
+                    <v6Rtti>2</v6Rtti>
+                    <VariousControls>
+                      <MiscControls></MiscControls>
+                      <Define></Define>
+                      <Undefine></Undefine>
+                      <IncludePath></IncludePath>
+                    </VariousControls>
+                  </Cads>
+                </FileArmAds>
+              </FileOption>
             </File>
           </Files>
         </Group>
         <Group>
-          <GroupName>HalBt</GroupName>
+          <GroupName>HalTrng</GroupName>
           <Files>
             <File>
-              <FileName>HalBt.c</FileName>
+              <FileName>halTrng.c</FileName>
               <FileType>1</FileType>
-              <FilePath>..\src\HalBt\HalBt.c</FilePath>
+              <FilePath>..\src\HalTrng\halTrng.c</FilePath>
             </File>
           </Files>
         </Group>
         <Group>
-          <GroupName>HalEncrypt</GroupName>
+          <GroupName>HalUart</GroupName>
           <Files>
             <File>
-              <FileName>hal_encrypt.c</FileName>
+              <FileName>halUart.c</FileName>
               <FileType>1</FileType>
-              <FilePath>..\src\HalEncrypt\hal_encrypt.c</FilePath>
+              <FilePath>..\src\HalUart\halUart.c</FilePath>
             </File>
           </Files>
         </Group>
         <Group>
-          <GroupName>HalNFC</GroupName>
+          <GroupName>HalUsb</GroupName>
           <Files>
             <File>
-              <FileName>yc_nfc_hal.c</FileName>
+              <FileName>halUsb.c</FileName>
               <FileType>1</FileType>
-              <FilePath>..\src\HalNFC\yc_nfc_hal.c</FilePath>
+              <FilePath>..\src\HalUsb\halUsb.c</FilePath>
             </File>
           </Files>
         </Group>
Index: fw/hal/jinghongling/src/HalAdc/halAdc.c
===================================================================
--- /YC3121_SDK/fw/hal/jinghongling/src/HalAdc/halAdc.c	(revision 732)
+++ /YC3121_SDK/fw/hal/jinghongling/src/HalAdc/halAdc.c	(working copy)
@@ -1,41 +1,272 @@
+/*******************************************************************************
+文件名: <halAdc.c>
+描  述: adc相关接口函数
+版  权:
+作  者: jqdeng
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改记录: 创建
+日期			修改人			修改内容
+2019.11.16		jqdeng				创建
+*******************************************************************************/
+
 #include "halAdc.h"
+#include "..\core\yc3121.h"
+#include "..\sdk\yc_adc.h"
+#include "yc_chrg.h"
 
+//#############################################################################
+//############################################################## 外部函数
 
+/*******************************************************************************
+函数功能: ADC初始化，当系统初始化时调用7种模型.
+输入参数:  无
+输出参数: 无
+返回值: 无
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.16    jqdeng    创建
+*******************************************************************************/
 void halAdcInit(void)
 {
 	ADC_InitTypeDef ADCInitStruct;
-	ADCInitStruct.ADC_Channel = ADC_CHANNEL_2;
-	ADCInitStruct.ADC_Mode = ADC_GPIO;
+    
+	ADCInitStruct.ADC_Channel = ADC_CHANNEL_0;
+	ADCInitStruct.ADC_Mode = ADC_HVIN;
+//    halPrintf("ADC_Channel = %d \n",ADCInitStruct.ADC_Channel);
+//    halPrintf("ADC_Mode = %d \n",ADCInitStruct.ADC_Mode);
+    halPrintf("ADC_Init\n");
 	ADC_Init(&ADCInitStruct);
 }
-u32 halAdcPhaseSelect(E_ADC_PHASE_NUM ePhase, E_ADC_CH eChn)
+
+/*******************************************************************************
+函数功能: 相位和通道mux配置.
+输入参数:
+        ePhase: 相数
+        eChn: 通道数量
+输出参数: 无
+返回值: 0
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.16    jqdeng    创建
+*******************************************************************************/
+s32 halAdcPhaseSelectt(E_ADC_PHASE_NUM ePhase, E_ADC_CH eChn)
 {
 	ADC_InitTypeDef ADCInitStruct;
 
 	ADCInitStruct.ADC_Channel = (ADC_ChxTypeDef)eChn;
 	ADCInitStruct.ADC_Mode = (ADC_ModeTypeDef)ePhase;
 	ADC_Init(&ADCInitStruct);
-	return 0;
+	return HAL_OK;
+}
+
+/*******************************************************************************
+函数功能: 启用adc dma输出。
+输入参数:
+        ucMask: Bit1 - phase0
+                Bit2 - phase1
+                Bit3 - phase2
+                Bit4 - phase30
+                Bit5 - phase31
+                Bit6 - phase32
+                Bit7 - phase33
+输出参数: 无
+返回值: 0
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.16    jqdeng    创建
+*******************************************************************************/
+s32 halAdcDmaOutEnable(u8 ucMask)
+{
+	return HAL_ERROR;
 }
 
-u32 halAdcStart(void)
+/*******************************************************************************
+函数功能: 开始ADC采样。
+输入参数: 无
+输出参数: 无
+返回值: 0
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.16    jqdeng    创建
+*******************************************************************************/
+s32 halAdcStart(void)
 {
 	ADC_ENBLE |= 1<<3;
-	return 0;
+	return HAL_OK;
 }
-int hal_AdcStop(void)
+
+/*******************************************************************************
+函数功能: 停止ADC采样。
+输入参数: 无
+输出参数: 无
+返回值: 0
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.16    jqdeng    创建
+*******************************************************************************/
+s32 halAdcStop(void)
 {
 	ADC_ENBLE &= ~(1<<3);
-	return 0;
+	return HAL_OK;
 }
 
-int halAdcReadData(E_ADC_PHASE_NUM ucPhase, u16* data)
+/*******************************************************************************
+函数功能: 读取ADC数据
+输入参数:
+        Phase: 相数
+        Data: adc数据
+输出参数: 无
+返回值: 0 success  -1 error
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.16    jqdeng    创建
+*******************************************************************************/
+s32 halAdcReadData(E_ADC_PHASE_NUM ucPhase, u16* undata)
 {
-	*data = ADC_GetResult((ADC_ChxTypeDef) ucPhase);
-	if(0 == *data)
+	*undata = ADC_GetResult((ADC_ChxTypeDef) ucPhase);
+	if(0 == *undata)
 	{
-		return FAILED;
+		return HAL_ERROR;
 	}
-	return SUCCESS;
+
+	return HAL_OK;
+}
+
+/*******************************************************************************
+函数功能: 当使用dam模型时，这个功能可以启用和禁用monit。
+输入参数:
+        Phase: 相数
+        Thrs: 阈值
+        Comp: 0 -超过阈值
+              1 -小于阈值
+输出参数: 无
+返回值: 0 success  -1 error
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.16    jqdeng    创建
+*******************************************************************************/
+s32 halAdcMonitCfg(E_ADC_PHASE_NUM ePhase, s16 unthrs, u32 uicomp, u32 uien)
+{
+    return HAL_ERROR;
+}
+
+/*******************************************************************************
+函数功能: 启动monit。当ADC值大于(或小于)阈值时，它将输出到DMA。
+输入参数: 无
+输出参数: 无
+返回值: 0 success
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.16    jqdeng    创建
+*******************************************************************************/
+s32 halAdcMonitStart(void)
+{
+    return HAL_ERROR;
+}
+
+/*******************************************************************************
+函数功能: 停止monit.
+输入参数: 无
+输出参数: 无
+返回值: 0 success
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.16    jqdeng    创建
+*******************************************************************************/
+s32 halAdcMonitStop(void)
+{
+    return HAL_ERROR;
+}
+
+/*******************************************************************************
+函数功能: 根据adc值转换成电压值
+输入参数: unVal : 当前采集到ADC值
+输出参数: 无
+返回值: 转换后的电压值
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.21    jqdeng    创建
+*******************************************************************************/
+//s32 getAdcVal(u16 unVal)
+//{
+//    return calculate_voltage(unVal, 698*1000, 658*1000, 4200, 3300);
+//}
+
+
+/*******************************************************************************
+函数功能: 获取充电状态
+输入参数: 无
+输出参数: 无
+返回值: HAL_CHARGE_FULL、HAL_CHARGE_ING、HAL_CHARGE_NULL
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.12.12    jqdeng    创建
+*******************************************************************************/
+u8 halChargeState(void)
+{
+    u8 ucState = HAL_CHARGE_NULL;
+
+    ucState = CHARGE_State();
+    switch (ucState)
+    {
+        case CHARG_CUTOFF:
+            ucState = HAL_CHARGE_FULL;
+            break;
+        case CHARG_ACTIVE:
+            ucState = HAL_CHARGE_ING;
+            break;
+        case CHARG_INACTIVE:
+            ucState = HAL_CHARGE_NULL;
+            break;
+        default:
+            ucState = HAL_CHARGE_NULL;
+            break;
+    }
+
+    return ucState;
+}
+
+
+//#############################################################################
+//############################################################## 测试函数
+
+void testAdc(void)
+{
+    s32 iRet = 0;
+    u16 unData = 0;
+    u8 i = 0;
+
+    halAdcInit();
+    halAdcPhaseSelectt(ADC_PHASE_2, ADC_CH_OFF);
+    halAdcStart();
+
+    while (1)//for (i=0; i<30; i++)
+    {
+        iRet = halAdcReadData(ADC_PHASE_2, &unData);
+        iRet = ADC_GetVoltage(ADC_CHANNEL_0);
+        halPrintf("V1: %d\n", iRet);
+        //if (HAL_OK == iRet)
+        {
+            halPrintf("adcData: %d\n", unData);
+        }
+        //else
+        {
+            //halPrintf("get adcData failed\n");
+        }
+        halMsDelay(500);
+    }
 }
 
Index: fw/hal/jinghongling/src/HalApp/main.c
===================================================================
--- /YC3121_SDK/fw/hal/jinghongling/src/HalApp/main.c	(revision 732)
+++ /YC3121_SDK/fw/hal/jinghongling/src/HalApp/main.c	(working copy)
@@ -1,509 +1,97 @@
-/* Includes ------------------------------------------------------------------*/
-#include "yc3121.h"
-#include "yc_gpio.h"
-#include "yc_uart.h"
 #include "halCommon.h"
-#include "halIFlash.h"
-#include "HalGpio.h"
-#include "yc_systick.h"
-#include "halPwm.h"
 #include "halUart.h"
-#include "HalBasics.h"
-#include "yc_lcd.h"
-#include "HalTrng.h"
-#include "yc_exti.h"
-#include "HalIcc.h"
-#include "yc_msr.h"
-#include "yc_ipc.h"
-#include "yc_crc16.h"
-#include "yc_lpm.h"
-#include "HalBt.h"
-#include "yc_bt.h"
-#include "halAdc.h"
-#include "yc_DTM.h"
-#include "yc_ssc.h"
-//#include "yc_nfc_common.h"
-#include "yc_emv_contactless_l1.h"
-uint8_t BT_Wake = 0;
-extern 	int test_halmag(void);
-uint8_t BtDataBuff[MAX_BLUETOOTH_DATA_LEN+1] = {0x00};
-void UART_Configuration(void)
-{
-	UART_InitTypeDef UART_InitStruct;
-
-	/* Configure serial ports 0 RX and TX for IO. */
-	GPIO_Config(GPIOA, GPIO_Pin_1, GPCFG_UART0_TXD);
-	GPIO_Config(GPIOA, GPIO_Pin_0, GPCFG_UART0_RXD);
-
-	/* USARTx configured as follow:
-  - BaudRate = 115200 baud  
-  - Word Length = 8 Bits
-  - Stop Bit = 1 Stop Bit
-  - Parity = No Parity
-  - Hardware flow control disabled (RTS and CTS signals)
-  - Receive and transmit enabled
-  */
-	UART_InitStruct.BaudRate = 115200;			//Configure serial port baud rate, the baud rate defaults to 128000.
-	UART_InitStruct.DataBits = Databits_8b;
-	UART_InitStruct.StopBits = StopBits_1;
-	UART_InitStruct.Parity = Parity_None;
-	UART_InitStruct.FlowCtrl = FlowCtrl_None;
-	UART_InitStruct.Mode = Mode_duplex;
-	
-	UART_Init(UART0, &UART_InitStruct);
-}
-
-int i=0;
-
-void printfBUF(u8 *buf, int len)
-{
-	for(int i=0;i<len; i++)
-		MyPrintf("%d ",buf[i]);
-	MyPrintf("\n");
-}
-
-#define wflen 32
-void test_iflash()
-{
-	int iRet = 0;
-	u8 ucWtBuff[wflen] = {0};
-	u32 uiAddr = 0xf6ee;//0x00010000-10;
-	int i = 6;
-	//halIFlashInit();
-	//halIflashErase(uiAddr);
-
-	{
-	halIflash_read(uiAddr, ucWtBuff,  wflen);
-	MyPrintf("before wirte flash data:"); printfBUF(ucWtBuff, wflen);MyPrintf("\n");
-		
-	memset(ucWtBuff,i++, wflen);
-	
-	MyPrintf(" wirte flash data:");  printfBUF(ucWtBuff, wflen);MyPrintf("\n");
-	halIflash_write(uiAddr,ucWtBuff, wflen);
-	
-	halIflash_read(uiAddr, ucWtBuff,  wflen);
-	MyPrintf("after wirted flash:"); printfBUF(ucWtBuff, wflen);MyPrintf("\n");
-	}
-}
-
-
-void systick_test(void)
-{
-	SysTick_Config(CPU_MHZ/1000);
-}
-
-extern uint32_t SystickCount;
-
-
-void SYSTICK_IRQHandler()
-{
-	SystickCount++;
-
-}
-void hal_pwm_test()
-{
-	GPIO_Config(GPIOB, GPIO_Pin_0, GPCFG_PWM_OUT0);
-	
-	halPwmInit();
-	halPwmConfig(PWM0,10,30,1);
-
-	while(1)
-	{
-		halPwmSwitch(PWM0,ENABLE);
-		halGpioWritePin(GPIOB,GPIO_Pin_1,1);
-		halMsDelay(1500);
-		halPwmSwitch(PWM0,DISABLE);
-		halGpioWritePin(GPIOB,GPIO_Pin_1,0);
-		halMsDelay(1500);
-	}
-}
-
-
-
-
-void gpio_init()
-{
-	halGpioRegIsr(GPIOB,GPIO_Pin_0, HAL_INT_LOW,NULL);
-
-	enable_intr(INTR_GPIO);
-}
-void mysoftdelay()
-{
-	int time = CPU_MHZ/1000;
-	while(time--);
-}
-
-void printfAssic(u8* buf,int len)
-{
-	for(int i=0; i<len; i++)
-	{
-		MyPrintf("%02x ",buf[i]);
-	}
-	MyPrintf("\n");
-}
-void hal_trng_test()
-{
-	u8 buf[20] = {0};
-	hal_RandomInint();
-
-	while(1)
-	{
-		mysoftdelay();
-		TRNG_Get((volatile unsigned long*)buf);
-		printfAssic(buf,16);
-	}
-}
-
-
-
-void CRC16test()
-{
-    enable_clock(CLKCLS_CRC);
-    uint8_t data[5] = {0x01,0x02,0x03,0x04,0x05};
-     uint16_t result = crc16_calc( 0, 0, data,  5);
-    MyPrintf("crcvalue:%d\n",result);
-	disable_intr(CLKCLS_CRC);
-}
-
-
-
-void lpm_test(void)
-{
-	Chip_Speedstep();
-}
-void BT_IRQHandler()
-{
-	if(BT_Wake == 1)
-	{
-		while(IPC_have_data())
-		{
-			BT_ParseBTData();
-		}
-	}
-	else
-	{
-		BT_Wake = 1;
-	}
-	BT_CONFIG &= (~(1<<BT_INIT_FLAG));
-}
-
-void test_enter_lpm(void);
-void IFlash_test(void);
-void _IFlash_test(void);
+#include "halGpio.h"
+#include "yc_systick.h"
+#include "yc3121.h"
 
+#include "yc_gpio.h"
+#include "yc_sysctrl.h"
 
-void tst_rf_frequency(void)
+#if 0
+void check_power_key()
 {
-	//halBtRfCtrl(HAL_ON);
-	//halBtRfSet(2416);
-	DTMTestInit();
-	ModifyDtmFreq(2416);
-	while(1);
-}
-
+    if (SYSCTRL_STATUS & (1 << 31)) // Chgr wakeup
+    {
+        tick start_time = SysTick_GetTick();
 
+        while ((SYSCTRL_STATUS & (1<<31)) && (!SysTick_IsTimeOut(start_time,2000)));
 
-void nfc_test()
-{
-
+        if (SYSCTRL_STATUS & (1<<31))
+        {
+            MyPrintf("power off\n");
 
+            uint32_t power_value = lpm_bt_read(0);
+            MyPrintf("power_value1 = %08x\n", power_value);
 
+            power_value &= ~((uint32_t)(1<<18));
+            MyPrintf("power_value2 = %08x\n", power_value);
 
+            lpm_bt_write(0, power_value);
 
+            while(1)
+            {
+                delay_ms(500);
+                MyPrintf("wait power off\n");
+            }
+        }
+    }
 }
+#endif
 
-
-void adc_hvin_voltage()
+#if 1
+void printf_uart_init(UART_TypeDef UARTx)
 {
-	int result = 0;
-	
-	ADC_InitTypeDef ADC_InitStruct;
-	ADC_InitStruct.ADC_Channel = ADC_CHANNEL_0;
-	ADC_InitStruct.ADC_Mode = ADC_HVIN;
-	
-	ADC_Init(&ADC_InitStruct);
-	
+	UART_InitTypeDef UART_InitStruct;
 	
-	while(1)
-	{
-		result = ADC_GetResult(ADC_CHANNEL_0);
-		MyPrintf("get result adc:%d \n",result);
-		
-		delay_ms(1000);
-	}
+	GPIO_Config(GPIOA,GPIO_Pin_0,UART0_RXD);
+	GPIO_Config(GPIOA,GPIO_Pin_1,UART0_TXD);
 	
-}
-
-
-
-
-
-void test_enter_lpm(void)
-{
-	lpm_test();
-	CM0_Sleep( 0, GPIOB ,  GPIO_Pin_0,  1,  1);
-	Disable_Trng();
-//	for(int i=0;i<48;i++)
-	GPIO_CONFIG(0) = 62;
-	GPIO_CONFIG(42) = 62;
-	GPIO_CONFIG(4) = 62;
-	GPIO_CONFIG(33) = 62;	
-	GPIO_CONFIG(10) = 128;	
-	GPIO_CONFIG(5) = 128;	
-}
+	UART_InitStruct.BaudRate = 921600;
+	UART_InitStruct.DataBits = Databits_8b;
+	UART_InitStruct.FlowCtrl = FlowCtrl_None ;
+	UART_InitStruct.Mode = Mode_duplex;
+	UART_InitStruct.StopBits = StopBits_1;
+	UART_InitStruct.Parity = Parity_None;
 
-#define iFlash_ADDR (0x020000)
-#define iFLash_LEN 	0x100
-void test_enc_write_flash_32K(uint32_t base_addr)
-{
-	uint8_t wbuf[256] ={0};
-	uint8_t rbuf[256] ={0};
-	uint32_t i = 0, j = 0;
-	uint32_t addr = 0;
-	
-	enc_erase_flash_32k(base_addr);
 	
-	for (j = 0; j < 32*1024; j += 256)
-	{
-		addr = base_addr + j;
-		
-		for (i = 0; i < 256; i++)
-		{
-			wbuf[i] = i;
-		}
-		
-		enc_write_flash(addr, wbuf, 256);
-	
-		enc_read_flash(addr, rbuf, 256);
-		
-		for(i=0;i<256;i++)
-		{
-			if(rbuf[i] != wbuf[i])
-			{
-				MyPrintf("\n test error rbuf[%d]=%x wbuf[%d]=%x",i,rbuf[i],i,wbuf[i]);
-			}
-		}
-	}	
+  	UART_Init(UARTx, &UART_InitStruct);
 }
 
-void _IFlash_test(void)
+int main(void)
 {
-	//if (flash_blank_check( iFlash_ADDR, iFLash_LEN ) == 0)
-	if( flash_blank_check(iFlash_ADDR&0xffffff, (iFlash_ADDR+0x20)&0xffffff)  == 0)
-	{
-		MyPrintf("iFlash_ADR_0x%0x LEN:%d,is not empty\n",iFlash_ADDR, iFLash_LEN);
-	}
-	else
-	{
-		MyPrintf("iFlash_ADR_0x%0x LEN:%d,is  empty\n",iFlash_ADDR, iFLash_LEN);
-	}
-}
-
-
-
-void IFlash_test(void)
-{
-	uint8_t flash_buf[iFLash_LEN]= {0};
-	uint8_t flash_bufREAD[iFLash_LEN]= {0};
-
+    u32 i = 0;
 
-	for(int i=0; i<iFLash_LEN; i++)
-	{
-			flash_buf[i] = i%256;
-	}
-		
-	MyPrintf("iflash_test\n");
-	
-	
-	if (flash_blank_check( iFlash_ADDR, iFLash_LEN ) )
-	{
-		MyPrintf("iFlash_ADR_0x%0x LEN:%d,is  empty\n",iFlash_ADDR, iFLash_LEN);
-	}
-	else
-	{
-		//qspi_flash_sectorerase( iFlash_ADDR);
-		enc_erase_flash_32k(iFlash_ADDR);
-		
-		enc_read_flash(iFlash_ADDR, flash_bufREAD, iFLash_LEN);
-		MyPrintf("before write flash data is:");
-
-		for(int i =0; i<iFLash_LEN; i++)
-		{
-			MyPrintf("%d ", flash_bufREAD[i]);
-		}
-		MyPrintf("\n");
-		
-	//	MyPrintf("iFlash_ADR_0x%0x LEN:%d,is  empty\n",iFlash_ADDR, iFLash_LEN);
-		enc_write_flash(iFlash_ADDR, flash_buf, iFLash_LEN);
-		delay(10000);
-		enc_read_flash(iFlash_ADDR, flash_bufREAD, iFLash_LEN);
-		
-		MyPrintf("flash_buf write :");
-		
-		
-		for(int i=0; i<iFLash_LEN; i++)
-		{
-			MyPrintf("%d ", flash_buf[i]);
-		}
-		
-		
-		MyPrintf("\n");
-		MyPrintf("flash_bufREAD :");
-		for(int i =0; i<iFLash_LEN; i++)
-		{
-			MyPrintf("%d ", flash_bufREAD[i]);
-		}
-		MyPrintf("\n");
-	}
+	halSysClkInit();//1ms
+	SYSCTRL_AHBPeriphClockCmd(SYSCTRL_AHBPeriph_UART,ENABLE);
+	printf_uart_init(UART0);
+	//testUart();
+  //halUsbInit(0);
+
+	while (1)
+	{
+		MyPrintf("-------< YC3121_HAL_V0.028>------ \n");
+		MyPrintf("\r\nData:%s-%s",__DATE__,__TIME__);
+		delay_ms(500);
+	}
+	//while (1)
+	//check_power_key();
+
+    //testCommon();
+    //testTrng();
+    //testIFlash();
+    //testPwm();
+    //testSpi();
+    //testEncrypt();
+    //testGpio();
+    //testMag();
+    //testAdc();
+    //testNfc();
+    //testSecurity_jhl();
+    //testICC();
+    //kbInit();
+	//testBt_jhl();
+    //testSleep();
+    //testUsb();
+    while (1);
 }
-
-
-s32 halSecurityInit(void)
-{
-    TAMPER_InitTypeDef TEMPER_InitStruct;
-
-    SSC_Interval(INTERVAL_999MS);
-    SSC_LPMSheildingAlarmEnable(ENABLE);
-    SSC_ClearKeyCMD(ENABLE);
-
-    SSC_SensorDur(SENSOR_DUR_8MS);
-    SSC_SensorDelay(SENEOR_DELAY_1_MS);
-
-#ifdef SEC_CFG_VOLTAGE
-    SSC_LPMSensorCmd(LPM_BAT_VDT12L_ENABLE, ENABLE);
-	SSC_LPMSensorCmd(LPM_BAT_VDT33H_ENABLE, ENABLE);
-	SSC_LPMSensorCmd(LPM_BAT_VDT33L_ENABLE, ENABLE);
-#endif
-
-#ifdef SEC_CFG_TEMPERATURE
-	SSC_LPMSensorCmd(LPM_TEMPERATURE_40_ENABLE, ENABLE);
-	SSC_LPMSensorCmd(LPM_TEMPERATURE_120_ENABLE, ENABLE);
-#endif
-
-	TEMPER_InitStruct.TAMPER_GlitchTimes   = TAMPER_GlitchTimes_4ms;
-	TEMPER_InitStruct.TAMPER_PUPU_HoldTime = TAMPER_PUPU_HoldTime_2ms;
-	TEMPER_InitStruct.TAMPER_Port_PullUp   = 0;
-#ifdef SEC_CFG_SD_DYNAMIC_01
-    //MyPrintf("\r\nhal security start!\n");
-	TEMPER_InitStruct.TAMPER_Port_mode   = TAMPER_Port_S01_active;
-	TEMPER_InitStruct.TAMPER_Port_Enable = TAMPER_Port_S01;
-	SSC_TemperInit(&TEMPER_InitStruct);
-	//MyPrintf("\r\nhal security start!\n");
-#endif
-
-#ifdef SEC_CFG_SD_DYNAMIC_23
-    TEMPER_InitStruct.TAMPER_Port_mode   = TAMPER_Port_S23_active;
-	TEMPER_InitStruct.TAMPER_Port_Enable = TAMPER_Port_S23;
-	SSC_TemperInit(&TEMPER_InitStruct);
-#endif
-
-#ifdef SEC_CFG_SD_DYNAMIC_45
-    TEMPER_InitStruct.TAMPER_Port_mode   = TAMPER_Port_S45_active;
-	TEMPER_InitStruct.TAMPER_Port_Enable = TAMPER_Port_S45;
-	SSC_TemperInit(&TEMPER_InitStruct);
 #endif
-
-#ifdef SEC_CFG_SD_DYNAMIC_67
-    TEMPER_InitStruct.TAMPER_Port_mode   = TAMPER_Port_S67_active;
-	TEMPER_InitStruct.TAMPER_Port_Enable = TAMPER_Port_S67;
-	SSC_TemperInit(&TEMPER_InitStruct);
-#endif
-
-  return HAL_OK;
-}
-
-
-//#define ICE_MOD
-int main__(void)
-{
-	
-
-	UART_Configuration();
-//	u8 pucBuf[256] = {0};
-//	MyPrintf("pwoer on\n");
-//	{MyPrintf("222");}
-	MyPrintf("yc3121 dev start \r\n");
-//	int recvlen = 0;
-#ifdef ICE_MOD
-	GPIO_CONFIG(33) = 0;
-	GPIO_CONFIG(1) = GPCFG_ICE;
-	while(1);
-#endif	
-	
-	
-	SSC_LPMSensorCmd(LPM_TEMPERATURE_40_ENABLE, ENABLE);
-	SSC_LPMSensorCmd( LPM_TEMPERATURE_120_ENABLE, ENABLE);
-	MyPrintf("sensor normal\n");
-	//adc_hvin_voltage();
-	//UART_SetITTimeout(UART0,1000);
-	//lpm_sleep();
-	//SYSCTRL_EnterSleep(SleepMode_STOP);
-	//while(1){MyPrintf("111");}
-	//hal_trng_test();
-	//gpio_init();
-	//ICCard_test();
-	//test_fun();
-	//systick_test();
-//	int result = calculate_voltage(0x54a>>1,0x2bd*1000,0x294*1000,4200,3300);
-//	MyPrintf("result1:%d",result);
-//	
-//	 result = calculate_voltage(0x54a>>1,0x2bd*1000,0x293*1000,4200,3300);
-//	MyPrintf("result2%d",result);
-//	
-//		 result = calculate_voltage(0x548>>1,0x2bb*1000,0x294*1000,4200,3300);
-//	MyPrintf("result3%d",result);
-	
-	HalBtOpen();	
-	MyPrintf("bt init suc\n");
-	//halAdcPhaseSelect(ADC_PHASE_2, ADC_CH_OFF);
-	MyPrintf("adc init suc\n");
-	while(1)
-	{
-		MyPrintf("adcresult:%d\n",ADC_GetResult(0));
-		delay_ms(1000);
-	}
-	
-	//_IFlash_test();
-	//IFlash_test();
-	//IFlash_test();
-//	while(1);
-//	HalBtOpen();
-//	delay(1000000);
-//	MyPrintf("run to here\n");
-//	test_iflash();
-	//CRC16test();
-//	//test_iflash();
-//	MyPrintf("delay");
-//	halMsDelay(200);
-//	MyPrintf("delay");
-//	hal_pwm_test();	
-//	ISO7816_LoopBack();
-
-		//ICCard_test();
-
-		//HalICCTest();			
-
-
-	//halGpioWritePin(GPIOB,GPIO_Pin_0,0);
-	//IICCard_test();
-	while(1)
-	{
-		//	UART_SetITTimeout(UART0,1000);
-
-	//	test_card_inset();
-		if(UART_IsRXFIFONotEmpty(UART0))
-		{
-			test_enter_lpm();
-			//UART_SendBuf(UART0,pucBuf,1);
-			//	HalICCTest();	
-			//halGpioWritePin(GPIOB,GPIO_Pin_0,1);
-			//Systick_Dealy_Ms(500);
-			//halGpioWritePin(GPIOB,GPIO_Pin_0,0);
-			//recvlen = UART_RecvBuf(UART0 ,  pucBuf, 10);
-			//recvlen = halUartRecv(UART_PT0 ,  pucBuf, 10);
-			//MyPrintf("received len:%d \n",recvlen);
-			//UART_SendBuf(UART0,pucBuf,recvlen);
-		}
-	}
-
-}
\ No newline at end of file
Index: fw/hal/jinghongling/src/HalBt/HalBt.c
===================================================================
--- /YC3121_SDK/fw/hal/jinghongling/src/HalBt/HalBt.c	(revision 732)
+++ /YC3121_SDK/fw/hal/jinghongling/src/HalBt/HalBt.c	(working copy)
@@ -1,16 +1,277 @@
+/*******************************************************************************
+文件名: halBt.c
+描  述: 蓝牙模块接口函数
+版  权: 1.0
+作  者: jqdeng
+--------------------------------------------------------------------------------
+备注  : 公用函数
+--------------------------------------------------------------------------------
+修改记录:
+日期		版本	修改人		修改内容
+2019/11/28	1.0		jqdeng	    创建
+*******************************************************************************/
 #include "HalBt.h"
 #include "yc_bt.h"
-#include "yc_dtm.h"
+#include "..\core\yc3121.h"
+#include "halIFlash.h"
 
-extern uint8_t BT_Wake;
-s32 HalBtOpen(void)
+#define HAL_MAX_NAME_LENGTH	    29
+#define HAL_MAX_PIN_LENGTH		16
+
+#define BIT_BLE_CONNECT			5
+#define BIT_BT_SPP_CONNECT		4
+
+#define HAL_MAX_SPP_DATA_LENGTH	210
+#define HAL_MAX_BLE_DATA_LENGTH	180
+#define HAL_BLE_DATA_HANDLE		0x2A
+
+u8 BT_Wake = 0;
+u8 BtDataBuff[MAX_BLUETOOTH_DATA_LEN+1] = {0x00};
+
+static T_BT_CALL_BACK_FUNC tBtCallBackFunc; // 定义函数指针结构体
+
+
+/*******************************************************************************
+函数功能: 蓝牙回调函数结构体初始化
+输入参数: ptBtCallBackFunc : 蓝牙回调函数结构体首地址
+输出参数: 无
+返回值: 无
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.12.17    jqdeng    创建
+*******************************************************************************/
+static void btCallBackFuncStructInit(T_BT_CALL_BACK_FUNC *ptBtCallBackFunc)
+{
+    ptBtCallBackFunc->pfnBtPairingDataGet = NULL;
+    ptBtCallBackFunc->pfnBtPairingDataSet = NULL;
+}
+
+
+/*******************************************************************************
+函数功能: 蓝牙事件处理
+输入参数: 无
+输出参数: 无
+返回值: 无
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.28    jqdeng    创建
+*******************************************************************************/
+void BT_Progress(void)
 {
-	if(BT_Wake==0)
+	switch(BT_GetEventOpcode())
+	{
+		case BT_DATA:
+		case BLE_DATA:
+			{
+				if(BtDataBuff[0] == 0)
+				{
+					BtDataBuff[0] = BT_ReadBTData(BtDataBuff+1);
+				}
+			}
+    		break;
+
+		case BT_CONNECTED:
+			MyPrintf("bt connected\n");
+    		break;
+
+		case BLE_CONNECTED:
+			MyPrintf("ble connected\n");
+    		break;
+
+		case BT_DISCONNECTED:
+			MyPrintf("bt disconnected\n");
+    		break;
+
+		case BLE_DISCONNECTED:
+			MyPrintf("ble disconnected\n");
+    		break;
+
+		case NVRAM_DATA:
+			{
+				uint8_t NvramData[MAX_BLUETOOTH_DATA_LEN];
+				int NvramDataLen=0;
+				NvramDataLen=BT_ReadBTData(NvramData);
+				if(NvramDataLen>0)
+				{
+                #ifdef BT_NO_DISPLAY_PINCODE
+                    if (HAL_OK == btSaveNvramDataInFlash(NvramData, NvramDataLen))
+                    {
+                        halPrintf("--btSaveNvramDataInFlash succ\n");
+                    }
+                    else
+                    {
+                        halPrintf("--btSaveNvramDataInFlash failed\n");
+                    }
+                #endif
+
+					MyPrintf("receive %dbytes Nvramdata:",NvramDataLen);
+					for(int i=0;i<NvramDataLen;i++)
+					{
+						MyPrintf("%02X ",NvramData[i]);
+					}
+					MyPrintf("\n");
+				}
+				else	MyPrintf("read Nvram data error");
+			}
+    		break;
+
+		case CONFIRM_GKEY:
+			{
+				uint8_t GkeyData[MAX_BLUETOOTH_DATA_LEN];
+				int GkeyDataLen=0;
+				GkeyDataLen=BT_ReadBTData(GkeyData);
+				if(GkeyDataLen>0)
+				{
+					MyPrintf("receive %dbytes Nvramdata:",GkeyDataLen);
+					for(int i=0;i<GkeyDataLen;i++)
+					{
+						MyPrintf("%02X ",GkeyData[i]);
+					}
+					MyPrintf("\n");
+				}
+				else	MyPrintf("read Nvram data error");
+			}
+    		break;
+
+		case PASSKEY:
+			MyPrintf("request Passkey");
+    		break;
+
+		case PAIRING_COMPLETED:
+			{
+				uint8_t PairingData[MAX_BLUETOOTH_DATA_LEN];
+				int PairingDataLen=0;
+				PairingDataLen=BT_ReadBTData(PairingData);
+				if(PairingDataLen>0)
+				{
+					MyPrintf("receive %dbytes Nvramdata:",PairingDataLen);
+					for(int i=0;i<PairingDataLen;i++)
+					{
+						MyPrintf("%02X ",PairingData[i]);
+					}
+					MyPrintf("\n");
+				}
+				else	MyPrintf("read Nvram data error");
+			}
+    		break;
+
+		default:
+    		break;
+	}
+}
+
+
+/*******************************************************************************
+函数功能: 保存配对信息到flash
+输入参数: pucNvram : 要保存的蓝牙NvramData
+          unLen : 要保存的蓝牙NvramData数据长度
+输出参数: 无
+返回值: HAL_OK
+        HAL_ERROR
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.29    jqdeng    创建
+*******************************************************************************/
+s32 btSaveNvramDataInFlash(u8 *pucNvram, u16 unLen)
+{
+    u8 ucTempBuff[NDLen] = {0};
+    u8 ucCnt = 0;
+
+    if (unLen > NDLen)
+    {
+        return HAL_ERROR;
+    }
+
+#if 1
+    if (NULL != tBtCallBackFunc.pfnBtPairingDataSet)
+    {
+        tBtCallBackFunc.pfnBtPairingDataSet(pucNvram, unLen);
+    }
+#else
+    ucCnt = 3;
+    do
+    {
+        halIFlashRead(BT_NVRAM_DATA_ADDR, ucTempBuff, unLen);
+        if (memcmp(ucTempBuff, pucNvram, unLen) == 0)
+        {
+            break;
+        }
+        halIFlashWrite(BT_NVRAM_DATA_ADDR, pucNvram, unLen);
+        ucCnt--;
+    } while(ucCnt);
+
+    if (0 == ucCnt)
+    {
+        return HAL_ERROR;
+    }
+#endif
+    return HAL_OK;
+}
+
+/*******************************************************************************
+函数功能: 从flash读取配对数据
+输入参数: unLen : 获取的蓝牙NvramData数据长度
+输出参数: pucNvram : 获取的蓝牙NvramData
+返回值: HAL_OK
+        HAL_ERROR
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.29    jqdeng    创建
+*******************************************************************************/
+s32 btGetNvramDataFromFlash(u8 *pucNvram, u16 unLen)
+{
+#if 1
+    if (NULL != tBtCallBackFunc.pfnBtPairingDataGet)
+    {
+        tBtCallBackFunc.pfnBtPairingDataGet(pucNvram, unLen);
+    }
+#else
+    halIFlashRead(BT_NVRAM_DATA_ADDR, pucNvram, unLen);
+#endif
+
+    return HAL_OK;
+}
+
+
+/*******************************************************************************
+函数功能: 启动蓝牙模块
+输入参数: 无
+输出参数: 无
+返回值: HAL_OK
+        HAL_ERROR
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.28    jqdeng    创建
+*******************************************************************************/
+s32 halBtOpen(void)
+{
+	if (BT_Wake == 0)
+	{
+        btCallBackFuncStructInit(&tBtCallBackFunc);
 		BT_Init();
+        enable_intr(BT_IRQn);
+    }
+
 	return HAL_OK;
 }
 
-s32 HalBtClose(void)
+/*******************************************************************************
+函数功能: 关闭蓝牙模块
+输入参数: 无
+输出参数: 无
+返回值: HAL_OK
+        HAL_ERROR
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.28    jqdeng    创建
+*******************************************************************************/
+s32 halBtClose(void)
 {
 	if(BT_Wake)
 	{
@@ -20,15 +281,25 @@
 	return HAL_OK;
 }
 
-
-s32 HalBtSet (s8 *cdevName, s8 *cPin)
+/*******************************************************************************
+函数功能: 设置设备名字和密码
+输入参数: pcdevName : 要设置的设备名(ASC码，以0x00结束）
+输出参数: pcPin : 要设置的设备密码(ASC码，以0x00结束）
+返回值: HAL_OK
+        HAL_ERROR
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.28    jqdeng    创建
+*******************************************************************************/
+s32 halBtSetNamePin(s8 *pcdevName, s8 *pcPin)
 {
-#define HAL_MAX_NAME_LENGTH	29
-#define HAL_MAX_PIN_LENGTH		16
 	u8 cdevNameLen=0,cPinLen = 0;
 	s8 *TempPoint;
+
 	MyPrintf("name length is %d\nPin length is %d\n",cdevNameLen,cPinLen);
-	TempPoint=cdevName;
+
+	TempPoint=pcdevName;
 	while(*TempPoint != 00)
 	{
 		cdevNameLen++;
@@ -36,7 +307,8 @@
 		if(cdevNameLen >HAL_MAX_NAME_LENGTH)
 			return HAL_ERROR;
 	}
-	TempPoint=cPin;
+
+	TempPoint=pcPin;
 	while(*TempPoint != 00)
 	{
 		cPinLen++;
@@ -44,73 +316,158 @@
 		if(cPinLen >HAL_MAX_PIN_LENGTH)
 			return HAL_ERROR;
 	}
+
 	MyPrintf("name length is %d\nPin length is %d\n",cdevNameLen,cPinLen);
-	if(BT_SetBleName(cdevName,cdevNameLen)==FALSE) 
+
+	if(BT_SetBleName((u8*)pcdevName,cdevNameLen)==FALSE)
 		return HAL_ERROR;
-	MyPrintf("SetBleName_suc ble name:%s\n",cdevName);
-	if(BT_SetBtName(cdevName,cdevNameLen)==FALSE)
+
+	MyPrintf("SetBleName_suc ble name:%s\n",pcdevName);
+
+	if(BT_SetBtName((u8*)pcdevName,cdevNameLen)==FALSE)
 		return HAL_ERROR;
-	MyPrintf("SetBtName_suc ble name:%s\n",cdevName);
+
+	MyPrintf("SetBtName_suc bt name:%s\n",pcdevName);
+
 	if(BT_SetParingMode(0)==FALSE)
 		return HAL_ERROR;
+
 	MyPrintf("SetPairingMode_succ,Mode is pincode\n");
-	if(BT_SetPincode(cPin, cPinLen) == FALSE)
+
+	if(BT_SetPincode((u8 *)pcPin, cPinLen) == FALSE)
 		return HAL_ERROR;
-	MyPrintf("SetPincode_succ Pin :%s\n", cPin);
+
+	MyPrintf("SetPincode_succ Pin :%s\n", pcPin);
+
 	if(BT_SetVisibility(TRUE,TRUE,TRUE)==FALSE)
 		return HAL_ERROR;
-	MyPrintf("SetVisibility_succ\n");
+
+    MyPrintf("SetVisibility_succ\n");
+
+#ifdef BT_NO_DISPLAY_PINCODE
+	u8 ucNvramData[256] = {0};
+    if (HAL_OK == btGetNvramDataFromFlash(ucNvramData, NDLen)) // 设置NVRAM DATA (去配对框)
+    {
+        BT_SetNVRAM(ucNvramData);
+        halPrintf("BT_SetNVRAM succ\n");
+        halPrintfWithTitle(ucNvramData, NDLen, "ucNvramData");
+    }
+#endif
 	return HAL_OK;
-	
+
 }
 
-s32 HalBtSetMac(u8 *pucMac)
+/*******************************************************************************
+函数功能: 设置蓝牙MAC
+输入参数: 要设置的MAC (hex，固定6字节长）
+输出参数: 无
+返回值: HAL_OK
+        HAL_ERROR
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.28    jqdeng    创建
+*******************************************************************************/
+s32 halBtSetMac(u8 *pucMac)
 {
 	if(BT_SetBtAddr(pucMac) == FALSE)
 		return HAL_ERROR;
 	if(BT_SetBleAddr(pucMac) == FALSE)
-		return HAL_ERROR;	
+		return HAL_ERROR;
+
 	MyPrintf("Set Mac is ");
 	for(s8 index=0; index<6; index++)
 	{
-		MyPrintf("%02x ",*(pucMac+6-index));
+		MyPrintf("%02x ",*(pucMac+index));
 	}
 	MyPrintf("\n");
-	return HAL_OK;
 
+	return HAL_OK;
 }
 
-#define BIT_BLE_CONNECT			5
-#define BIT_BT_SPP_CONNECT		4
+/*******************************************************************************
+函数功能: 获取蓝牙MAC
+输入参数: 获取的MAC (hex，固定6字节长）
+输出参数: 无
+返回值: HAL_OK
+        HAL_ERROR
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.28    jqdeng    创建
+*******************************************************************************/
+s32 halBtGetMac(u8 *pucMac)
+{
+    return HAL_ERROR;
+}
 
-s32 HalBtGetStatus(u8 *pucStatus)
+/*******************************************************************************
+函数功能: 得到当前蓝牙当前状态
+输入参数: 无
+输出参数: pucStatus : 0x00断开,0x01连接
+返回值: HAL_OK
+        HAL_ERROR
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.28    jqdeng    创建
+*******************************************************************************/
+s32 halBtGetStatus(u8 *pucStatus)
 {
 	s8 BtStatus = Bt_GetBtStatus();
 	if(BtStatus == 0x80)
 	{
-		MyPrintf("Get Bt Status error\n");
+		//MyPrintf("Get Bt Status error\n");
 		return HAL_ERROR;
 	}
 	else if(BtStatus & (1<<BIT_BLE_CONNECT))
 	{
-		MyPrintf("BLE Connect\n");
+		//MyPrintf("BLE Connect\n");
 		*pucStatus = 0x01;
 	}
 	else if(BtStatus & (1<<BIT_BT_SPP_CONNECT))
 	{
-		MyPrintf("SPP Connect\n");
+		//MyPrintf("SPP Connect\n");
 		*pucStatus = 0x01;
 	}
 	else
 	{
-		MyPrintf("No Bluetooth Connect\n");
+		//MyPrintf("No Bluetooth Connect\n");
 		*pucStatus = 0x00;
 	}
 	return HAL_OK;
-	
+
+}
+/*******************************************************************************
+函数功能: 得到当前蓝牙序列号
+输入参数: 无
+输出参数: pucSN : 蓝牙序列号(ASC码，以0x00结束）
+返回值: HAL_OK
+        HAL_ERROR
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.28    jqdeng    创建
+*******************************************************************************/
+s32 halBtGetSN(u8 *pucSN)
+{
+    // 读主芯片号 (yc3121芯片ID为6字节)
+    halGetMcuID(pucSN);
+    return HAL_OK;
 }
 
-s32 HalBtDisconnect(void)
+/*******************************************************************************
+函数功能: 断开链接
+输入参数: 无
+输出参数: 无
+返回值: HAL_OK
+        HAL_ERROR
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.28    jqdeng    创建
+*******************************************************************************/
+s32 halBtDisconnect(void)
 {
 	s8 BtStatus = Bt_GetBtStatus();
 	if(BtStatus == 0x80)
@@ -123,14 +480,14 @@
 		MyPrintf("BLE Connect\n");
 		if(BT_BleDisconnect()==FALSE)
 			return HAL_ERROR;
-		MyPrintf("Disconnect BLE Conn");
+		MyPrintf("Disconnect BLE Conn\n");
 	}
 	else if(BtStatus & (1<<BIT_BT_SPP_CONNECT))
 	{
 		MyPrintf("SPP Connect\n");
 		if(BT_BtDisconnect()==FALSE)
 			return HAL_ERROR;
-		MyPrintf("Disconnect SPP Conn");
+		MyPrintf("Disconnect SPP Conn\n");
 	}
 	else
 	{
@@ -140,15 +497,26 @@
 
 }
 
-s32 HalBtSendData(u8 *ucSendBuf, u32 uiSendLen)
+/*******************************************************************************
+函数功能: 通过蓝牙发送数据
+输入参数: pucSendBuf : 待发送的数据缓冲指针
+          uiSendLen : 待发送数据的字节数
+输出参数: 无
+返回值: >=0 实际发送的字节数
+        <0 发送失败
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.28    jqdeng    创建
+*******************************************************************************/
+s32 halBtSendData(u8 *pucSendBuf, u32 uiSendLen)
 {
-#define HAL_MAX_SPP_DATA_LENGTH	210
-#define HAL_MAX_BLE_DATA_LENGTH	180
-#define HAL_BLE_DATA_HANDLE		0x2A
 	s8 BtStatus = Bt_GetBtStatus();
 	s8 DataLen = 0;
+
 	if(uiSendLen==0)
 		return HAL_ERROR;
+
 	if(BtStatus & (1<<BIT_BLE_CONNECT))
 	{
 		MyPrintf("BLE Connect\n");
@@ -156,10 +524,10 @@
 		s8 SendBleDataBuff[HAL_MAX_BLE_DATA_LENGTH+2] = {HAL_BLE_DATA_HANDLE, 0x00};
 		for(s8 index=0; index<DataLen; index++)
 		{
-			SendBleDataBuff[2+index] = *ucSendBuf;
-			ucSendBuf++;
+			SendBleDataBuff[2+index] = *pucSendBuf;
+			pucSendBuf++;
 		}
-		if(BT_SendBleData(SendBleDataBuff,DataLen+2)==TRUE)
+		if(BT_SendBleData((uint8_t *)SendBleDataBuff,DataLen+2)==TRUE)
 		{
 			MyPrintf("Ble Send data len is %d\n",DataLen);
 			return DataLen;
@@ -171,7 +539,7 @@
 	{
 		MyPrintf("SPP Connect\n");
 		DataLen = uiSendLen>HAL_MAX_SPP_DATA_LENGTH?HAL_MAX_SPP_DATA_LENGTH:uiSendLen;
-		if(BT_SendSppData(ucSendBuf,DataLen)==TRUE)
+		if(BT_SendSppData(pucSendBuf,DataLen)==TRUE)
 		{
 			MyPrintf("SPP Send data len is %d\n",DataLen);
 			return DataLen;
@@ -181,49 +549,227 @@
 	}
 	MyPrintf("No BT connect\n");
 	return HAL_ERROR;
-	
+
 }
 
-extern uint8_t BtDataBuff[MAX_BLUETOOTH_DATA_LEN+1];
-s32 HalBtRecvData(u8 *ucRecvBuf, u32 uiRecvLen)
+/*******************************************************************************
+函数功能: 通过蓝牙接收数据
+输入参数: 无
+输出参数: pucRecvBuf : 指向接收数据的缓存
+          uiRecvLen : 期望接收的最大字节数
+返回值: >=0 实际接收到的数据字节数
+        <0 接收失败
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.28    jqdeng    创建
+*******************************************************************************/
+s32 halBtRecvData(u8 *pucRecvBuf, u32 uiRecvLen)
 {
-	if(BtDataBuff[0]>0)
+	if (BtDataBuff[0] > 0)
 	{
 		u8 *TempPoint = BtDataBuff+1;
 		uiRecvLen = BtDataBuff[0];
+
 		while(BtDataBuff[0]--)
-			*ucRecvBuf++ = *TempPoint++;
+			*pucRecvBuf++ = *TempPoint++;
+
 		BtDataBuff[0]=0;
 		return uiRecvLen;
 	}
+
 	return HAL_ERROR;
 }
 
-#define HAL_ON	0x01
-#define HAL_OFF	0x00
+/*******************************************************************************
+函数功能: 蓝牙事件处理
+输入参数: 无
+输出参数: 无
+返回值: 无
+--------------------------------------------------------------------------------
+备注  : 蓝牙事件处理，必须实时调用；
+--------------------------------------------------------------------------------
+修改信息: 2019.12.13    jqdeng    创建
+*******************************************************************************/
+void halBtProc(void)
+{
+    BT_Progress();
+}
+
+
+/*
+* 蓝牙需求增加两个接口:
+* a.打开射频载波
+* b.蓝牙频偏控制
+* c.蓝牙初始化接口修改，开放蓝牙频偏设置;
+*/
+
+/*******************************************************************************
+函数功能: 打开/关闭射频载波
+输入参数: ucMode : HAL_ON  (0x01)   开启
+                   HAL_OFF (0x00)   关闭
+输出参数: 无
+返回值: HAL_OK
+        HAL_ERROR
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.12.14    jqdeng    创建
+*******************************************************************************/
 s32 halBtRfCtrl(u8 ucMode)
 {
-	if(ucMode == HAL_ON)
+    if(ucMode == HAL_ON)
 	{
 		DTMTestInit();
 	}
 	else
 	{
 		BT_Wake = 0;
-		HalBtOpen();
+		halBtClose();
 	}
-	return HAL_OK;
+
+    return HAL_OK;
 }
 
+/*******************************************************************************
+函数功能: 蓝牙频偏控制
+输入参数: ucRfValue : 控制蓝牙频偏参数
+输出参数: 无
+返回值: HAL_OK
+        HAL_ERROR
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.12.14    jqdeng    创建
+*******************************************************************************/
 s32 halBtRfSet(u8 ucRfValue)
 {
-	HW_REG_8BIT(0xc804C, 0x0f);
+#if 0
+    HW_REG_8BIT(0xc804C, 0x0f);
 	HW_REG_8BIT(0xc804D, 0xcf);
 	HW_REG_8BIT(0xc804E, ucRfValue<<3|2);
 	HW_REG_8BIT(0xc804F, 0x3f);
 	delay_ms(3);
 	HW_REG_8BIT(0xc8005, 0x01);
 	HW_REG_8BIT(0xc4177, ucRfValue<<3|2);
+#else
+    u32 uiFreq = 2400;
+    if (ucRfValue>=1 && ucRfValue<=80)
+    {
+        uiFreq += ucRfValue;
+        ModifyDtmFreq(uiFreq);
+    }
+#endif
 	return HAL_OK;
 }
 
+/*******************************************************************************
+函数功能: 蓝牙中断处理服务函数
+输入参数: 无
+输出参数: 无
+返回值: 无
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.28    jqdeng    创建
+*******************************************************************************/
+void btIntIsr(void)
+{
+    if (0x01 == BT_Wake)
+	{
+		while (IPC_have_data())
+		{
+			BT_ParseBTData();
+		}
+	}
+	else
+	{
+		BT_Wake = 0x01;
+		MyPrintf("bt init succ\n");
+	}
+
+	BT_CONFIG &= (~(1<<BT_INIT_FLAG));
+}
+
+/*******************************************************************************
+函数功能: 注册蓝牙回调函数
+输入参数: ptBtCallBackFunc : 蓝牙回调函数结构体首地址
+输出参数: 无
+返回值: 无
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.12.17    jqdeng    创建
+*******************************************************************************/
+void halBtRegistFun(T_BT_CALL_BACK_FUNC *ptBtCallBackFunc)
+{
+    tBtCallBackFunc.pfnBtPairingDataGet = ptBtCallBackFunc->pfnBtPairingDataGet;
+    tBtCallBackFunc.pfnBtPairingDataSet = ptBtCallBackFunc->pfnBtPairingDataSet;
+}
+
+//##############################################################################
+//############################################################## 测试函数
+
+
+void testBt_jhl(void)
+{
+    s32 iRet = 0;
+    u8 ucBtStatus = 0;
+    u8 ucDataBuff[256] = {0};
+
+    halPrintf("<test bluetooth start>\n");
+
+#if 0
+    memset(ucDataBuff, 0x00, sizeof(ucDataBuff));
+    btGetNvramDataFromFlash(ucDataBuff, NDLen);
+    halPrintfWithTitle(ucDataBuff, NDLen, "ucDataBuff");
+
+    memset(ucDataBuff, 0x01, sizeof(ucDataBuff));
+    btSaveNvramDataInFlash(ucDataBuff, NDLen);
+    halPrintf("set 0x01\n");
+
+    memset(ucDataBuff, 0x00, sizeof(ucDataBuff));
+    btGetNvramDataFromFlash(ucDataBuff, NDLen);
+    halPrintfWithTitle(ucDataBuff, NDLen, "ucDataBuff");
+#endif
+
+#if 1
+    iRet = halBtOpen();
+    halPrintf("halBtOpen ret:%d\n", iRet);
+
+    iRet = halBtSetNamePin("yc3121-jqdeng", "1234");
+    halPrintf("halBtSetNamePin ret:%d\n", iRet);
+
+    iRet = halBtSetMac("\x01\x02\x03\xA1\xA2\xA3");
+    halPrintf("halBtSetMac ret:%d\n", iRet);
+
+    // 测试收发
+    while (1)
+    {
+        BT_Progress();
+        iRet = halBtGetStatus(&ucBtStatus);
+        if (BT_STATUS_CONNECT == ucBtStatus)
+        {
+            iRet = halBtRecvData(ucDataBuff, 255);
+            if (iRet > 0)
+            {
+                halPrintf("halBtRecvData : %d\n", iRet);
+
+                if ((0x02 == iRet) && (memcmp(ucDataBuff, "\x00\x02", 2) == 0))
+                {
+                    iRet = halBtDisconnect();
+                    halPrintf("halBtDisconnect ret: %d\n", iRet);
+                }
+                else
+                {
+                    halBtSendData(ucDataBuff, iRet);
+                }
+
+                memset(ucDataBuff, 0x00, sizeof(ucDataBuff));
+            }
+        }
+    }
+#endif
+    //halPrintf("<test bluetooth end>\n");
+}
+
Index: fw/hal/jinghongling/src/HalGpio/halGpio.c
===================================================================
--- /YC3121_SDK/fw/hal/jinghongling/src/HalGpio/halGpio.c	(revision 732)
+++ /YC3121_SDK/fw/hal/jinghongling/src/HalGpio/halGpio.c	(working copy)
@@ -12,11 +12,83 @@
 *******************************************************************************/
 
 #include "halGpio.h"
+#include "yc_exti.h"
+#include "yc_sysctrl.h"
+#include "..\core\yc3121.h"
+#include "..\sdk\yc_gpio.h"
 
+#if 0
+typedef int(*CallBack)(char *p);//声明CallBack 类型的函数指针
+
+int A(char *p)
+{
+    return 0;
+}
+
+int B(CallBack lpCall,char *p)
+{
+    lpCall(p); //借助回调完成的功能,也就是A函数来处理的.
+    return 0;
+}
+
+void hello()
+{
+    char *p="hello!";
+    B(A,p);
+}
+#endif
+
+
+
+gpioIsr pfnGpioIsr = NULL;
+
+//##############################################################################
+//############################################################## 本地函数和内部声明
+
+/*******************************************************************************
+函数功能: GPIO组编号转换
+输入参数: uiGpioGroup : GPIO组(HAL_GPIOA/HAL_GPIOB/HAL_GPIOC/HAL_GPIOD/HAL_GPIOE)
+输出参数: 无
+返回值: 对应到YC3121的组编号
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.19    jqdeng    创建
+*******************************************************************************/
+static u32 gpioGroup(u32 uiGpioGroup)
+{
+    return (uiGpioGroup-1);
+}
+
+static void GPIO_PullDownCmd(GPIO_TypeDef GPIOx, uint16_t GPIO_Pin, FunctionalState NewState)
+{
+    _ASSERT(ISGPIOGROUP(GPIOx));
+    _ASSERT(IS_GET_GPIO_PIN(GPIO_Pin));
+
+    int i;
+
+    for (i = 0; i < GPIO_PIN_NUM; i++)
+    {
+        if (GPIO_Pin & 1 << i)
+        {
+            if (NewState == ENABLE)
+            {
+                GPIO_CONFIG(GPIOx * GPIO_PIN_NUM + i) |= 1 << 7;
+            }
+            else if (NewState == DISABLE)
+            {
+                GPIO_CONFIG(GPIOx * GPIO_PIN_NUM + i) &= ~(1 << 7);
+            }
+        }
+    }
+}
+
+//##############################################################################
+//############################################################## 外部函数
 
 /*******************************************************************************
 函数功能: GPIO初始化
-输入参数: uiGpio	GPIO组(GPIOA/GPIOB/GPIOC/GPIOD/GPIOE)
+输入参数: uiGpio	GPIO组(HAL_GPIOA/HAL_GPIOB/HAL_GPIOC/HAL_GPIOD/HAL_GPIOE)
           uiGpioPin： Gpio Pin
           eMode： E_GPIO_PIN_MODE
           ePull： E_GPIO_PULL_MODE
@@ -29,57 +101,60 @@
 *******************************************************************************/
 void halGpioInit(u32 uiGpio, u32 uiGpioPin, E_GPIO_PIN_MODE eMode, E_GPIO_PULL_MODE ePull)
 {
-	
-    if ((HAL_SIG_INPUT == eMode) || (HAL_SIG_OUTPUT == eMode))
+    uiGpio = gpioGroup(uiGpio);
+
+    if ((HAL_SIG_INPUT == eMode) || (HAL_SIG_OUTPUT == eMode)) // 模拟输入输出
     {
         GPIO_Config((GPIO_TypeDef) uiGpio, (uint16_t)uiGpioPin, ANALOG);
-				return;
+        return;
+    }
+    else
+    {
+        GPIO_Config((GPIO_TypeDef) uiGpio, (uint16_t)uiGpioPin, INPUT);
+    }
+
+    int i;
+
+    switch(ePull)
+    {
+        case HAL_GPIO_NOPULL:
+            GPIO_PullUpCmd((GPIO_TypeDef) uiGpio, uiGpioPin, DISABLE);
+            GPIO_PullDownCmd((GPIO_TypeDef) uiGpio, uiGpioPin, DISABLE);
+            break;
+
+        case HAL_GPIO_PULLUP:
+            GPIO_PullUpCmd((GPIO_TypeDef) uiGpio, uiGpioPin, ENABLE);
+            break;
+
+        case HAL_GPIO_PULLDN:
+            GPIO_Config((GPIO_TypeDef) uiGpio,uiGpioPin,PULL_DOWN);
+            //GPIO_PullUpCmd((GPIO_TypeDef) uiGpio, uiGpioPin, DISABLE);
+            //GPIO_PullDownCmd((GPIO_TypeDef) uiGpio, uiGpioPin, ENABLE);
+            break;
+
+        case HAL_GPIO_DEFAULT:
+            for(i=0;i<GPIO_PIN_NUM;i++)
+            {
+                if(uiGpioPin&(1<<i))
+                {
+                    if((GPIO_CONFIG(uiGpio*GPIO_PIN_NUM+i)&0xc0) == 0x10)
+                    {
+                        GPIO_PullUpCmd( (GPIO_TypeDef)uiGpio,  uiGpioPin,  ENABLE);
+                    }
+                    else
+                    {
+                        GPIO_PullUpCmd( (GPIO_TypeDef)uiGpio,  uiGpioPin,  DISABLE);
+                    }
+                }
+            }
+            break;
     }
-		else
-		{
-				GPIO_Config((GPIO_TypeDef) uiGpio, (uint16_t)uiGpioPin, INPUT);
-		}
-
-	int i;
-		
-	switch(ePull)
-	{
-		case HAL_GPIO_NOPULL:
-			GPIO_PullUpCmd((GPIO_TypeDef) uiGpio,  uiGpioPin,  DISABLE);
-		    break;
-
-		case HAL_GPIO_PULLUP:
-			GPIO_PullUpCmd((GPIO_TypeDef) uiGpio, uiGpioPin, ENABLE);
-		    break;
-
-		case HAL_GPIO_PULLDN:
-			GPIO_Config((GPIO_TypeDef) uiGpio,uiGpioPin,PULL_DOWN);
-    		break;
-
-		case HAL_GPIO_DEFAULT: 
-			for(i=0;i<GPIO_PIN_NUM;i++)
-			{
-				if(uiGpioPin&(1<<i))
-				{
-					if((GPIO_CONFIG(uiGpio*GPIO_PIN_NUM+i)&0xc0) == 0x10)
-					{
-						GPIO_PullUpCmd( (GPIO_TypeDef)uiGpio,  uiGpioPin,  ENABLE);
-					}
-					else
-					{
-						GPIO_PullUpCmd( (GPIO_TypeDef)uiGpio,  uiGpioPin,  DISABLE);
-					}
-				}
-			}
-    		break;
-	}
 }
 
 /*******************************************************************************
 函数功能: 禁用中断的一个特定的gpio引脚
-输入参数:
-		uiGpioIndex：The index of GPIO
-		uiGpioPin： input or output singnal ID
+输入参数: uiGpioIndex：The index of GPIO
+		  uiGpioPin： input or output singnal ID
 输出参数: 无
 返回值: 无
 --------------------------------------------------------------------------------
@@ -89,15 +164,15 @@
 *******************************************************************************/
 s32 halGpioIntDisable(u32 uiGpioIndex, u32 uiGpioPin)
 {
+    uiGpioIndex = gpioGroup(uiGpioIndex);
 	GPIO_INTR_EN(uiGpioIndex) = (GPIO_INTR_EN(uiGpioIndex)&(~(uiGpioPin)));
     return HAL_OK;
 }
 
 /*******************************************************************************
 函数功能: 允许中断指定的GPIO引脚
-输入参数:
-		uiGpioIndex：The index of GPIO
-		uiGpioPin： input or output singnal ID
+输入参数: uiGpioIndex：The index of GPIO
+		  uiGpioPin： input or output singnal ID
 输出参数: 无
 返回值: 无
 --------------------------------------------------------------------------------
@@ -107,17 +182,17 @@
 *******************************************************************************/
 s32 halGpioIntEnable(u32 uiGpioIndex,u32 uiGpioPin)
 {
-	// EXTI_LineConfig( uiGpioIndex,uiGpioPin, EXTI_TriggerTypeDef EXTI_Trigger)
-	//GPIO_INTR_EN(uiGpioIndex) |= uiGpioPin;
+    uiGpioIndex = gpioGroup(uiGpioIndex);
+	GPIO_INTR_EN(uiGpioIndex) |= uiGpioPin;
     return HAL_OK;
 }
+
 /*******************************************************************************
 函数功能: 注册GPIO中断服务，设置GPIO中断模式
-输入参数:
-		uiGpioIndex：The index of GPIO
-		uiGpioPin： input or output singnal ID
-		eMode:  中断类型，参考E_GPIO_INT_MODE模式
-		isr:    指向中断服务函数的指针
+输入参数: uiGpioIndex：The index of GPIO
+		  uiGpioPin： input or output singnal ID
+		  eMode:  中断类型，参考E_GPIO_INT_MODE模式
+		  isr:    指向中断服务函数的指针
 输出参数: 无
 返回值: HAL_OK 成功
         HAL_ERROR 失败
@@ -126,8 +201,12 @@
 --------------------------------------------------------------------------------
 修改信息: 2019.11.15    jqdeng    创建
 *******************************************************************************/
-s32 halGpioRegIsr(u32 uiGpioIndex,u32 uiGpioPin, E_GPIO_INT_MODE eMode,void(*isr)(void))
+s32 halGpioRegIsr(u32 uiGpioIndex,u32 uiGpioPin, E_GPIO_INT_MODE eMode, void(*isr)(void))
 {
+    uiGpioIndex = gpioGroup(uiGpioIndex);
+
+    //halPrintf("halGpioRegIsr uiGpioPin: %08x\n", uiGpioPin);
+
     // YC3121不支持边沿触发，上升沿触发设置成高电平触发，下降沿改成低电平
     if ((eMode > HAL_INT_HIGH) || (HAL_INT_DUAL == eMode))
     {
@@ -136,23 +215,24 @@
 
     if ((HAL_INT_RISING == eMode) || (HAL_INT_HIGH == eMode))
     {
-			GPIO_TRIG_MODE(uiGpioIndex) &= ~uiGpioPin;
-
+        GPIO_TRIG_MODE(uiGpioIndex) &= ~uiGpioPin;
+        //halPrintf("halGpioRegIsr HAL_INT_HIGH: [%04x]\n", GPIO_TRIG_MODE(uiGpioIndex));
     }
     else if ((HAL_INT_FALLING == eMode) || (HAL_INT_LOW == eMode))
     {
-			GPIO_TRIG_MODE(uiGpioIndex) |= uiGpioPin;
-
+        GPIO_TRIG_MODE(uiGpioIndex) |= uiGpioPin;
+        //halPrintf("halGpioRegIsr HAL_INT_LOW: [%04x]\n", GPIO_TRIG_MODE(uiGpioIndex));
     }
 
+    pfnGpioIsr = isr;
+
     return HAL_OK;
 }
 
 /*******************************************************************************
 函数功能: 读取GPIO引脚的逻辑状态
-输入参数:
-		uiGpioIndex：The index of GPIO
-		uiGpioPin： input or output singnal ID
+输入参数: uiGpioIndex：The index of GPIO
+		  uiGpioPin： input or output singnal ID
 输出参数: 无
 返回值: Gpio状态值
 --------------------------------------------------------------------------------
@@ -162,15 +242,15 @@
 *******************************************************************************/
 u32 halGpioReadPin(u32 uiGpioIndex, u32 uiGpioPin)
 {
-	return GPIO_IN(uiGpioIndex)&uiGpioPin;
+    uiGpioIndex = gpioGroup(uiGpioIndex);
+	return ((GPIO_IN(uiGpioIndex)&uiGpioPin)>0);
 }
 
 /*******************************************************************************
 函数功能: 驱动逻辑0(低)或1(高)对一个GPIO引脚输出
-输入参数:
-		uiGpioIndex：The index of GPIO
-		uiGpioPin： input or output singnal ID
-		ucBit:  只有1或0，高电平和低电平的gpio引脚
+输入参数: uiGpioIndex：The index of GPIO
+		  uiGpioPin： input or output singnal ID
+		  ucBit:  只有1或0，高电平和低电平的gpio引脚
 输出参数: 无
 返回值: HAL_OK 成功
         HAL_ERROR 失败
@@ -181,6 +261,8 @@
 *******************************************************************************/
 s32 halGpioWritePin(u32 uiGpioIndex,u32 uiGpioPin,u8 ucBit)
 {
+    uiGpioIndex = gpioGroup(uiGpioIndex);
+
 	if(ucBit)
 		GPIO_SetBits((GPIO_TypeDef)uiGpioIndex, (uint16_t)uiGpioPin);
 	else
@@ -191,10 +273,9 @@
 
 /*******************************************************************************
 函数功能: 设置 GPIO 的复用模式
-输入参数:
-		uiGpioIndex：The index of GPIO
-		uiGpioPin： input or output singnal ID
-		ucMuxMode:  只有1或0，高电平和低电平的gpio引脚
+输入参数: uiGpioIndex：The index of GPIO
+		  uiGpioPin： input or output singnal ID
+		  ucMuxMode:  只有1或0，高电平和低电平的gpio引脚
 输出参数: 无
 返回值: HAL_OK 成功
         HAL_ERROR 失败
@@ -205,16 +286,17 @@
 *******************************************************************************/
 s32 halIoMuxSetMode(u32 uiGpioIndex,u32 uiGpioPin,u8 ucMuxMode)
 {
+    uiGpioIndex = gpioGroup(uiGpioIndex);
+
     GPIO_Config((GPIO_TypeDef)uiGpioIndex, (uint16_t)uiGpioPin, (GPIO_FunTypeDef)ucMuxMode);
     return HAL_OK;
 }
 
 /*******************************************************************************
 函数功能: 配置gpio的唤醒
-输入参数:
-		uiGpioIndex：The index of GPIO
-		uiGpioPin： input or output singnal ID
-		ucEn:  0 -禁用  1 -启用
+输入参数: uiGpioIndex：The index of GPIO
+		  uiGpioPin： input or output singnal ID
+		  ucEn:  0 -禁用  1 -启用
 输出参数: 无
 返回值: HAL_OK 成功
         HAL_ERROR 失败
@@ -223,40 +305,226 @@
 --------------------------------------------------------------------------------
 修改信息: 2019.11.15    jqdeng    创建
 *******************************************************************************/
-//s32 halGpioWakeupCfg(u32 uiGpioIndex,u32 uiGpioPin,u8 ucEn)
-//{
-//	GPIO_WeakEvenConfig((GPIO_TypeDef)uiGpioIndex, (uint16_t)uiGpioPin,(FunctionalState) ucEn);
-//    return HAL_OK;
-//}
+s32 halGpioWakeupCfg(u32 uiGpioIndex,u32 uiGpioPin,u8 ucEn)
+{
+    uiGpioIndex = gpioGroup(uiGpioIndex);
+
+	//GPIO_WeakEvenConfig((GPIO_TypeDef)uiGpioIndex, (uint16_t)uiGpioPin,(FunctionalState) ucEn);
+    return HAL_OK;
+}
+
+/*******************************************************************************
+函数功能: GPIO中断处理服务函数
+输入参数: 无
+输出参数: 无
+返回值: 无
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.28    jqdeng    创建
+*******************************************************************************/
+void gpioIntIsr(void)
+{
+    disable_intr(INTR_GPIO);
+    halPrintf("-------- io -------- \n");
+    pfnGpioIsr();
+    enable_intr(INTR_GPIO);
+}
+
+//##############################################################################
+//############################################################## 测试函数
+
+#define KEYBOARD_PORT_0         HAL_GPIOC    // 40
+#define KEYBOARD_PIN_0          HAL_GPIO_PIN_8
+
+#define KEYBOARD_PORT_1         HAL_GPIOC    // 43
+#define KEYBOARD_PIN_1          HAL_GPIO_PIN_11
+
+#define KEYBOARD_PORT_2         HAL_GPIOB    // 22
+#define KEYBOARD_PIN_2          HAL_GPIO_PIN_6
+
+#define KEYBOARD_PORT_3         HAL_GPIOC    // 42
+#define KEYBOARD_PIN_3          HAL_GPIO_PIN_10
+
+#define KEYBOARD_PORT_4         HAL_GPIOA    // 05
+#define KEYBOARD_PIN_4          HAL_GPIO_PIN_6
+
+s32 kbScanIsr(void);
+
+/*******************************************************************************
+函数功能: 按键初始化
+输入参数:
+输出参数: 无
+返回值: HAL_OK 成功
+        HAL_ERROR 失败
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.28    jqdeng    创建
+*******************************************************************************/
+s32 kbInit(void)
+{
+    s32 iRet = 0;
+
+    // 初始化按键IO
+    halGpioInit(KEYBOARD_PORT_0, KEYBOARD_PIN_0, HAL_GPIO_INPUT, HAL_GPIO_PULLUP);
+    halGpioInit(KEYBOARD_PORT_1, KEYBOARD_PIN_1, HAL_GPIO_INPUT, HAL_GPIO_PULLUP);
+
+    // IO中断配置
+    iRet = halGpioIntEnable(KEYBOARD_PORT_0, KEYBOARD_PIN_0);
+    iRet = halGpioRegIsr(KEYBOARD_PORT_0, KEYBOARD_PIN_0, HAL_INT_LOW, kbScanIsr);
+
+    //halPrintf("[%04x] [%04x] [%04x]\n", GPIO_TRIG_MODE(HAL_GPIOA-1),
+    //            GPIO_TRIG_MODE(HAL_GPIOB-1),GPIO_TRIG_MODE(HAL_GPIOC-1));
+
+    iRet = halGpioIntEnable(KEYBOARD_PORT_1, KEYBOARD_PIN_1);
+    iRet = halGpioRegIsr(KEYBOARD_PORT_1, KEYBOARD_PIN_1, HAL_INT_LOW, kbScanIsr);
+
+    //halPrintf("[%04x] [%04x] [%04x]\n", GPIO_TRIG_MODE(HAL_GPIOA-1),
+    //            GPIO_TRIG_MODE(HAL_GPIOB-1),GPIO_TRIG_MODE(HAL_GPIOC-1));
+
+    // 使能IO中断
+    halEnableIrq(HAL_INTR_GPIO);
+
+    return HAL_OK;
+}
+
+
+/*******************************************************************************
+函数功能: 测试GPIO中断扫描按键
+输入参数:
+输出参数: 无
+返回值: HAL_OK 成功
+        HAL_ERROR 失败
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.28    jqdeng    创建
+*******************************************************************************/
+s32 kbScanIsr(void)
+{
+    //return HAL_OK;
+    u16 unIoCfg = 0;
+    u16 unIoSel = KEYBOARD_PIN_0;
+    u8 ucIoLevel = 0;
 
+    // 确认是否为有效的触发
+    unIoCfg = GPIO_INTR_EN(KEYBOARD_PORT_0-1); // GPIO中断开启寄存器 (1使能)
 
+    halPrintf("GPIO_INTR_EN [%04x] [%04x] [%04x]\n", GPIO_INTR_EN(HAL_GPIOA-1),
+            GPIO_INTR_EN(HAL_GPIOB-1),GPIO_INTR_EN(HAL_GPIOC-1));
 
+    if (!(unIoCfg & unIoSel))
+    {
+        halPrintf("not KEY_0 int enable\n");
+        return HAL_ERROR;
+    }
 
 
+    unIoCfg = GPIO_TRIG_MODE(KEYBOARD_PORT_0-1); // 中断电平配置 (0-高，1-低)
 
-//// GPIO hal接口功能验证
-//void testGpio(void)
-//{
-//    // IO输出 gpio_17 = PB0
-//    halGpioInit(HAL_GPIOB, HAL_GPIO_PIN_0, HAL_GPIO_OUTPUT, HAL_GPIO_DEFAULT);
-//    while (1)
-//    {
-//        halGpioWritePin(HAL_GPIOB,HAL_GPIO_PIN_0, HAL_GPIO_RESET);
-//        delay_ms(5);
-//        halGpioWritePin(HAL_GPIOB,HAL_GPIO_PIN_0, HAL_GPIO_SET);
-//        delay_ms(5);
-//    }
-//		
-//		
-//		
-//		
+    halPrintf("GPIO_TRIG_MODE [%04x] [%04x] [%04x]\n", GPIO_TRIG_MODE(HAL_GPIOA-1),
+                GPIO_TRIG_MODE(HAL_GPIOB-1),GPIO_TRIG_MODE(HAL_GPIOC-1));
 
-//    // IO输入
+    ucIoLevel = halGpioReadPin(KEYBOARD_PORT_0, KEYBOARD_PIN_0);
+    halPrintf("ucIoLevel : %02x\n", ucIoLevel);
+
+    if (((unIoCfg & KEYBOARD_PIN_0) > 0) != (!ucIoLevel)) // 不是需要的触发
+    {
+        halPrintf("not KEY_0 int\n");
+        return HAL_ERROR;
+    }
+
+    // 开始扫描按键
+    halPrintf(">>> scan key\n");
+
+    return HAL_OK;
+}
 
-//    // IO中断
 
-//    // IO复用
 
-//    // IO唤醒
-//}
+
+// GPIO hal接口功能验证
+void testGpio(void)
+{
+    u8 ucData = 0;
+    s32 iRet = 0;
+
+#if 0
+    // IO输出 gpio_17 = PB1 gpio_16 = PB0
+    halGpioInit(HAL_GPIOB, HAL_GPIO_PIN_1, HAL_GPIO_OUTPUT, HAL_GPIO_PULLUP);
+    halGpioInit(HAL_GPIOB, HAL_GPIO_PIN_0, HAL_GPIO_OUTPUT, HAL_GPIO_PULLUP);
+    // gpio_2 -- PA2 // demo板LCD背光
+    //halGpioInit(HAL_GPIOA, HAL_GPIO_PIN_2, HAL_GPIO_OUTPUT, HAL_GPIO_NOPULL);
+    //halGpioWritePin(HAL_GPIOA, HAL_GPIO_PIN_2, HAL_GPIO_SET);
+    while (1)
+    {
+        //halGpioWritePin(HAL_GPIOB,HAL_GPIO_PIN_1, HAL_GPIO_RESET);
+        halGpioWritePin(HAL_GPIOB,HAL_GPIO_PIN_0, HAL_GPIO_RESET);
+        halMsDelay(50);
+        //halUsDelay(500);
+
+        //halGpioWritePin(HAL_GPIOB,HAL_GPIO_PIN_1, HAL_GPIO_SET);
+        halGpioWritePin(HAL_GPIOB,HAL_GPIO_PIN_0, HAL_GPIO_SET);
+        halMsDelay(50);
+        //halUsDelay(500);
+    }
+
+#endif
+
+#if 1
+    // IO输入
+    halGpioInit(HAL_GPIOB, HAL_GPIO_PIN_1, HAL_GPIO_INPUT, HAL_GPIO_PULLUP);
+    halGpioInit(HAL_GPIOB, HAL_GPIO_PIN_0, HAL_GPIO_INPUT, HAL_GPIO_PULLUP);
+
+    while (1)
+    {
+        ucData = halGpioReadPin(HAL_GPIOB, HAL_GPIO_PIN_1);
+        halPrintf("PB1 : %d  ", ucData);
+        ucData = halGpioReadPin(HAL_GPIOB, HAL_GPIO_PIN_0);
+        halPrintf("PB0 : %d\n", ucData);
+        halMsDelay(1000);
+    }
+#endif
+
+#if 0
+    // IO输入
+    halGpioInit(HAL_GPIOB, HAL_GPIO_PIN_0, HAL_GPIO_INPUT, HAL_GPIO_PULLUP);
+    // IO中断
+    iRet = halGpioIntEnable(HAL_GPIOB, HAL_GPIO_PIN_0);
+    iRet = halGpioRegIsr(HAL_GPIOB, HAL_GPIO_PIN_0, HAL_INT_LOW, NULL);
+    //EXTI_LineConfig(EXTI_Line1, HAL_GPIO_PIN_0, EXTI_Trigger_Falling);
+    halEnableIrq(HAL_INTR_GPIO);
+    MyPrintf("EXTI_Trigger_Falling!\n");
+
+#endif
+
+    // IO复用
+
+    // IO唤醒
+#if 0
+    halPrintf("sleep in\n");
+    //halGpioWakeupCfg();
+    SYSCTRL_EnterSleep(SleepMode_STOP);
+    halPrintf("sleep out\n");
+#endif
+
+#if 0
+    // 测试仿真口复用 (14-swd_clk 15-swd_io)
+    halGpioInit(HAL_GPIOA, HAL_GPIO_PIN_14, HAL_GPIO_OUTPUT, HAL_GPIO_NOPULL);
+    halGpioInit(HAL_GPIOA, HAL_GPIO_PIN_15, HAL_GPIO_OUTPUT, HAL_GPIO_NOPULL);
+
+    while (1)
+    {
+        halGpioWritePin(HAL_GPIOA,HAL_GPIO_PIN_14, HAL_GPIO_RESET);
+        halGpioWritePin(HAL_GPIOA,HAL_GPIO_PIN_15, HAL_GPIO_RESET);
+        halMsDelay(50);
+
+        halGpioWritePin(HAL_GPIOA,HAL_GPIO_PIN_14, HAL_GPIO_SET);
+        halGpioWritePin(HAL_GPIOA,HAL_GPIO_PIN_15, HAL_GPIO_SET);
+        halMsDelay(50);
+    }
+#endif
+
+}
 
Index: fw/hal/jinghongling/src/HalI2c/halI2c.c
===================================================================
--- /YC3121_SDK/fw/hal/jinghongling/src/HalI2c/halI2c.c	(revision 732)
+++ /YC3121_SDK/fw/hal/jinghongling/src/HalI2c/halI2c.c	(working copy)
@@ -1,15 +1,44 @@
+/*******************************************************************************
+文件名: halI2c.c
+描  述: 实现IIC相关接口函数
+版  权:
+作  者: jqdeng
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改记录:
+日期		版本	修改人		修改内容
+2010/11/16	1.0		jqdeng			创建
+*******************************************************************************/
+
 #include "halI2c.h"
+#include "..\core\yc3121.h"
+#include "..\sdk\yc_iic.h"
+
 
 #define IS_SPEED_PARA(SPEED) ((SPEED) == 400 || (SPEED) == 100)
 
-int halI2CConfig(u32 index, u32 speed)
+/*******************************************************************************
+函数功能: IIC初始化配置
+输入参数: index： 索引
+          speed: 传输速度
+          支持 100KHz, 400KHz
+输出参数: None
+返回值:   0 =  成功
+          < 0  失败
+--------------------------------------------------------------------------------
+备注  :   配置IIC为主机模式
+--------------------------------------------------------------------------------
+修改信息: 2019.11.16    jqdeng     创建
+*******************************************************************************/
+s32 halI2CConfig(u32 uiIndex, u32 uiSpeed)
 {
-	if( !IS_SPEED_PARA(speed))
-		return FAILED;
+	if( !IS_SPEED_PARA(uiSpeed))
+		return HAL_ERROR;
 	IIC_InitTypeDef IIC_InitStruct;
 
 //	/* Configure the IIC bus rate */
-	if(400 == speed)
+	if(400 == uiSpeed)
 	{
 		IIC_InitStruct.scll = 56;
 		IIC_InitStruct.sclh = 56;
@@ -35,26 +64,55 @@
 	return 0;
 }
 
-int halI2CSend(u32 uiIndex,u32 uiAddr,u8 *puBuf ,u32 uiLen)
+/*******************************************************************************
+函数功能: I2C 发送数据
+输入参数: uiIndex： 端口索引号
+          uiAddr:   从机地址
+          puBuf ：  发送数据BUF的指针
+          u32uiLen：发送数据长度
+输出参数: None
+返回值:   0 =  成功
+          < 0  失败
+--------------------------------------------------------------------------------
+备注  :   无
+--------------------------------------------------------------------------------
+修改信息: 2019.11.16    jqdeng     创建
+*******************************************************************************/
+s32 halI2CSend(u32 uiIndex,u32 uiAddr,u8 *pucBuf ,u32 uiLen)
 {
-	if((NULL == puBuf) || uiLen == 0)
-		return FAILED;
+	if((NULL == pucBuf) || uiLen == 0)
+		return HAL_ERROR;
 
 	uint8_t adrbuf[2] = {(uiAddr&0xff),(uiAddr>>8)&0xff};
 	IIC_SendData(adrbuf,2);
-	IIC_SendData(puBuf, uiLen);
+	IIC_SendData(pucBuf, uiLen);
 	return 0;
 
 }
 
-int halI2CRecv(u32 uiIndex,u32 uiAddr,u8 *pubuf, u32 uiLen)
+/*******************************************************************************
+函数功能: I2C 接收数据
+输入参数: u32 uiIndex： 端口索引号
+          uiAddr: 从机地址
+          pubuf： 数据接收缓存指针
+          uiLen： 期望接收数据长度
+输出参数: None
+返回值:   0 = 成功
+          < 0 失败
+--------------------------------------------------------------------------------
+备注  :   无
+--------------------------------------------------------------------------------
+修改信息: 2019.11.16    jqdeng     创建
+*******************************************************************************/
+s32 halI2CRecv(u32 uiIndex,u32 uiAddr,u8 *pucBuf, u32 uiLen)
 {
-	if((NULL == pubuf) || uiLen == 0)
-		return FAILED;
+	if((NULL == pucBuf) || uiLen == 0)
+		return HAL_ERROR;
 
 	uint8_t adrbuf[2] = {(uiAddr&0xff),(uiAddr>>8)&0xff};
 
-	IIC_ReceiveData( adrbuf,  2, pubuf, uiLen);
+	IIC_ReceiveData( adrbuf,  2, pucBuf, uiLen);
 
-	return SUCCESS;
+	return HAL_OK;
 }
+
Index: fw/hal/jinghongling/src/HalIFlash/halIFlash.c
===================================================================
--- /YC3121_SDK/fw/hal/jinghongling/src/HalIFlash/halIFlash.c	(revision 732)
+++ /YC3121_SDK/fw/hal/jinghongling/src/HalIFlash/halIFlash.c	(working copy)
@@ -1,22 +1,334 @@
+/*******************************************************************************
+文件名: halIFLASH.c
+描  述:
+版  权:
+作  者: jqdeng
+--------------------------------------------------------------------------------
+备注  : -
+--------------------------------------------------------------------------------
+修改记录:
+日期		版本	修改人		修改内容
+2019/11/16	1.0		jqdeng 		创建
+2019/12/25	1.1		Cyclie 		增加App 读/写/擦除接口
+*******************************************************************************/
 #include "halIFlash.h"
-#define W25X_SectorErase 0x20
+#include "..\core\yc3121.h"
+#include "..\sdk\yc_qspi.h"
 
+/*******************************************************************************
+函数功能: 系统初始化后初始化内部FLASH
+输入参数: 无
+输出参数: 无
+返回值  : =0  成功
+          其他  失败
+--------------------------------------------------------------------------------
+备注    : 无
+--------------------------------------------------------------------------------
+修改信息: 2019/11/16    jqdeng      创建
+*******************************************************************************/
+s32 halIFlashInit(void)
+{
+    return HAL_OK;
+}
+
+/*******************************************************************************
+函数功能: 擦除IFLASH扇区
+输入参数: addr          要被擦除的页起始物理地址，必须与4096对齐
+输出参数: 无
+返回值  : =0 成功
+          <0 失败
+--------------------------------------------------------------------------------
+备注    : 每次擦除4K
+--------------------------------------------------------------------------------
+修改信息: 2019/11/16 jqdeng 创建
+*******************************************************************************/
+s32 halIFlashErase(u32 uiAddr)
+{
+	if (uiAddr % 4096 != 0)
+	{
+		return HAL_ERROR;
+    }
+
+    if (SUCCESS == qspi_flash_sectorerase(uiAddr))
+    {
+        return HAL_OK;
+    }
+    else
+    {
+        return HAL_ERROR;
+    }
+}
+
+/*******************************************************************************
+函数功能: 向IFLASH写数据
+输入参数: uiAddr        物理地址
+          ucData        指向要写入闪存的数据的指针
+          uiDataLen     数据长度
+输出参数:
+返回值:   >=0  实际写入的数据长度
+          <0  失败
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019/11/16     jqdeng        创建
+*******************************************************************************/
+s32 halIFlashWrite(u32 uiAddr,u8 *pucData, u32 uiDataLen)
+{
+    if (SUCCESS == qspi_flash_write(uiAddr , pucData, uiDataLen))
+    {
+        return uiDataLen;
+    }
+	else
+	{
+        return HAL_ERROR;
+    }
+}
+
+/*******************************************************************************
+函数功能: 从IFLASH读取数据
+输入参数: uiAddr        物理地址
+          uiDataLen     读取的数据长度
+输出参数: pucData       读到的数据
+返回值:   >=0  实际读取的数据长度
+          <0  失败
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019/11/16     jqdeng        创建
+*******************************************************************************/
+s32 halIFlashRead(u32 uiAddr,u8 *pucData, u32 uiDataLen)
+{
+    if (SUCCESS == qspi_flash_read(uiAddr, pucData, uiDataLen))
+    {
+        return uiDataLen;
+    }
+    else
+    {
+        return HAL_ERROR;
+    }
+}
+
+/*******************************************************************************
+函数功能: 向AppFLASH写数据
+输入参数: uiAddr        逻辑地址
+          ucData        指向要写入闪存的数据的指针
+          uiDataLen     数据长度
+输出参数:
+返回值  : >=0  实际写入的数据长度
+          <0  失败
+--------------------------------------------------------------------------------
+备注    : 应用保存专用接口
+--------------------------------------------------------------------------------
+修改信息: 2019/12/17 Cyclie 创建
+*******************************************************************************/
+s32 halAppFlashWrite(u32 uiAddr,u8 *pucData, u32 uiDataLen)
+{
+    enc_write_flash( uiAddr, pucData, uiDataLen);
+    return 0;
+}
+
+/*******************************************************************************
+函数功能: 从AppFLASH读取数据
+输入参数: uiAddr        逻辑地址
+          uiDataLen     读取的数据长度
+输出参数: pucData       读到的数据
+返回值  : >=0  实际读取的数据长度
+          <0  失败
+--------------------------------------------------------------------------------
+备注    : 应用读取专用接口
+--------------------------------------------------------------------------------
+修改信息: 2019/12/17 Cyclie 创建
+*******************************************************************************/
+s32 halAppFlashRead(u32 uiAddr,u8 *pucData, u32 uiDataLen)
+{
+    if (flash_blank_check(uiAddr, (uiAddr+uiDataLen)&0xffffff) == 0)
+    {
+        enc_read_flash(uiAddr, pucData, uiDataLen);
+    }
+    return 0;
+}
+
+/*******************************************************************************
+函数功能: 擦除指定位置起连续的32K逻辑地址
+输入参数: uiAddr        逻辑地址
+输出参数:
+返回值  : 0             成功
+--------------------------------------------------------------------------------
+备注    : 应用擦除专用接口, 位置32K对齐
+--------------------------------------------------------------------------------
+修改信息: 2019/12/17 Cyclie 创建
+*******************************************************************************/
+s32 halAppFlashErase(u32 uiAddr)
+{
+    enc_erase_flash_32k(uiAddr);
+    return 0;
+}
+
+void test_enc_write_flash_32byte(uint32_t base_addr)
+{
+	uint8_t wbuf[32] = {0};
+	Boolean isblank = FALSE;
+
+	//check flash is blank
+	isblank = flash_blank_check(base_addr&0xffffff, (base_addr+0x20)&0xffffff);
+	halPrintf("flash status iblank:%d \n", isblank);
+	halPrintf("\r\nflash blank check(%x~%x)= %d\n", base_addr, base_addr + 0x20, isblank);
+    if (0 == isblank)
+    {
+        enc_read_flash(base_addr, wbuf, 32);
+        halPrintfHex("rbuf:", wbuf, 32);
+    }
+
+	enc_erase_flash_32byte(base_addr);
+
+    memset(wbuf, 0x32, 32);
+    halPrintfHex("wbuf:", wbuf, 32);
+
+	enc_write_flash(base_addr,wbuf,32);
+	prefetch((volatile uint32_t *)base_addr, (volatile uint32_t *)(base_addr+32));
 
-int halIflashErase(u32 addr)
+	//read new data
+    halPrintfHex("base_addr NEW data:", (volatile uint8_t*)(base_addr), 32);
+	for (int i = 0; i < 32; i++)
+	{
+		if(wbuf[i] != *(volatile uint8_t*)(base_addr+i))
+		{
+			halPrintf("Error wbuf[%d] = %x\r\n", i, *(volatile uint8_t*)(base_addr+i));
+		}
+	}
+}
+
+/*******************************************************************************
+函数功能: 测试明文的Flash读写
+输入参数: base_addr             起始地址
+输出参数: None
+返回值  : None
+--------------------------------------------------------------------------------
+备注    :
+--------------------------------------------------------------------------------
+修改信息: 20191225 Cyclie 创建
+*******************************************************************************/
+void testWriteFlash32ByteL(uint32_t base_addr)
 {
-	if(addr%4096 !=0)
-		return FAILED;
-			
-	return	qspi_flash_sectorerase(addr);
-	 
+	u8 ucTempBuf[4096] = {0};
+    u8 ucWBuf[256] ={0};
+    s32 i = 0;
+    u32 uiPage = 0;
+    u32 uiPhysicalAddr = 0;
+    u32 uiOffset = 0;
+
+    halPrintf("base_addr:%x \n", base_addr);
+    //逻辑地址 To 物理地址
+    uiPage = ((base_addr - 0x1000000) / 0x8000);
+    uiPhysicalAddr = uiPage * 0x9000;
+    uiPhysicalAddr = uiPhysicalAddr + 0x1000000;
+    uiOffset = ((base_addr - 0x1000000) % 0x1000);
+    uiOffset = uiOffset + 0x00000010;
+    halPrintf("uiPhysicalAddr:%x \n", uiPhysicalAddr);
+    halPrintf("uiOffset:%x \n", uiOffset);
+
+    qspi_flash_read(uiPhysicalAddr, ucTempBuf, 4096);
+    halPrintfHex("rbuf1:", ucTempBuf, 4096);
+
+    qspi_flash_sectorerase(uiPhysicalAddr);
+    halPrintf("qspi_flash_sectorerase OK \n");
+
+    for (i = 0; i < 32; i++)
+	{
+		ucWBuf[i] = i;
+	}
+    memcpy(ucTempBuf + uiOffset, ucWBuf, 32);
+
+    halPrintfHex("wbuf:", ucTempBuf, 4096);
+    qspi_flash_write(uiPhysicalAddr,ucTempBuf,4096);
+    //read new data
+	qspi_flash_read(uiPhysicalAddr, ucTempBuf, 4096);
+    halPrintfHex("rbuf2:", ucTempBuf, 4096);
 }
 
-int halIflash_write(u32 uiAddr,u8 *pucData, u32 uiDataLen)
+void test_enc_write_flash_32K(uint32_t base_addr)
 {
-	return (qspi_flash_write( uiAddr, pucData, uiDataLen)) ;
+	uint8_t wbuf[256] ={0};
+	uint8_t rbuf[256] ={0};
+	uint32_t i = 0, j = 0;
+	uint32_t addr = 0;
+
+	enc_erase_flash_32k(base_addr);
+
+	for (j = 0; j < 32*1024; j += 256)
+	{
+		addr = base_addr + j;
+
+		for (i = 0; i < 256; i++)
+		{
+			wbuf[i] = i;
+		}
+
+		enc_write_flash(addr, wbuf, 256);
+
+		enc_read_flash(addr, rbuf, 256);
+
+		for(i=0;i<256;i++)
+		{
+			if(rbuf[i] != wbuf[i])
+			{
+				halPrintf("\n test error rbuf[%d]=%x wbuf[%d]=%x",i,rbuf[i],i,wbuf[i]);
+			}
+		}
+	}
 }
 
-int halIflash_read(u32 addr, u8* data, u32 size)
+// 测试内部flash
+void testIFlash(void)
 {
-	return qspi_flash_read(addr, data,size);
+    s32 iRet = 0;
+    u8 ucWtBuff[32] = {0};
+    u32 uiAddr = 0x0008000-10;
+    u8 ucBpkBuff[4096] = {0};
+    u8 ucTmpData = 0;
+
+    halIFlashInit();
+
+    test_enc_write_flash_32byte(0x1010000); // 0x1020000
+    testWriteFlash32ByteL(0x1010000);
+
+#if 0
+    memset(ucWtBuff, 0x00, sizeof(ucWtBuff));
+    halIFlashRead(uiAddr, ucWtBuff, sizeof(ucWtBuff));
+    halPrintfWithTitle(ucWtBuff, sizeof(ucWtBuff), "rd1:");
+
+    ucTmpData = ucWtBuff[0];
+    memset(ucWtBuff, ucTmpData++, sizeof(ucWtBuff));
+    halIFlashWrite(uiAddr, ucWtBuff, sizeof(ucWtBuff));
+
+    memset(ucWtBuff, 0x00, sizeof(ucWtBuff));
+    halIFlashRead(uiAddr, ucWtBuff, sizeof(ucWtBuff));
+    halPrintfWithTitle(ucWtBuff, sizeof(ucWtBuff), "rd2:");
+
+    memset(ucWtBuff, ucTmpData++, sizeof(ucWtBuff));
+    halIFlashWrite(uiAddr, ucWtBuff, sizeof(ucWtBuff));
+
+    memset(ucWtBuff, 0x00, sizeof(ucWtBuff));
+    halIFlashRead(uiAddr, ucWtBuff, sizeof(ucWtBuff));
+    halPrintfWithTitle(ucWtBuff, sizeof(ucWtBuff), "rd3:");
+
+    // 页首对齐写
+    memset(ucWtBuff, ucTmpData++, sizeof(ucWtBuff));
+    memset(ucBpkBuff, 0x00, sizeof(ucBpkBuff));
+    halIFlashRead(0x0008000-4096, ucBpkBuff, sizeof(ucBpkBuff));
+
+    memcpy(ucBpkBuff+4096-10, ucWtBuff, 10);
+    halIFlashWrite(0x0008000-4096, ucBpkBuff, sizeof(ucBpkBuff));
+
+    memset(ucBpkBuff, 0x00, sizeof(ucBpkBuff));
+    halIFlashRead(0x0008000, ucBpkBuff, sizeof(ucBpkBuff));
+
+    memcpy(ucBpkBuff, ucWtBuff, sizeof(ucWtBuff)-10);
+    halIFlashWrite(0x0008000, ucBpkBuff, sizeof(ucBpkBuff));
+
+    halIFlashRead(uiAddr, ucWtBuff, sizeof(ucWtBuff));
+    halPrintfWithTitle(ucWtBuff, sizeof(ucWtBuff), "rd4:");
+#endif
 }
+
+
Index: fw/hal/jinghongling/src/HalMag/HalMag.c
===================================================================
--- /YC3121_SDK/fw/hal/jinghongling/src/HalMag/HalMag.c	(revision 732)
+++ /YC3121_SDK/fw/hal/jinghongling/src/HalMag/HalMag.c	(working copy)
@@ -1,136 +1,240 @@
-#include "HalMag.h"
+/*******************************************************************************
+文件名: halMag.c
+描  述: 磁卡相关接口
+版  权:
+作  者: jqdeng
+--------------------------------------------------------------------------------
+备注  : -
+--------------------------------------------------------------------------------
+修改记录:
+日期		版本	修改人		修改内容
+2019/11/18	1.0		jqdeng 			创建
+*******************************************************************************/
+#include "halMag.h"
+#include "..\core\yc3121.h"
+#include "..\sdk\yc_adc.h"
+#include "..\sdk\yc_msr\yc_msr.h"
+
 
-s32 HalMagInit(void)
+/*******************************************************************************
+函数功能: 磁卡阅读器初始化
+输入参数: 无
+输出参数: 无
+返回值:   HAL_OK        打开成功
+          HAL_ERROR     打开失败
+--------------------------------------------------------------------------------
+备注  :   无
+--------------------------------------------------------------------------------
+修改信息: 2019/11/18    jqdeng      创建
+*******************************************************************************/
+s32 halMagInit(void)
 {
 	MSR_Init();
+    return HAL_OK;
 }
 
-s32 HalMagOpen(void)
+/*******************************************************************************
+函数功能: 打开磁卡阅读器
+输入参数: 无
+输出参数: 无
+返回值:   HAL_OK        打开成功
+          HAL_ERROR     打开失败
+--------------------------------------------------------------------------------
+备注  :   无
+--------------------------------------------------------------------------------
+修改信息: 2019/11/18    jqdeng      创建
+*******************************************************************************/
+s32 halMagOpen(void)
 {
 	MSR_ENABLE(ENABLE);
 	return HAL_OK;
 }
-s32 HalMagClose(void)
+
+/*******************************************************************************
+函数功能: 关闭磁卡阅读器
+输入参数: 无
+输出参数: 无
+返回值:   HAL_OK        关闭成功
+          HAL_ERROR     关闭失败
+--------------------------------------------------------------------------------
+备注  :   无
+--------------------------------------------------------------------------------
+修改信息: 2019/11/18    jqdeng      创建
+*******************************************************************************/
+s32 halMagClose(void)
 {
 	MSR_ENABLE(DISABLE);//
 	return HAL_OK;
 }
-void HalMagReset(void)
+
+/*******************************************************************************
+函数功能: 复位磁头，并清除磁卡缓冲区数据
+输入参数: 无
+输出参数: 无
+返回值:   HAL_OK        关闭成功
+          HAL_ERROR     关闭失败
+--------------------------------------------------------------------------------
+备注  :   在磁头已上电的情况下，该函数复位磁头，清除磁卡缓冲区数据；
+在磁头没有上电的情况下，只清除磁卡缓冲区数据。为确保磁头读入的数据是最新的数据，
+在循环检测是否刷卡之前，最好调用该函数一次，以清除磁卡缓冲数据。
+--------------------------------------------------------------------------------
+修改信息: 2019/11/18    jqdeng      创建
+*******************************************************************************/
+void halMagReset(void)
 {
-		MSR_ENABLE(DISABLE);
-		MSR_ENABLE(ENABLE);
+	MSR_ENABLE(DISABLE);
+	MSR_ENABLE(ENABLE);
 }
 
-s32 HalMagSwiped(void)
+/*******************************************************************************
+函数功能: 检查是否刷过卡
+输入参数: 无
+输出参数: 无
+返回值:   HAL_TRUE      有刷卡
+          HAL_FALSE     无刷卡
+--------------------------------------------------------------------------------
+备注  :   无
+--------------------------------------------------------------------------------
+修改信息: 2019/11/18    jqdeng      创建
+*******************************************************************************/
+s32 halMagSwiped(void)
 {
 	return (DETECT_SWIPING_CARD == MSR_DetectSwipingCard());
-}	
+}
 
 /*******************************************************************************
-函数功能: 
-输入参数: 
-输出参数: 无
+函数功能: 读取磁卡缓冲区的1、2、3磁道的数据
+输入参数: 无
+输出参数: cTrack1 : 存放1磁道数据的指针 [应用层缓冲区要设为256]
+          cTrack2 : 存放2磁道数据的指针 [应用层缓冲区要设为256]
+          cTrack3 : 存放3磁道数据的指针 [应用层缓冲区要设为256]
 返回值:   bit0 bit1 bit2  equal 1 decode success
+
+        bit0 = 1  正确读出1磁道数据
+        bit1 = 1  正确读出2磁道数据
+        bit2 = 1  正确读出3磁道数据
+        bit4 = 1  1磁道数据有校验错
+        bit5 = 1  2磁道数据有校验错
+        bit6 = 1  3磁道数据有校验错
 --------------------------------------------------------------------------------
 备注  :   无
 --------------------------------------------------------------------------------
-修改信息: 
+修改信息: 2019/11/18    jqdeng      创建
 *******************************************************************************/
-
-s32 HalMagRead(s8 *cTrack1, s8 *cTrack2, s8 *cTrack3)
+s32 halMagRead(s8 *cTrack1, s8 *cTrack2, s8 *cTrack3)
 {
-	
-		u8 cfmt, tflag;
-		u8 track_sel = 0;
-		s32 ret = 0;
-		u32 i=0;
-		track_data tdata[MAX_TRACK_NUM];
-
-	
-		if(NULL != cTrack1)
-			track_sel |= TRACK_SELECT_1;
-		if(NULL != cTrack2)
-			track_sel |= TRACK_SELECT_2;
-		if(NULL != cTrack3)
-			track_sel |= TRACK_SELECT_3;
-	
-		if(0 == track_sel)
-			return 0;
-		
-		u8 result = MSR_GetDecodeData(tdata, track_sel, &cfmt, &tflag);
-		
-		if(tdata[0].len > 0)
-		{
-			//mymemcpy(cTrack1, tdata[0].buf,tdata[0].len );
+    u8 ucCfmt, ucTflag;
+    u8 ucTrackSel = 0;
+    u32 i=0;
+    track_data tData[MAX_TRACK_NUM];
+
+    if(NULL != cTrack1)
+    {
+        ucTrackSel |= TRACK_SELECT_1;
+    }
+
+    if(NULL != cTrack2)
+    {
+        ucTrackSel |= TRACK_SELECT_2;
+    }
+
+    if(NULL != cTrack3)
+    {
+        ucTrackSel |= TRACK_SELECT_3;
+    }
+
+    if(0 == ucTrackSel)
+    {
+        return 0;
+    }
+
+    u8 result = MSR_GetDecodeData(tData, ucTrackSel, &ucCfmt, &ucTflag);
+
+    if (tData[0].len > 0)
+    {
+        //mymemcpy(cTrack1, tdata[0].buf,tdata[0].len );
+
+        for(i =1;i<tData[0].len-1;i++)
+        {
+            cTrack1[i-1] = tData[0].buf[i];
+        }
+    }
+
+    if (tData[1].len > 0)
+    {
+        //mymemcpy(cTrack1, tdata[0].buf,tdata[0].len );
+        for(i =1;i<tData[1].len-1;i++)
+        {
+            cTrack2[i-1] = tData[1].buf[i];
+        }
+    }
+
+    if (tData[2].len > 0)
+    {
+        //mymemcpy(cTrack1, tdata[0].buf,tdata[0].len );
+        for(i =1;  i< tData[2].len-1; i++)
+        {
+            cTrack3[i-1] = tData[2].buf[i];
+        }
+    }
 
-			for(i =1;i<tdata[0].len-1;i++)
-			{
-					cTrack1[i-1] = tdata[0].buf[i];
-			}
-
-		
-		}
-		if(tdata[1].len > 0)
-		{
-			//mymemcpy(cTrack1, tdata[0].buf,tdata[0].len );
-			for(i =1;i<tdata[1].len-1;i++)
-			{
-
-					cTrack2[i-1] = tdata[1].buf[i];
-			}
-		}
-
-		if(tdata[2].len > 0)
-		{
-			//mymemcpy(cTrack1, tdata[0].buf,tdata[0].len );
-			for(i =1;  i< tdata[2].len-1; i++)
-			{
-					cTrack3[i-1] = tdata[2].buf[i];
-			}	
-		}
-		return tflag;
+    return ucTflag;
 }
 
-u8 t1data[128] = {0};
-u8 t2data[128] = {0};
-u8 t3data[128] = {0};
 
-void  test_halmag()
+/*******************************************************************************
+函数功能: 磁卡测试接口
+输入参数: 无
+输出参数: 无
+返回值: 无
+--------------------------------------------------------------------------------
+备注  :   无
+--------------------------------------------------------------------------------
+修改信息: 2019/11/18    jqdeng      创建
+*******************************************************************************/
+void testMag(void)
 {
 	int i = 0;
 	u8 result = 0;
-	HalMagInit();
-HalMagReset();
+    u8 ucT1data[128] = {0};
+    u8 ucT2data[128] = {0};
+    u8 ucT3data[128] = {0};
+
+	halPrintf(">>>>testMag\n");	
+	halMagInit();
+    halMagReset();
+
 	while(1)
 	{
-		if(HalMagSwiped())
+		if (halMagSwiped())
 		{
-			MyPrintf("dectected card\n");
-			result = HalMagRead(t1data, t2data, t3data);
-			if(result&0x01)
+			halPrintf("dectected card\n");
+			result = halMagRead(ucT1data, ucT2data, ucT3data);
+
+			if (result & 0x01)
 			{
-				MyPrintf("t1data:");
-				UART_SendBuf(UART0, t1data, 79);
-				MyPrintf("\n");
+				halPrintf("t1data:");
+				UART_SendBuf(UART0, ucT1data, 79);
+				halPrintf("\n");
 			}
-			if(result&0x02)
+
+			if (result & 0x02)
 			{
-				MyPrintf("t2data:");
-				UART_SendBuf(UART0, t2data, 40);
-				MyPrintf("\n");
+				halPrintf("t2data:");
+				UART_SendBuf(UART0, ucT2data, 40);
+				halPrintf("\n");
 
 			}
-			if(result&0x04)
+
+			if (result & 0x04)
 			{
-				MyPrintf("t3data:");
-				UART_SendBuf(UART0,t3data, 107);
-				MyPrintf("\n");
+				halPrintf("t3data:");
+				UART_SendBuf(UART0,ucT3data, 107);
+				halPrintf("\n");
 			}
-			HalMagClose();
-			HalMagOpen();
+
+			halMagClose();
+			halMagOpen();
 		}
-	
-	
 	}
-	
-}
\ No newline at end of file
+}
Index: fw/hal/jinghongling/src/HalPwm/halPwm.c
===================================================================
--- /YC3121_SDK/fw/hal/jinghongling/src/HalPwm/halPwm.c	(revision 732)
+++ /YC3121_SDK/fw/hal/jinghongling/src/HalPwm/halPwm.c	(working copy)
@@ -1,14 +1,54 @@
+/*******************************************************************************
+文件名: halPwm.c
+描  述: PWM实现相关文件
+版  权:
+作  者: jqdeng
+--------------------------------------------------------------------------------
+备注  : -
+--------------------------------------------------------------------------------
+修改记录:
+日期		版本	修改人		修改内容
+2019/11/16 	1.0		jqdeng			创建
+*******************************************************************************/
 #include "halPwm.h"
+#include "halGpio.h"
+#include "..\core\yc3121.h"
+#include "..\sdk\yc_timer.h"
 
-#define PWM_TIMx TIM0
+#define PWM_DEFAULT_MAX_MS_TIME         (100) // 默认PWM执行的时间为1s
 
-void halPwmInit(void)
+T_PWM_MAX_MS gtPwmMaxMs;
+
+
+/*******************************************************************************
+函数功能: 初始化PWM
+输入参数: eIndex  PWM索引
+输出参数: 无
+返回值:   无
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019/11/16    jqdeng       创建
+*******************************************************************************/
+void halPwmInit(E_PWM_INDEX eIndex)
 {
-    TIM_ModeConfig(PWM_TIMx, TIM_Mode_PWM);
+    TIM_ModeConfig((TIM_NumTypeDef)eIndex, TIM_Mode_PWM);
 }
 
-
-void halPwmConfig(E_PWM_INDEX eIndex,u32 uiUs,u32 uiDuty,u8 ucType)
+/*******************************************************************************
+函数功能: 脉冲宽度调制配置
+输入参数: eIndex: PWM 逻辑编号
+          uiUs:   脉冲宽度时间, us
+          uiDuty: 占空比（0~100）
+          ucType: 输出格式 0 空闲是输出低电平 ， 1空闲是输出高电平
+输出参数: 无
+返回值:   无
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019/11/16    jqdeng       创建
+*******************************************************************************/
+void halPwmConfig(E_PWM_INDEX eIndex, u32 uiUs, u32 uiDuty, u8 ucType)
 {
 	PWM_InitTypeDef PWM_init_struct;
 
@@ -33,20 +73,193 @@
 	PWM_init_struct.HighLevelPeriod = highcnt;
 	PWM_init_struct.SatrtLevel = OutputLow;
 	TIM_PWMInit(&PWM_init_struct);
-
 }
 
-
-void halPwmSwitch(E_PWM_INDEX eIndex,u32 ucIsOn)
+/*******************************************************************************
+函数功能: PWM打开或者关闭
+输入参数: eIndex  PWM逻辑编号
+          ucIsOn  =0 关闭， =1 打开
+输出参数: 无
+返回值:   无
+--------------------------------------------------------------------------------
+备注  :   无
+--------------------------------------------------------------------------------
+修改信息: 2019/11/16    jqdeng      创建
+*******************************************************************************/
+void halPwmSwitch(E_PWM_INDEX eIndex, u8 ucIsOn)
 {
-	
-	
-	if(ucIsOn)
+    //halGpioWritePin(HAL_GPIOB, HAL_GPIO_PIN_0, 1);
+	if (ucIsOn)
 	{
 		TIM_Cmd((TIM_NumTypeDef)eIndex, ENABLE);
+        halPwmSetTimeout(eIndex, PWM_DEFAULT_MAX_MS_TIME);
 	}
 	else
 	{
 		TIM_Cmd((TIM_NumTypeDef)eIndex, DISABLE);
+        halPwmSetTimeout(eIndex, 0);
 	}
+    //halGpioWritePin(HAL_GPIOB, HAL_GPIO_PIN_0, 0);
+}
+
+/*******************************************************************************
+函数功能: PWM设置执行的时间(定时停止)
+输入参数: eIndex  PWM逻辑编号
+          un10MsCnt PWM执行时长 (单位10ms)
+输出参数: 无
+返回值:   HAL_OK
+          HAL_ERROR
+--------------------------------------------------------------------------------
+备注  :   无
+--------------------------------------------------------------------------------
+修改信息: 2019/12/03    jqdeng      创建
+*******************************************************************************/
+s32 halPwmSetTimeout(E_PWM_INDEX eIndex, u16 un10MsCnt)
+{
+    s32 iRet = HAL_OK;
+
+    switch (eIndex)
+    {
+        case HAL_PWM0:
+            gtPwmMaxMs.unPwm0Max = un10MsCnt;
+            break;
+        case HAL_PWM1:
+            gtPwmMaxMs.unPwm1Max = un10MsCnt;
+            break;
+        case HAL_PWM2:
+            gtPwmMaxMs.unPwm2Max = un10MsCnt;
+            break;
+        case HAL_PWM3:
+            gtPwmMaxMs.unPwm3Max = un10MsCnt;
+            break;
+        case HAL_PWM4:
+            gtPwmMaxMs.unPwm4Max = un10MsCnt;
+            break;
+        case HAL_PWM5:
+            gtPwmMaxMs.unPwm5Max = un10MsCnt;
+            break;
+        case HAL_PWM6:
+            gtPwmMaxMs.unPwm6Max = un10MsCnt;
+            break;
+        case HAL_PWM7:
+            gtPwmMaxMs.unPwm7Max = un10MsCnt;
+            break;
+        default:
+            iRet = HAL_ERROR;
+            break;
+    }
+
+    return iRet;
+}
+
+/*******************************************************************************
+函数功能: 获取PWM执行的剩余时间
+输入参数: tTimeLeft  剩余时间
+输出参数: 无
+返回值:   HAL_OK
+          HAL_ERROR
+--------------------------------------------------------------------------------
+备注  :   无
+--------------------------------------------------------------------------------
+修改信息: 2019/12/03    jqdeng      创建
+*******************************************************************************/
+s32 halPwmGetTimeout(T_PWM_MAX_MS *tTimeLeft)
+{
+    tTimeLeft->unPwm0Max = gtPwmMaxMs.unPwm0Max;
+    tTimeLeft->unPwm1Max = gtPwmMaxMs.unPwm1Max;
+    tTimeLeft->unPwm2Max = gtPwmMaxMs.unPwm2Max;
+    tTimeLeft->unPwm3Max = gtPwmMaxMs.unPwm3Max;
+    tTimeLeft->unPwm4Max = gtPwmMaxMs.unPwm4Max;
+    tTimeLeft->unPwm5Max = gtPwmMaxMs.unPwm5Max;
+    tTimeLeft->unPwm6Max = gtPwmMaxMs.unPwm6Max;
+    tTimeLeft->unPwm7Max = gtPwmMaxMs.unPwm7Max;
+
+    return HAL_OK;
+}
+
+
+/*******************************************************************************
+函数功能: PWM超时时间计时，时间到了，停止对应的PWM
+输入参数: 无
+输出参数: 无
+返回值: 无
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019/12/03    jqdeng      创建
+*******************************************************************************/
+void pwmMsCntDecrease(void)
+{
+    if (gtPwmMaxMs.unPwm7Max)
+        gtPwmMaxMs.unPwm7Max--;
+
+    if (gtPwmMaxMs.unPwm6Max)
+        gtPwmMaxMs.unPwm6Max--;
+
+    if (gtPwmMaxMs.unPwm5Max)
+        gtPwmMaxMs.unPwm5Max--;
+
+    if (gtPwmMaxMs.unPwm4Max)
+        gtPwmMaxMs.unPwm4Max--;
+
+    if (gtPwmMaxMs.unPwm3Max)
+        gtPwmMaxMs.unPwm3Max--;
+
+    if (gtPwmMaxMs.unPwm2Max)
+        gtPwmMaxMs.unPwm2Max--;
+
+    if (gtPwmMaxMs.unPwm1Max)
+        gtPwmMaxMs.unPwm1Max--;
+
+    if (gtPwmMaxMs.unPwm0Max)
+        gtPwmMaxMs.unPwm0Max--;
 }
+
+void testPwm(void)
+{
+    s32 iRet = 0;
+    u8 i = 0;
+    T_PWM_MAX_MS tTimeLeft;
+    u8 ucPwmOnFlag = 0;
+
+    halPrintf("<test PWM start>\n");
+
+    halIoMuxSetMode(HAL_GPIOB, HAL_GPIO_PIN_2, GPCFG_PWM_OUT0);
+    halPwmInit(HAL_PWM0);
+	halPwmConfig(HAL_PWM0, 500, 50, 0);
+
+    while (1)
+    {
+        if (0x00 == ucPwmOnFlag)
+        {
+            halPwmSwitch(HAL_PWM0, HAL_ON);
+            halPwmSetTimeout(HAL_PWM0, 30);
+            ucPwmOnFlag = 0x01;
+            halPrintf("pwm on\n");
+        }
+
+        halPwmGetTimeout(&tTimeLeft);
+        if (0x00 == tTimeLeft.unPwm0Max)
+        {
+            halPwmSwitch(HAL_PWM0, HAL_OFF);
+            ucPwmOnFlag = 0x00;
+            halPrintf("pwm off\n");
+            delay_ms(2000);
+        }
+    }
+
+#if 0
+    for (i=0; i<5; i++)
+    {
+        halPrintf("- pwm on\n");
+        halGpioWritePin(HAL_GPIOB, HAL_GPIO_PIN_0, 0);
+        halPwmSwitch(HAL_PWM0, HAL_ON);
+        halMsDelay(300);
+        halGpioWritePin(HAL_GPIOB, HAL_GPIO_PIN_0, 0);
+        halPwmSwitch(HAL_PWM0, HAL_OFF);
+        halPrintf("- pwm off\n");
+        halMsDelay(100);
+    }
+#endif
+}
+
Index: fw/hal/jinghongling/src/HalSpi/halSpi.c
===================================================================
--- /YC3121_SDK/fw/hal/jinghongling/src/HalSpi/halSpi.c	(revision 732)
+++ /YC3121_SDK/fw/hal/jinghongling/src/HalSpi/halSpi.c	(working copy)
@@ -11,6 +11,27 @@
 2019.11.15		jqdeng				创建
 *******************************************************************************/
 #include "halSpi.h"
+#include "halGpio.h"
+#include "yc_lcd.h"
+#include "..\core\yc3121.h"
+#include "..\sdk\yc_spi.h"
+
+
+/*******************************************************************************
+函数功能: spi组编号转换
+输入参数: ucSpi : ucSpi组(HAL_SPI0/HAL_SPI1/HAL_SPI2/HAL_SPI3)
+输出参数: 无
+返回值: 对应到YC3121的组编号
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.19    jqdeng    创建
+*******************************************************************************/
+u8 spiGroup(u8 ucSpi)
+{
+    return (ucSpi+1);
+}
+
 
 
 /*******************************************************************************
@@ -33,11 +54,11 @@
 *******************************************************************************/
 s32 halSpiConfig(E_SPI_INDEX eIndex, u32 uiSpeed, u8 ucDataBits, u8 ucMode)
 {
+	SPI_InitTypeDef SPI_InitStruct;
 
+    eIndex = spiGroup(eIndex);
 
-	SPI_InitTypeDef SPI_InitStruct;
 	SPI_InitStruct.Mode = SPI_Mode_Master;
-
 	SPI_InitStruct.BaudRatePrescaler = uiSpeed;
 	switch(ucMode)
 	{
@@ -87,7 +108,22 @@
 *******************************************************************************/
 s32 halSpiSend(E_SPI_INDEX eIndex,u8 *pucBuf, u32 uiLen)
 {
-  SPI_SendBuff( (SPIx_TypeDef)eIndex, pucBuf, uiLen);
+#if 0
+    u8 ucRecvData = 0;
+    u32 i = 0;
+
+    eIndex = spiGroup(eIndex);
+
+    for (i=0; i<uiLen; i++)
+    {
+        SPI_SendAndReceiveData((SPIx_TypeDef)eIndex, &pucBuf[i], 1, &ucRecvData, 1);
+    }
+#else
+    eIndex = spiGroup(eIndex);
+    SPI_SendBuff((SPIx_TypeDef)eIndex, pucBuf, uiLen);
+#endif
+
+    return HAL_OK;
 }
 
 
@@ -106,11 +142,209 @@
 *******************************************************************************/
 s32 halSpiRecv(E_SPI_INDEX eIndex,u8 *pucBuf, u32 uiLen)
 {
-
+#if 0
+    u8 ucSendData = 0;
+    u32 i = 0;
+
+    eIndex = spiGroup(eIndex);
+
+    for (i=0; i<uiLen; i++)
+    {
+        SPI_SendAndReceiveData((SPIx_TypeDef)eIndex, &ucSendData, 1, &pucBuf[i], 1);
+    }
+#else
+    u8 ucSendData = 0x00;
+    eIndex = spiGroup(eIndex);
+    memset(pucBuf, 0x00, uiLen);
+    SPI_SendAndReceiveData((SPIx_TypeDef) eIndex,  &ucSendData,  1,  pucBuf,  uiLen);
+#endif
+    return HAL_OK;
 }
 
 void s_SpiSendRecv(u32 index,u8 *sbuf, u32 slen,u8* rbuf, u32 rlen)
 {
-	 SPI_SendAndReceiveData((SPIx_TypeDef) index,  sbuf,  slen,  rbuf,  rlen);
+    index = spiGroup(index);
+    SPI_SendAndReceiveData((SPIx_TypeDef) index,  sbuf,  slen,  rbuf,  rlen);
+}
+
+
+
+void lcdIoInit(void)
+{
+    extern uint16_t LCD_SDA_PIN;
+    extern uint16_t LCD_SCL_PIN;
+    extern uint16_t LCD_A0_PIN;
+    extern uint16_t LCD_RES_PIN;
+    extern uint16_t LCD_CS_PIN;
+
+    extern GPIO_TypeDef LCD_SDA_Port;
+    extern GPIO_TypeDef LCD_SCL_Port;
+    extern GPIO_TypeDef LCD_A0_Port;
+    extern GPIO_TypeDef LCD_RES_Port;
+    extern GPIO_TypeDef LCD_CS_Port;
+
+    extern uint8_t LCD_BL_PIN;//背光
+    extern GPIO_TypeDef LCD_BL_Port;//背光
+
+    //SPIx = SPI0;
+	LCD_SDA_Port = GPIOB;
+	LCD_SDA_PIN = GPIO_Pin_1;
+	LCD_SCL_Port = GPIOB;
+	LCD_SCL_PIN = GPIO_Pin_0;
+	LCD_CS_Port = GPIOC;
+	LCD_CS_PIN = GPIO_Pin_6;
+	LCD_RES_Port = GPIOA;
+	LCD_RES_PIN = GPIO_Pin_5;
+	LCD_A0_Port = GPIOA;
+	LCD_A0_PIN = GPIO_Pin_10;
+	LCD_BL_Port = GPIOA;
+	LCD_BL_PIN = GPIO_Pin_2;
+
+    halIoMuxSetMode(LCD_SCL_Port+1, LCD_SCL_PIN, SPID0_SCK);
+	halIoMuxSetMode(LCD_CS_Port+1, LCD_CS_PIN, SPID0_NCS);
+	halIoMuxSetMode(LCD_SDA_Port+1, LCD_SDA_PIN, SPID0_MOSI);
+	halIoMuxSetMode(LCD_BL_Port+1, LCD_BL_PIN, OUTPUT_LOW);
+	halSpiConfig(HAL_SPI0, SPI_BaudRatePrescaler_64, 8, 3);
+
+    halGpioWritePin(LCD_A0_Port+1, LCD_A0_PIN, HAL_GPIO_SET);
+    halGpioWritePin(LCD_RES_Port+1, LCD_RES_PIN, HAL_GPIO_SET);
+	delay_ms(20);
+    halGpioWritePin(LCD_RES_Port+1, LCD_RES_PIN, HAL_GPIO_RESET);
+	delay_ms(100);
+    halGpioWritePin(LCD_RES_Port+1, LCD_RES_PIN, HAL_GPIO_SET);
+
+    // 背光
+    halGpioInit(HAL_GPIOA, HAL_GPIO_PIN_2, HAL_GPIO_OUTPUT, HAL_GPIO_NOPULL);
+    halGpioWritePin(HAL_GPIOA, HAL_GPIO_PIN_2, HAL_GPIO_SET);
 }
 
+void SPI_LCD_Test(void)
+{
+	unsigned char i;
+
+    unsigned char Bmp001[24 * 6]={
+        0x00,0x00,0x00,0x00,0x00,0xFC,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,
+        0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0xFC,0x00,0x00,0x00,0x00,0x00,
+        0x00,0x00,0x80,0xC0,0x60,0x63,0x32,0x3E,0x3E,0xF6,0xF2,0x32,
+        0x32,0x32,0xF2,0xF2,0x32,0x32,0x33,0xF0,0xF0,0x00,0x00,0x00,
+        0x00,0x00,0x00,0x04,0x0C,0x44,0x66,0x63,0x33,0x31,0x18,0x1C,
+        0x0E,0x07,0x03,0x60,0x60,0x60,0x70,0x3F,0x07,0x00,0x00,0x00
+    }; /* ? */
+    unsigned char Bmp002[24 * 6]={
+        0x00,0x00,0x40,0xE0,0xC0,0x80,0x00,0x00,0xFC,0xFC,0x00,0x00,
+        0x00,0xFC,0xFC,0x00,0x00,0x80,0xC0,0x70,0x60,0x00,0x00,0x00,
+        0x00,0x00,0xC0,0xC0,0x61,0x63,0x31,0x30,0xFF,0xFF,0x00,0x00,
+        0x00,0xFF,0xFF,0x20,0x31,0x71,0x60,0xE0,0xC0,0x00,0x00,0x00,
+        0x00,0x00,0x61,0x60,0x30,0x30,0x18,0x0E,0x07,0x01,0x00,0x00,
+        0x00,0x3F,0x3F,0x30,0x20,0x20,0x20,0x20,0x38,0x3C,0x08,0x00
+    }; /* ? */
+    unsigned char Bmp004[24 * 6]={
+        0x00,0x00,0xE0,0xE0,0xE0,0x60,0x60,0x60,0x60,0x60,0xFE,0xFE,
+        0x60,0x60,0x60,0x60,0x60,0x60,0xE0,0x00,0x00,0x00,0x00,0x00,
+        0x00,0x00,0x00,0xFF,0xFF,0x0C,0x0C,0x0C,0x0C,0x0C,0xFF,0xFF,
+        0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0xFF,0x00,0x00,0x00,0x00,0x00,
+        0x00,0x00,0x04,0x07,0x07,0x01,0x01,0x01,0x01,0x01,0x3F,0x7F,
+        0x61,0x41,0x41,0x41,0x41,0x41,0x41,0x60,0x60,0x78,0x10,0x00
+    }; /* ? */
+    unsigned char Bmp003[24 * 6]={
+        0x00,0x40,0x60,0x30,0x1C,0xCC,0x80,0xF0,0xF0,0x00,0xFC,0xFC,
+        0x00,0xF0,0x00,0x00,0xF0,0xFC,0x84,0x80,0x80,0x80,0xC0,0x00,
+        0x00,0x20,0x38,0x1C,0xFF,0x03,0x00,0x0D,0xCD,0x4D,0x4D,0xCD,
+        0xCD,0x0D,0x19,0x0F,0xFF,0xC0,0x00,0xFF,0x3F,0x00,0x00,0x00,
+        0x00,0x00,0x00,0x00,0x7F,0x00,0x10,0x3C,0x0F,0x00,0x00,0x0F,
+        0x0F,0x6C,0x76,0x30,0x18,0x0F,0x0F,0x19,0x30,0x70,0x20,0x00
+    }; /* ? */
+    unsigned char Bmp005[24 * 6]={
+        0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+        0x98,0x98,0xD8,0x78,0x78,0x38,0x18,0x18,0x00,0x00,0x00,0x00,
+        0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xFF,
+        0xFF,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,
+        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x60,0x7F,
+        0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+    }; /* ? */
+
+	clr_screen();
+
+	for(i = 0; i < 6; i++)
+	{
+		/* Set the starting pixel X and Y positions */
+		set_xy(4,i+2);
+		write_bytes_lcd(&Bmp001[24*i], 24, LCD_RS_DATA);
+	}
+	for(i = 0; i < 6; i++)
+	{
+		set_xy(28,i+2);
+		write_bytes_lcd(&Bmp002[24*i], 24, LCD_RS_DATA);
+	}
+	for(i = 0; i < 6; i++)
+	{
+		set_xy(52,i+2);
+		write_bytes_lcd(&Bmp003[24*i], 24, LCD_RS_DATA);
+	}
+	for(i = 0; i < 6; i++)
+	{
+		set_xy(76,i+2);
+		write_bytes_lcd(&Bmp004[24*i], 24, LCD_RS_DATA);
+	}
+	for(i = 0; i < 6; i++)
+	{
+		set_xy(100,i+2);
+		write_bytes_lcd(&Bmp005[24*i], 24, LCD_RS_DATA);
+	}
+}
+
+
+void eFlashIoInit(void)
+{
+	SPI_InitTypeDef SPI_InitStruct;
+
+    halIoMuxSetMode(HAL_GPIOB, HAL_GPIO_PIN_2, GPCFG_SPID0_MISO);
+    halIoMuxSetMode(HAL_GPIOB, HAL_GPIO_PIN_1, GPCFG_SPID0_MOSI);
+    halIoMuxSetMode(HAL_GPIOC, HAL_GPIO_PIN_9, GPCFG_SPID0_NCS);
+    halIoMuxSetMode(HAL_GPIOB, HAL_GPIO_PIN_0, GPCFG_SPID0_SCK);
+    halSpiConfig(HAL_SPI0, SPI_BaudRatePrescaler_16, 8, 0);
+}
+
+u16 eFlashReadDeviceID(void)
+{
+	u32 unID = 0;
+	u8 RxBuff[4] = {0};
+	u8 TxBuff[6] = {0x9F,0x00,0x00,0x00};
+
+#if 1
+    halSpiSend(HAL_SPI0, TxBuff, 1);
+    halSpiRecv(HAL_SPI0, RxBuff, 3);
+#else
+	SPI_SendAndReceiveData(SPI0, TxBuff, 3, RxBuff, 3);
+#endif
+
+	halPrintf("(1) %02x, %02x, %02x\n", RxBuff[0],RxBuff[1],RxBuff[2]);
+    SPI_SendAndReceiveData((SPIx_TypeDef) spiGroup(HAL_SPI0),  TxBuff,  1,  RxBuff,  3);
+    halPrintf("(2) %02x, %02x, %02x\n", RxBuff[0],RxBuff[1],RxBuff[2]);
+	unID = (RxBuff[0] << 32) + (RxBuff[1] << 16) + (RxBuff[2] << 8) + RxBuff[3];
+	return unID;
+}
+
+
+void testSpi(void)
+{
+    u8 i = 0;
+
+    halPrintf("<testSpi start>\n");
+
+#if 0
+    // 测试eFlash
+    eFlashIoInit();
+    eFlashReadDeviceID();
+#endif
+
+    // 测试LCD通讯
+#if 1
+    lcdIoInit();
+    init_lcd();
+    SPI_LCD_Test();
+#endif
+    halPrintf("<testSpi end>\n");
+}
+
+
Index: fw/hal/jinghongling/src/HalTimer/halTimer.c
===================================================================
--- /YC3121_SDK/fw/hal/jinghongling/src/HalTimer/halTimer.c	(revision 732)
+++ /YC3121_SDK/fw/hal/jinghongling/src/HalTimer/halTimer.c	(working copy)
@@ -1,43 +1,184 @@
+/*******************************************************************************
+文件名: <halTims.c>
+描  述: timer相关接口函数
+版  权:
+作  者: jqdeng
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改记录: 创建
+日期			修改人			修改内容
+2019.11.16		jqdeng				创建
+*******************************************************************************/
+
 #include "halTimer.h"
+#include "yc_timer.h"
+#include "yc_systick.h"
+
 
 volatile  uint32_t tick_Timer[9] = {0};
 
-void hal_TimerInit(void)
-{
 
-}
-void hal_TimerConfig(ST_TM_PARAM *tmr)
-{
+/*******************************************************************************
+函数功能: 在系统初始化时为timerwhen设置一些全局设置
+输入参数: 无
+输出参数: 无
+返回值: 无
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.16    jqdeng    创建
+*******************************************************************************/
+s32 halTimerInit(void)
+{
+	return HAL_ERROR;
+}
+
+/*******************************************************************************
+函数功能: 配置定时器
+输入参数: ptTimerParam：指向数据结构的指针 T_TIMER_PARAM
+输出参数: 无
+返回值: HAL_OK      成功
+        HAL_ERROR   失败
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.16    jqdeng    创建
+*******************************************************************************/
+s32 halTimerConfig(T_TIMER_PARAM *ptTimerParam)
+{
+#if 0
+    return HAL_ERROR;
+#else
 	TIM_InitTypeDef TIM_InitStruct;
 
-	TIM_InitStruct.period = tmr->perhald;
-	TIM_InitStruct.TIMx = (TIM_NumTypeDef)tmr->index;
+	TIM_InitStruct.period = ptTimerParam->perhald;
+	TIM_InitStruct.TIMx = (TIM_NumTypeDef)ptTimerParam->index;
 	TIM_Init(&TIM_InitStruct);
-}
-void hal_TimerStart(u32 index)
-{
-	TIM_Cmd((TIM_NumTypeDef)index,ENABLE);
-}
-void hal_TimerStop(u32 index)
-{
-	TIM_Cmd((TIM_NumTypeDef)index,DISABLE);
-}
 
-int hal_TimerGet(u32 index)
-{
-	return tick_Timer[index];
-}
-void hal_TimerLeft(ST_Timer_UNIT *timer)
-{
+    TIM_ModeConfig(ptTimerParam->index, TIM_Mode_TIMER);
 
+	return HAL_OK;
+#endif
 }
 
-int hal_GetSysTick(void)
-{
-	return SysTick_GetTick();
-}
+/*******************************************************************************
+函数功能: 启动定时器
+输入参数: eIndex：定时器索引
+输出参数: 无
+返回值: HAL_OK      成功
+        HAL_ERROR   失败
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.16    jqdeng    创建
+*******************************************************************************/
+s32 halTimerStart(E_TIMER_ID eIndex)
+{
+#if 0
+    return HAL_ERROR;
+#else
+	TIM_Cmd((TIM_NumTypeDef)eIndex, ENABLE);
+	return HAL_OK;
+#endif
+}
+
+/*******************************************************************************
+函数功能: 停止一个计时器
+输入参数: eIndex：定时器索引
+输出参数: 无
+返回值: HAL_OK      成功
+        HAL_ERROR   失败
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.16    jqdeng    创建
+*******************************************************************************/
+s32 halTimerStop(E_TIMER_ID eIndex)
+{
+#if 0
+    return HAL_ERROR;
+#else
+	TIM_Cmd((TIM_NumTypeDef)eIndex, DISABLE);
+	return HAL_OK;
+#endif
+}
+
+
+/*******************************************************************************
+函数功能: 设置一个软件计时器
+输入参数: ptTimerUnit：指向软件计时器的指针
+		  uiTimeout: 软件计时器重载值
+输出参数: 无
+返回值: HAL_OK      成功
+        HAL_ERROR   失败
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.16    jqdeng    创建
+*******************************************************************************/
+s32 halTimerGet(T_TIMER_UNIT *ptTimerUnit,u32 uiTimeout)
+{
+	return HAL_ERROR;
+}
+
+
+/*******************************************************************************
+函数功能: 查询软件计时器的剩余计数
+输入参数: ptTimerUnit：指向软件计时器的指针
+输出参数: 无
+返回值: HAL_OK      成功
+        HAL_ERROR   失败
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.16    jqdeng    创建
+*******************************************************************************/
+s32 halTimerLeft(T_TIMER_UNIT *ptTimerUnit)
+{
+	return HAL_ERROR;
+}
+
+/*******************************************************************************
+函数功能: 获取系统计时器的刻度值(以毫秒为单位)
+输入参数: 无
+输出参数: 无
+返回值: 系统计时器以毫秒为单位计时
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.16    jqdeng    创建
+*******************************************************************************/
+u32 halGetSysTick(void)
+{
+    return SysTick_GetTick();
+}
+
+
+//#############################################################################
+//############################################################## 测试函数
+
+// 定时器测试
+void testTimer(void)
+{
+    s32 iRet = 0;
+    T_TIMER_PARAM ptTimerParam;
+
+    halPrintf("<testTimer start>\n");
+
+    ptTimerParam.perhald = 20 * TIMER_RELOAD_1MS;
+    ptTimerParam.index = SYS_TM_4; // TIM4
+
+    // 初始化定时器
+    iRet = halTimerConfig(&ptTimerParam);
 
-uint32_t TIMM0_GetTick(uint32_t TIMx)
-{
-	return tick_Timer[TIMx];
+    // 启动定时器
+    iRet = halTimerStart(SYS_TM_4);
+
+    halEnableIrq(HAL_INTR_TMR4);
+
+    halPrintf("<testTimer end>\n");
 }
+
+
+
Index: fw/hal/jinghongling/src/HalTrng/halTrng.c
===================================================================
--- /YC3121_SDK/fw/hal/jinghongling/src/HalTrng/halTrng.c	(revision 732)
+++ /YC3121_SDK/fw/hal/jinghongling/src/HalTrng/halTrng.c	(working copy)
@@ -1,19 +1,61 @@
+/*******************************************************************************
+文件名: <halTrng.c>
+描  述: Trng相关接口函数
+版  权:
+作  者: jqdeng
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改记录: 创建
+日期			修改人			修改内容
+2019.11.16		jqdeng				创建
+*******************************************************************************/
+
 #include "halTrng.h"
+#include "..\core\yc3121.h"
+#include "..\sdk\yc_trng.h"
 
-void	hal_RandomInint(void)
+/*******************************************************************************
+函数功能: 初始化随机数
+输入参数: 无
+输出参数: 无
+返回值: 无
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.16    jqdeng    创建
+*******************************************************************************/
+s32 halRandomInit(void)
 {
-		TRNG_Init();
+    TRNG_Init();
+    //Disable_Trng(); // 20191226 
+    return HAL_OK;
 }
 
-
-void hal_GetRandom(u8 *random,u32 len)
+/*******************************************************************************
+函数功能: 得到随机数据
+输入参数:
+        len: 随机数据字节长度
+        random: 随机数据
+输出参数: 无
+返回值: 无
+--------------------------------------------------------------------------------
+备注  :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.16    jqdeng    创建
+*******************************************************************************/
+s32 halGetRandom(u8 *random, u32 len)
 {
-	if((NULL == random) || (len==0)) return;
 	int i,j;
 	int gettimes = len/16+1;
 	u8 buf[16] = {0};
 
-	TRNG_Init();
+	if((NULL == random) || (len==0))
+    {
+        return HAL_ERROR;
+    }
+
+    TRNG_Init();
 	for(j=0;j<gettimes;j++)
 	{
 		TRNG_Get((volatile unsigned long*)buf);
@@ -21,14 +63,32 @@
 		for(i=0; i<16;i++)
 		{
 			random[j*16+i] = buf[i];
-			if((j*16+i)==len) 
-			{	
-				Disable_Trng();
-
-				return;
-			}
+			if((j*16+i)==len)
+            {
+                break;
+            }
 		}
 	}
-	
-	Disable_Trng();
+
+    Disable_Trng();
+    return HAL_OK;
 }
+
+
+void testTrng(void)
+{
+    s32 iRet = 0;
+    u8 ucRandBuff[32] = {0};
+    u16 i = 0;
+
+    iRet = halRandomInit();
+
+    for (i=0; i<50; i++)
+    {
+        memset(ucRandBuff, 0x00, sizeof(ucRandBuff));
+        iRet = halGetRandom(ucRandBuff, 32);
+        halPrintf("halGetRandom iRet: %d\n", iRet);
+        halPrintfWithTitle(ucRandBuff, 32, "ucRandBuff");
+    }
+}
+
Index: fw/hal/jinghongling/src/Haluart/halUart.c
===================================================================
--- /YC3121_SDK/fw/hal/jinghongling/src/Haluart/halUart.c	(revision 732)
+++ /YC3121_SDK/fw/hal/jinghongling/src/Haluart/halUart.c	(working copy)
@@ -1,8 +1,8 @@
 /*******************************************************************************
 文件名: halUart.c
-描  述:
+描  述: 串口接口函数
 版  权:
-作  者: YJK
+作  者: jqdeng
 --------------------------------------------------------------------------------
 备注  : -
 --------------------------------------------------------------------------------
@@ -11,9 +11,121 @@
 2010/11/16	1.0		jqdeng			创建
 *******************************************************************************/
 #include "halUart.h"
-#include "yc_systick.h"
+#include "halGpio.h"
+#include "..\core\yc3121.h"
+#include "..\sdk\yc_uart.h"
+
+
+
+//#############################################################################
+//############################################################## 本地函数和内部声明
+
+#define HAL_UART_PARAM_UNSUPPORT            (0XFFFF) // 不支持的值
+
+/*******************************************************************************
+函数功能: E_UART_DATA_BIT枚举变量转换，转换到对应芯片内部枚举
+输入参数: eDataBit : JHL串口数据位枚举
+输出参数: 无
+返回值  : 对应芯片的串口数据位枚举值 (不支持返回 HAL_UART_PARAM_UNSUPPORT)
+--------------------------------------------------------------------------------
+备注    : YC3121只支持数据位8位、9位
+--------------------------------------------------------------------------------
+修改信息: 2019.11.26 jqdeng 创建
+*******************************************************************************/
+static u32 uartDataBit(E_UART_DATA_BIT eDataBit)
+{
+    u32 uiResult = HAL_UART_PARAM_UNSUPPORT;
+
+    switch (eDataBit)
+    {
+        case UART_DATA_5_BITS:
+            break;
+        case UART_DATA_6_BITS:
+            break;
+        case UART_DATA_7_BITS:
+            break;
+        case UART_DATA_8_BITS:
+            uiResult = Databits_8b;
+            break;
+//        case UART_DATA_9_BITS:
+//            uiResult = Databits_9b;
+//            break;
+        default:
+            break;
+    }
+
+    return uiResult;
+}
+
+/*******************************************************************************
+函数功能: E_UART_STOP_BIT枚举变量转换，转换到对应芯片内部枚举
+输入参数: eStopBit : JHL串口停止位枚举
+输出参数: 无
+返回值  : 对应芯片的串口停止位枚举值 (不支持返回 HAL_UART_PARAM_UNSUPPORT)
+--------------------------------------------------------------------------------
+备注    :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.26 jqdeng 创建
+*******************************************************************************/
+static u32 uartStopBit(E_UART_STOP_BIT eStopBit)
+{
+    u32 uiResult = HAL_UART_PARAM_UNSUPPORT;
+
+    switch (eStopBit)
+    {
+        case UART_STOP_BITS_1:
+            uiResult = StopBits_1;
+            break;
+        case UART_STOP_BITS_1_5:
+            break;
+        case UART_STOP_BITS_2:
+            uiResult = StopBits_2;
+            break;
+        default:
+            break;
+    }
+
+    return uiResult;
+}
+
+
+/*******************************************************************************
+函数功能: E_PARITY_TYPE 枚举变量转换，转换到对应芯片内部枚举
+输入参数: eParity : JHL串口校验位枚举
+输出参数: 无
+返回值  : 对应芯片的串口校验位枚举值 (不支持返回 HAL_UART_PARAM_UNSUPPORT)
+--------------------------------------------------------------------------------
+备注    :
+--------------------------------------------------------------------------------
+修改信息: 2019.11.26 jqdeng 创建
+*******************************************************************************/
+static u32 uartParityType(E_PARITY_TYPE eParity)
+{
+    u32 uiResult = HAL_UART_PARAM_UNSUPPORT;
+
+    switch (eParity)
+    {
+        case UART_PARITY_DISABLE:
+            uiResult = Parity_None;
+            break;
+        case UART_PARITY_EVEN:
+            uiResult = Parity_Even;
+            break;
+        case UART_PARITY_ODD:
+            uiResult = Parity_Odd;
+            break;
+        default:
+            break;
+    }
+
+    return uiResult;
+}
+
+
+//#############################################################################
+//############################################################## 外部函数
+
 
-#define RECV_TIMEOUT 30//ms
 
 
 /*******************************************************************************
@@ -30,14 +142,36 @@
 --------------------------------------------------------------------------------
 修改信息: 2019.11.16    jqdeng     创建
 *******************************************************************************/
-s32 halUartOpen(E_UART_INDEX eChannel, u32 uiBaud, E_UART_DATA_BIT eDataBit, E_PARITY_TYPE eParity, E_UART_STOP_BIT eStopBit)
+s32 halUartOpen(E_UART_INDEX eChannel, u32 uiBaud, E_UART_DATA_BIT eDataBit,
+            E_PARITY_TYPE eParity, E_UART_STOP_BIT eStopBit)
 {
 	UART_InitTypeDef UART_InitStruct;
+    u32 uiDataBit = 0;
+    u32 uiStopBit = 0;
+    u32 uiParity = 0;
+
+    uiDataBit = uartDataBit(eDataBit);
+    if (HAL_UART_PARAM_UNSUPPORT == uiDataBit)
+    {
+        return HAL_ERROR;
+    }
+
+    uiStopBit = uartStopBit(eStopBit);
+    if (HAL_UART_PARAM_UNSUPPORT == uiStopBit)
+    {
+        return HAL_ERROR;
+    }
+
+    uiParity = uartParityType(eParity);
+    if (HAL_UART_PARAM_UNSUPPORT == uiParity)
+    {
+        return HAL_ERROR;
+    }
 
 	UART_InitStruct.BaudRate = uiBaud;
-	UART_InitStruct.DataBits = eDataBit;
-	UART_InitStruct.StopBits = eStopBit;
-	UART_InitStruct.Parity = eParity;
+	UART_InitStruct.DataBits = (u8)(uiDataBit & 0xff);
+	UART_InitStruct.StopBits = (u8)(uiStopBit & 0xff);
+	UART_InitStruct.Parity = (u8)(uiParity & 0xff);
 	UART_InitStruct.FlowCtrl = FlowCtrl_None;
 	UART_InitStruct.Mode = Mode_duplex;
 
@@ -61,8 +195,17 @@
 *******************************************************************************/
 s32 halUartSend(E_UART_INDEX eChannel, u8 *pucBuf, u32 uiLen)
 {
-	MyPrintf("pubuf:%d\n", pucBuf);
-	UART_SendBuf((UART_TypeDef)eChannel, pucBuf, uiLen);
+#if 0
+    volatile u8 *pucTemp = NULL;
+    pucTemp = pucBuf;
+	UART_SendBuf((UART_TypeDef)eChannel, pucTemp, uiLen);
+#else
+	u32 i = 0;
+    for (i=0; i<uiLen; i++)
+    {
+        UART_SendData(eChannel, pucBuf[i]);
+    }
+#endif
 }
 
 /*******************************************************************************
@@ -71,7 +214,7 @@
           *pucBuf   指向缓存BUF的指针
           uiLen     期望接收的数据长度
 输出参数: 无
-返回值:   =0 成功   <0 失败
+返回值:   >0 实际接收数据长度   <0 失败
 --------------------------------------------------------------------------------
 备注  :   无
 --------------------------------------------------------------------------------
@@ -79,21 +222,42 @@
 *******************************************************************************/
 s32 halUartRecv(E_UART_INDEX eChannel, u8 *pucBuf, u32 uiLen)
 {
-	
-	MyPrintf("uiLen");
-	 tick StartTick;
-	
+	u32 uiTmpLen = 0;
+    u32 i = 0;
+    u16 ucCnt = 0;
+    u32 uiCurTicks = 0;
+    u32 uiRecLen = 0;
 
+    uiCurTicks = halGetSysTick();
+
+    while (1)
+    {
+        uiRecLen = UART_RecvBuf((UART_TypeDef)eChannel, pucBuf+uiTmpLen, uiLen);
+        if (uiRecLen)
+        {
+            uiCurTicks = halGetSysTick();
+        }
+
+        uiTmpLen += uiRecLen;
+        if (uiTmpLen >= uiLen)
+        {
+            break;
+        }
+
+        if ((halGetSysTick() - uiCurTicks) > 5)
+        {
+            break;
+        }
+    }
 
-	int tplen = UART_RecvBuf((UART_TypeDef)eChannel, pucBuf,uiLen);
-	StartTick = SysTick_GetTick();
-   do
-    {
-		if((tplen < uiLen))
-			tplen += UART_RecvBuf((UART_TypeDef)eChannel, pucBuf+tplen,uiLen - tplen);
-		
-    }while((!SysTick_IsTimeOut(StartTick,RECV_TIMEOUT)));
-	return tplen;
+    if (uiTmpLen)
+    {
+        return uiTmpLen;
+    }
+    else
+    {
+        return HAL_ERROR;
+    }
 }
 
 /*******************************************************************************
@@ -127,21 +291,37 @@
 
     return HAL_OK;
 }
-//void testGpio(void)
-//{
-//    u8 ucData = 0;
-
-//    halGpioInit(HAL_GPIOB, HAL_GPIO_PIN_1, HAL_GPIO_OUTPUT, HAL_GPIO_NOPULL);
-//    halGpioInit(HAL_GPIOB, HAL_GPIO_PIN_0, HAL_GPIO_OUTPUT, HAL_GPIO_NOPULL);
-//    while (1)
-//    {
-//        halGpioWritePin(HAL_GPIOB,HAL_GPIO_PIN_1, HAL_GPIO_RESET);
-//        halGpioWritePin(HAL_GPIOB,HAL_GPIO_PIN_0, HAL_GPIO_RESET);
-//        halMsDelay(500);
-
-//        halGpioWritePin(HAL_GPIOB,HAL_GPIO_PIN_1, HAL_GPIO_SET);
-//        halGpioWritePin(HAL_GPIOB,HAL_GPIO_PIN_0, HAL_GPIO_SET);
-//        halMsDelay(500);
-//    }
-//	}
+
+
+void testUart(E_UART_INDEX eChannel)
+{
+    s32 iRet = 0;
+    u8 ucSendBuff[256] = {0};
+    u8 i = 0;
+
+    halIoMuxSetMode(HAL_GPIOA, HAL_GPIO_PIN_1,GPCFG_UART0_TXD);
+    halIoMuxSetMode(HAL_GPIOA, HAL_GPIO_PIN_0,GPCFG_UART0_RXD);
+    iRet = halUartOpen(UART_PT0, 115200, UART_DATA_8_BITS, UART_PARITY_DISABLE, UART_STOP_BITS_1);
+
+#if 0
+    for (i=0; i<2; i++)
+    {
+        iRet = halUartSend(UART_PT0, "yc3121 power on\n", strlen("yc3121 power on\n"));
+        halMsDelay(200);
+    }
+
+    while (1)
+    {
+        iRet = halUartRecv(UART_PT0, ucSendBuff, 10);
+        if (iRet > 0)
+        {
+            halPrintf(">> ret : %d\n", iRet);
+            halPrintfWithTitle(ucSendBuff, iRet, "uart recv:");
+            memset(ucSendBuff, 0x00, sizeof(ucSendBuff));
+            //halMsDelay(500);
+        }
+    }
+#endif
+}
+
 
Index: fw/hal/jinghongling/锦弘霖安全芯片硬件抽象层接口规范V2.2_20200928.pdf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: fw/hal/jinghongling/锦弘霖安全芯片硬件抽象层接口规范V2.2_20200928.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
