summaryrefslogtreecommitdiff
path: root/software/rda1846dongle/rda1846.c
diff options
context:
space:
mode:
Diffstat (limited to 'software/rda1846dongle/rda1846.c')
-rw-r--r--software/rda1846dongle/rda1846.c67
1 files changed, 46 insertions, 21 deletions
diff --git a/software/rda1846dongle/rda1846.c b/software/rda1846dongle/rda1846.c
index 6607ec8..921296c 100644
--- a/software/rda1846dongle/rda1846.c
+++ b/software/rda1846dongle/rda1846.c
@@ -326,6 +326,52 @@ rda1846_state_t rda1846_get_state(void)
+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 0xFFFF;
+
+ 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 data;
+}
+
+void rda1846_clear_int(void)
+{
+ rda1846_write_register(0x00, 0x1846);
+}
+
+
+
+void rda1846_set_volume(int8_t vol)
+{
+ uint16_t data;
+ if(vol < -30 || vol > 0)
+ return;
+
+ if(vol >= -15)
+ data = 0x000F | (((vol + 15)<<4) & 0xF0);
+ else
+ data = (vol + 30) & 0x0F;
+
+ rda1846_write_register(RDA1846_REG_RX_VOICE, data);
+}
+
+int8_t rda1846_get_volume(void)
+{
+ uint16_t data;
+ if(rda1846_read_register(RDA1846_REG_RX_VOICE, &data))
+ return 1;
+
+ return (int8_t)(((data & 0x00F0)>>4) + (data & 0x000F)) - 30;
+}
+
+
+
void rda1846_gpio_default(void)
{
rda1846_write_register(RDA1846_REG_GPIO, RDA1846_GPIO_7_VOX | RDA1846_GPIO_6_SQ |
@@ -388,27 +434,6 @@ uint16_t rda1846_get_flags(void)
-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 0xFFFF;
-
- 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 data;
-}
-
-void rda1846_clear_int(void)
-{
- rda1846_write_register(0x00, 0x1846);
-}
-
-
-
static char* rda1846_regaddr_to_string(uint8_t addr)
{
switch(addr) {