/*******************************************************************************
 * (c) Copyright 2015 Microsemi Corporation.  All rights reserved.
 *
 *
 *
 * SVN $Revision: $
 * SVN $Date: $
 */

/*
 * osal.c
 *
 */

#include <stdio.h>
#include "osal.h"
#include <FreeRTOS.h>
#include <task.h>
//VR declaration of free, malloc


//#ifdef OS_IS_FREE_RTOS

osMutex_t	ts_printf_mutex		= NULL;
osMutex_t	ts_mem_mgnt_mutex	= NULL;

void * osCreateTimoutTimer(uint32_t tOutMilliSec, uint32_t	ID, osTimeoutCallback_t tOutCallback )
{
	void *	xTimerHandle;

	#ifndef API_FOR_WIN_HOST
		xTimerHandle = xTimerCreate( '\0',(portTickType)(tOutMilliSec/portTICK_RATE_MS ), pdFALSE, (void *) ID, tOutCallback);
		if (xTimerHandle != NULL)
		{
			if( xTimerStart(xTimerHandle, 0 ) != pdPASS )
				printf("Error Starting Timer\n");
		}
		else
			printf("Error Creating Timer\n");
	#else
			xTimerHandle = NULL;
	#endif
	return(xTimerHandle);
}

void init_ts_printf(void)
{
	if (ts_printf_mutex == NULL)
		ts_printf_mutex = osMutexCreate();
}

void init_ts_mem_mgnt(void)
{
	if (ts_mem_mgnt_mutex == NULL)
		ts_mem_mgnt_mutex = osMutexCreate();
}

void osTaskGetRunTimeStats( signed char *pcWriteBuffer )
{
	vTaskGetRunTimeStats(pcWriteBuffer);
}

void osTaskGetTaskStats( signed char *pcWriteBuffer )
{
	vTaskList(pcWriteBuffer);
}


//#endif
