📄 nu.c
字号:
}
else
/* Invalid task id, status as such. */
status = NU_INVALID_TASK;
/* Return the status to caller. */
return(status);
} /* end of NU_Reset */
/************************************************************************/
/* */
/* FUNCTION "NU_Read_Time" */
/* */
/* */
/* DESCRIPTION */
/* */
/* This function is used to read the current system time in */
/* terms specified by the clock management functions. */
/* */
/* AUTHOR */
/* */
/* William E. Lamie, Accelerated Technology */
/* */
/* CALLED FROM */
/* */
/* Application Routines */
/* */
/* ROUTINES CALLED */
/* */
/* DS_Make_History_Entry Make an history entry */
/* CLD_Read_Clock Get the current system time */
/* */
/* INPUTS */
/* */
/* None */
/* */
/* OUTPUTS */
/* */
/* return(status) System clock value */
/* */
/************************************************************************/
unsigned int NU_Read_Time()
{
/* Make an entry in the history table, if the conditional compilation
flag is set. */
#ifdef NU_ENABLE_HISTORY
DS_Make_History_Entry(NU_HIST_NU_READ_TIME, 0, 0);
#endif
/* Call "CLD_Read_Clock" to read the current system time. */
return(CLD_Read_Clock());
} /* end of NU_Read_Time */
/************************************************************************/
/* */
/* FUNCTION "NU_Set_Time" */
/* */
/* */
/* DESCRIPTION */
/* */
/* This function is used to set the current system time in */
/* terms specified by the clock management functions. */
/* */
/* AUTHOR */
/* */
/* William E. Lamie, Accelerated Technology */
/* */
/* CALLED FROM */
/* */
/* Application Routines */
/* */
/* ROUTINES CALLED */
/* */
/* DS_Make_History_Entry Make an history entry */
/* CLD_Load_Clock Set the current system time */
/* */
/* INPUTS */
/* */
/* System_Time New system time */
/* */
/* OUTPUTS */
/* */
/* return() None */
/* */
/************************************************************************/
void NU_Set_Time(unsigned int System_Time)
{
/* Make an entry in the history table, if the conditional compilation
flag is set. */
#ifdef NU_ENABLE_HISTORY
DS_Make_History_Entry(NU_HIST_NU_SET_TIME, System_Time, 0);
#endif
/* Call "CLD_Load_Clock" to set the current system time. */
CLD_Load_Clock(System_Time);
} /* end of NU_Set_Time */
/************************************************************************/
/* */
/* FUNCTION "NU_Change_Priority" */
/* */
/* */
/* DESCRIPTION */
/* */
/* This function is used to modify the selected tasks priority. */
/* */
/* AUTHOR */
/* */
/* William E. Lamie, Accelerated Technology */
/* */
/* CALLED FROM */
/* */
/* Application Routines */
/* */
/* ROUTINES CALLED */
/* */
/* DS_Make_History_Entry Make entry in history log */
/* IND_Set_Interrupt_Level Enable/Disable Interrupts */
/* SKP_Set_Task_Priority Set task priority */
/* */
/* INPUTS */
/* */
/* task_id Selected task's ID */
/* new_priority The new priority level */
/* */
/* OUTPUTS */
/* */
/* return(status) Status or old priority */
/* */
/************************************************************************/
signed int NU_Change_Priority(signed int task_id, unsigned char new_priority)
{
int interrupt_level; /* Saved interrupt level */
signed int status; /* Return status/old prior */
/* Make an entry in the history table, if the conditional compilation
flag is set. */
#ifdef NU_ENABLE_HISTORY
DS_Make_History_Entry(NU_HIST_NU_CHANGE_PRIORITY,
(unsigned int) task_id,
(unsigned int) new_priority);
#endif
/* Initialize the return value. */
status = NU_SUCCESS;
/* Check for a valid task ID entry. */
if ((task_id >= 0) && (task_id < NU_Total_Tasks))
{
/* Lock out interrupts while changing the priority. */
interrupt_level = IND_Set_Interrupt_Level(NU_DISABLE_INTERRUPTS);
/* Call "SKP_Set_Task_Priority" to modify the priority of the
specified task. */
status = (signed int) SKP_Set_Task_Priority(task_id, new_priority);
/* Restore previous interrupt posture. */
IND_Set_Interrupt_Level(interrupt_level);
}
else
/* Invalid task id, status as such. */
status = NU_INVALID_TASK;
/* Return the status to caller. */
return(status);
} /* end of NU_Change_Priority */
/************************************************************************/
/* */
/* FUNCTION "NU_Current_Task_ID" */
/* */
/* */
/* DESCRIPTION */
/* */
/* This function is used to find out what the current task ID is. */
/* */
/* AUTHOR */
/* */
/* William E. Lamie, Accelerated Technology */
/* */
/* CALLED FROM */
/* */
/* Application Routines */
/* */
/* ROUTINES CALLED */
/* */
/* DS_Make_History_Entry Make entry in history log */
/* SKP_Get_Task_ID Get task ID */
/* */
/* INPUTS */
/* */
/* None */
/* */
/* OUTPUTS */
/* */
/* return(status) Current task ID */
/* */
/************************************************************************/
signed int NU_Current_Task_ID()
{
/* Make an entry in the history table, if the conditional compilation
flag is set. */
#ifdef NU_ENABLE_HISTORY
DS_Make_History_Entry(NU_HIST_NU_CURRENT_TASK_ID, 0, 0);
#endif
/* Call "SKP_Get_Task_ID" and return the value immediately. */
return(SKP_Get_Task_ID());
} /* end of NU_Current_Task_ID */
/************************************************************************/
/* */
/* FUNCTION "NU_Disable_Preemption" */
/* */
/* */
/* DESCRIPTION */
/* */
/* This function is used to disable preemption of the calling */
/* task. Note that this is implemented as a counter in order to */
/* support nested calls to routines that turn off preemption. */
/* */
/* AUTHOR */
/* */
/* William E. Lamie, Accelerated Technology */
/* */
/* CALLED FR
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -