1 /* 2 * Author: Jon Trulson <jtrulson@ics.com> 3 * Copyright (c) 2015 Intel Corporation. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining 6 * a copy of this software and associated documentation files (the 7 * "Software"), to deal in the Software without restriction, including 8 * without limitation the rights to use, copy, modify, merge, publish, 9 * distribute, sublicense, and/or sell copies of the Software, and to 10 * permit persons to whom the Software is furnished to do so, subject to 11 * the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be 14 * included in all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 */ 24 #pragma once 25 26 #include <stdint.h> 27 28 #include <mraa/gpio.h> 29 30 namespace upm { 31 /** 32 * @brief HT9170 DTMF Decoder library 33 * @defgroup ht9170 libupm-ht9170 34 * @ingroup seeed gpio other 35 */ 36 37 /** 38 * @library ht9170 39 * @sensor ht9170 40 * @comname HT9170 DTMF Decoder 41 * @altname HT9170B, HT9170D 42 * @type other 43 * @man seeed 44 * @web http://www.seeedstudio.com/depot/DTMFDual-Tone-Multi-Frequency-Shield-p-1839.html 45 * @con gpio 46 * 47 * @brief API for the HT9170 DTMF Decoder 48 * 49 * This driver was developed using the DTMF (Dual-Tone 50 * Multi-Frequency) Shield by Seeed Studio*. It can decode DTMF signals presented at 51 * its audio input. It does not generate DTMF signals. 52 * 53 * @image html ht9170.jpg 54 * @snippet ht9170.cxx Interesting 55 */ 56 class HT9170 { 57 public: 58 59 /** 60 * HT9170 constructor 61 * 62 * @param dr Data ready pin 63 * @param o1 Digital pin for data output 1 64 * @param o2 Digital pin for data output 2 65 * @param o3 Digital pin for data output 3 66 * @param o4 Digital pin for data output 4 67 */ 68 HT9170(int dr, int o1, int o2, int o3, int o4); 69 70 /** 71 * HT9170 destructor 72 */ 73 ~HT9170(); 74 75 /** 76 * Checks to see if a DTMF number is ready to be read 77 * 78 * @return True if there is a digit available to decode 79 */ 80 bool digitReady(); 81 82 /** 83 * Decodes a digit and returns it 84 * 85 */ 86 char decodeDigit(); 87 88 private: 89 mraa_gpio_context m_dr; 90 mraa_gpio_context m_o1; 91 mraa_gpio_context m_o2; 92 mraa_gpio_context m_o3; 93 mraa_gpio_context m_o4; 94 }; 95 } 96 97 98