/*
 $License:
    Copyright (C) 2010 InvenSense Corporation, All Rights Reserved.
    Copyright (C) 2012 MBARI
 $
 */
/*******************************************************************************
 *
 * $Id: mlos_win32.c 4598 2011-01-25 19:33:13Z prao $
 *
 *******************************************************************************/

/**
 *  @defgroup MLOS
 *  @brief OS Interface for Persistor CF2
 *
 *  @{
 *      @file mlos.c
 *      @brief OS Interface.
 */

/* ------------- */
/* - Includes. - */
/* ------------- */

#include <mbariTypes.h>			/* MBARI type definitions	    */
#include <mbariConst.h>			/* MBARI constants		    */
#include <cfxbios.h>			/* Persistor BIOS definitions	    */
#include <cfxpico.h>			/* Persistor PicoDOS definitions    */
#include <stdlib.h>
#include <beds.h>			/* BEDS general definitions	    */	
#include <io.h>

#include "mlos.h"
#include "stdint_invensense.h"
#include "log.h"
#undef MPL_LOG_TAG
#define MPL_LOG_TAG "mlos_cf2"

/* -------------- */
/* - Functions. - */
/* -------------- */

/**
 *  @brief  Allocate space.
 *  @param  numBytes  
 *              number of bytes.
 *  @return pointer to allocated space.
 */
void *inv_malloc(unsigned int numBytes)
{
#pragma unused(numBytes)
    MPL_LOGE("inv_malloc should not be used!\n");
    return NULL;
}


/**
 *  @brief  Free allocated space.
 *  @param  ptr pointer to space to deallocate
 *  @return error code.
 */
inv_error_t inv_free(void *ptr)
{
    MPL_LOGE("inv_free should not be used!\n", ptr);
    return INV_SUCCESS;
}


/**
 *  @brief  open file
 *  @param  filename    name of the file to open.
 *  @return error code.
 */
FILE *inv_fopen(char *filename)
{
    MPL_LOGE("inv_fopen should not be used!\n", filename);
    return NULL;
}


/**
 *  @brief  close the file.
 *  @param  fp  handle to file to close.
 *  @return error code.
 */
void inv_fclose(FILE *fp)
{
    MPL_LOGE("inv_fclose should not be used!\n", fp);
    return;
}


/**
 *  @brief  Sleep function.
**/
void inv_sleep(int mSecs)
{
    RTCDelayMicroSeconds(((ulong)mSecs)*1000);
}


/**
 *  @brief  get system's internal tick count.
 *          Used for time reference.
 *  @return current tick count.
**/
unsigned long inv_get_tick_count(void)
{
    return(ioGetTick() * MS_PER_TICK);
}

/**
 *
 * MUTEX Stubs
 *
**/
inv_error_t inv_create_mutex(HANDLE *mutex) 
{
#pragma unused(mutex)
    return INV_SUCCESS;
}

inv_error_t inv_lock_mutex(HANDLE mutex)
{
#pragma unused(mutex)
    return INV_SUCCESS;
}

inv_error_t inv_unlock_mutex(HANDLE mutex)
{
#pragma unused(mutex)
    return INV_SUCCESS;
}

inv_error_t inv_destroy_mutex(HANDLE mutex)
{
#pragma unused(mutex)
    return INV_SUCCESS;
}

  /**********************/
 /** @} */ /* defgroup */
/**********************/


