cocoOS  4.0.0
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 /*********************************************************************************/
297 /* event_wait_multiple(waitAll, args...) */
324 #define event_wait_multiple(waitAll, args...) OS_WAIT_MULTIPLE_EVENTS( waitAll, args)
325 
326 
327 /*********************************************************************************/
328 /* event_signal(event) */
351 #define event_signal(event) OS_SIGNAL_EVENT(event)
352 
353 
354 /*********************************************************************************/
355 /* event_ISR_signal(event) */
375 #define event_ISR_signal(event) OS_INT_SIGNAL_EVENT(event)
376 
377 
378 /*********************************************************************************/
379 /* sem_wait(sem) */
402 #define sem_wait(sem) OS_WAIT_SEM(sem)
403 
404 
405 /*********************************************************************************/
406 /* sem_signal(sem) */
429 #define sem_signal(sem) OS_SIGNAL_SEM(sem)
430 
431 
432 /*********************************************************************************/
433 /* sem_ISR_signal(sem) */
459 #define sem_ISR_signal(sem) OS_SIGNAL_SEM_NO_SCHEDULE(sem)
460 
461 
462 /*********************************************************************************/
463 /* msg_post(task, msg) */
519 /*********************************************************************************/
520 #define msg_post(task, msg) OS_MSG_Q_POST(task, msg, 0, 0, 0)
521 
522 
523 /*********************************************************************************/
524 /* msg_post_async(task, msg) */
580 /*********************************************************************************/
581 #define msg_post_async(task, msg) OS_MSG_Q_POST(task, msg, 0, 0, 1)
582 
583 
584 /*********************************************************************************/
585 /* msg_post_in(task, msg, delay) */
643 /*********************************************************************************/
644 #define msg_post_in(task, msg, delay) OS_MSG_Q_POST(task, msg, delay, 0, 0)
645 
646 
647 /*********************************************************************************/
648 /* msg_post_every(task, msg, period) */
705 /*********************************************************************************/
706 #define msg_post_every(task, msg, period) OS_MSG_Q_POST(task, msg, period, period, 0)
707 
708 
709 /*********************************************************************************/
710 /* msg_receive( task, pMsg ) */
766 /*********************************************************************************/
767 #define msg_receive( task, pMsg ) OS_MSG_Q_RECEIVE( task, pMsg, 0 )
768 
769 
770 /*********************************************************************************/
771 /* msg_receive_async( task, pMsg ) */
831 /*********************************************************************************/
832 #define msg_receive_async( task, pMsg ) OS_MSG_Q_RECEIVE( task, pMsg, 1 )
833 
834 
835 
836 void os_init( void );
837 void os_start( void );
838 void os_tick( void );
839 void os_sub_tick( uint8_t id );
840 void os_sub_nTick( uint8_t id, uint16_t nTicks );
841 
842 
843 uint8_t task_create( taskproctype taskproc, uint8_t prio, Msg_t* msgPool, uint8_t poolSize, uint16_t msgSize );
844 TaskState_t task_state_get( taskproctype taskproc );
845 uint8_t task_id_get( taskproctype taskproc );
846 void task_kill( taskproctype taskproc );
847 
848 Sem_t sem_bin_create( uint8_t initial );
849 Sem_t sem_counting_create( uint8_t max, uint8_t initial );
850 
851 Evt_t event_create( void );
852 uint8_t event_signaling_taskId_get( Evt_t ev );
853 
854 void os_cbkSleep( void );
855 
856 #ifdef __cplusplus
857 }
858 #endif
859 
860 #endif
void os_start(void)
Definition: os_kernel.c:117
void os_tick(void)
Definition: os_kernel.c:146
void os_init(void)
Definition: os_kernel.c:64
uint8_t task_id_get(taskproctype taskproc)
Definition: os_task.c:242
Evt_t event_create(void)
Definition: os_event.c:74
uint8_t task_create(taskproctype taskproc, uint8_t prio, Msg_t *msgPool, uint8_t poolSize, uint16_t msgSize)
Definition: os_task.c:99
void os_sub_nTick(uint8_t id, uint16_t nTicks)
Definition: os_kernel.c:202
void task_kill(taskproctype taskproc)
Definition: os_task.c:294
void os_cbkSleep(void)
Definition: os_cbk.c:49
Sem_t sem_bin_create(uint8_t initial)
Definition: os_sem.c:88
Sem_t sem_counting_create(uint8_t max, uint8_t initial)
Definition: os_sem.c:112
uint8_t event_signaling_taskId_get(Evt_t ev)
Definition: os_event.c:113
TaskState_t task_state_get(taskproctype taskproc)
Definition: os_task.c:196
void os_sub_tick(uint8_t id)
Definition: os_kernel.c:173