/* ************************************************************************************************************************ * Post a msg to the all the task waiting for on this queue with size * * Description: This function is called to post a msg to the queue end and implement FIFO or LIFO as opt specified. * * Arguments :p_q is the address of the queue object * ----- * p_void is the address of the msg * ----- * opt: the opt option is: * SEND_TO_END implement FIFO * SEND_TO_FRONTimplement LIFO * ----- * * size : is the message size to be posted * * Returns * RAW_SUCCESS: raw os return success * RAW_MSG_MAX:queue is full * *Note(s) THis function will wake all the task waiting for this queue other than one! * * ************************************************************************************************************************ */ RAW_OS_ERROR raw_queue_size_all_post(RAW_QUEUE_SIZE *p_q, void *p_void, MSG_SIZE_TYPE size, RAW_U8 opt) { #if (RAW_QUEUE_SIZE_FUNCTION_CHECK > 0) if (p_q == 0) { return RAW_NULL_OBJECT; } /*if send null pointer, just return*/ if (p_void == 0) { return RAW_NULL_POINTER; } #endif #if (CONFIG_RAW_ZERO_INTERRUPT > 0) if (raw_int_nesting) { return int_msg_post(RAW_TYPE_Q_SIZE_ALL, p_q, p_void, size, 0, opt); } #endif return msg_size_post(p_q, p_void, size, opt, WAKE_ALL_QUEUE); }
/* ************************************************************************************************************************ * Post a msg to the queue end with size * * Description: This function is called to post a msg to the queue end and implement FIFO. * * Arguments :p_q is the address of the queue object * ----- * p_void is the address of the msg * ----- * wait_option: is how the service behaves if the msg queue is full. * The wait options are * defined as follows: * RAW_NO_WAIT (0x00000000) * RAW_WAIT_FOREVER (0xFFFFFFFF) * timeout value (0x00000001 * through * 0xFFFFFFFE) * --------- * size : is the message size to be posted * * Returns * RAW_SUCCESS: raw os return success * RAW_MSG_MAX:queue is full * * Note(s) * * ************************************************************************************************************************ */ RAW_OS_ERROR raw_queue_size_end_post(RAW_QUEUE_SIZE *p_q, void *p_void, MSG_SIZE_TYPE size) { #if (RAW_QUEUE_SIZE_FUNCTION_CHECK > 0) if (p_q == 0) { return RAW_NULL_OBJECT; } /*if send null pointer, just return*/ if (p_void == 0) { return RAW_NULL_POINTER; } #endif #if (CONFIG_RAW_ZERO_INTERRUPT > 0) if (raw_int_nesting && raw_sched_lock) { return int_msg_post(RAW_TYPE_Q_SIZE_END, p_q, p_void, size, 0, 0); } #endif return msg_size_post(p_q, p_void, size, SEND_TO_END, WAKE_ONE_QUEUE); }
/* ************************************************************************************************************************ * Post a msg to the all the task waiting for on this queue with size * * Description: This function is called to post a msg to the queue end and implement FIFO or LIFO as opt specified. * * Arguments :p_q is the address of the queue object * ----- * p_void is the address of the msg * ----- * opt: the opt option is: * SEND_TO_END implement FIFO * SEND_TO_FRONTimplement LIFO * ----- * * size : is the message size to be posted * * Returns * RAW_SUCCESS: raw os return success * RAW_MSG_MAX:queue is full * *Note(s) THis function will wake all the task waiting for this queue other than one! * * ************************************************************************************************************************ */ RAW_OS_ERROR raw_queue_size_all_post(RAW_QUEUE_SIZE *p_q, void *p_void, MSG_SIZE_TYPE size, RAW_U8 opt) { #if (RAW_QUEUE_SIZE_FUNCTION_CHECK > 0) if (p_q == 0) { return RAW_NULL_OBJECT; } /*if send null pointer, just return*/ if (p_void == 0) { return RAW_NULL_POINTER; } #endif return msg_size_post(p_q, p_void, size, opt, WAKE_ALL_QUEUE); }
/* ************************************************************************************************************************ * Post a msg to the queue front with size * * Description: This function is called to post a msg to the queue front and implement LIFO. * * Arguments :p_q is the address of the queue object * ----- * p_void is the address of the msg * * * ------- * size : is the message size to be posted * * Returns * RAW_SUCCESS: raw os return success * RAW_MSG_MAX:queue is full * * Note(s) * * ************************************************************************************************************************ */ RAW_OS_ERROR raw_queue_size_front_post(RAW_QUEUE_SIZE *p_q, void *p_void, MSG_SIZE_TYPE size) { #if (RAW_QUEUE_SIZE_FUNCTION_CHECK > 0) if (p_q == 0) { return RAW_NULL_OBJECT; } /*if send null pointer, just return*/ if (p_void == 0) { return RAW_NULL_POINTER; } #endif return msg_size_post(p_q, p_void,size,SEND_TO_FRONT, WAKE_ONE_QUEUE); }
static void int_msg_handler(TASK_0_EVENT_TYPE ev, void *msg_data) { OBJECT_INT_MSG *int_msg; RAW_OS_ERROR int_msg_ret; RAW_SR_ALLOC(); int_msg = msg_data; int_msg_ret = RAW_SYSTEM_ERROR; switch (ev) { #if (CONFIG_RAW_TASK_SUSPEND > 0) case RAW_TYPE_SUSPEND: int_msg_ret = task_suspend((RAW_TASK_OBJ *)(int_msg->object)); break; #endif #if (CONFIG_RAW_TASK_RESUME > 0) case RAW_TYPE_RESUME: int_msg_ret = task_resume((RAW_TASK_OBJ *)(int_msg->object)); break; #endif #if (CONFIG_RAW_SEMAPHORE > 0) case RAW_TYPE_SEM: int_msg_ret = semaphore_put((RAW_SEMAPHORE *)(int_msg->object), WAKE_ONE_SEM); break; case RAW_TYPE_SEM_ALL: int_msg_ret = semaphore_put((RAW_SEMAPHORE *)(int_msg->object), WAKE_ALL_SEM); break; #endif #if (CONFIG_RAW_QUEUE > 0) case RAW_TYPE_Q_FRONT: int_msg_ret = msg_post((RAW_QUEUE *)(int_msg->object), int_msg->msg, SEND_TO_FRONT, WAKE_ONE_QUEUE); break; case RAW_TYPE_Q_END: int_msg_ret = msg_post((RAW_QUEUE *)(int_msg->object), int_msg->msg, SEND_TO_END, WAKE_ONE_QUEUE); break; case RAW_TYPE_Q_ALL: int_msg_ret = msg_post((RAW_QUEUE *)(int_msg->object), int_msg->msg, int_msg->opt, WAKE_ALL_QUEUE); break; #endif #if (CONFIG_RAW_QUEUE_SIZE > 0) case RAW_TYPE_Q_SIZE_FRONT: int_msg_ret = msg_size_post((RAW_QUEUE_SIZE *)(int_msg->object), int_msg->msg, int_msg->msg_size, SEND_TO_FRONT, WAKE_ONE_QUEUE); break; case RAW_TYPE_Q_SIZE_END: int_msg_ret = msg_size_post((RAW_QUEUE_SIZE *)(int_msg->object), int_msg->msg, int_msg->msg_size, SEND_TO_END, WAKE_ONE_QUEUE); break; case RAW_TYPE_Q_SIZE_ALL: int_msg_ret = msg_size_post((RAW_QUEUE_SIZE *)(int_msg->object), int_msg->msg, int_msg->msg_size, int_msg->opt, WAKE_ALL_QUEUE); break; #endif #if (CONFIG_RAW_EVENT > 0) case RAW_TYPE_EVENT: int_msg_ret = event_set((RAW_EVENT *)(int_msg->object), int_msg->event_flags, int_msg->opt); break; #endif #if (CONFIG_RAW_IDLE_EVENT > 0) case RAW_TYPE_IDLE_END_EVENT_POST: int_msg_ret = event_post((ACTIVE_EVENT_STRUCT *)(int_msg->object), int_msg->msg_size, int_msg->msg, SEND_TO_END); break; case RAW_TYPE_IDLE_FRONT_EVENT_POST: int_msg_ret = event_post((ACTIVE_EVENT_STRUCT *)(int_msg->object), int_msg->msg_size, int_msg->msg, SEND_TO_FRONT); break; #endif default: RAW_ASSERT(0); } if (int_msg_ret != RAW_SUCCESS) { /*trace the incorrect information here, there is no way to infrom user at this condition*/ TRACE_INT_MSG_HANDLE_ERROR(ev, int_msg->object, int_msg_ret); } RAW_CPU_DISABLE(); int_msg->next = free_object_int_msg; free_object_int_msg = int_msg; RAW_CPU_ENABLE(); }