Skip to content

Commit e67d6b6

Browse files
committed
Redefine the uint type in the at_rtos.h file to avoid the conflict in application SDK.
1 parent 0bc36d5 commit e67d6b6

31 files changed

+703
-698
lines changed

clock/clock_native_gcc.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
*/
1313
typedef struct {
1414
/* The last load count value */
15-
u32_t last_load;
15+
_u32_t last_load;
1616

1717
/* The clock time total count value */
18-
u32_t total;
18+
_u32_t total;
1919

2020
/* The clock time has reported count value */
21-
u32_t reported;
21+
_u32_t reported;
2222

2323
/* The hook function interface for clock time data pushing */
2424
time_report_handler_t pCallFunc;
2525

2626
/* The flag indicates the clock ctrl register enabled status */
27-
b_t ctrl_enabled;
27+
_b_t ctrl_enabled;
2828
} _clock_resource_t;
2929

3030
/**
@@ -37,18 +37,18 @@ static _clock_resource_t g_clock_resource = {0u};
3737
*
3838
* @return True if the clock wrap, otherwise return false
3939
*/
40-
static b_t _clock_isWrap(void)
40+
static _b_t _clock_isWrap(void)
4141
{
4242
/* Nothing need to do for kernel cmake sample build. */
43-
return FALSE;
43+
return false;
4444
}
4545

