2009-07-03 06:48:23 +08:00
|
|
|
/*
|
|
|
|
* File : rtthread.h
|
|
|
|
* This file is part of RT-Thread RTOS
|
2012-03-17 14:43:49 +08:00
|
|
|
* COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
|
2009-07-03 06:48:23 +08:00
|
|
|
*
|
2013-06-24 17:06:09 +08:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2009-07-03 06:48:23 +08:00
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2006-03-18 Bernard the first version
|
|
|
|
* 2006-04-26 Bernard add semaphore APIs
|
|
|
|
* 2006-08-10 Bernard add version information
|
|
|
|
* 2007-01-28 Bernard rename RT_OBJECT_Class_Static to RT_Object_Class_Static
|
|
|
|
* 2007-03-03 Bernard clean up the definitions to rtdef.h
|
2011-09-23 13:57:31 +08:00
|
|
|
* 2010-04-11 yi.qiu add module feature
|
2013-06-24 00:08:10 +08:00
|
|
|
* 2013-06-24 Bernard add rt_kprintf re-define when not use RT_USING_CONSOLE.
|
2009-07-03 06:48:23 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __RT_THREAD_H__
|
|
|
|
#define __RT_THREAD_H__
|
2013-06-30 20:17:41 +08:00
|
|
|
|
2014-01-11 16:37:13 +08:00
|
|
|
#include <rtconfig.h>
|
2011-06-12 18:01:48 +08:00
|
|
|
#include <rtdebug.h>
|
2014-01-11 16:37:13 +08:00
|
|
|
#include <rtdef.h>
|
2012-03-22 14:11:44 +08:00
|
|
|
#include <rtservice.h>
|
2012-10-05 16:44:10 +08:00
|
|
|
#include <rtm.h>
|
2009-07-03 06:48:23 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup KernelObject
|
|
|
|
*/
|
2012-03-17 14:43:49 +08:00
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
/*@{*/
|
2012-03-17 14:43:49 +08:00
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
/*
|
|
|
|
* kernel object interface
|
|
|
|
*/
|
|
|
|
void rt_system_object_init(void);
|
2012-09-05 13:36:08 +08:00
|
|
|
struct rt_object_information *
|
|
|
|
rt_object_get_information(enum rt_object_class_type type);
|
2012-09-07 14:48:02 +08:00
|
|
|
void rt_object_init(struct rt_object *object,
|
|
|
|
enum rt_object_class_type type,
|
|
|
|
const char *name);
|
2009-07-03 06:48:23 +08:00
|
|
|
void rt_object_detach(rt_object_t object);
|
2012-09-07 14:48:02 +08:00
|
|
|
rt_object_t rt_object_allocate(enum rt_object_class_type type,
|
|
|
|
const char *name);
|
2009-07-03 06:48:23 +08:00
|
|
|
void rt_object_delete(rt_object_t object);
|
2012-06-02 17:20:19 +08:00
|
|
|
rt_bool_t rt_object_is_systemobject(rt_object_t object);
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_object_t rt_object_find(const char *name, rt_uint8_t type);
|
2009-11-06 15:45:37 +08:00
|
|
|
|
|
|
|
#ifdef RT_USING_HOOK
|
2011-09-23 13:57:31 +08:00
|
|
|
void rt_object_attach_sethook(void (*hook)(struct rt_object *object));
|
|
|
|
void rt_object_detach_sethook(void (*hook)(struct rt_object *object));
|
|
|
|
void rt_object_trytake_sethook(void (*hook)(struct rt_object *object));
|
|
|
|
void rt_object_take_sethook(void (*hook)(struct rt_object *object));
|
|
|
|
void rt_object_put_sethook(void (*hook)(struct rt_object *object));
|
2009-11-06 15:45:37 +08:00
|
|
|
#endif
|
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
/*@}*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup Clock
|
|
|
|
*/
|
2012-03-17 14:43:49 +08:00
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
/*@{*/
|
2012-03-17 14:43:49 +08:00
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
/*
|
|
|
|
* clock & timer interface
|
|
|
|
*/
|
|
|
|
void rt_system_tick_init(void);
|
|
|
|
rt_tick_t rt_tick_get(void);
|
2011-06-29 22:45:35 +08:00
|
|
|
void rt_tick_set(rt_tick_t tick);
|
2009-07-03 06:48:23 +08:00
|
|
|
void rt_tick_increase(void);
|
|
|
|
rt_tick_t rt_tick_from_millisecond(rt_uint32_t ms);
|
|
|
|
|
|
|
|
void rt_system_timer_init(void);
|
2009-12-23 21:52:42 +08:00
|
|
|
void rt_system_timer_thread_init(void);
|
|
|
|
|
2012-09-05 13:36:08 +08:00
|
|
|
void rt_timer_init(rt_timer_t timer,
|
|
|
|
const char *name,
|
|
|
|
void (*timeout)(void *parameter),
|
|
|
|
void *parameter,
|
|
|
|
rt_tick_t time,
|
|
|
|
rt_uint8_t flag);
|
2009-07-03 06:48:23 +08:00
|
|
|
rt_err_t rt_timer_detach(rt_timer_t timer);
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_timer_t rt_timer_create(const char *name,
|
2012-09-05 13:36:08 +08:00
|
|
|
void (*timeout)(void *parameter),
|
|
|
|
void *parameter,
|
|
|
|
rt_tick_t time,
|
|
|
|
rt_uint8_t flag);
|
2009-07-03 06:48:23 +08:00
|
|
|
rt_err_t rt_timer_delete(rt_timer_t timer);
|
|
|
|
rt_err_t rt_timer_start(rt_timer_t timer);
|
|
|
|
rt_err_t rt_timer_stop(rt_timer_t timer);
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_err_t rt_timer_control(rt_timer_t timer, rt_uint8_t cmd, void *arg);
|
2009-11-06 15:45:37 +08:00
|
|
|
|
2012-06-12 07:38:28 +08:00
|
|
|
rt_tick_t rt_timer_next_timeout_tick(void);
|
|
|
|
void rt_timer_check(void);
|
|
|
|
|
2009-11-06 15:45:37 +08:00
|
|
|
#ifdef RT_USING_HOOK
|
2011-09-23 13:57:31 +08:00
|
|
|
void rt_timer_timeout_sethook(void (*hook)(struct rt_timer *timer));
|
2009-11-06 15:45:37 +08:00
|
|
|
#endif
|
2012-03-17 14:43:49 +08:00
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
/*@}*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup Thread
|
|
|
|
*/
|
2012-03-17 14:43:49 +08:00
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
/*@{*/
|
2012-03-17 14:43:49 +08:00
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
/*
|
|
|
|
* thread interface
|
|
|
|
*/
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_err_t rt_thread_init(struct rt_thread *thread,
|
2012-09-05 13:36:08 +08:00
|
|
|
const char *name,
|
|
|
|
void (*entry)(void *parameter),
|
|
|
|
void *parameter,
|
|
|
|
void *stack_start,
|
|
|
|
rt_uint32_t stack_size,
|
|
|
|
rt_uint8_t priority,
|
|
|
|
rt_uint32_t tick);
|
2010-04-20 09:09:07 +08:00
|
|
|
rt_err_t rt_thread_detach(rt_thread_t thread);
|
2012-09-07 14:48:02 +08:00
|
|
|
rt_thread_t rt_thread_create(const char *name,
|
2012-09-05 13:36:08 +08:00
|
|
|
void (*entry)(void *parameter),
|
2012-09-07 14:48:02 +08:00
|
|
|
void *parameter,
|
|
|
|
rt_uint32_t stack_size,
|
|
|
|
rt_uint8_t priority,
|
|
|
|
rt_uint32_t tick);
|
2010-04-20 09:09:07 +08:00
|
|
|
rt_thread_t rt_thread_self(void);
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_thread_t rt_thread_find(char *name);
|
2010-04-20 09:09:07 +08:00
|
|
|
rt_err_t rt_thread_startup(rt_thread_t thread);
|
|
|
|
rt_err_t rt_thread_delete(rt_thread_t thread);
|
|
|
|
|
|
|
|
rt_err_t rt_thread_yield(void);
|
|
|
|
rt_err_t rt_thread_delay(rt_tick_t tick);
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_err_t rt_thread_control(rt_thread_t thread, rt_uint8_t cmd, void *arg);
|
2010-04-20 09:09:07 +08:00
|
|
|
rt_err_t rt_thread_suspend(rt_thread_t thread);
|
|
|
|
rt_err_t rt_thread_resume(rt_thread_t thread);
|
2011-09-23 13:57:31 +08:00
|
|
|
void rt_thread_timeout(void *parameter);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* idle thread interface
|
|
|
|
*/
|
|
|
|
void rt_thread_idle_init(void);
|
|
|
|
#ifdef RT_USING_HOOK
|
|
|
|
void rt_thread_idle_sethook(void (*hook)(void));
|
|
|
|
#endif
|
2010-08-05 16:16:30 +08:00
|
|
|
void rt_thread_idle_excute(void);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* schedule service
|
|
|
|
*/
|
|
|
|
void rt_system_scheduler_init(void);
|
|
|
|
void rt_system_scheduler_start(void);
|
|
|
|
|
|
|
|
void rt_schedule(void);
|
2011-09-23 13:57:31 +08:00
|
|
|
void rt_schedule_insert_thread(struct rt_thread *thread);
|
|
|
|
void rt_schedule_remove_thread(struct rt_thread *thread);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
|
|
|
void rt_enter_critical(void);
|
|
|
|
void rt_exit_critical(void);
|
2013-12-21 11:24:37 +08:00
|
|
|
rt_uint16_t rt_critical_level(void);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
|
|
|
#ifdef RT_USING_HOOK
|
2009-12-04 17:37:14 +08:00
|
|
|
void rt_scheduler_sethook(void (*hook)(rt_thread_t from, rt_thread_t to));
|
2009-07-03 06:48:23 +08:00
|
|
|
#endif
|
2012-03-17 14:43:49 +08:00
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
/*@}*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup MM
|
|
|
|
*/
|
2012-03-17 14:43:49 +08:00
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
/*@{*/
|
2012-03-17 14:43:49 +08:00
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
/*
|
|
|
|
* memory management interface
|
|
|
|
*/
|
|
|
|
#ifdef RT_USING_MEMPOOL
|
|
|
|
/*
|
|
|
|
* memory pool interface
|
|
|
|
*/
|
2012-09-05 13:36:08 +08:00
|
|
|
rt_err_t rt_mp_init(struct rt_mempool *mp,
|
|
|
|
const char *name,
|
|
|
|
void *start,
|
|
|
|
rt_size_t size,
|
|
|
|
rt_size_t block_size);
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_err_t rt_mp_detach(struct rt_mempool *mp);
|
2012-09-05 13:36:08 +08:00
|
|
|
rt_mp_t rt_mp_create(const char *name,
|
|
|
|
rt_size_t block_count,
|
|
|
|
rt_size_t block_size);
|
2009-07-03 06:48:23 +08:00
|
|
|
rt_err_t rt_mp_delete(rt_mp_t mp);
|
|
|
|
|
2011-09-23 13:57:31 +08:00
|
|
|
void *rt_mp_alloc(rt_mp_t mp, rt_int32_t time);
|
|
|
|
void rt_mp_free(void *block);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
|
|
|
#ifdef RT_USING_HOOK
|
2011-09-23 13:57:31 +08:00
|
|
|
void rt_mp_alloc_sethook(void (*hook)(struct rt_mempool *mp, void *block));
|
|
|
|
void rt_mp_free_sethook(void (*hook)(struct rt_mempool *mp, void *block));
|
2009-07-03 06:48:23 +08:00
|
|
|
#endif
|
2012-03-17 14:43:49 +08:00
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RT_USING_HEAP
|
|
|
|
/*
|
|
|
|
* heap memory interface
|
|
|
|
*/
|
2011-09-23 13:57:31 +08:00
|
|
|
void rt_system_heap_init(void *begin_addr, void *end_addr);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2011-09-23 13:57:31 +08:00
|
|
|
void *rt_malloc(rt_size_t nbytes);
|
|
|
|
void rt_free(void *ptr);
|
|
|
|
void *rt_realloc(void *ptr, rt_size_t nbytes);
|
2009-10-11 13:43:15 +08:00
|
|
|
void *rt_calloc(rt_size_t count, rt_size_t size);
|
2012-03-17 14:43:49 +08:00
|
|
|
void *rt_malloc_align(rt_size_t size, rt_size_t align);
|
|
|
|
void rt_free_align(void *ptr);
|
2009-12-23 21:52:42 +08:00
|
|
|
|
2012-09-05 13:36:08 +08:00
|
|
|
void rt_memory_info(rt_uint32_t *total,
|
|
|
|
rt_uint32_t *used,
|
|
|
|
rt_uint32_t *max_used);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2011-08-15 22:05:41 +08:00
|
|
|
#ifdef RT_USING_SLAB
|
|
|
|
void *rt_page_alloc(rt_size_t npages);
|
|
|
|
void rt_page_free(void *addr, rt_size_t npages);
|
|
|
|
#endif
|
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
#ifdef RT_USING_HOOK
|
|
|
|
void rt_malloc_sethook(void (*hook)(void *ptr, rt_uint32_t size));
|
|
|
|
void rt_free_sethook(void (*hook)(void *ptr));
|
|
|
|
#endif
|
2010-10-28 09:21:47 +08:00
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
#endif
|
2012-03-17 14:43:49 +08:00
|
|
|
|
2012-04-14 11:52:56 +08:00
|
|
|
#ifdef RT_USING_MEMHEAP
|
|
|
|
/**
|
|
|
|
* memory heap object interface
|
|
|
|
*/
|
2012-09-05 13:36:08 +08:00
|
|
|
rt_err_t rt_memheap_init(struct rt_memheap *memheap,
|
|
|
|
const char *name,
|
|
|
|
void *start_addr,
|
|
|
|
rt_uint32_t size);
|
|
|
|
rt_err_t rt_memheap_detach(struct rt_memheap *heap);
|
|
|
|
void* rt_memheap_alloc(struct rt_memheap *heap, rt_uint32_t size);
|
2013-04-17 22:09:48 +08:00
|
|
|
void *rt_memheap_realloc(struct rt_memheap* heap, void* ptr, rt_size_t newsize);
|
2012-09-05 13:36:08 +08:00
|
|
|
void rt_memheap_free(void *ptr);
|
2012-04-14 11:52:56 +08:00
|
|
|
#endif
|
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
/*@}*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup IPC
|
|
|
|
*/
|
2012-03-17 14:43:49 +08:00
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
/*@{*/
|
2012-03-17 14:43:49 +08:00
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
#ifdef RT_USING_SEMAPHORE
|
|
|
|
/*
|
|
|
|
* semaphore interface
|
|
|
|
*/
|
2012-09-07 14:48:02 +08:00
|
|
|
rt_err_t rt_sem_init(rt_sem_t sem,
|
|
|
|
const char *name,
|
|
|
|
rt_uint32_t value,
|
|
|
|
rt_uint8_t flag);
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_err_t rt_sem_detach(rt_sem_t sem);
|
|
|
|
rt_sem_t rt_sem_create(const char *name, rt_uint32_t value, rt_uint8_t flag);
|
|
|
|
rt_err_t rt_sem_delete(rt_sem_t sem);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_err_t rt_sem_take(rt_sem_t sem, rt_int32_t time);
|
2009-07-03 06:48:23 +08:00
|
|
|
rt_err_t rt_sem_trytake(rt_sem_t sem);
|
|
|
|
rt_err_t rt_sem_release(rt_sem_t sem);
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_err_t rt_sem_control(rt_sem_t sem, rt_uint8_t cmd, void *arg);
|
2009-07-03 06:48:23 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RT_USING_MUTEX
|
|
|
|
/*
|
|
|
|
* mutex interface
|
|
|
|
*/
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_err_t rt_mutex_init(rt_mutex_t mutex, const char *name, rt_uint8_t flag);
|
|
|
|
rt_err_t rt_mutex_detach(rt_mutex_t mutex);
|
|
|
|
rt_mutex_t rt_mutex_create(const char *name, rt_uint8_t flag);
|
|
|
|
rt_err_t rt_mutex_delete(rt_mutex_t mutex);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_err_t rt_mutex_take(rt_mutex_t mutex, rt_int32_t time);
|
2009-07-03 06:48:23 +08:00
|
|
|
rt_err_t rt_mutex_release(rt_mutex_t mutex);
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_err_t rt_mutex_control(rt_mutex_t mutex, rt_uint8_t cmd, void *arg);
|
2009-07-03 06:48:23 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RT_USING_EVENT
|
|
|
|
/*
|
|
|
|
* event interface
|
|
|
|
*/
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_err_t rt_event_init(rt_event_t event, const char *name, rt_uint8_t flag);
|
2009-07-03 06:48:23 +08:00
|
|
|
rt_err_t rt_event_detach(rt_event_t event);
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_event_t rt_event_create(const char *name, rt_uint8_t flag);
|
|
|
|
rt_err_t rt_event_delete(rt_event_t event);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
|
|
|
rt_err_t rt_event_send(rt_event_t event, rt_uint32_t set);
|
2012-09-05 13:36:08 +08:00
|
|
|
rt_err_t rt_event_recv(rt_event_t event,
|
|
|
|
rt_uint32_t set,
|
|
|
|
rt_uint8_t opt,
|
|
|
|
rt_int32_t timeout,
|
|
|
|
rt_uint32_t *recved);
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_err_t rt_event_control(rt_event_t event, rt_uint8_t cmd, void *arg);
|
2009-07-03 06:48:23 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RT_USING_MAILBOX
|
|
|
|
/*
|
|
|
|
* mailbox interface
|
|
|
|
*/
|
2012-09-07 14:48:02 +08:00
|
|
|
rt_err_t rt_mb_init(rt_mailbox_t mb,
|
|
|
|
const char *name,
|
|
|
|
void *msgpool,
|
|
|
|
rt_size_t size,
|
|
|
|
rt_uint8_t flag);
|
2009-07-03 06:48:23 +08:00
|
|
|
rt_err_t rt_mb_detach(rt_mailbox_t mb);
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_mailbox_t rt_mb_create(const char *name, rt_size_t size, rt_uint8_t flag);
|
|
|
|
rt_err_t rt_mb_delete(rt_mailbox_t mb);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_err_t rt_mb_send(rt_mailbox_t mb, rt_uint32_t value);
|
2012-09-05 13:36:08 +08:00
|
|
|
rt_err_t rt_mb_send_wait(rt_mailbox_t mb,
|
|
|
|
rt_uint32_t value,
|
|
|
|
rt_int32_t timeout);
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_err_t rt_mb_recv(rt_mailbox_t mb, rt_uint32_t *value, rt_int32_t timeout);
|
|
|
|
rt_err_t rt_mb_control(rt_mailbox_t mb, rt_uint8_t cmd, void *arg);
|
2009-07-03 06:48:23 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RT_USING_MESSAGEQUEUE
|
|
|
|
/*
|
|
|
|
* message queue interface
|
|
|
|
*/
|
2012-09-05 13:36:08 +08:00
|
|
|
rt_err_t rt_mq_init(rt_mq_t mq,
|
|
|
|
const char *name,
|
|
|
|
void *msgpool,
|
|
|
|
rt_size_t msg_size,
|
|
|
|
rt_size_t pool_size,
|
|
|
|
rt_uint8_t flag);
|
2009-07-03 06:48:23 +08:00
|
|
|
rt_err_t rt_mq_detach(rt_mq_t mq);
|
2012-09-05 13:36:08 +08:00
|
|
|
rt_mq_t rt_mq_create(const char *name,
|
|
|
|
rt_size_t msg_size,
|
|
|
|
rt_size_t max_msgs,
|
|
|
|
rt_uint8_t flag);
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_err_t rt_mq_delete(rt_mq_t mq);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_err_t rt_mq_send(rt_mq_t mq, void *buffer, rt_size_t size);
|
|
|
|
rt_err_t rt_mq_urgent(rt_mq_t mq, void *buffer, rt_size_t size);
|
2012-09-07 14:48:02 +08:00
|
|
|
rt_err_t rt_mq_recv(rt_mq_t mq,
|
|
|
|
void *buffer,
|
|
|
|
rt_size_t size,
|
|
|
|
rt_int32_t timeout);
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_err_t rt_mq_control(rt_mq_t mq, rt_uint8_t cmd, void *arg);
|
2009-07-03 06:48:23 +08:00
|
|
|
#endif
|
2012-03-17 14:43:49 +08:00
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
/*@}*/
|
|
|
|
|
|
|
|
#ifdef RT_USING_DEVICE
|
|
|
|
/**
|
|
|
|
* @addtogroup Device
|
|
|
|
*/
|
2012-03-17 14:43:49 +08:00
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
/*@{*/
|
2012-03-17 14:43:49 +08:00
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
/*
|
|
|
|
* device (I/O) system interface
|
|
|
|
*/
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_device_t rt_device_find(const char *name);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2012-09-07 14:48:02 +08:00
|
|
|
rt_err_t rt_device_register(rt_device_t dev,
|
|
|
|
const char *name,
|
|
|
|
rt_uint16_t flags);
|
2009-07-03 06:48:23 +08:00
|
|
|
rt_err_t rt_device_unregister(rt_device_t dev);
|
|
|
|
rt_err_t rt_device_init_all(void);
|
|
|
|
|
2012-09-05 13:36:08 +08:00
|
|
|
rt_err_t
|
|
|
|
rt_device_set_rx_indicate(rt_device_t dev,
|
|
|
|
rt_err_t (*rx_ind)(rt_device_t dev, rt_size_t size));
|
|
|
|
rt_err_t
|
|
|
|
rt_device_set_tx_complete(rt_device_t dev,
|
|
|
|
rt_err_t (*tx_done)(rt_device_t dev, void *buffer));
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2010-05-04 07:17:25 +08:00
|
|
|
rt_err_t rt_device_init (rt_device_t dev);
|
2009-07-03 06:48:23 +08:00
|
|
|
rt_err_t rt_device_open (rt_device_t dev, rt_uint16_t oflag);
|
|
|
|
rt_err_t rt_device_close(rt_device_t dev);
|
2012-09-07 14:48:02 +08:00
|
|
|
rt_size_t rt_device_read (rt_device_t dev,
|
|
|
|
rt_off_t pos,
|
|
|
|
void *buffer,
|
|
|
|
rt_size_t size);
|
|
|
|
rt_size_t rt_device_write(rt_device_t dev,
|
|
|
|
rt_off_t pos,
|
|
|
|
const void *buffer,
|
|
|
|
rt_size_t size);
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_err_t rt_device_control(rt_device_t dev, rt_uint8_t cmd, void *arg);
|
2012-03-17 14:43:49 +08:00
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
/*@}*/
|
|
|
|
#endif
|
|
|
|
|
2010-09-13 09:16:10 +08:00
|
|
|
#ifdef RT_USING_MODULE
|
|
|
|
/**
|
|
|
|
* @addtogroup Module
|
|
|
|
*/
|
2012-03-17 14:43:49 +08:00
|
|
|
|
2010-09-13 09:16:10 +08:00
|
|
|
/*@{*/
|
2012-03-17 14:43:49 +08:00
|
|
|
|
2010-09-13 09:16:10 +08:00
|
|
|
/*
|
|
|
|
* module interface
|
|
|
|
*/
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_module_t rt_module_load(const char *name, void *module_ptr);
|
2010-09-13 09:16:10 +08:00
|
|
|
rt_err_t rt_module_unload(rt_module_t module);
|
2012-11-28 22:25:06 +08:00
|
|
|
#ifdef RT_USING_DFS
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_module_t rt_module_open(const char *filename);
|
2014-04-02 14:05:15 +08:00
|
|
|
rt_module_t rt_module_exec_cmd(const char *path, const char* cmd_line, int size);
|
2012-11-28 22:25:06 +08:00
|
|
|
#endif
|
2010-10-28 09:21:47 +08:00
|
|
|
void *rt_module_malloc(rt_size_t size);
|
|
|
|
void *rt_module_realloc(void *ptr, rt_size_t size);
|
|
|
|
void rt_module_free(rt_module_t module, void *addr);
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_module_t rt_module_self(void);
|
|
|
|
rt_module_t rt_module_find(const char *name);
|
2011-07-05 07:48:07 +08:00
|
|
|
|
|
|
|
#ifdef RT_USING_HOOK
|
|
|
|
void rt_module_load_sethook(void (*hook)(rt_module_t module));
|
|
|
|
void rt_module_unload_sethook(void (*hook)(rt_module_t module));
|
|
|
|
#endif
|
|
|
|
|
2014-03-11 15:44:35 +08:00
|
|
|
void rt_module_init_object_container(struct rt_module *module);
|
|
|
|
rt_err_t rt_module_destroy(rt_module_t module);
|
|
|
|
|
2015-03-22 09:06:48 +08:00
|
|
|
/*
|
|
|
|
* application module system initialization
|
|
|
|
*/
|
|
|
|
int rt_system_module_init(void);
|
|
|
|
|
2010-11-29 08:04:55 +08:00
|
|
|
/*@}*/
|
2012-03-17 14:43:49 +08:00
|
|
|
#endif
|
2013-06-24 17:06:09 +08:00
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
/*
|
|
|
|
* interrupt service
|
|
|
|
*/
|
2013-03-18 16:42:29 +08:00
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
/*
|
|
|
|
* rt_interrupt_enter and rt_interrupt_leave only can be called by BSP
|
|
|
|
*/
|
|
|
|
void rt_interrupt_enter(void);
|
|
|
|
void rt_interrupt_leave(void);
|
2012-03-17 14:43:49 +08:00
|
|
|
|
2011-06-15 07:59:42 +08:00
|
|
|
/*
|
|
|
|
* the number of nested interrupts.
|
|
|
|
*/
|
|
|
|
rt_uint8_t rt_interrupt_get_nest(void);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2015-03-22 09:06:48 +08:00
|
|
|
#ifdef RT_USING_COMPONENTS_INIT
|
|
|
|
void rt_components_init(void);
|
|
|
|
void rt_components_board_init(void);
|
|
|
|
#endif
|
2012-05-30 14:50:06 +08:00
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
/**
|
|
|
|
* @addtogroup KernelService
|
|
|
|
*/
|
2012-03-17 14:43:49 +08:00
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
/*@{*/
|
2012-03-17 14:43:49 +08:00
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
/*
|
|
|
|
* general kernel service
|
|
|
|
*/
|
2013-06-24 00:08:10 +08:00
|
|
|
#ifndef RT_USING_CONSOLE
|
|
|
|
#define rt_kprintf(...)
|
|
|
|
#else
|
2012-03-17 14:43:49 +08:00
|
|
|
void rt_kprintf(const char *fmt, ...);
|
2013-06-24 00:08:10 +08:00
|
|
|
#endif
|
2009-07-03 06:48:23 +08:00
|
|
|
rt_int32_t rt_vsprintf(char *dest, const char *format, va_list arg_ptr);
|
2013-09-23 11:27:48 +08:00
|
|
|
rt_int32_t rt_vsnprintf(char *buf, rt_size_t size, const char *fmt, va_list args);
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_int32_t rt_sprintf(char *buf ,const char *format, ...);
|
2010-04-12 00:44:54 +08:00
|
|
|
rt_int32_t rt_snprintf(char *buf, rt_size_t size, const char *format, ...);
|
|
|
|
|
2012-11-28 22:25:06 +08:00
|
|
|
#if defined(RT_USING_DEVICE) && defined(RT_USING_CONSOLE)
|
2011-09-23 13:57:31 +08:00
|
|
|
rt_device_t rt_console_set_device(const char *name);
|
2012-11-28 22:25:06 +08:00
|
|
|
rt_device_t rt_console_get_device(void);
|
2011-01-24 21:40:42 +08:00
|
|
|
#endif
|
2009-07-03 06:48:23 +08:00
|
|
|
|
|
|
|
rt_err_t rt_get_errno(void);
|
|
|
|
void rt_set_errno(rt_err_t no);
|
2011-08-28 23:57:10 +08:00
|
|
|
int *_rt_errno(void);
|
|
|
|
#ifndef RT_USING_NEWLIB
|
|
|
|
#ifndef errno
|
2012-09-05 13:36:08 +08:00
|
|
|
#define errno *_rt_errno()
|
2011-08-28 23:57:10 +08:00
|
|
|
#endif
|
|
|
|
#endif
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2011-09-23 13:57:31 +08:00
|
|
|
void *rt_memset(void *src, int c, rt_ubase_t n);
|
|
|
|
void *rt_memcpy(void *dest, const void *src, rt_ubase_t n);
|
2009-07-03 06:48:23 +08:00
|
|
|
|
2015-05-20 20:37:40 +08:00
|
|
|
rt_int32_t rt_strncmp(const char *cs, const char *ct, rt_ubase_t count);
|
|
|
|
rt_int32_t rt_strcmp (const char *cs, const char *ct);
|
|
|
|
rt_size_t rt_strlen (const char *src);
|
2009-07-03 06:48:23 +08:00
|
|
|
char *rt_strdup(const char *s);
|
|
|
|
|
2011-09-23 13:57:31 +08:00
|
|
|
char *rt_strstr(const char *str1, const char *str2);
|
|
|
|
rt_int32_t rt_sscanf(const char *buf, const char *fmt, ...);
|
2009-07-03 06:48:23 +08:00
|
|
|
char *rt_strncpy(char *dest, const char *src, rt_ubase_t n);
|
2011-09-23 13:57:31 +08:00
|
|
|
void *rt_memmove(void *dest, const void *src, rt_ubase_t n);
|
|
|
|
rt_int32_t rt_memcmp(const void *cs, const void *ct, rt_ubase_t count);
|
2009-07-03 06:48:23 +08:00
|
|
|
rt_uint32_t rt_strcasecmp(const char *a, const char *b);
|
|
|
|
|
|
|
|
void rt_show_version(void);
|
|
|
|
|
|
|
|
/*@}*/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2012-03-17 14:43:49 +08:00
|
|
|
|
2009-07-03 06:48:23 +08:00
|
|
|
#endif
|