#include "sr_log.h"
#include "sr_config.h"
#include "sr_shell.h"
#include "sr_osal.h"


#include "luat_debug.h"


#if  0
static int _MyLogTest(int argc, char *argv[])
{
    int ret = 0;
	float volt SR_ALIGN(8) =0;
	
	double vf2 __attribute__((aligned(8))) =3.14261;
	int cnt= 10;

	SR_PRINTF("address：volt=%x  vf2=%x\r\n",&volt,&vf2);

	SR_PRINTF("value=%f  %d\r\n",0.2,100);

	LUAT_DEBUG_PRINT("value=%f %d\r\n",0.2,100);
	
	SR_PRINTF("value=%f %lf\r\n",volt,vf2);

	LUAT_DEBUG_PRINT("value=%f %lf\r\n",volt,vf2);
	

	SR_PRINTF("value=%f \r\n",1.5);

	LUAT_DEBUG_PRINT("value=%f \r\n",1.5);

	SR_PRINTF("value=%lf \r\n",8.21732);

	LUAT_DEBUG_PRINT("value=%lf \r\n",8.21732);

	SR_PRINTF("value=%lf \r\n",8.217324);

	LUAT_DEBUG_PRINT("value=%lf \r\n",8.217322);

	volt=0;
	
	
	while(cnt--)
	{

		SR_PRINTF("[STK] prop report,volt=%f ret=%d\r\n",volt,ret);

		LUAT_DEBUG_PRINT("[STK] prop report,volt=%f ret=%d\r\n",volt,ret);
	
	     volt += 0.001;

	     osDelay(1000);

	}

	

    return 0;
}
SR_SHELL_CMD_EXPORT(logTest, _MyLogTest);

#endif

static int _MyLogTest(int argc, char *argv[])
{
    int ret = 0;
	float volt = 3.1415;
	
	double vf2 =8.1426123;

	//float volt  = 3.1415;
	
	//double vf2  = 8.1426123;

	
	LUAT_DEBUG_PRINT("[LOG]addr: volt(%d)  vf2(%d)\r\n",&volt,&vf2);


	LUAT_DEBUG_PRINT("[LOG]value1: volt=%f  vf2=%lf\r\n",volt,vf2);
		

	LUAT_DEBUG_PRINT("[LOG]value2:%f   %d\r\n",1.5,100);

    return 0;
}
SR_SHELL_CMD_EXPORT(logTest, _MyLogTest);


#if  0
static void _cmsisThd(void *args)
{
    int ret = 0;
	float volt = 3.1415;
	
	double vf2 =8.1426123;


	while(gShellThreadRun)
	{
		LUAT_DEBUG_PRINT("[CMSIS]addr: volt(%d)  vf2(%d)\r\n",&volt,&vf2);


	    LUAT_DEBUG_PRINT("[CMSIS]value1: volt=%f  vf2=%lf\r\n",volt,vf2);
		

	    LUAT_DEBUG_PRINT("[CMSIS]value2:%f   %d\r\n",1.5,100);

		osDelay(5000);

	}
	
	osThreadExit();
    
}


StaticTask_t  myTCM;

uint8_t myStack[512] __attribute__((aligned(4)));;

//static int _cmsisThdTest(int argc, char *argv[])
static void _cmsisThdTest(void)

{
	osThreadId_t  stkThread=SR_NULL;
	
	const osThreadAttr_t threadAttr = 
	{
	  .stack_size = 512,	
	  .stack_mem = myStack,
	  .cb_mem = &myTCM,
	  .cb_size = sizeof(StaticTask_t),
	};

	gShellThreadRun =1;


	//SR_OsEnterCritical();

	osThreadSuspendAll();
	stkThread = osThreadNew(_cmsisThd, SR_NULL, SR_NULL);
	osThreadResumeAll();
	//SR_OsExitCritical();
	//return 0;
}
//SR_SHELL_CMD_EXPORT(cmsisThd, _cmsisThdTest);
#endif