4646
/**
4747
* @brief Calculate the elapsed time.
4848
*
4949
* @return Value of the elapsed time.
5050
*/
51-
static u32_t _clock_elapsed(void)
51+
static _u32_t _clock_elapsed(void)
5252
{
5353
/* Nothing need to do for kernel cmake sample build. */
5454
return 0u;
@@ -59,7 +59,7 @@ static u32_t _clock_elapsed(void)
5959
*
6060
* @param Value of the elapsed time.
6161
*/
62-
static void _clock_time_elapsed_report(u32_t us)
62+
static void _clock_time_elapsed_report(_u32_t us)
6363
{
6464
if (g_clock_resource.pCallFunc) {
6565
g_clock_resource.pCallFunc(us);
@@ -79,7 +79,7 @@ void clock_isr(void)
7979
*
8080
* @param Value of the next timeout.
8181
*/
82-
void clock_time_interval_set(u32_t interval_us)
82+
void clock_time_interval_set(_u32_t interval_us)
8383
{
8484
/* Nothing need to do for kernel cmake sample build. */
8585
}
@@ -89,7 +89,7 @@ void clock_time_interval_set(u32_t interval_us)
8989
*
9090
* @return Value of the unreported elapse time.
9191
*/
92-
u32_t clock_time_elapsed_get(void)
92+
_u32_t clock_time_elapsed_get(void)
9393
{
9494
/* Nothing need to do for kernel cmake sample build. */
9595
return 0u;
@@ -100,7 +100,7 @@ u32_t clock_time_elapsed_get(void)
100100
*
101101
* @return Value of the current clock time.
102102
*/
103-
u32_t clock_time_get(void)
103+
_u32_t clock_time_get(void)
104104
{
105105
/* Nothing need to do for kernel cmake sample build. */
106106
return 0u;

clock/clock_systick.c

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
#include "ktype.h"
1212

1313
/* Convert the microsecond to clock count */
14-
#define _CONVERT_MICROSENCOND_TO_COUNT(us) ((u32_t)(us) * (PORTAL_SYSTEM_CORE_CLOCK_MHZ)-1u)
14+
#define _CONVERT_MICROSENCOND_TO_COUNT(us) ((_u32_t)(us) * (PORTAL_SYSTEM_CORE_CLOCK_MHZ)-1u)
1515

1616
/* Convert the clock count to microsecond */
17-
#define _CONVERT_COUNT_TO_MICROSENCOND(count) ((u32_t)(count) / (PORTAL_SYSTEM_CORE_CLOCK_MHZ))
17+
#define _CONVERT_COUNT_TO_MICROSENCOND(count) ((_u32_t)(count) / (PORTAL_SYSTEM_CORE_CLOCK_MHZ))
1818

1919
enum {
2020
/* The maximum timeout setting value */
@@ -32,19 +32,19 @@ enum {
3232
*/
3333
typedef struct {
3434
/* The last load count value */
35-
u32_t last_load;
35+
_u32_t last_load;
3636

3737
/* The clock time total count value */
38-
u32_t total;
38+
_u32_t total;
3939

4040
/* The clock time has reported count value */
41-
u32_t reported;
41+
_u32_t reported;
4242

4343
/* The hook function interface for clock time data pushing */
4444
time_report_handler_t pCallFunc;
4545

4646
/* The flag indicates the clock ctrl register enabled status */
47-
b_t ctrl_enabled;
47+
_b_t ctrl_enabled;
4848
} _clock_resource_t;
4949

5050
/**
@@ -57,28 +57,28 @@ static _clock_resource_t g_clock_resource = {0u};
5757
*
5858
* @return True if the clock wrap, otherwise return false
5959
*/
60-
static b_t _clock_isWrap(void)
60+
static _b_t _clock_isWrap(void)
6161
{
6262
if (SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) {
6363
g_clock_resource.total += g_clock_resource.last_load;
64-
return TRUE;
64+
return true;
6565
}
66-
return FALSE;
66+
return false;
6767
}
6868

6969
/**
7070
* @brief Calculate the elapsed time.
7171
*
7272
* @return Value of the elapsed time.
7373
*/
74-
static u32_t _clock_elapsed(void)
74+
static _u32_t _clock_elapsed(void)
7575
{
76-
u32_t expired = 0u;
76+
_u32_t expired = 0u;
7777

7878
/**
7979
* The elasped time has to calculate when no wrap occur.
8080
*/
81-
b_t previous, next = _clock_isWrap();
81+
_b_t previous, next = _clock_isWrap();
8282
do {
8383
previous = next;
8484
expired = g_clock_resource.last_load - SysTick->VAL;
@@ -93,7 +93,7 @@ static u32_t _clock_elapsed(void)
9393
*
9494
* @param Value of the elapsed time.
9595
*/
96-
static void _clock_time_elapsed_report(u32_t us)
96+
static void _clock_time_elapsed_report(_u32_t us)
9797
{
9898
if (g_clock_resource.pCallFunc) {
9999
g_clock_resource.pCallFunc(us);
@@ -108,13 +108,13 @@ void clock_isr(void)
108108
/**
109109
* For maintain purpose.
110110
*/
111-
u32_t total_count = _clock_elapsed();
111+
_u32_t total_count = _clock_elapsed();
112112
total_count += g_clock_resource.total;
113113

114114
/**
115115
* Avoid the count lost.
116116
*/
117-
u32_t elapsed_interval_us = _CONVERT_COUNT_TO_MICROSENCOND(total_count - g_clock_resource.reported);
117+
_u32_t elapsed_interval_us = _CONVERT_COUNT_TO_MICROSENCOND(total_count - g_clock_resource.reported);
118118
g_clock_resource.reported += _CONVERT_MICROSENCOND_TO_COUNT(elapsed_interval_us);
119119

120120
_clock_time_elapsed_report(elapsed_interval_us);
@@ -125,11 +125,11 @@ void clock_isr(void)
125125
*
126126
* @param Value of the next timeout.
127127
*/
128-
void clock_time_interval_set(u32_t interval_us)
128+
void clock_time_interval_set(_u32_t interval_us)
129129
{
130130
if (interval_us == OS_TIME_FOREVER_VAL) {
131131
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
132-
g_clock_resource.ctrl_enabled = FALSE;
132+
g_clock_resource.ctrl_enabled = false;
133133
return;
134134
} else if (!g_clock_resource.ctrl_enabled) {
135135
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
@@ -142,9 +142,9 @@ void clock_time_interval_set(u32_t interval_us)
142142
} else if (interval_us < _CLOCK_INTERVAL_MIN_US) {
143143
interval_us = _CLOCK_INTERVAL_MIN_US;
144144
}
145-
u32_t set_count = _CONVERT_MICROSENCOND_TO_COUNT(interval_us);
145+
_u32_t set_count = _CONVERT_MICROSENCOND_TO_COUNT(interval_us);
146146

147-
u32_t elapsed = _clock_elapsed();
147+
_u32_t elapsed = _clock_elapsed();
148148

149149
g_clock_resource.total += elapsed;
150150

@@ -154,12 +154,12 @@ void clock_time_interval_set(u32_t interval_us)
154154
* The following code helps to reduce the redundance time,
155155
* but it can't be fixed entirily
156156
*/
157-
u32_t last_load = g_clock_resource.last_load;
158-
u32_t before = SysTick->VAL;
157+
_u32_t last_load = g_clock_resource.last_load;
158+
_u32_t before = SysTick->VAL;
159159

160-
u32_t unreported = g_clock_resource.total - g_clock_resource.reported;
160+
_u32_t unreported = g_clock_resource.total - g_clock_resource.reported;
161161

162-
if ((i32_t)unreported < 0) {
162+
if ((_i32_t)unreported < 0) {
163163
g_clock_resource.last_load = _CONVERT_MICROSENCOND_TO_COUNT(100u);
164164
} else {
165165
if ((interval_us != _CLOCK_INTERVAL_MAX_US) && (set_count > unreported)) {
@@ -172,7 +172,7 @@ void clock_time_interval_set(u32_t interval_us)
172172
g_clock_resource.last_load = set_count;
173173
}
174174

175-
u32_t after = SysTick->VAL;
175+
_u32_t after = SysTick->VAL;
176176

177177
SysTick->LOAD = g_clock_resource.last_load;
178178
SysTick->VAL = 0;
@@ -192,11 +192,11 @@ void clock_time_interval_set(u32_t interval_us)
192192
*
193193
* @return Value of the unreported elapse time.
194194
*/
195-
u32_t clock_time_elapsed_get(void)
195+
_u32_t clock_time_elapsed_get(void)
196196
{
197197
PORT_ENTER_CRITICAL_SECTION();
198198

199-
u32_t us = _CONVERT_COUNT_TO_MICROSENCOND(_clock_elapsed() + g_clock_resource.total - g_clock_resource.reported);
199+
_u32_t us = _CONVERT_COUNT_TO_MICROSENCOND(_clock_elapsed() + g_clock_resource.total - g_clock_resource.reported);
200200

201201
PORT_EXIT_CRITICAL_SECTION();
202202

@@ -208,11 +208,11 @@ u32_t clock_time_elapsed_get(void)
208208
*
209209
* @return Value of the current clock time.
210210
*/
211-
u32_t clock_time_get(void)
211+
_u32_t clock_time_get(void)
212212
{
213213
PORT_ENTER_CRITICAL_SECTION();
214214

215-
u32_t us = _CONVERT_COUNT_TO_MICROSENCOND(g_clock_resource.total + _clock_elapsed());
215+
_u32_t us = _CONVERT_COUNT_TO_MICROSENCOND(g_clock_resource.total + _clock_elapsed());
216216

217217
PORT_EXIT_CRITICAL_SECTION();
218218

@@ -225,7 +225,7 @@ u32_t clock_time_get(void)
225225
void clock_time_enable(void)
226226
{
227227
if (!g_clock_resource.ctrl_enabled) {
228-
g_clock_resource.ctrl_enabled = TRUE;
228+
g_clock_resource.ctrl_enabled = true;
229229
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
230230
}
231231
}
@@ -247,7 +247,7 @@ void clock_time_init(time_report_handler_t pTime_function)
247247

248248
NVIC_SetPriority(SysTick_IRQn, 0xFFu);
249249
g_clock_resource.last_load = SysTick_LOAD_RELOAD_Msk;
250-
g_clock_resource.ctrl_enabled = TRUE;
250+
g_clock_resource.ctrl_enabled = true;
251251

252252
SysTick->CTRL = 0x0u;
253253
SysTick->LOAD = g_clock_resource.last_load;

include/clock_tick.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
/**
1313
* Function pointer structure for the clock tells how much time has passed.
1414
*/
15-
typedef void (*time_report_handler_t)(u32_t);
15+
typedef void (*time_report_handler_t)(_u32_t);
1616

1717
/**
1818
* The implement function lists for rtos kernel internal use.
1919
*/
2020
void clock_isr(void);
21-
void clock_time_interval_set(u32_t interval_us);
22-
u32_t clock_time_elapsed_get(void);
23-
u32_t clock_time_get(void);
21+
void clock_time_interval_set(_u32_t interval_us);
22+
_u32_t clock_time_elapsed_get(void);
23+
_u32_t clock_time_get(void);
2424
void clock_time_enable(void);
2525
void clock_time_disable(void);
2626
void clock_time_init(time_report_handler_t pTime_function);

include/kernel/at_rtos.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,30 @@
77
#ifndef _AT_RTOS_H_
88
#define _AT_RTOS_H_
99

10+
#define AT_RTOS_TYPE_API_DEFINE
11+
1012
#include "ktype.h"
1113
#include "kstruct.h"
1214
#include "configuration.h"
1315
#include "postcode.h"
1416
#include "trace.h"
1517
#include "init.h"
1618

19+
#if (OS_TYPEDEF_DEFAULT_ENABLED)
20+
typedef _char_t char_t;
21+
typedef _uchar_t uchar_t;
22+
typedef _u8_t u8_t;
23+
typedef _u16_t u16_t;
24+
typedef _u32_t u32_t;
25+
typedef _u64_t u64_t;
26+
typedef _i8_t i8_t;
27+
typedef _i16_t i16_t;
28+
typedef _i32_t i32_t;
29+
typedef _i64_t i64_t;
30+
typedef _b_t b_t;
31+
typedef _i32p_t i32p_t;
32+
#endif
33+
1734
#define OS_PC_OK (PC_OS_OK)
1835
#define OS_PC_TIMEOUT (PC_OS_WAIT_TIMEOUT)
1936
#define OS_PC_AVAILABLE (PC_OS_WAIT_AVAILABLE)
@@ -873,7 +890,7 @@ static inline void os_object_free_force(struct os_id id)
873890
}
874891

875892
/* It defined the AtOS extern symbol for convenience use, but it has extra memory consumption */
876-
#if (OS_API_ENABLE)
893+
#if (OS_API_ENABLED)
877894
typedef struct {
878895
os_thread_id_t (*thread_init)(u32_t *, u32_t, i16_t, pThread_entryFunc_t, const char_t *);
879896
i32p_t (*thread_sleep)(u32_t);

include/kernel/configuration.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
#include "atos_configuration.h"
1111
#include "build_version.h"
1212

13-
#define ENABLED (1u)
14-
#define DISABLED (0u)
15-
1613
#ifndef THREAD_RUNTIME_NUMBER_SUPPORTED
1714
#define THREAD_RUNTIME_NUMBER_SUPPORTED (1u)
1815
#endif
@@ -57,10 +54,6 @@
5754
#define PORTAL_SYSTEM_CLOCK_INTERVAL_MIN_US (50u)
5855
#endif
5956

60-
#ifndef AT_RTOS_USE_INTERNAL_IRQ_ENUM
61-
#define AT_RTOS_USE_INTERNAL_IRQ_ENUM (DISABLED)
62-
#endif
63-
6457
#ifndef STACK_ALIGN
6558
#define STACK_ALIGN (8u)
6659
#endif
@@ -86,8 +79,13 @@
8679
#endif
8780

8881
/* It defined the AtOS extern symbol for convenience use, but it has extra memory consumption */
89-
#ifndef OS_API_ENABLE
90-
#define OS_API_ENABLE (ENABLED)
82+
#ifndef OS_API_DISABLED
83+
#define OS_API_ENABLED (1)
84+
#endif
85+
86+
/* It defined the AtOS extern symbol typedef for convenience use, but it has extra memory consumption */
87+
#ifndef OS_TYPEDEF_DISABLED
88+
#define OS_TYPEDEF_DEFAULT_ENABLED (1)
9189
#endif
9290

9391
/* Configuration of the Cortex-M Processor and Core Peripherals.

0 commit comments

Comments
 (0)