tinyOS  v1.00
内核核心

tinyOS 内核核心支持代码 More...

Macros

#define TICKS_PER_SEC   (1000 / TINYOS_SYSTICK_MS)
 
#define NVIC_INT_CTRL   0xE000ED04
 
#define NVIC_PENDSVSET   0x10000000
 
#define NVIC_SYSPRI2   0xE000ED22
 
#define NVIC_PENDSV_PRI   0x000000FF
 
#define MEM32(addr)   *(volatile unsigned long *)(addr)
 
#define MEM8(addr)   *(volatile unsigned char *)(addr)
 

Typedefs

typedef enum _tError tError
 
typedef uint32_t tTaskCritical_t
 

Enumerations

enum  _tError {
  tErrorNoError = 0, tErrorTimeout, tErrorResourceUnavaliable, tErrorDel,
  tErrorResourceFull, tErrorOwner
}
 

Functions

tTasktTaskHighestReady (void)
 获取当前最高优先级且可运行的任务 More...
 
void tTaskSchedInit (void)
 初始化调度器 More...
 
void tTaskSchedDisable (void)
 禁止任务调度 More...
 
void tTaskSchedEnable (void)
 允许任务调度 More...
 
void tTaskSchedRdy (tTask *task)
 将任务设置为就绪状态 More...
 
void tTaskSchedUnRdy (tTask *task)
 将任务从就绪列表中移除 More...
 
void tTaskSchedRemove (tTask *task)
 将任务从就绪列表中移除 More...
 
void tTaskSched (void)
 任务调度接口。通过它来选择下一个具体的任务,然后切换至该任务运行。 More...
 
void tTaskDelayedInit (void)
 初始化任务延时机制 More...
 
void tTimeTaskWait (tTask *task, uint32_t ticks)
 将任务加入延时队列中 More...
 
void tTimeTaskWakeUp (tTask *task)
 将延时的任务从延时队列中唤醒 More...
 
void tTimeTaskRemove (tTask *task)
 将延时的任务从延时队列中移除 More...
 
void tTimeTickInit (void)
 初始化时钟节拍计数 More...
 
void tTaskSystemTickHandler (void)
 系统时钟节拍处理 More...
 
void idleTaskEntry (void *param)
 空闲任务 More...
 
int main ()
 系统入口,完成所有功能的创建,空闲任务的创建等功能 More...
 
tTaskCritical_t tTaskEnterCritical (void)
 
void tTaskExitCritical (tTaskCritical_t status)
 
void tTaskRunFirst (void)
 
void tTaskSwitch (void)
 
void tTaskDelay (uint32_t delay)
 
void tInitApp (void)
 
void tSetSysTickPeriod (uint32_t ms)
 
float tCpuUsageGet (void)
 
__asm void PendSV_Handler (void)
 
uint32_t saveAndLoadStackAddr (uint32_t stackAddr)
 

Variables

tTaskcurrentTask
 当前任务:记录当前是哪个任务正在运行 More...
 
tTasknextTask
 下一个将即运行的任务:在进行任务切换前,先设置好该值,然后任务切换过程中会从中读取下一任务信息 More...
 
tTaskidleTask
 
tBitmap taskPrioBitmap
 
tList taskTable [TINYOS_PRO_COUNT]
 
uint8_t schedLockCount
 
uint32_t tickCount
 
tList tTaskDelayedList
 
uint32_t idleCount
 
uint32_t idleMaxCount
 
tTask tTaskIdle
 
tTaskStack idleTaskEnv [TINYOS_IDLETASK_STACK_SIZE]
 
tTaskcurrentTask
 当前任务:记录当前是哪个任务正在运行 More...
 
tTasknextTask
 下一个将即运行的任务:在进行任务切换前,先设置好该值,然后任务切换过程中会从中读取下一任务信息 More...
 

Detailed Description

tinyOS 内核核心支持代码

tinyOS任务切换与CPU相关的函数

tinyOS的核心头文件。包含了所有关键数据类型的定义,还有核心的函数。

Author
01课堂 lishutong
Date
2017-06-01
Version
1.0

Macro Definition Documentation

◆ MEM32

#define MEM32 (   addr)    *(volatile unsigned long *)(addr)

Definition at line 29 of file tSwitch.c.

◆ MEM8

