mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-16 15:08:15 +08:00
修改了Web后台的部分界面,增加了HAmqtt中的总电量传感器,后台新增mqtt上报频率设置
This commit is contained in:
17
mico-os/MiCO/RTOS/mocOS/mico/mico.mk
Normal file
17
mico-os/MiCO/RTOS/mocOS/mico/mico.mk
Normal file
@@ -0,0 +1,17 @@
|
||||
#
|
||||
# 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 := MiCO_mocOS_Interface
|
||||
|
||||
GLOBAL_INCLUDES := .
|
||||
|
||||
$(NAME)_SOURCES := mico_rtos.c \
|
||||
../../mico_rtos_common.c
|
||||
|
||||
#$(NAME)_CFLAGS = $(COMPILER_SPECIFIC_PEDANTIC_CFLAGS)
|
||||
250
mico-os/MiCO/RTOS/mocOS/mico/mico_rtos.c
Normal file
250
mico-os/MiCO/RTOS/mocOS/mico/mico_rtos.c
Normal file
@@ -0,0 +1,250 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file mico_rtos.c
|
||||
* @author William Xu
|
||||
* @version V1.0.0
|
||||
* @date 05-Aug-2018
|
||||
* @brief This file provide the MiCO RTOS abstract layer functions.
|
||||
******************************************************************************
|
||||
*
|
||||
* 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 <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "moc_api.h"
|
||||
|
||||
/******************************************************
|
||||
* Macros
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Constants
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Enumerations
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Type Definitions
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Structures
|
||||
******************************************************/
|
||||
|
||||
|
||||
/******************************************************
|
||||
* Function Declarations
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Variables Definitions
|
||||
******************************************************/
|
||||
|
||||
extern const mico_api_t *lib_api_p;
|
||||
|
||||
static mico_time_t mico_time_offset = 0;
|
||||
|
||||
/******************************************************
|
||||
* Function Definitions
|
||||
******************************************************/
|
||||
|
||||
/* OS Layer*/
|
||||
OSStatus mico_rtos_create_thread( mico_thread_t* thread, uint8_t priority, const char* name, mico_thread_function_t function, uint32_t stack_size, mico_thread_arg_t arg )
|
||||
{
|
||||
return lib_api_p->mico_rtos_create_thread( thread, priority, name, function, stack_size, (void *)arg );
|
||||
}
|
||||
|
||||
OSStatus mico_rtos_delete_thread( mico_thread_t* thread )
|
||||
{
|
||||
return lib_api_p->mico_rtos_delete_thread( thread );
|
||||
}
|
||||
|
||||
void mico_rtos_suspend_thread(mico_thread_t* thread)
|
||||
{
|
||||
lib_api_p->mico_rtos_suspend_thread(thread);
|
||||
}
|
||||
|
||||
void mico_rtos_suspend_all_thread(void)
|
||||
{
|
||||
lib_api_p->mico_rtos_suspend_all_thread();
|
||||
}
|
||||
|
||||
long mico_rtos_resume_all_thread(void)
|
||||
{
|
||||
return lib_api_p->mico_rtos_resume_all_thread();
|
||||
}
|
||||
|
||||
OSStatus mico_rtos_thread_join( mico_thread_t* thread )
|
||||
{
|
||||
return lib_api_p->mico_rtos_thread_join(thread);
|
||||
}
|
||||
|
||||
OSStatus mico_rtos_thread_force_awake( mico_thread_t* thread )
|
||||
{
|
||||
return lib_api_p->mico_rtos_thread_force_awake(thread);
|
||||
}
|
||||
|
||||
bool mico_rtos_is_current_thread( mico_thread_t* thread )
|
||||
{
|
||||
return lib_api_p->mico_rtos_is_current_thread(thread);
|
||||
}
|
||||
|
||||
OSStatus mico_rtos_init_semaphore( mico_semaphore_t* semaphore, int count )
|
||||
{
|
||||
return lib_api_p->mico_rtos_init_semaphore(semaphore, count);
|
||||
}
|
||||
OSStatus mico_rtos_set_semaphore( mico_semaphore_t* semaphore )
|
||||
{
|
||||
return lib_api_p->mico_rtos_set_semaphore(semaphore);
|
||||
}
|
||||
OSStatus mico_rtos_get_semaphore( mico_semaphore_t* semaphore, uint32_t timeout_ms )
|
||||
{
|
||||
return lib_api_p->mico_rtos_get_semaphore(semaphore, timeout_ms);
|
||||
}
|
||||
OSStatus mico_rtos_deinit_semaphore( mico_semaphore_t* semaphore )
|
||||
{
|
||||
return lib_api_p->mico_rtos_deinit_semaphore(semaphore);
|
||||
}
|
||||
OSStatus mico_rtos_init_mutex( mico_mutex_t* mutex )
|
||||
{
|
||||
return lib_api_p->mico_rtos_init_mutex( mutex );
|
||||
}
|
||||
OSStatus mico_rtos_lock_mutex( mico_mutex_t* mutex )
|
||||
{
|
||||
return lib_api_p->mico_rtos_lock_mutex( mutex );
|
||||
}
|
||||
OSStatus mico_rtos_unlock_mutex( mico_mutex_t* mutex )
|
||||
{
|
||||
return lib_api_p->mico_rtos_unlock_mutex( mutex );
|
||||
}
|
||||
OSStatus mico_rtos_deinit_mutex( mico_mutex_t* mutex )
|
||||
{
|
||||
return lib_api_p->mico_rtos_deinit_mutex( mutex );
|
||||
}
|
||||
OSStatus mico_rtos_init_queue( mico_queue_t* queue, const char* name, uint32_t message_size, uint32_t number_of_messages )
|
||||
{
|
||||
return lib_api_p->mico_rtos_init_queue( queue, name, message_size, number_of_messages );
|
||||
}
|
||||
OSStatus mico_rtos_push_to_queue( mico_queue_t* queue, void* message, uint32_t timeout_ms )
|
||||
{
|
||||
return lib_api_p->mico_rtos_push_to_queue( queue, message, timeout_ms );
|
||||
}
|
||||
OSStatus mico_rtos_pop_from_queue( mico_queue_t* queue, void* message, uint32_t timeout_ms )
|
||||
{
|
||||
return lib_api_p->mico_rtos_pop_from_queue( queue, message, timeout_ms );
|
||||
}
|
||||
OSStatus mico_rtos_deinit_queue( mico_queue_t* queue )
|
||||
{
|
||||
return lib_api_p->mico_rtos_deinit_queue( queue );
|
||||
}
|
||||
bool mico_rtos_is_queue_empty( mico_queue_t* queue )
|
||||
{
|
||||
return lib_api_p->mico_rtos_is_queue_empty( queue );
|
||||
}
|
||||
bool mico_rtos_is_queue_full( mico_queue_t* queue )
|
||||
{
|
||||
return lib_api_p->mico_rtos_is_queue_full( queue );
|
||||
}
|
||||
|
||||
OSStatus mico_init_timer( mico_timer_t* timer, uint32_t time_ms, timer_handler_t function, void* arg )
|
||||
{
|
||||
return lib_api_p->mico_init_timer( timer, time_ms, function, arg );
|
||||
}
|
||||
OSStatus mico_start_timer( mico_timer_t* timer )
|
||||
{
|
||||
return lib_api_p->mico_start_timer( timer );
|
||||
}
|
||||
OSStatus mico_stop_timer( mico_timer_t* timer )
|
||||
{
|
||||
return lib_api_p->mico_stop_timer( timer );
|
||||
}
|
||||
OSStatus mico_reload_timer( mico_timer_t* timer )
|
||||
{
|
||||
return lib_api_p->mico_reload_timer( timer );
|
||||
}
|
||||
OSStatus mico_deinit_timer( mico_timer_t* timer )
|
||||
{
|
||||
return lib_api_p->mico_deinit_timer( timer );
|
||||
}
|
||||
bool mico_is_timer_running( mico_timer_t* timer )
|
||||
{
|
||||
return lib_api_p->mico_is_timer_running( timer );
|
||||
}
|
||||
int mico_create_event_fd(mico_event_t handle)
|
||||
{
|
||||
return lib_api_p->mico_create_event_fd(handle);
|
||||
}
|
||||
int mico_delete_event_fd(int fd)
|
||||
{
|
||||
return lib_api_p->mico_delete_event_fd(fd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets time in milliseconds since RTOS start
|
||||
*
|
||||
* @Note: since this is only 32 bits, it will roll over every 49 days, 17 hours.
|
||||
*
|
||||
* @returns Time in milliseconds since RTOS started.
|
||||
*/
|
||||
mico_time_t mico_rtos_get_time( void )
|
||||
{
|
||||
return lib_api_p->mico_get_time();
|
||||
}
|
||||
|
||||
OSStatus mico_time_get_time( mico_time_t* time_ptr )
|
||||
{
|
||||
*time_ptr = lib_api_p->mico_get_time( ) + mico_time_offset;
|
||||
return kNoErr;
|
||||
}
|
||||
|
||||
OSStatus mico_time_set_time( const mico_time_t* time_ptr )
|
||||
{
|
||||
mico_time_offset = *time_ptr - lib_api_p->mico_get_time( );
|
||||
return kNoErr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delay for a number of milliseconds
|
||||
*
|
||||
* Processing of this function depends on the minimum sleep
|
||||
* time resolution of the RTOS.
|
||||
* The current thread sleeps for the longest period possible which
|
||||
* is less than the delay required, then makes up the difference
|
||||
* with a tight loop
|
||||
*
|
||||
* @return OSStatus : kNoErr if delay was successful
|
||||
*
|
||||
*/
|
||||
OSStatus mico_rtos_delay_milliseconds( uint32_t num_ms )
|
||||
{
|
||||
lib_api_p->mico_thread_msleep(num_ms);
|
||||
return kNoErr;
|
||||
}
|
||||
|
||||
void *mico_malloc( size_t xWantedSize )
|
||||
{
|
||||
return lib_api_p->malloc(xWantedSize);
|
||||
}
|
||||
|
||||
void mico_free( void *pv )
|
||||
{
|
||||
lib_api_p->free(pv);
|
||||
}
|
||||
|
||||
void *mico_realloc( void *pv, size_t xWantedSize )
|
||||
{
|
||||
return lib_api_p->realloc(pv, xWantedSize);
|
||||
}
|
||||
|
||||
83
mico-os/MiCO/RTOS/mocOS/mico/rtos.h
Normal file
83
mico-os/MiCO/RTOS/mocOS/mico/rtos.h
Normal file
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file rtos.h
|
||||
* @author William Xu
|
||||
* @version V1.0.0
|
||||
* @date 05-Aug-2018
|
||||
* @brief This file provide the FreeRTOS system configurations.
|
||||
******************************************************************************
|
||||
*
|
||||
* 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
|
||||
|
||||
|
||||
/******************************************************
|
||||
* Macros
|
||||
******************************************************/
|
||||
|
||||
//#define MICO_PRIORITY_TO_NATIVE_PRIORITY(priority) (uint8_t)(RTOS_HIGHEST_PRIORITY - priority)
|
||||
//
|
||||
//#define MICO_GET_THREAD_HANDLE( thread ) (thread)
|
||||
//#define MICOD_GET_QUEUE_HANDLE( queue ) (queue)
|
||||
//
|
||||
//#define RTOS_HIGHER_PRIORTIY_THAN(x) (x < RTOS_HIGHEST_PRIORITY ? x+1 : RTOS_HIGHEST_PRIORITY)
|
||||
//#define RTOS_LOWER_PRIORTIY_THAN(x) (x > RTOS_LOWEST_PRIORITY ? x-1 : RTOS_LOWEST_PRIORITY)
|
||||
//#define RTOS_LOWEST_PRIORITY (0)
|
||||
//#define RTOS_HIGHEST_PRIORITY (configMAX_PRIORITIES-1)
|
||||
//#define RTOS_DEFAULT_THREAD_PRIORITY (1)
|
||||
|
||||
/******************************************************
|
||||
* Constants
|
||||
******************************************************/
|
||||
|
||||
/* Configuration of Built-in Worker Threads
|
||||
*
|
||||
* 1. mico_hardware_io_worker_thread is designed to handle deferred execution of quick, non-blocking hardware I/O operations.
|
||||
* - priority : higher than that of mico_networking_worker_thread
|
||||
* - stack size : small. Consequently, no printf is allowed here.
|
||||
* - event queue size : the events are quick; therefore, large queue isn't required.
|
||||
*
|
||||
* 2. mico_networking_worker_thread is designed to handle deferred execution of networking operations
|
||||
* - priority : lower to allow mico_hardware_io_worker_thread to preempt and run
|
||||
* - stack size : considerably larger than that of mico_hardware_io_worker_thread because of the networking functions.
|
||||
* - event queue size : larger than that of mico_hardware_io_worker_thread because networking operation may block
|
||||
*/
|
||||
#define HARDWARE_IO_WORKER_THREAD_STACK_SIZE (512)
|
||||
#define HARDWARE_IO_WORKER_THREAD_QUEUE_SIZE (10)
|
||||
|
||||
#define NETWORKING_WORKER_THREAD_STACK_SIZE (2 * 1024)
|
||||
#define NETWORKING_WORKER_THREAD_QUEUE_SIZE (15)
|
||||
|
||||
#define RTOS_NAME "mocOS"
|
||||
#define RTOS_VERSION mocOS_VERSION
|
||||
|
||||
/******************************************************
|
||||
* Enumerations
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Type Definitions
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Structures
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Global Variables
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Function Declarations
|
||||
******************************************************/
|
||||
|
||||
OSStatus init_timer_thread(void);
|
||||
Reference in New Issue
Block a user