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

📄 kpd_test_misc2.c

📁 MMI层OBJ不能完全编译
💻 C
📖 第 1 页 / 共 2 页
字号:
/********************************************************************************/
/*                                                                              */
/*      File Name:   kpd_test_misc2.c                                            */
/*                                                                              */
/*      Purpose:   This file gathers miscellaneous tests fot KPD.               */
/*                                                                              */
/*      Notes:      None.                                                       */
/*                                                                              */
/*                                                                              */
/*   (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 <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

//Can be removed when the pwr is operational
#define EXIT_KEY    KPD_KEY_SOFT_LEFT
//#define EXIT_KEY    KPD_KEY_DISCONNECT

extern T_KPD_ENV_CTRL_BLK* kpd_env_ctrl_blk;

static 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);
}



#if ((CHIPSET == 12) || (CHIPSET == 15))
/********************************************************************************/
/*                                                                              */
/*      Function Name:   kpd_test_misc_201                                      */
/*                                                                              */
/*      Notes:         This function executes KPD misc tests.                   */
/*                                                                              */
/*                                                                              */
/********************************************************************************/
T_RV_MISC_RET kpd_test_misc_201(void)
{
   T_RV_MISC_RET  test_verdict   = TEST_PASSED;
   UINT16         received_event;
   T_RV_HDR*      msg_p;
   BOOL           exit = FALSE;

   T_RVF_MB_STATUS mb_status;
   T_KPD_GENERIC_INTERRUPT_MSG* msg_interrupt;

   T_KPD_SUBSCRIBER subscriber_id0;
   T_KPD_VIRTUAL_KEY_TABLE notified_keys;
   T_RV_RETURN kpd_return_path;


   /* Test definition */
   kpd_test_trace("*** KPD TEST MISC201: Generate a MISS EVENT interrupt");
   kpd_test_trace("*** KPD TEST MISC201: Press * to generate interrupt");

   /* 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);

   kpd_define_key_notification(subscriber_id0, &notified_keys, KPD_FIRST_PRESS_NOTIF|KPD_RELEASE_NOTIF, 0, 0);

   kpd_register_for_miss_event(subscriber_id0, KPD_MISS_EVENT_ON);

   /* 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 == EXIT_KEY)
                  {
                     kpd_unsubscribe(&subscriber_id0);
                     exit = TRUE;
                  }
                  if (msg_key_event_p->key_info.virtual_key_id == KPD_KEY_STAR)
                  {
                    /* Activate miss_event */
                    mb_status = rvf_get_buf (kpd_env_ctrl_blk->prim_id, sizeof(T_KPD_GENERIC_INTERRUPT_MSG), (void **) &msg_interrupt);
    
                    if (mb_status != RVF_RED) /* Memory allocation success */
                    {
                      msg_interrupt->hdr.msg_id = KPD_MISS_EVENT_INTERRUPT_MSG;
 
                      /* Send message to the keypad task */
                      rvf_send_msg(kpd_env_ctrl_blk->addr_id, msg_interrupt);
                    }
                    else
                    {
                      KPD_SEND_TRACE("KPD: Not enough memory to send interrupt message", RV_TRACE_LEVEL_ERROR);
                    }
                  }
                  break;
                  }

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

               case KPD_KEYPAD_MISS_EVENT_MSG:
                  kpd_test_trace("Received Miss Event Message");
                  break;

               default :
                  break;

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

/********************************************************************************/
/*                                                                              */
/*      Function Name:   kpd_test_misc_202                                      */
/*                                                                              */
/*      Notes:         This function executes KPD misc tests.                   */
/*                                                                              */
/*                                                                              */
/********************************************************************************/
T_RV_MISC_RET kpd_test_misc_202(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_VIRTUAL_KEY_TABLE notified_keys;
   T_RV_RETURN kpd_return_path;


   /* Test definition */
   kpd_test_trace("*** KPD TEST MISC202: Register for key jam");
   kpd_test_trace("*** KPD TEST MISC202: Press a key more than 60 sec to generate interrupt");

   /* 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);

   kpd_define_key_notification(subscriber_id0, &notified_keys, KPD_FIRST_PRESS_NOTIF|KPD_RELEASE_NOTIF, 0, 0);

   kpd_register_for_keypad_timeout(subscriber_id0, KPD_TIMEOUT_KEY_JAM,60000);

   /* 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 == EXIT_KEY)
                    {
                       kpd_unsubscribe(&subscriber_id0);
                       exit = TRUE;
                    }
                    break;
                  }

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

               case KPD_KEYPAD_TIMEOUT_MSG:
                  kpd_test_trace("Received Time out Message");
                  break;

               default :
                  break;

            }
            rvf_free_buf(msg_p);
         }
      }

⌨️ 快捷键说明

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