1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
diff --git a/firmware/export/config/sansafuzev2.h b/firmware/export/config/sansafuzev2.h
index 4caab84..b920e41 100644
--- a/firmware/export/config/sansafuzev2.h
+++ b/firmware/export/config/sansafuzev2.h
@@ -21,7 +21,7 @@

 /* Define bitmask of input sources - recordable bitmask can be defined
    explicitly if different */
-#define INPUT_SRC_CAPS (SRC_CAP_MIC /*| SRC_CAP_FMRADIO*/)
+#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_FMRADIO)

 /* define this if you have a bitmap LCD display */
 #define HAVE_LCD_BITMAP
@@ -117,7 +117,7 @@
 #define AB_REPEAT_ENABLE 1

 /* FM Tuner - suspected to be the SI4702 */
-//#define CONFIG_TUNER SI4700
+#define CONFIG_TUNER SI4700
 /* #define HAVE_TUNER_PWR_CTRL */

 /* Define this for LCD backlight available */
diff --git a/firmware/target/arm/as3525/fmradio-i2c-as3525.c b/firmware/target/arm/as3525/fmradio-i2c-as3525.c
index c86e3f5..47cb6b6 100644
--- a/firmware/target/arm/as3525/fmradio-i2c-as3525.c
+++ b/firmware/target/arm/as3525/fmradio-i2c-as3525.c
@@ -30,6 +30,7 @@
 #include "as3525.h"
 #include "generic_i2c.h"
 #include "fmradio_i2c.h"
+#include "system.h"

 #if     defined(SANSA_CLIP) || defined(SANSA_C200V2)
 #define I2C_SCL_GPIO(x) GPIOB_PIN(x)
@@ -63,6 +64,14 @@
 #define I2C_SCL_PIN 6
 #define I2C_SDA_PIN 7

+#elif   defined(SANSA_FUZEV2)
+#define I2C_SCL_GPIO(x) GPIOB_PIN(x)
+#define I2C_SDA_GPIO(x) GPIOA_PIN(x)
+#define I2C_SCL_GPIO_DIR GPIOB_DIR
+#define I2C_SDA_GPIO_DIR GPIOA_DIR
+#define I2C_SCL_PIN 1
+#define I2C_SDA_PIN 4
+
 #else
 #error no FM I2C GPIOPIN defines
 #endif
@@ -125,7 +134,7 @@ static void fm_delay(void)
     volatile int i;

     /* this loop is uncalibrated and could use more sophistication */
-    for (i = 0; i < 20; i++) {
+    for (i = 0; i < 100; i++) {
     }
 }

@@ -158,13 +167,14 @@ void fmradio_i2c_init(void)

 int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count)
 {
+    int s = disable_irq_save();
     return i2c_write_data(fm_i2c_bus, address, -1, buf, count);
+    restore_irq(s);
 }

 int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count)
 {
+    int s = disable_irq_save();
     return i2c_read_data(fm_i2c_bus, address, -1, buf, count);
+    restore_irq(s);
 }
-
-
-
diff --git a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
index d23fb43..189a37d 100644
--- a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
+++ b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
@@ -232,6 +232,9 @@ int button_read_device(void)

     CCU_IO &= ~(1<<12);

+    bool gpiob_pin0_dir = GPIOB_DIR & (1<<1);
+    GPIOB_DIR &= ~(1<<1);
+
     GPIOB_PIN(0) = 1<<0;
     udelay(4);

@@ -266,6 +269,9 @@ int button_read_device(void)
         }
     }

+    if(gpiob_pin0_dir)
+        GPIOB_DIR |= 1<<1;
+
     CCU_IO |= 1<<12;

 #ifdef HAS_BUTTON_HOLD