Skip to content

Commit 377217c

Browse files
committed
CoOS 1.12 and 1.1.6 (latest), and FreeRTOS 8.2.1
Ported FreeRTOS 8.2.1 by finding the changes in the 7.0.1 version and carrying them over. Then found an almost working port of CoOS, and corrected it to work, and then carried the changes to 1.1.6 Tested all of them with USBSerial, GPIO, SPI, DMA and a DMA ISR all working fine. Similar examples ported to all of them.
1 parent e13b9a0 commit 377217c

22 files changed

Lines changed: 8233 additions & 0 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
*******************************************************************************
3+
* @file OsTime.c
4+
* @version V1.1.6
5+
* @date 2014.05.23
6+
* @brief Header file related to time management
7+
* @details Thie file including some data declare related to time managment.
8+
*******************************************************************************
9+
* @copy
10+
*
11+
* Redistribution and use in source and binary forms, with or without
12+
* modification, are permitted provided that the following conditions
13+
* are met:
14+
*
15+
* * Redistributions of source code must retain the above copyright
16+
* notice, this list of conditions and the following disclaimer.
17+
* * Redistributions in binary form must reproduce the above copyright
18+
* notice, this list of conditions and the following disclaimer in the
19+
* documentation and/or other materials provided with the distribution.
20+
* * Neither the name of the <ORGANIZATION> nor the names of its
21+
* contributors may be used to endorse or promote products derived
22+
* from this software without specific prior written permission.
23+
*
24+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
34+
* THE POSSIBILITY OF SUCH DAMAGE.
35+
*
36+
* <h2><center>&copy; COPYRIGHT 2014 CooCox </center></h2>
37+
*******************************************************************************
38+
*/
39+
40+
#ifndef _TIME_H
41+
#define _TIME_H
42+
43+
/*---------------------------- Variable declare ------------------------------*/
44+
extern P_OSTCB DlyList; /*!< A pointer to ther delay list. */
45+
46+
/*---------------------------- Function declare ------------------------------*/
47+
extern void TimeDispose(void); /*!< Time dispose function. */
48+
extern void isr_TimeDispose(void);
49+
extern void RemoveDelayList(P_OSTCB ptcb);
50+
extern void InsertDelayList(P_OSTCB ptcb,U32 ticks);
51+
#endif
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/**
2+
*******************************************************************************
3+
* @file OsTimer.h
4+
* @version V1.1.6
5+
* @date 2014.05.23
6+
* @brief Timer manage header file
7+
* @details This file including some declares and defines related to timer
8+
* management.
9+
*******************************************************************************
10+
* @copy
11+
*
12+
* Redistribution and use in source and binary forms, with or without
13+
* modification, are permitted provided that the following conditions
14+
* are met:
15+
*
16+
* * Redistributions of source code must retain the above copyright
17+
* notice, this list of conditions and the following disclaimer.
18+
* * Redistributions in binary form must reproduce the above copyright
19+
* notice, this list of conditions and the following disclaimer in the
20+
* documentation and/or other materials provided with the distribution.
21+
* * Neither the name of the <ORGANIZATION> nor the names of its
22+
* contributors may be used to endorse or promote products derived
23+
* from this software without specific prior written permission.
24+
*
25+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
35+
* THE POSSIBILITY OF SUCH DAMAGE.
36+
*
37+
* <h2><center>&copy; COPYRIGHT 2014 CooCox </center></h2>
38+
*******************************************************************************
39+
*/
40+
41+
#ifndef _TIMER_H
42+
#define _TIMER_H
43+
44+
#define TMR_STATE_RUNNING 0 /*!< Timer State: Running */
45+
#define TMR_STATE_STOPPED 1 /*!< Timer State: Stopped */
46+
47+
/**
48+
* @struct tmrCtrl timer.h
49+
* @brief Timer control block
50+
* @details This struct is use to manage user timer.
51+
*
52+
*/
53+
typedef struct tmrCtrl /* Timer Control Block Define. */
54+
{
55+
OS_TCID tmrID; /*!< Timer ID. */
56+
U8 tmrType; /*!< Timer Type. */
57+
U8 tmrState; /*!< Timer State. */
58+
U32 tmrCnt; /*!< Timer Counter. */
59+
U32 tmrReload; /*!< Timer Reload Counter Value. */
60+
vFUNCPtr tmrCallBack; /*!< Call-back Function When Timer overrun. */
61+
struct tmrCtrl* tmrNext; /*!< Point to Next Timer Control Block. */
62+
struct tmrCtrl* tmrPrev; /*!< Point to Previous Timer Control Block*/
63+
64+
}TmrCtrl,*P_TmrCtrl;
65+
66+
/*---------------------------- Variable declare ------------------------------*/
67+
extern P_TmrCtrl TmrList; /*!< A pointer to the timer list. */
68+
extern U32 TmrIDVessel;
69+
/*---------------------------- Function declare ------------------------------*/
70+
extern void TmrDispose(void); /*!< Timer counter function. */
71+
extern void isr_TmrDispose(void);
72+
#endif
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
/**
2+
*******************************************************************************
3+
* @file arch.c
4+
* @version V1.1.6
5+
* @date 2014.05.23
6+
* @brief This file provides InitTaskContext() and SysTick_Handler().
7+
*******************************************************************************
8+
* @copy
9+
* Redistribution and use in source and binary forms, with or without
10+
* modification, are permitted provided that the following conditions
11+
* are met:
12+
*
13+
* * Redistributions of source code must retain the above copyright
14+
* notice, this list of conditions and the following disclaimer.
15+
* * Redistributions in binary form must reproduce the above copyright
16+
* notice, this list of conditions and the following disclaimer in the
17+
* documentation and/or other materials provided with the distribution.
18+
* * Neither the name of the <ORGANIZATION> nor the names of its
19+
* contributors may be used to endorse or promote products derived
20+
* from this software without specific prior written permission.
21+
*
22+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32+
* THE POSSIBILITY OF SUCH DAMAGE.
33+
*
34+
* <h2><center>&copy; COPYRIGHT 2014 CooCox </center></h2>
35+
*******************************************************************************
36+
*/
37+
38+
/*---------------------------- Include ---------------------------------------*/
39+
#include <coocox.h>
40+
U64 OSTickCnt = 0; /*!< Current system tick counter */
41+
42+
/**
43+
******************************************************************************
44+
* @brief Initial task context
45+
* @param[in] task Entry point of task.
46+
* @param[in] param The parameter pass to task.
47+
* @param[in] pstk The pointer to stack top.
48+
* @param[out] None
49+
* @retval Returns location of new stack top.
50+
*
51+
* @par Description
52+
* @details This function is called to initialize the stack frame of the
53+
* task being created.
54+
******************************************************************************
55+
*/
56+
OS_STK *InitTaskContext(FUNCPtr task,void *param,OS_STK *pstk)
57+
{
58+
OS_STK *context;
59+
context = pstk;
60+
#if CFG_CHIP_TYPE == 3
61+
context = context - 18;
62+
#endif
63+
*(context--) = (U32)0x01000000L; /* xPSR */
64+
*(context--) = (U32)task; /* Entry point of task. */
65+
*(context) = (U32)0xFFFFFFFEL;
66+
context = context - 5;
67+
*(context) = (U32)param; /* R0: argument */
68+
context = context - 8;
69+
#if CFG_CHIP_TYPE == 3
70+
context = context - 16;
71+
#endif
72+
// *(--context) = 0xfffffffd; /* LR */
73+
74+
return (context); /* Returns location of new stack top. */
75+
}
76+
77+
78+
79+
/**
80+
*******************************************************************************
81+
* @brief System tick interrupt handler.
82+
* @param[in] None
83+
* @param[out] None
84+
* @retval None
85+
*
86+
* @par Description
87+
* @details This is system tick interrupt headler.
88+
* @note CoOS may schedule when exiting this ISR.
89+
*******************************************************************************
90+
*/
91+
void CoSysTick_Handler(void)
92+
{
93+
OSSchedLock++; /* Lock scheduler. */
94+
OSTickCnt++; /* Increment systerm time. */
95+
#if CFG_TASK_WAITTING_EN >0
96+
if(DlyList != Co_NULL) /* Have task in delay list? */
97+
{
98+
if(DlyList->delayTick > 1) /* Delay time > 1? */
99+
{
100+
DlyList->delayTick--; /* Decrease delay time of the list head. */
101+
}
102+
else
103+
{
104+
DlyList->delayTick = 0;
105+
isr_TimeDispose(); /* Call hander for delay time list */
106+
}
107+
}
108+
#endif
109+
110+
#if CFG_TMR_EN > 0
111+
if(TmrList != Co_NULL) /* Have timer in working? */
112+
{
113+
if(TmrList->tmrCnt > 1) /* Timer time > 1? */
114+
{
115+
TmrList->tmrCnt--; /* Decrease timer time of the list head. */
116+
}
117+
else
118+
{
119+
TmrList->tmrCnt = 0;
120+
isr_TmrDispose(); /* Call hander for timer list */
121+
}
122+
}
123+
#endif
124+
TaskSchedReq = Co_TRUE;
125+
OsSchedUnlock();
126+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/**
2+
*******************************************************************************
3+
* @file coocox.h
4+
* @version V1.1.6
5+
* @date 2014.05.23
6+
* @brief Gather for all header file of CooCox CoOS.
7+
*******************************************************************************
8+
* @copy
9+
*
10+
* Redistribution and use in source and binary forms, with or without
11+
* modification, are permitted provided that the following conditions
12+
* are met:
13+
*
14+
* * Redistributions of source code must retain the above copyright
15+
* notice, this list of conditions and the following disclaimer.
16+
* * Redistributions in binary form must reproduce the above copyright
17+
* notice, this list of conditions and the following disclaimer in the
18+
* documentation and/or other materials provided with the distribution.
19+
* * Neither the name of the <ORGANIZATION> nor the names of its
20+
* contributors may be used to endorse or promote products derived
21+
* from this software without specific prior written permission.
22+
*
23+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
33+
* THE POSSIBILITY OF SUCH DAMAGE.
34+
*
35+
* <h2><center>&copy; COPYRIGHT 2014 CooCox </center></h2>
36+
*******************************************************************************
37+
*/
38+
39+
40+
#ifndef _COOCOX_H
41+
#define _COOCOX_H
42+
43+
#define OS_VERSION (U16)0x0114 /*!< OS version.(format: Vx.xx),
44+
e.g. value 0x0114 is version V1.14*/
45+
/*---------------------------- Include ---------------------------------------*/
46+
#include "CoOS.h"
47+
#include "OsArch.h"
48+
#include "OsCore.h"
49+
#include "OsTask.h"
50+
#include "OsServiceReq.h"
51+
#include "OsError.h"
52+
#include "OsTime.h"
53+
54+
55+
#if CFG_TMR_EN > 0
56+
#include "OsTimer.h"
57+
#endif
58+
59+
#if CFG_KHEAP_EN > 0
60+
#include "OsKernelHeap.h"
61+
#endif
62+
63+
#if CFG_MM_EN >0
64+
#include "OsMM.h"
65+
#endif
66+
67+
#if CFG_EVENT_EN > 0
68+
#include "OsEvent.h"
69+
#endif
70+
71+
#if CFG_MUTEX_EN > 0
72+
#include "OsMutex.h"
73+
#endif
74+
75+
#if CFG_QUEUE_EN > 0
76+
#include "OsQueue.h"
77+
#endif
78+
79+
#if CFG_FLAG_EN > 0
80+
#include "OsFlag.h"
81+
#endif
82+
83+
#endif /* _COOCOX_H */

0 commit comments

Comments
 (0)