#define MEM8 (   addr)    *(volatile unsigned char *)(addr)

Definition at line 30 of file tSwitch.c.

◆ NVIC_INT_CTRL

#define NVIC_INT_CTRL   0xE000ED04

Definition at line 24 of file tSwitch.c.

◆ NVIC_PENDSV_PRI

#define NVIC_PENDSV_PRI   0x000000FF

Definition at line 27 of file tSwitch.c.

◆ NVIC_PENDSVSET

#define NVIC_PENDSVSET   0x10000000

Definition at line 25 of file tSwitch.c.

◆ NVIC_SYSPRI2

#define NVIC_SYSPRI2   0xE000ED22

Definition at line 26 of file tSwitch.c.

◆ TICKS_PER_SEC

#define TICKS_PER_SEC   (1000 / TINYOS_SYSTICK_MS)

Definition at line 30 of file tinyOS.h.

Typedef Documentation

◆ tError

typedef enum _tError tError

◆ tTaskCritical_t

typedef uint32_t tTaskCritical_t

Definition at line 48 of file tinyOS.h.

Enumeration Type Documentation

◆ _tError

enum _tError
Enumerator
tErrorNoError 

没有错误

tErrorTimeout 

等待超时

tErrorResourceUnavaliable 

资源不可用

tErrorDel 

被删除

tErrorResourceFull 

资源缓冲区满

tErrorOwner 

不匹配的所有者

Definition at line 33 of file tinyOS.h.

Function Documentation

◆ idleTaskEntry()

void idleTaskEntry ( void *  param)

空闲任务

Parameters
param空闲任务的初始参数

Definition at line 340 of file tCore.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( )

系统入口,完成所有功能的创建,空闲任务的创建等功能

Returns
0, 无用

Definition at line 378 of file tCore.c.

Here is the call graph for this function:

◆ PendSV_Handler()

__asm void PendSV_Handler ( void  )

PendSV异常处理函数,用于任务切换

Definition at line 54 of file tSwitch.c.

Here is the call graph for this function:

◆ saveAndLoadStackAddr()

uint32_t saveAndLoadStackAddr ( uint32_t  stackAddr)

保存前一任务栈地址,获取下一任务栈地址

Parameters
stackAddr前一任务栈地址
Returns
下一要运行的任务栈地址

Definition at line 74 of file tSwitch.c.

Here is the caller graph for this function:

◆ tCpuUsageGet()

float tCpuUsageGet ( void  )
Here is the caller graph for this function:

◆ tInitApp()

void tInitApp ( void  )
Here is the caller graph for this function:

◆ tSetSysTickPeriod()

void tSetSysTickPeriod ( uint32_t  ms)
Here is the caller graph for this function:

◆ tTaskDelay()

void tTaskDelay ( uint32_t  delay)

使当前任务进入延时状态

Parameters
delay延时多少个ticks

Definition at line 20 of file tTime.c.

Here is the call graph for this function:

◆ tTaskDelayedInit()

void tTaskDelayedInit ( void  )

初始化任务延时机制

Definition at line 158 of file tCore.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tTaskEnterCritical()

uint32_t tTaskEnterCritical ( void  )

进入临界区

Returns
进入之前的临界区状态值

Definition at line 36 of file tSwitch.c.

Here is the caller graph for this function:

◆ tTaskExitCritical()

void tTaskExitCritical ( uint32_t  status)

退出临界区,恢复之前的临界区状态

Parameters
status进入临界区之前的CPU
Returns
进入临界区之前的临界区状态值

Definition at line 47 of file tSwitch.c.

Here is the caller graph for this function:

◆ tTaskHighestReady()

tTask * tTaskHighestReady ( void  )

获取当前最高优先级且可运行的任务

Returns
优先级最高的且可运行的任务

Definition at line 42 of file tCore.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tTaskRunFirst()

void tTaskRunFirst ( )

在启动tinyOS时,调用该函数,将切换至第一个任务运行

Definition at line 85 of file tSwitch.c.

Here is the caller graph for this function:

◆ tTaskSched()

void tTaskSched ( void  )

任务调度接口。通过它来选择下一个具体的任务,然后切换至该任务运行。

Definition at line 126 of file tCore.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tTaskSchedDisable()

void tTaskSchedDisable ( void  )

禁止任务调度

