關 閉

        新聞中心

        EEPW首頁 > 工控自動化 > 設計應用 > 觸控設備手勢喚醒的設計思路及其實現

        觸控設備手勢喚醒的設計思路及其實現

        作者: 時間:2012-07-14 來源:網絡 收藏
        示例代碼3

        本文引用地址:http://www.104case.com/article/160306.htm

          // this handles hardware-level interrupts on the micro

          __interrupt void irq_handler( void )

          {

          ...

          // if the hardware interrupt came from the MAX44000 sensor

          // pulling its INT pin low

          if ( irq_source == MAX44000 )

          {

          // if the device is in sleep mode

          if (device_status == SLEEP_MODE)

          {

          device_status = WAKE_MODE; // wake up the device

          ...

          // reconfigure whatever else you need here as the system wakes up

          }

          // otherwise, handle it however it is you wish

          else

          {

          ...

          }

          }

          ...

          }

          /**

          * configure_max44000_for_sleep_mode()

          *

          * Sets up the MAX44000 to trigger a hardware interrupt when the proximity

          * counts go above some set threshold.

          *

          * Arguments:

          * uint8 upper_threshold - the set threshold (8-bit mode)

          *

          * Returns:

          * n/a

          */

          void configure_max44000_for_sleep_mode(uint8 upper_threshold)

          {

          uint8 max44000_thresh_registers[] = {0x0B,0x0C};

          uint8 max44000_upper_thresh[] = {0x40,0};

          max44000_upper_thresh[1] = upper_threshold;

          // do a consecutive write of 0 followed by upper_threshold to

          // registers 0xB and 0xC, respectively

          // MAX44000_ADDR is usually 0x94

          // interrupt will trigger only if proximity value is above the threshold

          write_i2c_register(MAX44000_ADDR,max44000_thresh_registers,

          max44000_upper_thresh,2);

          // write to bits 2 and 3 of register 0x0A here if you wish to set the

          // persist time to anything other than one sample

          // writes to register 0x01 to enable interrupts on the MAX44000

          max44000_enable_interrupt();

          return;

          }


        上一頁 1 2 3 4 下一頁

        評論


        相關推薦

        技術專區

        關閉
        主站蜘蛛池模板: 碌曲县| 韶关市| 绥宁县| 铜陵市| 广宁县| 池州市| 吉隆县| 昌平区| 瑞金市| 汾西县| 吴川市| 长丰县| 百色市| 个旧市| 琼结县| 绵阳市| 建始县| 兴国县| 上饶县| 旌德县| 漳平市| 娄烦县| 隆子县| 无为县| 库伦旗| 锡林郭勒盟| 盐山县| 定安县| 靖安县| 眉山市| 忻州市| 万山特区| 上高县| 泸州市| 古浪县| 门头沟区| 平湖市| 武夷山市| 湖北省| 南宁市| 通山县|