task_irq: Simplify task_irq_test() API family
Changes the task IRQ API so that not only does task_irq_test() become task_irq_wait(), but that the timeout parameter must also be specified. Use of task_irq_wait() obsoletes the following APIs: task_irq_test() task_irq_test_wait() task_irq_test_wait_timeout() _task_irq_test() Change-Id: Ie4d15f29941429249e9fbb258d29ec2b3ae73a93 Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
This commit is contained in:
parent
b4ba8087e7
commit
1a163f53b7
5 changed files with 22 additions and 66 deletions
|
@ -91,7 +91,7 @@ acknowledge the interrupt, and take the necessary steps to service it.
|
|||
|
||||
.. code-block:: c
|
||||
|
||||
task_irq_test_wait(FOO_DEVICE);
|
||||
task_irq_wait(FOO_DEVICE, TICKS_UNLIMITED);
|
||||
|
||||
/* Device interrupt is now masked */
|
||||
/* Do pre-acknowledgement device processing (if any) */
|
||||
|
@ -134,11 +134,5 @@ The following task IRQ APIs are provided by :file:`microkernel.h`:
|
|||
:cpp:func:`task_irq_free()`
|
||||
Unbinds a task IRQ from a device and disables interrupts.
|
||||
|
||||
:c:func:`task_irq_test()`
|
||||
Tests to determine if an interrupt has occurred.
|
||||
|
||||
:c:func:`task_irq_test_wait()`
|
||||
Waits for an interrupt to occur.
|
||||
|
||||
:c:func:`task_irq_test_wait_timeout()`
|
||||
Waits for an interrupt to occur within a specified time period.
|
||||
:c:func:`task_irq_wait()`
|
||||
Waits for an interrupt to occur within a specified time period.
|
||||
|
|
|
@ -50,14 +50,6 @@
|
|||
*/
|
||||
extern uint32_t task_irq_alloc(kirq_t irq_obj, uint32_t irq, uint32_t priority,
|
||||
uint32_t flags);
|
||||
/**
|
||||
* @cond internal
|
||||
*/
|
||||
extern int _task_irq_test(kirq_t irq_ob, int32_t time);
|
||||
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -82,43 +74,23 @@ extern void task_irq_ack(kirq_t irq_obj);
|
|||
extern void task_irq_free(kirq_t irq_obj);
|
||||
|
||||
/**
|
||||
* @brief Determine if a task IRQ object has had an interrupt
|
||||
* @brief Wait for task IRQ to signal an interrupt
|
||||
*
|
||||
* This tests a task IRQ object to see if it has signaled an interrupt.
|
||||
* It fails immediately if no interrupt has occurred.
|
||||
* This routine waits up to @a timeout ticks for the IRQ object @a irq_obj
|
||||
* to signal an interrupt.
|
||||
*
|
||||
* @param irq_obj IRQ object identifier
|
||||
* @param timeout Affects the action taken should the task IRQ not yet be
|
||||
* signaled. If TICKS_NONE, the return immediately. If TICKS_UNLIMITED, then
|
||||
* wait as long as necessary. Otherwise wait up to the specified number of
|
||||
* ticks before timing out.
|
||||
*
|
||||
* @return RC_OK, RC_FAIL
|
||||
* @retval RC_OK Successfully detected signaled interrupt
|
||||
* @retval RC_TIME Timed out while waiting for interrupt
|
||||
* @retval RC_FAIL Failed to immediately detect signaled interrupt when
|
||||
* @a timeout = TICKS_NONE
|
||||
*/
|
||||
#define task_irq_test(irq_obj) _task_irq_test(irq_obj, TICKS_NONE)
|
||||
|
||||
/**
|
||||
* @brief Determine if a task IRQ object has had an interrupt and wait
|
||||
*
|
||||
* This tests a task IRQ object to see if it has signaled an interrupt.
|
||||
* It waits forever for a interrupt to happen.
|
||||
*
|
||||
* @param irq_obj IRQ object identifier
|
||||
*
|
||||
* @return RC_OK
|
||||
*/
|
||||
#define task_irq_test_wait(irq_obj) _task_irq_test(irq_obj, TICKS_UNLIMITED)
|
||||
|
||||
#ifdef CONFIG_SYS_CLOCK_EXISTS
|
||||
/**
|
||||
* @brief Determine if a task IRQ object has had an interrupt and timeout
|
||||
*
|
||||
* This tests a task IRQ object to see if it has signaled an interrupt
|
||||
* with a timeout option.
|
||||
*
|
||||
* @param irq_obj IRQ object identifier
|
||||
* @param time Time to wait (in ticks)
|
||||
*
|
||||
* @return RC_OK, RC_FAIL, or RC_TIME
|
||||
*/
|
||||
#define task_irq_test_wait_timeout(irq_obj, time) _task_irq_test(irq_obj, time)
|
||||
#endif
|
||||
extern int task_irq_wait(kirq_t irq_obj, int32_t timeout);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
|
@ -145,23 +145,13 @@ void task_irq_ack(kirq_t irq_obj)
|
|||
irq_enable(task_irq_object[irq_obj].irq);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Determine if a task IRQ object has had an interrupt
|
||||
*
|
||||
* This tests a task IRQ object to see if it has signaled an interrupt.
|
||||
* @param irq_obj IRQ object identifier
|
||||
* @param time Time to wait (in ticks)
|
||||
*
|
||||
* @return RC_OK, RC_FAIL, or RC_TIME
|
||||
*/
|
||||
int _task_irq_test(kirq_t irq_obj, int32_t time)
|
||||
int task_irq_wait(kirq_t irq_obj, int32_t timeout)
|
||||
{
|
||||
__ASSERT(irq_obj < MAX_TASK_IRQS, "Invalid IRQ object");
|
||||
__ASSERT(task_irq_object[irq_obj].task_id == task_id_get(),
|
||||
"Incorrect Task ID");
|
||||
|
||||
return _task_event_recv(task_irq_object[irq_obj].event, time);
|
||||
return _task_event_recv(task_irq_object[irq_obj].event, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -76,7 +76,7 @@ static pfunc func_array[] = {
|
|||
#ifdef TEST_max
|
||||
/* task device interrupt functions */
|
||||
(pfunc)task_irq_alloc,
|
||||
(pfunc)_task_irq_test,
|
||||
(pfunc)task_irq_wait,
|
||||
(pfunc)task_irq_ack,
|
||||
(pfunc)task_irq_free,
|
||||
/* semaphore functions */
|
||||
|
|
|
@ -85,14 +85,14 @@ int taskA(ksem_t semRdy)
|
|||
|
||||
task_sem_give(semRdy);
|
||||
|
||||
if (task_irq_test_wait(DEV1_ID) != RC_OK) {
|
||||
if (task_irq_wait(DEV1_ID, TICKS_UNLIMITED) != RC_OK) {
|
||||
TC_ERROR("Not able to test IRQ object event\n");
|
||||
return TC_FAIL;
|
||||
}
|
||||
TC_PRINT("Received event for IRQ object %d\n", DEV1_ID);
|
||||
task_irq_ack(DEV1_ID);
|
||||
|
||||
if (task_irq_test_wait(DEV2_ID) != RC_OK) {
|
||||
if (task_irq_wait(DEV2_ID, TICKS_UNLIMITED) != RC_OK) {
|
||||
TC_ERROR("Not able to test IRQ object event\n");
|
||||
return TC_FAIL;
|
||||
}
|
||||
|
@ -157,14 +157,14 @@ int taskB(ksem_t semRdy)
|
|||
|
||||
task_sem_give(semRdy);
|
||||
|
||||
if (task_irq_test_wait(DEV3_ID) != RC_OK) {
|
||||
if (task_irq_wait(DEV3_ID, TICKS_UNLIMITED) != RC_OK) {
|
||||
TC_ERROR("Not able to test IRQ object event\n");
|
||||
return TC_FAIL;
|
||||
}
|
||||
TC_PRINT("Received event for IRQ object %d\n", DEV3_ID);
|
||||
task_irq_ack(DEV3_ID);
|
||||
|
||||
if (task_irq_test_wait(DEV4_ID) != RC_OK) {
|
||||
if (task_irq_wait(DEV4_ID, TICKS_UNLIMITED) != RC_OK) {
|
||||
TC_ERROR("Not able to test IRQ object event\n");
|
||||
return TC_FAIL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue