cocoOS  5.0.1
os_applAPI.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 Peter Eckstrand
3  *
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted (subject to the limitations in the
8  * disclaimer below) provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in the
15  * documentation and/or other materials provided with the
16  * distribution.
17  *
18  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
19  * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
20  * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
21  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
27  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
30  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  * This file is part of the cocoOS operating system.
33  * Author: Peter Eckstrand <info@cocoos.net>
34  */
35 
36 
37 #ifndef _os_applapi_h__
38 #define _os_applapi_h__
39 
40 #include "cocoos.h"
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 
48 /*********************************************************************************/
49 /* task_open() */
67 #define task_open() OS_BEGIN
68 
69 
70 /*********************************************************************************/
71 /* task_close() */
88 #define task_close() OS_END
89 
90 
91 /*********************************************************************************/
92 /* task_wait(x) */
112 #define task_wait(x) OS_WAIT_TICKS(x,0)
113 
114 
115 /*********************************************************************************/
116 /* task_wait_id(id,x) */
137 #define task_wait_id(id,x) OS_WAIT_TICKS(x,id)
138 
139 
140 /*********************************************************************************/
141 /* task_suspend( id ) */
187 #define task_suspend( id ) OS_SUSPEND_TASK( id )
188 
189 
190  /*********************************************************************************/
191 /* task_resume(id) */
236 #define task_resume( id ) OS_RESUME_TASK( id )
237 
238 
239 /*********************************************************************************/
240 /* event_wait(event) */
263 #define event_wait(event) OS_WAIT_SINGLE_EVENT(event,0)
264 
265 
266 /*********************************************************************************/
267 /* event_wait_timeout(event,timeout) */
293 #define event_wait_timeout(event,timeout) OS_WAIT_SINGLE_EVENT(event,timeout)
294 
295 /*********************************************************************************/
296 /* event_get_timeout() */
326 #define event_get_timeout() OS_GET_TASK_TIMEOUT_VALUE()
327 
328 /*********************************************************************************/
329 /* event_wait_multiple(waitAll, args...) */
356 #define event_wait_multiple(waitAll, args...) OS_WAIT_MULTIPLE_EVENTS( waitAll, args)
357 
358 
359 /*********************************************************************************/
360 /* event_signal(event) */
383 #define event_signal(event) OS_SIGNAL_EVENT(event)
384 
385 
386 /*********************************************************************************/
387 /* event_ISR_signal(event) */
407 #define event_ISR_signal(event) OS_INT_SIGNAL_EVENT(event)
408 
409 
410 /*********************************************************************************/
411 /* sem_wait(sem) */
434 #define sem_wait(sem) OS_WAIT_SEM(sem)
435 
436 
437 /*********************************************************************************/
438 /* sem_signal(sem) */
461 #define sem_signal(sem) OS_SIGNAL_SEM(sem)
462 
463 
464 /*********************************************************************************/
465 /* sem_ISR_signal(sem) */
491 #define sem_ISR_signal(sem) OS_SIGNAL_SEM_NO_SCHEDULE(sem)
492 
493 
494 /*********************************************************************************/
495 /* msg_post(task_id, msg) */
552 /*********************************************************************************/
553 #define msg_post(task_id, msg) OS_MSG_Q_POST(task_id, msg, 0, 0, 0)
554 
555 
556 /*********************************************************************************/
557 /* msg_post_async(task_id, msg) */
614 /*********************************************************************************/
615 #define msg_post_async(task_id, msg) OS_MSG_Q_POST(task_id, msg, 0, 0, 1)
616 
617 
618 /*********************************************************************************/
619 /* msg_post_in(task_id, msg, delay) */
678 /*********************************************************************************/
679 #define msg_post_in(task_id, msg, delay) OS_MSG_Q_POST(task_id, msg, delay, 0, 0)
680 
681 
682 /*********************************************************************************/
683 /* msg_post_every(task_id, msg, period) */
741 /*********************************************************************************/
742 #define msg_post_every(task_id, msg, period) OS_MSG_Q_POST(task_id, msg, period, period, 0)
743 
744 
745 /*********************************************************************************/
746 /* msg_receive( task_id, pMsg ) */
803 /*********************************************************************************/
804 #define msg_receive( task_id, pMsg ) OS_MSG_Q_RECEIVE( task_id, pMsg, 0 )
805 
806 
807 /*********************************************************************************/
808 /* msg_receive_async( task_id, pMsg ) */
869 /*********************************************************************************/
870 #define msg_receive_async( task_id, pMsg ) OS_MSG_Q_RECEIVE( task_id, pMsg, 1 )
871 
872 
873 
874 void os_init( void );
875 void os_start( void );
876 void os_tick( void );
877 void os_sub_tick( uint8_t id );
878 void os_sub_nTick( uint8_t id, uint16_t nTicks );
879 uint8_t os_get_running_tid(void);
880 
881 uint8_t task_create( taskproctype taskproc, void *data, uint8_t prio, Msg_t* msgPool, uint8_t poolSize, uint16_t msgSize );
882 void task_kill( uint8_t tid );
883 void *task_get_data();
884 Sem_t sem_bin_create( uint8_t initial );
885 Sem_t sem_counting_create( uint8_t max, uint8_t initial );
886 
887 Evt_t event_create( void );
888 uint8_t event_signaling_taskId_get( Evt_t ev );
889 TaskState_t task_state_get(uint8_t tid);
890 void os_cbkSleep( void );
891 
892 #ifdef __cplusplus
893 }
894 #endif
895 
896 #endif
void os_start(void)
Definition: os_kernel.c:121
void os_tick(void)
Definition: os_kernel.c:149
void os_init(void)
Definition: os_kernel.c:64
void * task_get_data()
Definition: os_task.c:270
uint8_t task_create(taskproctype taskproc, void *data, uint8_t prio, Msg_t *msgPool, uint8_t poolSize, uint16_t msgSize)
Definition: os_task.c:134
Evt_t event_create(void)
Definition: os_event.c:81
void os_sub_nTick(uint8_t id, uint16_t nTicks)
Definition: os_kernel.c:205
void task_kill(uint8_t tid)
Definition: os_task.c:234
void os_cbkSleep(void)
Definition: os_cbk.c:49
Sem_t sem_bin_create(uint8_t initial)
Definition: os_sem.c:95
Sem_t sem_counting_create(uint8_t max, uint8_t initial)
Definition: os_sem.c:120
uint8_t event_signaling_taskId_get(Evt_t ev)
Definition: os_event.c:120
Definition: os_msgqueue.h:50
void os_sub_tick(uint8_t id)
Definition: os_kernel.c:176