Ucos_ii2.52 source code

Source: Internet
Author: User

Ucos_ii2.52 source code

 

Ucos_ii2.52 is a perfect embedded development system. It is a good choice to embed the UCOS system and add your own source code on the basis of learning arm, at present, there are already a large number of UCOS embedded cases in the market, especially in arm and DSP Applications, has become a mainstream, although compared with other embedded systems, UCOS is not perfect, such as no memory allocation and few task levels. But it is an embedded operating system with short code, clear organization, real-time performance, and high security performance.

 

Compared with the 2.8 tasks in version 256, ucos_ii2.52 has a relatively small number of tasks, but is currently the most widely used version, which can meet our basic requirements, in addition, a lot of message processing is added, especially in terms of priority, which has incomparable advantages. I tried to read the source code of eCos but still failed, there is also the idea of challenging the source code of linux0.01, so I can't help but succumb to it. For UCOS, many beginners are a good news, because it has very few codes, in addition, he can directly refer to Beibei's books. His books explain the structure in extreme Xian detail.

 

In the whole process of learning UCOS, the understanding of E is a fatal blow, because my E level is poor, but UCOS still gave me the motivation to try, adding Chinese Decoding Based on the author's source code is also a very good choice. I believe there are a lot of people in China and me. The Chinese annotation is for the source code, it has a high understanding value and can fully understand the true meaning of UCOS in a very short time.

The entire translation process lasted for four months. Every winter in lunar December, I sat in front of the computer, constantly reading the books of teacher Bay to understand the entire UCOS, and translating each source code one by one, it is also a matter of courage, but many variables in e-wen translation cannot be fully understood. Therefore, there are many incorrect translations in the translation process, the errors caused by this problem can be corrected by the reader. I believe that you will be familiar with all kinds of difficulties.

 

For me with financial embarrassment, I tried to sell some materials to support my family. However, this practice is not realistic at all. Many readers may be like me and get used to free-of-charge materials, it also has a deep sense of hate for disguised charges. After thinking a lot, I decided to contribute it, so that more people can (more easily) Understand UCOS and contribute their own strength.

 

I hope that more people will join in this kind of high learning atmosphere and share with us one day before the source code of the complete U series, I wish you all an early realization of your dreams.

 

 

/*
**************************************** **************************************** *****************
* UC/OS-II real-time control kernel
* Main include files
* File: ucos_ii.h UCOS internal function parameter settings
* Author: Jean J. labrosse
* Chinese annotation: Zhong changwei zhongcw @ 126.com: 1.0 please respect the original content
**************************************** **************************************** *****************
*/

/*
**************************************** **************************************** *****************
* Mixed settings
**************************************** **************************************** *****************
*/

# Define OS _version 251 // define the uC/OS-II version
 
# Ifdef OS _globals // If OS _globals has been declared and defined, the code will be compiled immediately.
# Define OS _ext // define OS _ext
# Else
# Define OS _ext extern // otherwise, OS _ext is defined as extern
# Endif

# Ifndef false // whether to define false
# Define false 0 // If yes, the value of false is 0.
# Endif

# Ifndef true // whether to define true
# Define true 1 // define true as 1 If yes
# Endif

# Define OS _prio_self 0xff // define OS _prio_self as 0xff
# If OS _task_stat_en> 0
# Define OS _n_sys_tasks 2 // task system number
# Else
# Define OS _n_sys_tasks 1
# Endif

# Define OS _stat_prio (OS _lowest_prio-1) // statistics task priority
# Define OS _idle_prio (OS _lowest_prio) // idle task priority

# Define OS _event_tbl_size (OS _lowest_prio)/8 + 1) // event list bytes
# Define OS _rdy_tbl_size (OS _lowest_prio)/8 + 1) // ready list bytes

# Define OS _task_idle_id 65535/* I. D. Numbers for idle and stat tasks */
# Define OS _task_stat_id 65534

# Define
OS _event_en (OS _q_en> 0) & (OS _max_qs> 0) |
(OS _mbox_en> 0) | (OS _sem_en> 0) | (OS _mutex_en> 0 ))

/* $ Page */
/*
**************************************** **************************************** *************************
* Task status: Task status (defined in ostcbstat in bytes)
**************************************** **************************************** *************************
*/
# Define OS _stat_rdy 0x00 // (enter the task status word) in the completed status
# Define OS _stat_sem 0x01 // (State word of the task) in the SEM state
# Define OS _stat_mbox 0x02 // (State word of the task) in mbox status
# Define OS _stat_q 0x04 // (set the task status to Q)
# Define OS _stat_suspend 0x08 // indicates that the task is suspended.
# Define OS _stat_mutex 0x10 // (State word of the task) in the mutex state
# Define OS _stat_flag 0x20 // (set the task status to flag)

/*
**************************************** **************************************** *************************
* Event type (OS _event types)
**************************************** **************************************** *************************
*/
# Define OS _event_type_unused 0 // define the event type (no event type ------------ 0)
# Define OS _event_type_mbox 1 // define the event type (the email address is a digital sequence -------- 1)
# Define OS _event_type_q 2 // define the event type (message queue is a digital sequence ---- 2)
# Define OS _event_type_sem 3 // define the event type (semaphores are numerical sequences ------ 3)
# Define OS _event_type_mutex 4 // define the event type (mutex semaphores are numerical sequences 4)
# Define OS _event_type_flag 5 // define the event type (the event flag group is a numerical sequence -- 5)

/*
**************************************** **************************************** *************************
* Event flags)
**************************************** **************************************** *************************
*/
# Define OS _flag_wait_clr_all 0 // defines 0 for all specified event flag spaces ------ 0
# Define OS _flag_wait_clr_and 0 // same as above

# Define OS _flag_wait_clr_any 1 // define any specified event flag clearance 0 ------ 1
# Define OS _flag_wait_clr_or 1 // same as above

# Define OS _flag_wait_set_all 2 // define all specified event flag positions 1 ------ 2
# Define OS _flag_wait_set_and 2 // same as above

# Define OS _flag_wait_set_any 3 // define any specified event flag location 1 ------ 3
# Define OS _flag_wait_set_or 3 // same as above

// If you need to restore the event flag after obtaining the expected flag, add this constant

# Define OS _flag_consume 0x80 // defines the constant OS _flag_consume as 0x80

# Define OS _flag_clr 0 // define OS _flag_clr as clear 0
# Define OS _flag_set 1 // define OS _flag_set as 1

/*
**************************************** **************************************** *************************
* The setting word is in 'opt' and applies to ossemdel (), osmboxdel (), osqdel (), and osmutexdel () functions.
**************************************** **************************************** *************************
*/
# Define OS _del_no_pend 0 // you can delete a semaphore only when no task is waiting for the semaphore.
# Define OS _del_always 1 // Delete the semaphore immediately regardless of whether a task is waiting for the semaphore.

/*
**************************************** **************************************** *************************
* OS ??? Postopt () Options (settings)
*
* This setting applies to the osmboxpostopt () and osqpostopt () functions.
**************************************** **************************************** *************************
*/
# Define OS _post_opt_none 0x00 // send a message (or email) to a task waiting for a message
# Define OS _post_opt_broadcast 0x01 // send messages to all tasks waiting for queue messages */
# Define OS _post_opt_front 0x02 // send messages in the FIFO mode (simulate osqpostfront ())

/*
**************************************** **************************************** *************************
* Set task options (view ostaskcreateext ())
**************************************** **************************************** *************************
*/
# Define OS _task_opt_stk_chk 0x0001 // determines whether to perform a job stack check
# Define OS _task_opt_stk_clr 0x0002 // determines whether to clear the stack
# Define OS _task_opt_save_fp 0x0004 // determines whether to save the value of the floating point register. This operation is only performed when the processor has a floating point hard-
// Valid. The Save operation is completed by hardware-related code.
/*
**************************************** **************************************** *************************
* Error code: Error Codes
**************************************** **************************************** *************************
*/
# Define OS _no_err 0 // The function returns success;

# Define OS _err_event_type 1 // It is not a pointer to the event (related) type;
# Define OS _err_pend_isr 2 // call various OS signal class accept () functions in the interrupt service subroutine.
# Define OS _err_post_null_ptr 3 // The user issues a null pointer. According to the rules, null pointers are not supported here;
# Define OS _err_pevent_null 4 // 'pevent' indicates a null pointer;
# Define OS _err_post_isr 5 // try to call the osmutexpost () function [release a mutex] In the interrupt service subroutine;
# Define OS _err_query_isr 6 // try to call osmutexquery () in the interrupt subroutine [obtain the current mutex status information]
# Define OS _err_invalid_opt 7 // The defined opt parameter is invalid;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.