mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-17 07:28:14 +08:00
修改了Web后台的部分界面,增加了HAmqtt中的总电量传感器,后台新增mqtt上报频率设置
This commit is contained in:
16
mico-os/platform/GCC/GCC.mk
Normal file
16
mico-os/platform/GCC/GCC.mk
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
# UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
# Copyright (c) 2016 MXCHIP Inc.
|
||||
#
|
||||
# The contents of this file may not be disclosed to third parties, copied or
|
||||
# duplicated in any form, in whole or in part, without the prior written
|
||||
# permission of MXCHIP Corporation.
|
||||
#
|
||||
|
||||
NAME := GCC
|
||||
|
||||
$(NAME)_SOURCES = mem_newlib.c math_newlib.c stdio_newlib.c time_newlib.c eabi.c
|
||||
|
||||
ifneq ($(filter $(subst ., ,$(COMPONENTS)),mocOS),)
|
||||
GLOBAL_LDFLAGS += -Wl,-wrap,_malloc_r -Wl,-wrap,free -Wl,-wrap,realloc -Wl,-wrap,malloc -Wl,-wrap,calloc -Wl,-wrap,_free_r -Wl,-wrap,_realloc_r #-Wl,-wrap,printf -Wl,-wrap,sprintf
|
||||
endif
|
||||
80
mico-os/platform/GCC/eabi.c
Normal file
80
mico-os/platform/GCC/eabi.c
Normal file
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
* Copyright (c) 2016 MXCHIP Inc.
|
||||
*
|
||||
* The contents of this file may not be disclosed to third parties, copied or
|
||||
* duplicated in any form, in whole or in part, without the prior written
|
||||
* permission of MXCHIP Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
//void* __dso_handle = 0;
|
||||
|
||||
/* Make this a weak symbol to avoid a multiple definition error when linking
|
||||
* with libstdc++-v3. */
|
||||
int __attribute__((weak))
|
||||
__aeabi_atexit (void *object, void (*destructor) (void *), void *dso_handle)
|
||||
{
|
||||
//return __cxa_atexit(destructor, object, dso_handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void __aeabi_memcpy8(void *dest, const void *src, size_t n) {
|
||||
memcpy(dest, src, n);
|
||||
}
|
||||
|
||||
void __aeabi_memcpy4(void *dest, const void *src, size_t n) {
|
||||
memcpy(dest, src, n);
|
||||
}
|
||||
|
||||
void __aeabi_memcpy(void *dest, const void *src, size_t n) {
|
||||
memcpy(dest, src, n);
|
||||
}
|
||||
|
||||
|
||||
void __aeabi_memmove8(void *dest, const void *src, size_t n) {
|
||||
memmove(dest, src, n);
|
||||
}
|
||||
|
||||
void __aeabi_memmove4(void *dest, const void *src, size_t n) {
|
||||
memmove(dest, src, n);
|
||||
}
|
||||
|
||||
void __aeabi_memmove(void *dest, const void *src, size_t n) {
|
||||
memmove(dest, src, n);
|
||||
}
|
||||
|
||||
/*
|
||||
* __aeabi_memset has the order of its second and third arguments reversed.
|
||||
* This allows __aeabi_memclr to tail-call __aeabi_memset
|
||||
*/
|
||||
|
||||
void __aeabi_memset8(void *dest, size_t n, int c) {
|
||||
memset(dest, c, n);
|
||||
}
|
||||
|
||||
void __aeabi_memset4(void *dest, size_t n, int c) {
|
||||
memset(dest, c, n);
|
||||
}
|
||||
|
||||
void __aeabi_memset(void *dest, size_t n, int c) {
|
||||
memset(dest, c, n);
|
||||
}
|
||||
|
||||
|
||||
void __aeabi_memclr8(void *dest, size_t n) {
|
||||
__aeabi_memset8(dest, n, 0);
|
||||
}
|
||||
|
||||
void __aeabi_memclr4(void *dest, size_t n) {
|
||||
__aeabi_memset4(dest, n, 0);
|
||||
}
|
||||
|
||||
void __aeabi_memclr(void *dest, size_t n) {
|
||||
__aeabi_memset(dest, n, 0);
|
||||
}
|
||||
|
||||
52
mico-os/platform/GCC/linker_symbols.h
Normal file
52
mico-os/platform/GCC/linker_symbols.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
* Copyright (c) 2016 MXCHIP Inc.
|
||||
*
|
||||
* The contents of this file may not be disclosed to third parties, copied or
|
||||
* duplicated in any form, in whole or in part, without the prior written
|
||||
* permission of MXCHIP Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/******************************************************
|
||||
* Macros
|
||||
******************************************************/
|
||||
#define ENTRY_ADDRESS (&Reset_Handler)
|
||||
|
||||
/******************************************************
|
||||
* Constants
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Enumerations
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Type Definitions
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Structures
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Global Variables
|
||||
******************************************************/
|
||||
//extern void* Reset_Handler;
|
||||
extern void Reset_Handler(void);
|
||||
extern void* link_stack_end;
|
||||
|
||||
/******************************************************
|
||||
* Function Declarations
|
||||
******************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C" */
|
||||
#endif
|
||||
76
mico-os/platform/GCC/math_newlib.c
Normal file
76
mico-os/platform/GCC/math_newlib.c
Normal file
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
* Copyright (c) 2016 MXCHIP Inc.
|
||||
*
|
||||
* The contents of this file may not be disclosed to third parties, copied or
|
||||
* duplicated in any form, in whole or in part, without the prior written
|
||||
* permission of MXCHIP Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Sine function
|
||||
*
|
||||
* Simple Taylor series approximation of sine function
|
||||
* Since Newlib doesn't contain one
|
||||
* see http://www.wolframalpha.com/input/?i=taylor+series+sin+x
|
||||
*
|
||||
* @param x : the value for which Sine will be computed
|
||||
*
|
||||
* @return the Sine of x
|
||||
*/
|
||||
#define PI (3.1415926)
|
||||
|
||||
double sin( double x )
|
||||
{
|
||||
int term = 1;
|
||||
double val = 0;
|
||||
|
||||
x -= ( (int) ( x / ( 2 * PI ) ) ) * 2 * PI;
|
||||
|
||||
if ( x > PI )
|
||||
{
|
||||
x -= 2 * PI;
|
||||
}
|
||||
if ( x < -PI )
|
||||
{
|
||||
x += 2 * PI;
|
||||
}
|
||||
|
||||
for ( term = 0; term < 6; term++ )
|
||||
{
|
||||
double multval = x;
|
||||
double denval = 1;
|
||||
int ex;
|
||||
for ( ex = 0; ex < ( term * 2 ); ex++ )
|
||||
{
|
||||
multval *= x;
|
||||
denval *= ( ex + 2 );
|
||||
}
|
||||
val += ( ( term % 2 == 1 ) ? -1 : 1 ) * multval / denval;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
/* Simple Taylor series approximation of natural logarithm function
|
||||
* see http://www.efunda.com/math/taylor_series/logarithmic.cfm
|
||||
*/
|
||||
|
||||
double log( double x )
|
||||
{
|
||||
int term = 1;
|
||||
double val = 0;
|
||||
|
||||
for ( term = 1; term < 5; term++ )
|
||||
{
|
||||
double multval = ( x - 1.0 ) / ( x + 1.0 );
|
||||
int ex;
|
||||
for ( ex = 0; ex < ( term * 2 - 2 ); ex++ )
|
||||
{
|
||||
multval *= multval;
|
||||
}
|
||||
val += multval / ( term * 2 - 1 );
|
||||
}
|
||||
return 2 * val;
|
||||
}
|
||||
188
mico-os/platform/GCC/mem_newlib.c
Normal file
188
mico-os/platform/GCC/mem_newlib.c
Normal file
@@ -0,0 +1,188 @@
|
||||
/**
|
||||
* UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
* Copyright (c) 2016 MXCHIP Inc.
|
||||
*
|
||||
* The contents of this file may not be disclosed to third parties, copied or
|
||||
* duplicated in any form, in whole or in part, without the prior written
|
||||
* permission of MXCHIP Corporation.
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* @file
|
||||
* Interface functions for Newlib libC implementation
|
||||
*/
|
||||
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/times.h>
|
||||
#include <sys/unistd.h>
|
||||
#include <malloc.h>
|
||||
|
||||
|
||||
//#include "platform.h"
|
||||
|
||||
extern char read_usart_blocking( void );
|
||||
extern void write_usart_blocking( char channel, char val );
|
||||
|
||||
#undef errno
|
||||
extern int errno;
|
||||
|
||||
struct mxchip_mallinfo {
|
||||
int num_of_chunks; /* number of free chunks */
|
||||
int total_memory; /* maximum total allocated space */
|
||||
int allocted_memory; /* total allocated space */
|
||||
int free_memory; /* total free space */
|
||||
};
|
||||
#if 1
|
||||
/* sbrk
|
||||
* Increase program data space.
|
||||
* Malloc and related functions depend on this
|
||||
*/
|
||||
extern unsigned char _heap[];
|
||||
extern unsigned char _eheap[];
|
||||
static unsigned char *sbrk_heap_top = _heap;
|
||||
caddr_t _sbrk( int incr )
|
||||
{
|
||||
unsigned char *prev_heap;
|
||||
|
||||
if ( sbrk_heap_top + incr > _eheap )
|
||||
{
|
||||
/* Out of dynamic memory heap space */
|
||||
errno = ENOMEM;
|
||||
return (caddr_t) -1;
|
||||
}
|
||||
prev_heap = sbrk_heap_top;
|
||||
|
||||
sbrk_heap_top += incr;
|
||||
|
||||
return (caddr_t) prev_heap;
|
||||
}
|
||||
|
||||
/* Override the default Newlib assert, since it tries to do printf stuff */
|
||||
|
||||
void __assert_func( const char * file, int line, const char * func, const char * failedexpr )
|
||||
{
|
||||
/* Assertion failed!
|
||||
*
|
||||
* To find out where this assert was triggered, either look up the call stack,
|
||||
* or inspect the file, line and function parameters
|
||||
*/
|
||||
|
||||
/* unused parameters */
|
||||
(void)file;
|
||||
(void)line;
|
||||
(void)func;
|
||||
(void)failedexpr;
|
||||
}
|
||||
|
||||
/*
|
||||
* These are needed for C++ programs. They shouldn't really be here, so let's just
|
||||
* hit a breakpoint when these functions are called.
|
||||
*/
|
||||
|
||||
#if 1
|
||||
|
||||
int _kill( int pid, int sig )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _getpid( )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int __data_GetMemChunk()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct mxchip_mallinfo *mxchip_memory_info(void);
|
||||
|
||||
#if defined (MOC) && ( MOC == 1 )
|
||||
#include "moc_api.h"
|
||||
extern mico_api_t *lib_api_p;
|
||||
|
||||
void * __wrap_malloc (size_t size)
|
||||
{
|
||||
return lib_api_p->malloc(size);
|
||||
}
|
||||
|
||||
void * __wrap__malloc_r (void *p, size_t size)
|
||||
{
|
||||
|
||||
return lib_api_p->malloc(size);
|
||||
}
|
||||
|
||||
void __wrap_free (void *pv)
|
||||
{
|
||||
lib_api_p->free(pv);
|
||||
}
|
||||
|
||||
|
||||
void * __wrap_calloc (size_t a, size_t b)
|
||||
{
|
||||
return lib_api_p->calloc(a, b);
|
||||
}
|
||||
|
||||
void * __wrap_realloc (void* pv, size_t size)
|
||||
{
|
||||
return lib_api_p->realloc(pv, size);
|
||||
}
|
||||
|
||||
|
||||
void __wrap__free_r (void *p, void *x)
|
||||
{
|
||||
lib_api_p->free(x);
|
||||
}
|
||||
|
||||
void* __wrap__realloc_r (void *p, void* x, size_t sz)
|
||||
{
|
||||
return realloc (x, sz);
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
struct mxchip_mallinfo* mico_memory_info(void)
|
||||
{
|
||||
struct mallinfo mi = mallinfo();
|
||||
static struct mxchip_mallinfo mico_memory;
|
||||
unsigned int total_mem = _eheap - _heap;
|
||||
|
||||
mico_memory.allocted_memory = mi.uordblks;
|
||||
mico_memory.free_memory = total_mem - mi.uordblks;
|
||||
mico_memory.num_of_chunks = mi.ordblks;
|
||||
mico_memory.total_memory = total_mem;
|
||||
return &mico_memory;
|
||||
}
|
||||
#endif // MOC
|
||||
|
||||
#else
|
||||
|
||||
caddr_t _sbrk( int incr )
|
||||
{
|
||||
return (caddr_t) -1;
|
||||
}
|
||||
|
||||
void _exit(int __status )
|
||||
{
|
||||
}
|
||||
|
||||
struct mxchip_mallinfo *mxchip_memory_info(void);
|
||||
|
||||
struct mxchip_mallinfo* mico_memory_info(void)
|
||||
{
|
||||
struct mallinfo mi = mallinfo();
|
||||
static struct mxchip_mallinfo mico_memory;
|
||||
// unsigned int total_mem = _eheap - _heap;
|
||||
|
||||
mico_memory.allocted_memory = mi.uordblks;
|
||||
//mico_memory.free_memory = total_mem - mi.uordblks;
|
||||
mico_memory.num_of_chunks = mi.ordblks;
|
||||
//mico_memory.total_memory = total_mem;
|
||||
return &mico_memory;
|
||||
}
|
||||
#endif
|
||||
96
mico-os/platform/GCC/platform_toolchain.h
Normal file
96
mico-os/platform/GCC/platform_toolchain.h
Normal file
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
* Copyright (c) 2016 MXCHIP Inc.
|
||||
*
|
||||
* The contents of this file may not be disclosed to third parties, copied or
|
||||
* duplicated in any form, in whole or in part, without the prior written
|
||||
* permission of MXCHIP Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/******************************************************
|
||||
* Macros
|
||||
******************************************************/
|
||||
|
||||
#ifndef WEAK
|
||||
#ifndef __MINGW32__
|
||||
#define WEAK __attribute__((weak))
|
||||
#else
|
||||
/* MinGW doesn't support weak */
|
||||
#define WEAK
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef USED
|
||||
#define USED __attribute__((used))
|
||||
#endif
|
||||
|
||||
#ifndef MAY_BE_UNUSED
|
||||
#define MAY_BE_UNUSED __attribute__((unused))
|
||||
#endif
|
||||
|
||||
#ifndef NORETURN
|
||||
#define NORETURN __attribute__((noreturn))
|
||||
#endif
|
||||
|
||||
#ifndef ALIGNED
|
||||
#define ALIGNED(size) __attribute__((aligned(size)))
|
||||
#endif
|
||||
|
||||
#ifndef SECTION
|
||||
#define SECTION(name) __attribute__((section(name)))
|
||||
#endif
|
||||
|
||||
#ifndef NEVER_INLINE
|
||||
#define NEVER_INLINE __attribute__((noinline))
|
||||
#endif
|
||||
|
||||
#ifndef ALWAYS_INLINE
|
||||
#define ALWAYS_INLINE __attribute__((always_inline))
|
||||
#endif
|
||||
|
||||
/******************************************************
|
||||
* Constants
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Enumerations
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Type Definitions
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Structures
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Global Variables
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Function Declarations
|
||||
******************************************************/
|
||||
|
||||
void *memrchr( const void *s, int c, size_t n );
|
||||
|
||||
|
||||
/* Windows doesn't come with support for strlcpy */
|
||||
#ifdef WIN32
|
||||
size_t strlcpy (char *dest, const char *src, size_t size);
|
||||
#endif /* WIN32 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
142
mico-os/platform/GCC/stdio_newlib.c
Normal file
142
mico-os/platform/GCC/stdio_newlib.c
Normal file
@@ -0,0 +1,142 @@
|
||||
/**
|
||||
* UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
* Copyright (c) 2016 MXCHIP Inc.
|
||||
*
|
||||
* The contents of this file may not be disclosed to third parties, copied or
|
||||
* duplicated in any form, in whole or in part, without the prior written
|
||||
* permission of MXCHIP Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* @file
|
||||
* Interface functions for Newlib libC implementation
|
||||
*/
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/times.h>
|
||||
#include <sys/unistd.h>
|
||||
#include "stdio_newlib.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#undef errno
|
||||
extern int errno;
|
||||
|
||||
|
||||
#ifndef EBADF
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
int _close( int file )
|
||||
{
|
||||
(void) file; /* unused parameter */
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _open(const char *name, int flags, int mode)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* fstat
|
||||
* Status of an open file. For consistency with other minimal implementations in these examples,
|
||||
* all files are regarded as character special devices.
|
||||
* The `sys/stat.h' header file required is distributed in the `include' subdirectory for this C library.
|
||||
*/
|
||||
|
||||
int _fstat( int file, struct stat *st )
|
||||
{
|
||||
(void) file; /* unused parameter */
|
||||
|
||||
st->st_mode = S_IFCHR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* isatty
|
||||
* Query whether output stream is a terminal. For consistency with the other minimal implementations,
|
||||
*/
|
||||
|
||||
int _isatty( int file )
|
||||
{
|
||||
switch ( file )
|
||||
{
|
||||
case STDOUT_FILENO:
|
||||
case STDERR_FILENO:
|
||||
case STDIN_FILENO:
|
||||
return 1;
|
||||
default:
|
||||
/* errno = ENOTTY; */
|
||||
errno = EBADF;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* lseek - Set position in a file. Minimal implementation: */
|
||||
|
||||
int _lseek( int file, int ptr, int dir )
|
||||
{
|
||||
(void) file; /* unused parameter */
|
||||
(void) ptr; /* unused parameter */
|
||||
(void) dir; /* unused parameter */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* read
|
||||
* Read a character to a file. `libc' subroutines will use this system routine for input from all files, including stdin
|
||||
* Returns -1 on error or blocks until the number of characters have been read.
|
||||
*/
|
||||
|
||||
int _read( int file, char *ptr, int len )
|
||||
{
|
||||
switch ( file )
|
||||
{
|
||||
case STDIN_FILENO:
|
||||
MicoUartRecv(STDIO_UART, ptr, len, 0xFFFFFFFF );
|
||||
break;
|
||||
default:
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
/* write
|
||||
* Write a character to a file. `libc' subroutines will use this system routine for output to all files, including stdout
|
||||
* Returns -1 on error or number of bytes sent
|
||||
*/
|
||||
|
||||
int _write( int file, char *ptr, int len )
|
||||
{
|
||||
char channel;
|
||||
switch ( file )
|
||||
{
|
||||
case STDOUT_FILENO: /*stdout*/
|
||||
channel = 0;
|
||||
break;
|
||||
case STDERR_FILENO: /* stderr */
|
||||
channel = 1;
|
||||
break;
|
||||
default:
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
UNUSED_PARAMETER( channel );
|
||||
#ifndef MICO_DISABLE_STDIO
|
||||
|
||||
MicoUartSend( STDIO_UART, (const char*)ptr, len );
|
||||
|
||||
#endif
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
39
mico-os/platform/GCC/stdio_newlib.h
Normal file
39
mico-os/platform/GCC/stdio_newlib.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
* Copyright (c) 2016 MXCHIP Inc.
|
||||
*
|
||||
* The contents of this file may not be disclosed to third parties, copied or
|
||||
* duplicated in any form, in whole or in part, without the prior written
|
||||
* permission of MXCHIP Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "stdint.h"
|
||||
#include "platform.h"
|
||||
#include "platform_config.h"
|
||||
|
||||
/** Transmit data on a UART interface
|
||||
*
|
||||
* @param uart : the UART interface
|
||||
* @param data : pointer to the start of data
|
||||
* @param size : number of bytes to transmit
|
||||
*
|
||||
* @return kNoErr : on success.
|
||||
* @return kGeneralErr : if an error occurred with any step
|
||||
*/
|
||||
int MicoUartSend( mico_uart_t uart, const void* data, uint32_t size );
|
||||
|
||||
|
||||
/** Receive data on a UART interface
|
||||
*
|
||||
* @param uart : the UART interface
|
||||
* @param data : pointer to the buffer which will store incoming data
|
||||
* @param size : number of bytes to receive
|
||||
* @param timeout : timeout in milisecond
|
||||
*
|
||||
* @return kNoErr : on success.
|
||||
* @return kGeneralErr : if an error occurred with any step
|
||||
*/
|
||||
int MicoUartRecv( mico_uart_t uart, void* data, uint32_t size, uint32_t timeout );
|
||||
|
||||
47
mico-os/platform/GCC/time_newlib.c
Normal file
47
mico-os/platform/GCC/time_newlib.c
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
* Copyright (c) 2016 MXCHIP Inc.
|
||||
*
|
||||
* The contents of this file may not be disclosed to third parties, copied or
|
||||
* duplicated in any form, in whole or in part, without the prior written
|
||||
* permission of MXCHIP Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "sys/time.h"
|
||||
#include "common.h"
|
||||
#include "mico_system.h"
|
||||
|
||||
int _gettimeofday( struct timeval * __p, void * __tz )
|
||||
{
|
||||
mico_utc_time_ms_t current_utc_time_ms = 0;
|
||||
uint64_t current_time_ns;
|
||||
mico_time_get_utc_time_ms( ¤t_utc_time_ms );
|
||||
|
||||
current_time_ns = mico_nanosecond_clock_value();
|
||||
__p->tv_sec = current_utc_time_ms / 1000;
|
||||
__p->tv_usec = ( current_utc_time_ms % 1000 ) * 1000 + ( current_time_ns / 1000 ) % 1000;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int gettimeofday( struct timeval *__restrict __p, void *__restrict __tz )
|
||||
{
|
||||
return _gettimeofday( __p, __tz );
|
||||
}
|
||||
|
||||
|
||||
time_t time(time_t *tloc)
|
||||
{
|
||||
mico_utc_time_ms_t current_utc_time_ms = 0;
|
||||
unsigned long long t;
|
||||
|
||||
mico_time_get_utc_time_ms( ¤t_utc_time_ms );
|
||||
|
||||
t = current_utc_time_ms / 1000;
|
||||
|
||||
if (tloc)
|
||||
*tloc = t ;
|
||||
|
||||
return t;
|
||||
}
|
||||
Reference in New Issue
Block a user