Definition at line 64 of file tCore.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tTaskSchedEnable()

void tTaskSchedEnable ( void  )

允许任务调度

Definition at line 77 of file tCore.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tTaskSchedInit()

void tTaskSchedInit ( void  )

初始化调度器

Definition at line 51 of file tCore.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tTaskSchedRdy()

void tTaskSchedRdy ( tTask task)

将任务设置为就绪状态

Parameters
task等待设置为就绪状态的任务

Definition at line 93 of file tCore.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tTaskSchedRemove()

void tTaskSchedRemove ( tTask task)

将任务从就绪列表中移除

Parameters
task等待移除的任务

Definition at line 115 of file tCore.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tTaskSchedUnRdy()

void tTaskSchedUnRdy ( tTask task)

将任务从就绪列表中移除

Parameters
task等待取消就绪的任务

Definition at line 102 of file tCore.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tTaskSwitch()

void tTaskSwitch ( )

进行一次任务切换,tinyOS会预先配置好currentTask和nextTask, 然后调用该函数,切换至nextTask运行

Definition at line 100 of file tSwitch.c.

Here is the caller graph for this function:

◆ tTaskSystemTickHandler()

void tTaskSystemTickHandler ( void  )

系统时钟节拍处理

Definition at line 203 of file tCore.c.

Here is the call graph for this function:

◆ tTimeTaskRemove()

void tTimeTaskRemove ( tTask task)

将延时的任务从延时队列中移除

Parameters
task需要移除的任务

Definition at line 189 of file tCore.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tTimeTaskWait()

void tTimeTaskWait ( tTask task,
uint32_t  ticks 
)

将任务加入延时队列中

Parameters
task需要延时的任务
ticks延时的ticks

Definition at line 167 of file tCore.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tTimeTaskWakeUp()

void tTimeTaskWakeUp ( tTask task)

将延时的任务从延时队列中唤醒

Parameters
task需要唤醒的任务

Definition at line 177 of file tCore.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tTimeTickInit()

void tTimeTickInit ( void  )

初始化时钟节拍计数

Definition at line 196 of file tCore.c.

Here is the caller graph for this function:

Variable Documentation

◆ currentTask [1/2]

tTask* currentTask

当前任务:记录当前是哪个任务正在运行

当前任务:记录当前是哪个任务正在运行

Definition at line 17 of file tCore.c.

◆ currentTask [2/2]

tTask* currentTask

当前任务:记录当前是哪个任务正在运行

当前任务:记录当前是哪个任务正在运行

Definition at line 17 of file tCore.c.

◆ idleCount

uint32_t idleCount

空闲任务计数

Definition at line 29 of file tCore.c.

◆ idleMaxCount

uint32_t idleMaxCount

空闲任务最大计数

Definition at line 30 of file tCore.c.

◆ idleTask

tTask* idleTask

空闲任务

Definition at line 19 of file tCore.c.

◆ idleTaskEnv

tTaskStack idleTaskEnv[TINYOS_IDLETASK_STACK_SIZE]

空闲任务堆栈

Definition at line 334 of file tCore.c.

◆ nextTask [1/2]

tTask* nextTask

下一个将即运行的任务:在进行任务切换前,先设置好该值,然后任务切换过程中会从中读取下一任务信息

下一个将即运行的任务:

Definition at line 18 of file tCore.c.

◆ nextTask [2/2]

tTask* nextTask

下一个将即运行的任务:在进行任务切换前,先设置好该值,然后任务切换过程中会从中读取下一任务信息

下一个将即运行的任务:

Definition at line 18 of file tCore.c.

◆ schedLockCount

uint8_t schedLockCount

调度锁计数器

Definition at line 24 of file tCore.c.

◆ taskPrioBitmap

tBitmap taskPrioBitmap

任务优先级的标记位置结构

Definition at line 21 of file tCore.c.

◆ taskTable

tList taskTable[TINYOS_PRO_COUNT]

所有任务的指针数组

Definition at line 22 of file tCore.c.

◆ tickCount

uint32_t tickCount

时钟节拍计数

Definition at line 25 of file tCore.c.

◆ tTaskDelayedList

tList tTaskDelayedList

延时队列

Definition at line 27 of file tCore.c.

◆ tTaskIdle

tTask tTaskIdle

空闲任务结构

Definition at line 333 of file tCore.c.