diff options
Diffstat (limited to 'software/rda1846dongle')
-rw-r--r-- | software/rda1846dongle/rda1846.c | 20 | ||||
-rw-r--r-- | software/rda1846dongle/rda1846.h | 3 | ||||
-rw-r--r-- | software/rda1846dongle/rda1846dongle.c | 8 |
3 files changed, 20 insertions, 11 deletions
diff --git a/software/rda1846dongle/rda1846.c b/software/rda1846dongle/rda1846.c index 9f8f356..3b89f2a 100644 --- a/software/rda1846dongle/rda1846.c +++ b/software/rda1846dongle/rda1846.c @@ -142,8 +142,8 @@ void rda1846_reg_init(void) // rda1846_write_register(RDA1846_REG_TX_VOICE, RDA1846_TX_VOICE_TONE2); // rda1846_write_register(RDA1846_REG_DTMF_T2, 6689); -// rda1846_write_register(RDA1846_REG_DTMF_CTL, RDA1846_DTMF_DUAL | RDA1846_DTMF_EN); -// rda1846_write_register(RDA1846_REG_INT, RDA1846_INT_DTMF_IDLE); + rda1846_write_register(RDA1846_REG_DTMF_CTL, RDA1846_DTMF_DUAL | RDA1846_DTMF_EN); + rda1846_write_register(RDA1846_REG_INT, RDA1846_INT_DTMF_IDLE); rda1846_gpio_default(); } @@ -299,17 +299,23 @@ uint16_t rda1846_get_flags(void) return data & 0x1687; } -uint8_t rda1846_get_dtmf(uint8_t* idx1, uint8_t* idx2, uint8_t* code) +uint16_t rda1846_get_dtmf(uint8_t* idx1, uint8_t* idx2, uint8_t* code, uint8_t* valid) { uint16_t data; if(rda1846_read_register(RDA1846_REG_DTMF_OUT, &data)) - return 1; + return 0xFFFF; - if(idx1) *idx1 = (uint8_t)((data & 0x0380)>>7); - if(idx2) *idx2 = (uint8_t)((data & 0x0070)>>4); + if(idx1) *idx1 = (uint8_t)((data & 0x0700)>>8); + if(idx2) *idx2 = (uint8_t)((data & 0x00E0)>>5); if(code) *code = (uint8_t)(data & 0x000F); + if(valid) *valid = data & 0x0010 ? 0 : 1; - return 0; + return data; +} + +void rda1846_clear_int(void) +{ + rda1846_write_register(0x00, 0x1846); } int32_t rda1846_get_freq_kHz(void) diff --git a/software/rda1846dongle/rda1846.h b/software/rda1846dongle/rda1846.h index 7e22a7e..35246cb 100644 --- a/software/rda1846dongle/rda1846.h +++ b/software/rda1846dongle/rda1846.h @@ -57,7 +57,8 @@ void rda1846_gpio_off(void); int16_t rda1846_get_rssi(void); int16_t rda1846_get_vssi(void); uint16_t rda1846_get_flags(void); -uint8_t rda1846_get_dtmf(uint8_t*, uint8_t*, uint8_t*); +uint16_t rda1846_get_dtmf(uint8_t*, uint8_t*, uint8_t*, uint8_t*); +void rda1846_clear_int(void); int32_t rda1846_get_freq_kHz(void); uint8_t rda1846_set_freq_kHz(int32_t freq); diff --git a/software/rda1846dongle/rda1846dongle.c b/software/rda1846dongle/rda1846dongle.c index d6f1b85..94f4b26 100644 --- a/software/rda1846dongle/rda1846dongle.c +++ b/software/rda1846dongle/rda1846dongle.c @@ -156,11 +156,13 @@ static void print_status(void) static void print_dtmf(void) { - uint8_t idx1, idx2, code; - if(rda1846_get_dtmf(&idx1, &idx2, &code)) + uint8_t idx1, idx2, code, valid; + uint16_t raw = rda1846_get_dtmf(&idx1, &idx2, &code, &valid); + if(raw == 0xFFFF) printf("DTMF: ERROR\r\n"); else - printf("DTMF: tone1=%d, tone2=%d, code=0x%02X\r\n", idx1, idx2, code); + printf("DTMF: raw=0x%04X, tone1=%d, tone2=%d, code=0x%02X, valid=%d\r\n", raw, idx1, idx2, code, valid); + rda1846_clear_int(); } |