📄 os_core.lst
字号:
158:../OSsrc/os_core.c **** * Description: This function assigns a name to a semaphore, mutex, mailbox or queue.
159:../OSsrc/os_core.c **** *
160:../OSsrc/os_core.c **** * Arguments : pevent is a pointer to the event group. 'pevent' can point either to a semaphore
161:../OSsrc/os_core.c **** * a mutex, a mailbox or a queue. Where this function is concerned, it doesn
162:../OSsrc/os_core.c **** * matter the actual type.
163:../OSsrc/os_core.c **** *
164:../OSsrc/os_core.c **** * pname is a pointer to an ASCII string that will be used as the name of the semap
165:../OSsrc/os_core.c **** * mutex, mailbox or queue. The string must be able to hold at least
166:../OSsrc/os_core.c **** * OS_EVENT_NAME_SIZE characters.
167:../OSsrc/os_core.c **** *
168:../OSsrc/os_core.c **** * perr is a pointer to an error code that can contain one of the following values
169:../OSsrc/os_core.c **** *
170:../OSsrc/os_core.c **** * OS_ERR_NONE if the requested task is resumed
171:../OSsrc/os_core.c **** * OS_ERR_EVENT_TYPE if 'pevent' is not pointing to the proper event
172:../OSsrc/os_core.c **** * control block type.
173:../OSsrc/os_core.c **** * OS_ERR_PNAME_NULL You passed a NULL pointer for 'pname'
174:../OSsrc/os_core.c **** * OS_ERR_PEVENT_NULL if you passed a NULL pointer for 'pevent'
175:../OSsrc/os_core.c **** * OS_ERR_NAME_SET_ISR if you called this function from an ISR
176:../OSsrc/os_core.c **** *
177:../OSsrc/os_core.c **** * Returns : None
178:../OSsrc/os_core.c **** ***************************************************************************************************
179:../OSsrc/os_core.c **** */
180:../OSsrc/os_core.c ****
181:../OSsrc/os_core.c **** #if OS_EVENT_EN && (OS_EVENT_NAME_SIZE > 1)
182:../OSsrc/os_core.c **** void OSEventNameSet (OS_EVENT *pevent, INT8U *pname, INT8U *perr)
183:../OSsrc/os_core.c **** {
184:../OSsrc/os_core.c **** INT8U len;
185:../OSsrc/os_core.c **** #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register
186:../OSsrc/os_core.c **** OS_CPU_SR cpu_sr = 0;
187:../OSsrc/os_core.c **** #endif
188:../OSsrc/os_core.c ****
189:../OSsrc/os_core.c ****
190:../OSsrc/os_core.c ****
191:../OSsrc/os_core.c **** #if OS_ARG_CHK_EN > 0
192:../OSsrc/os_core.c **** if (perr == (INT8U *)0) { /* Validate 'perr'
193:../OSsrc/os_core.c **** return;
194:../OSsrc/os_core.c **** }
195:../OSsrc/os_core.c **** if (pevent == (OS_EVENT *)0) { /* Is 'pevent' a NULL pointer?
196:../OSsrc/os_core.c **** *perr = OS_ERR_PEVENT_NULL;
197:../OSsrc/os_core.c **** return;
198:../OSsrc/os_core.c **** }
199:../OSsrc/os_core.c **** if (pname == (INT8U *)0) { /* Is 'pname' a NULL pointer?
200:../OSsrc/os_core.c **** *perr = OS_ERR_PNAME_NULL;
201:../OSsrc/os_core.c **** return;
202:../OSsrc/os_core.c **** }
203:../OSsrc/os_core.c **** #endif
204:../OSsrc/os_core.c **** if (OSIntNesting > 0) { /* See if trying to call from an ISR
205:../OSsrc/os_core.c **** *perr = OS_ERR_NAME_SET_ISR;
206:../OSsrc/os_core.c **** return;
207:../OSsrc/os_core.c **** }
208:../OSsrc/os_core.c **** switch (pevent->OSEventType) {
209:../OSsrc/os_core.c **** case OS_EVENT_TYPE_SEM:
210:../OSsrc/os_core.c **** case OS_EVENT_TYPE_MUTEX:
211:../OSsrc/os_core.c **** case OS_EVENT_TYPE_MBOX:
212:../OSsrc/os_core.c **** case OS_EVENT_TYPE_Q:
213:../OSsrc/os_core.c **** break;
214:../OSsrc/os_core.c ****
215:../OSsrc/os_core.c **** default:
216:../OSsrc/os_core.c **** *perr = OS_ERR_EVENT_TYPE;
217:../OSsrc/os_core.c **** return;
218:../OSsrc/os_core.c **** }
219:../OSsrc/os_core.c **** OS_ENTER_CRITICAL();
220:../OSsrc/os_core.c **** len = OS_StrLen(pname); /* Can we fit the string in the storage area?
221:../OSsrc/os_core.c **** if (len > (OS_EVENT_NAME_SIZE - 1)) { /* No
222:../OSsrc/os_core.c **** OS_EXIT_CRITICAL();
223:../OSsrc/os_core.c **** *perr = OS_ERR_EVENT_NAME_TOO_LONG;
224:../OSsrc/os_core.c **** return;
225:../OSsrc/os_core.c **** }
226:../OSsrc/os_core.c **** (void)OS_StrCopy(pevent->OSEventName, pname); /* Yes, copy name to the event control block
227:../OSsrc/os_core.c **** OS_EXIT_CRITICAL();
228:../OSsrc/os_core.c **** *perr = OS_ERR_NONE;
229:../OSsrc/os_core.c **** }
230:../OSsrc/os_core.c **** #endif
231:../OSsrc/os_core.c ****
232:../OSsrc/os_core.c **** /*$PAGE*/
233:../OSsrc/os_core.c **** /*
234:../OSsrc/os_core.c **** ***************************************************************************************************
235:../OSsrc/os_core.c **** * INITIALIZATION
236:../OSsrc/os_core.c **** *
237:../OSsrc/os_core.c **** * Description: This function is used to initialize the internals of uC/OS-II and MUST be called pri
238:../OSsrc/os_core.c **** * creating any uC/OS-II object and, prior to calling OSStart().
239:../OSsrc/os_core.c **** *
240:../OSsrc/os_core.c **** * Arguments : none
241:../OSsrc/os_core.c **** *
242:../OSsrc/os_core.c **** * Returns : none
243:../OSsrc/os_core.c **** ***************************************************************************************************
244:../OSsrc/os_core.c **** */
245:../OSsrc/os_core.c ****
246:../OSsrc/os_core.c **** void OSInit (void)
247:../OSsrc/os_core.c **** {
248:../OSsrc/os_core.c **** OSInitHookBegin(); /* Call port specific initializati
249:../OSsrc/os_core.c ****
250:../OSsrc/os_core.c **** OS_InitMisc(); /* Initialize miscellaneous variab
251:../OSsrc/os_core.c ****
252:../OSsrc/os_core.c **** OS_InitRdyList(); /* Initialize the Ready List
253:../OSsrc/os_core.c ****
254:../OSsrc/os_core.c **** OS_InitTCBList(); /* Initialize the free list of OS_
255:../OSsrc/os_core.c ****
256:../OSsrc/os_core.c **** OS_InitEventList(); /* Initialize the free list of OS_
257:../OSsrc/os_core.c ****
258:../OSsrc/os_core.c **** #if (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
259:../OSsrc/os_core.c **** OS_FlagInit(); /* Initialize the event flag struc
260:../OSsrc/os_core.c **** #endif
261:../OSsrc/os_core.c ****
262:../OSsrc/os_core.c **** #if (OS_MEM_EN > 0) && (OS_MAX_MEM_PART > 0)
263:../OSsrc/os_core.c **** OS_MemInit(); /* Initialize the memory manager
264:../OSsrc/os_core.c **** #endif
265:../OSsrc/os_core.c ****
266:../OSsrc/os_core.c **** #if (OS_Q_EN > 0) && (OS_MAX_QS > 0)
267:../OSsrc/os_core.c **** OS_QInit(); /* Initialize the message queue st
268:../OSsrc/os_core.c **** #endif
269:../OSsrc/os_core.c ****
270:../OSsrc/os_core.c **** OS_InitTaskIdle(); /* Create the Idle Task
271:../OSsrc/os_core.c **** #if OS_TASK_STAT_EN > 0
272:../OSsrc/os_core.c **** OS_InitTaskStat(); /* Create the Statistic Task
273:../OSsrc/os_core.c **** #endif
274:../OSsrc/os_core.c ****
275:../OSsrc/os_core.c **** #if OS_TMR_EN > 0
276:../OSsrc/os_core.c **** OSTmr_Init(); /* Initialize the Timer Manager
277:../OSsrc/os_core.c **** #endif
278:../OSsrc/os_core.c ****
279:../OSsrc/os_core.c **** OSInitHookEnd(); /* Call port specific init. code
280:../OSsrc/os_core.c ****
281:../OSsrc/os_core.c **** #if OS_DEBUG_EN > 0
282:../OSsrc/os_core.c **** OSDebugInit();
283:../OSsrc/os_core.c **** #endif
284:../OSsrc/os_core.c **** }
285:../OSsrc/os_core.c **** /*$PAGE*/
286:../OSsrc/os_core.c **** /*
287:../OSsrc/os_core.c **** ***************************************************************************************************
288:../OSsrc/os_core.c **** * ENTER ISR
289:../OSsrc/os_core.c **** *
290:../OSsrc/os_core.c **** * Description: This function is used to notify uC/OS-II that you are about to service an interrupt
291:../OSsrc/os_core.c **** * service routine (ISR). This allows uC/OS-II to keep track of interrupt nesting and
292:../OSsrc/os_core.c **** * only perform rescheduling at the last nested ISR.
293:../OSsrc/os_core.c **** *
294:../OSsrc/os_core.c **** * Arguments : none
295:../OSsrc/os_core.c **** *
296:../OSsrc/os_core.c **** * Returns : none
297:../OSsrc/os_core.c **** *
298:../OSsrc/os_core.c **** * Notes : 1) This function should be called ith interrupts already disabled
299:../OSsrc/os_core.c **** * 2) Your ISR can directly increment OSIntNesting without calling this function becaus
300:../OSsrc/os_core.c **** * OSIntNesting has been declared 'global'.
301:../OSsrc/os_core.c **** * 3) You MUST still call OSIntExit() even though you increment OSIntNesting directly.
302:../OSsrc/os_core.c **** * 4) You MUST invoke OSIntEnter() and OSIntExit() in pair. In other words, for every
303:../OSsrc/os_core.c **** * to OSIntEnter() at the beginning of the ISR you MUST have a call to OSIntExit() a
304:../OSsrc/os_core.c **** * end of the ISR.
305:../OSsrc/os_core.c **** * 5) You are allowed to nest interrupts up to 255 levels deep.
306:../OSsrc/os_core.c **** * 6) I removed the OS_ENTER_CRITICAL() and OS_EXIT_CRITICAL() around the increment bec
307:../OSsrc/os_core.c **** * OSIntEnter() is always called with interrupts disabled.
308:../OSsrc/os_core.c **** ***************************************************************************************************
309:../OSsrc/os_core.c **** */
310:../OSsrc/os_core.c ****
311:../OSsrc/os_core.c **** void OSIntEnter (void)
312:../OSsrc/os_core.c **** {
313:../OSsrc/os_core.c **** if (OSRunning == OS_TRUE) {
314:../OSsrc/os_core.c **** if (OSIntNesting < 255u) {
315:../OSsrc/os_core.c **** OSIntNesting++; /* Increment ISR nesting level
316:../OSsrc/os_core.c **** }
317:../OSsrc/os_core.c **** }
318:../OSsrc/os_core.c **** }
319:../OSsrc/os_core.c **** /*$PAGE*/
320:../OSsrc/os_core.c **** /*
321:../OSsrc/os_core.c **** ***************************************************************************************************
322:../OSsrc/os_core.c **** * EXIT ISR
323:../OSsrc/os_core.c **** *
324:../OSsrc/os_core.c **** * Description: This function is used to notify uC/OS-II that you have completed serviving an ISR.
325:../OSsrc/os_core.c **** * the last nested ISR has completed, uC/OS-II will call the scheduler to determine whe
326:../OSsrc/os_core.c **** * a new, high-priority task, is ready to run.
327:../OSsrc/os_core.c **** *
328:../OSsrc/os_core.c **** * Arguments : none
329:../OSsrc/os_core.c **** *
330:../OSsrc/os_core.c **** * Returns : none
331:../OSsrc/os_core.c **** *
332:../OSsrc/os_core.c **** * Notes : 1) You MUST invoke OSIntEnter() and OSIntExit() in pair. In other words, for every
333:../OSsrc/os_core.c **** * to OSIntEnter() at the beginning of the ISR you MUST have a call to OSIntExit() a
334:../OSsrc/os_core.c **** * end of the ISR.
335:../OSsrc/os_core.c **** * 2) Rescheduling is prevented when the scheduler is locked (see OS_SchedLock())
336:../OSsrc/os_core.c **** ***************************************************************************************************
337:../OSsrc/os_core.c **** */
338:../OSsrc/os_core.c ****
339:../OSsrc/os_core.c **** void OSIntExit (void)
340:../OSsrc/os_core.c **** {
341:../OSsrc/os_core.c **** #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status regis
342:../OSsrc/os_core.c **** OS_CPU_SR cpu_sr = 0;
343:../OSsrc/os_core.c **** #endif
344:../OSsrc/os_core.c ****
345:../OSsrc/os_core.c ****
346:../OSsrc/os_core.c ****
347:../OSsrc/os_core.c **** if (OSRunning == OS_TRUE) {
348:../OSsrc/os_core.c **** OS_ENTER_CRITICAL();
349:../OSsrc/os_core.c **** if (OSIntNesting > 0) { /* Prevent OSIntNesting from wrapping
350:../OSsrc/os_core.c **** OSIntNesting--;
351:../OSsrc/os_core.c **** }
352:../OSsrc/os_core.c **** if (OSIntNesting == 0) { /* Reschedule only if all ISRs complete
353:../OSsrc/os_core.c **** if (OSLockNesting == 0) { /* ... and not locked.
354:../OSsrc/os_core.c **** OS_SchedNew();
355:../OSsrc/os_core.c **** if (OSPrioHighRdy != OSPrioCur) { /* No Ctx Sw if current task is highest
356:../OSsrc/os_core.c **** OSTCBHighRdy = OSTCBPrioTbl[OSPrioHighRdy];
357:../OSsrc/os_core.c **** #if OS_TASK_PROFILE_EN > 0
358:../OSsrc/os_core.c **** OSTCBHighRdy->OSTCBCtxSwCtr++; /* Inc. # of context switches to this ta
359:../OSsrc/os_core.c **** #endif
360:../OSsrc/os_core.c **** OSCtxSwCtr++; /* Keep track of the number of ctx switc
361:../OSsrc/os_core.c **** OSIntCtxSw(); /* Perform interrupt level ctx switch
362:../OSsrc/os_core.c **** }
363:../OSsrc/os_core.c **** }
364:../OSsrc/os_core.c **** }
365:../OSsrc/os_core.c **** OS_EXIT_CRITICAL();
366:../OSsrc/os_core.c **** }
367:../OSsrc/os_core.c **** }
368:../OSsrc/os_core.c **** /*$PAGE*/
369:../OSsrc/os_core.c **** /*
370:../OSsrc/os_core.c **** ***************************************************************************************************
371:../OSsrc/os_core.c **** * PREVENT SCHEDULING
372:../OSsrc/os_core.c **** *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -