⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kpd_test_misc0.c

📁 MMI层OBJ不能完全编译
💻 C
📖 第 1 页 / 共 5 页
字号:
/********************************************************************************/
/*                                                                              */
/*      File Name:   kpd_test_misc0.c                              */
/*                                                                              */
/*      Purpose:   This file gathers miscellaneous tests for KPD.               */
/*                                                                              */
/*      Notes:      None.                                                       */
/*                                                                              */
/*      Revision History:                                                       */
/*      10/29/01      Laurent Sollier         Create.                           */
/*                                                                              */
/*   (C) Copyright 2000 by Texas Instruments Incorporated, All Rights Reserved  */
/*                                                                              */
/********************************************************************************/

/********************************************************************************/
/*                                                                              */
/*   Include files used for KPD testing.                                        */
/*                                                                              */
/********************************************************************************/

#include "tests/rv/rv_test_filter.h"

#if (KPD_MISC == SW_COMPILED)

#include "kpd/kpd_api.h"
#include "tests/rv/rv_test_misc.h"
#include "kpd_test.h"
#include "r2d/lcd_messages_ti.h"
#include "r2d/lcd_messages.h"
#include "r2d/r2d.h"
#include "kpd/kpd_messages_i.h"
#include "kpd/kpd_env.h"
#include "rvm/rvm_use_id_list.h"
#include "kpd_test_misc.h"
#include "kpd_test_misc0.h"

#include <stdio.h>


#define KPD_TEST_MBOX_0 0
#define KPD_TEST_MBOX_1 256
#define KPD_TEST_MBOX_2 512
#define KPD_TEST_MBOX_3 1024

void display_message(T_KPD_KEY_EVENT_MSG* msg_key_event_p, UINT8 i)
{
   char         texte[20];
   static UINT8 val = 1;

   sprintf(texte,"Key %s event   ",msg_key_event_p->key_info.ascii_value_p);
   LCD_WriteString (1, 0, texte, NORMAL);

   if (msg_key_event_p->key_info.press_state == KPD_FIRST_PRESS)
      LCD_WriteString(i,0,"First press    ", NORMAL);
   if (msg_key_event_p->key_info.press_state == KPD_LONG_PRESS)
      LCD_WriteString(i,0,"Long press     ", NORMAL);
   if (msg_key_event_p->key_info.press_state == KPD_REPEAT_PRESS)
   {
      sprintf(texte,"Repeat press %d ",val++);
      LCD_WriteString(i,0,texte, NORMAL);
      if (val == 4) val = 1;
   }

   if (msg_key_event_p->key_info.state == KPD_KEY_RELEASED)
      LCD_WriteString(i,0,"Released       ", NORMAL);
}



/********************************************************************************/
/*                                                                              */
/*      Function Name:   kpd_test_misc_1                                        */
/*                                                                              */
/*      Notes:         This function executes KPD misc test 1.                  */
/*                                                                              */
/*      Revision History:                                                       */
/*      11/05/01      Laurent Sollier         Create.                           */
/*                                                                              */
/********************************************************************************/
T_RV_MISC_RET kpd_test_misc_1(void)
{
   T_RV_MISC_RET  test_verdict   = TEST_PASSED;
   UINT16         received_event;
   T_RV_HDR*      msg_p;
   BOOL           exit = FALSE;

   T_KPD_SUBSCRIBER subscriber_id;
   T_KPD_VIRTUAL_KEY_TABLE notified_keys;
   T_RV_RETURN kpd_return_path;


   /* Test definition */
   kpd_test_trace("*** KPD TEST MISC1: All keys are notified of release event (default event)");
   kpd_test_trace("*** KPD TEST MISC1: Press DISC to exit");


   /* Keypad registration */
   kpd_return_path.addr_id = kpd_test_path.addr_id + KPD_TEST_MBOX_0;
   kpd_return_path.callback_func = 0;
   notified_keys.nb_notified_keys = KPD_NB_PHYSICAL_KEYS;
   kpd_subscribe (&subscriber_id,
                  KPD_DEFAULT_MODE,
                  &notified_keys,
                  kpd_return_path);

   /* loop to process messages */
   while (!exit)
   {
      /* Wait for the necessary events (infinite wait for a msg in the mailbox 0). */
      received_event = rvf_wait(RVF_TASK_MBOX_0_EVT_MASK,0);

      if (received_event & RVF_TASK_MBOX_0_EVT_MASK)
      {
         /* Read the message */
         msg_p = (T_RV_HDR *) rvf_read_mbox(0);

         if (msg_p->dest_addr_id == (kpd_test_path.addr_id + KPD_TEST_MBOX_0))
         {
            switch (msg_p->msg_id)
            {
               case KPD_KEY_EVENT_MSG:
                  {
                  T_KPD_KEY_EVENT_MSG* msg_key_event_p = (T_KPD_KEY_EVENT_MSG*) msg_p;
                  display_message(msg_key_event_p, 2);

                  if (msg_key_event_p->key_info.virtual_key_id == KPD_KEY_DISCONNECT)
                  {
                     kpd_unsubscribe(&subscriber_id);
                     exit = TRUE;
				  }
                  break;
                  }

               case KPD_STATUS_MSG:
                  kpd_test_trace("Received status message in mailbox 0");
                  break;

               default :
                  break;

            }
            rvf_free_buf(msg_p);
         }
      }
   }
   return test_verdict;
}


/********************************************************************************/
/*                                                                              */
/*      Function Name:   kpd_test_misc_2                                        */
/*                                                                              */
/*      Notes:         This function executes KPD misc tests.                   */
/*                                                                              */
/*      Revision History:                                                       */
/*      11/05/01      Laurent Sollier         Create.                           */
/*                                                                              */
/********************************************************************************/
T_RV_MISC_RET kpd_test_misc_2(void)
{
   T_RV_MISC_RET  test_verdict   = TEST_PASSED;
   UINT16         received_event;
   T_RV_HDR*      msg_p;
   BOOL           exit = FALSE;

   T_KPD_SUBSCRIBER subscriber_id;
   T_KPD_VIRTUAL_KEY_TABLE notified_keys;
   T_RV_RETURN kpd_return_path;

   /* Test definition */
   kpd_test_trace("*** KPD TEST MISC2: Keys 1,2,3,* and DISC are notified of released event");
   kpd_test_trace("*** KPD TEST MISC2: Press DISC to exit");


   /* Keypad registration */
   kpd_return_path.addr_id = kpd_test_path.addr_id + KPD_TEST_MBOX_0;
   kpd_return_path.callback_func = 0;
   notified_keys.nb_notified_keys = 5;
   notified_keys.notified_keys[0] = KPD_KEY_1;
   notified_keys.notified_keys[1] = KPD_KEY_2;
   notified_keys.notified_keys[2] = KPD_KEY_3;
   notified_keys.notified_keys[3] = KPD_KEY_STAR;
   notified_keys.notified_keys[4] = KPD_KEY_DISCONNECT;
   kpd_subscribe (&subscriber_id,
                  KPD_DEFAULT_MODE,
                  &notified_keys,
                  kpd_return_path);

   /* loop to process messages */
   while (!exit)
   {
      /* Wait for the necessary events (infinite wait for a msg in the mailbox 0). */
      received_event = rvf_wait(RVF_TASK_MBOX_0_EVT_MASK,0);

      if (received_event & RVF_TASK_MBOX_0_EVT_MASK)
      {
         /* Read the message */
         msg_p = (T_RV_HDR *) rvf_read_mbox(0);

         if (msg_p->dest_addr_id == (kpd_test_path.addr_id + KPD_TEST_MBOX_0))
         {
            switch (msg_p->msg_id)
            {
               case KPD_KEY_EVENT_MSG:
                  {
                  T_KPD_KEY_EVENT_MSG* msg_key_event_p = (T_KPD_KEY_EVENT_MSG*) msg_p;
                  display_message(msg_key_event_p, 2);

                  if (msg_key_event_p->key_info.virtual_key_id == KPD_KEY_DISCONNECT)
                  {
                     kpd_unsubscribe(&subscriber_id);
                     exit = TRUE;
                  }
                  break;
                  }

               case KPD_STATUS_MSG:
                  kpd_test_trace("Received status message in mailbox 0");
                  break;

               default :
                  break;

            }
            rvf_free_buf(msg_p);
         }
      }
   }
   return test_verdict;
}





/********************************************************************************/
/*                                                                              */
/*      Function Name:   kpd_test_misc_3                                        */
/*                                                                              */
/*      Notes:         This function executes KPD misc tests.                   */
/*                                                                              */
/*      Revision History:                                                       */
/*      11/05/01      Laurent Sollier         Create.                           */
/*                                                                              */
/********************************************************************************/
T_RV_MISC_RET kpd_test_misc_3(void)
{
   T_RV_MISC_RET  test_verdict   = TEST_PASSED;
   UINT16         received_event;
   T_RV_HDR*      msg_p;
   BOOL           exit = FALSE;

   T_KPD_SUBSCRIBER subscriber_id0;
   T_KPD_SUBSCRIBER subscriber_id1;
   T_KPD_VIRTUAL_KEY_TABLE notified_keys;
   T_RV_RETURN kpd_return_path;

   /* Test definition */
   kpd_test_trace("*** KPD TEST MISC3: Keys 1,2,3,* and DISC are notified of released event");
   kpd_test_trace("*** KPD TEST MISC3: Press * to unsubscribe");
   kpd_test_trace("*** KPD TEST MISC3: Press DISC to exit");

   /* Keypad registration */
   kpd_return_path.addr_id = kpd_test_path.addr_id + KPD_TEST_MBOX_0;
   kpd_return_path.callback_func = 0;
   notified_keys.nb_notified_keys = KPD_NB_PHYSICAL_KEYS;
   kpd_subscribe (&subscriber_id0,
                  KPD_DEFAULT_MODE,
                  &notified_keys,
                  kpd_return_path);

   /* Keypad registration */
   kpd_return_path.addr_id = kpd_test_path.addr_id + KPD_TEST_MBOX_1;
   kpd_return_path.callback_func = 0;
   notified_keys.nb_notified_keys = 5;
   notified_keys.notified_keys[0] = KPD_KEY_1;
   notified_keys.notified_keys[1] = KPD_KEY_2;
   notified_keys.notified_keys[2] = KPD_KEY_3;
   notified_keys.notified_keys[3] = KPD_KEY_STAR;
   notified_keys.notified_keys[4] = KPD_KEY_DISCONNECT;
   kpd_subscribe (&subscriber_id1,
                  KPD_DEFAULT_MODE,
                  &notified_keys,
                  kpd_return_path);

   /* loop to process messages */
   while (!exit)
   {
      /* Wait for the necessary events (infinite wait for a msg in the mailbox 0). */
      received_event = rvf_wait(RVF_TASK_MBOX_0_EVT_MASK,0);

      if (received_event & RVF_TASK_MBOX_0_EVT_MASK)
      {
         /* Read the message */
         msg_p = (T_RV_HDR *) rvf_read_mbox(0);

         if (msg_p->dest_addr_id == (kpd_test_path.addr_id + KPD_TEST_MBOX_1))
         {
            switch (msg_p->msg_id)
            {
               case KPD_KEY_EVENT_MSG:
                  {
                  T_KPD_KEY_EVENT_MSG* msg_key_event_p = (T_KPD_KEY_EVENT_MSG*) msg_p;

                  display_message(msg_key_event_p, 2);

                  if (msg_key_event_p->key_info.virtual_key_id == KPD_KEY_STAR)
                  {
                     kpd_unsubscribe(&subscriber_id1);
                  }
                  break;
                  }

               case KPD_STATUS_MSG:
                  kpd_test_trace("Received status message in mailbox 1");
                  break;

               default :
                  break;

            }
            rvf_free_buf(msg_p);
         }

         if (msg_p->dest_addr_id == (kpd_test_path.addr_id + KPD_TEST_MBOX_0))
         {
            switch (msg_p->msg_id)
            {
               case KPD_KEY_EVENT_MSG:
                  {
                  T_KPD_KEY_EVENT_MSG* msg_key_event_p = (T_KPD_KEY_EVENT_MSG*) msg_p;

                  if (msg_key_event_p->key_info.virtual_key_id == KPD_KEY_DISCONNECT)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -