2
2
3
3
#define TAG "MagHelpers"
4
4
5
- // Haviv Board - pins gpio_ext_pa7 & gpio_ext_pa6 was swapped.
6
- #define GPIO_PIN_A &gpio_ext_pa7
7
- #define GPIO_PIN_B &gpio_ext_pa6
8
- #define GPIO_PIN_ENABLE &gpio_ext_pa4
9
- #define RFID_PIN_OUT &gpio_rfid_carrier_out
10
-
11
5
#define ZERO_PREFIX 25 // n zeros prefix
12
6
#define ZERO_BETWEEN 53 // n zeros between tracks
13
7
#define ZERO_SUFFIX 25 // n zeros suffix
@@ -22,15 +16,15 @@ uint8_t last_value = 2;
22
16
void play_halfbit (bool value , MagState * state ) {
23
17
switch (state -> tx ) {
24
18
case MagTxStateRFID :
25
- furi_hal_gpio_write (RFID_PIN_OUT , value );
19
+ furi_hal_gpio_write (& gpio_rfid_carrier_out , value );
26
20
/*furi_hal_gpio_write(RFID_PIN_OUT, !value);
27
21
furi_hal_gpio_write(RFID_PIN_OUT, value);
28
22
furi_hal_gpio_write(RFID_PIN_OUT, !value);
29
23
furi_hal_gpio_write(RFID_PIN_OUT, value);*/
30
24
break ;
31
25
case MagTxStateGPIO :
32
- furi_hal_gpio_write (GPIO_PIN_A , value );
33
- furi_hal_gpio_write (GPIO_PIN_B , !value );
26
+ furi_hal_gpio_write (mag_state_enum_to_pin ( state -> pin_input ) , value );
27
+ furi_hal_gpio_write (mag_state_enum_to_pin ( state -> pin_output ) , !value );
34
28
break ;
35
29
case MagTxStatePiezo :
36
30
furi_hal_gpio_write (& gpio_speaker , value );
@@ -41,7 +35,7 @@ void play_halfbit(bool value, MagState* state) {
41
35
42
36
break ;
43
37
case MagTxStateLF_P :
44
- furi_hal_gpio_write (RFID_PIN_OUT , value );
38
+ furi_hal_gpio_write (& gpio_rfid_carrier_out , value );
45
39
furi_hal_gpio_write (& gpio_speaker , value );
46
40
47
41
/* // Weaker but cleaner signal
@@ -143,14 +137,14 @@ void tx_init_rfid() {
143
137
furi_hal_gpio_init (& gpio_nfc_irq_rfid_pull , GpioModeOutputPushPull , GpioPullNo , GpioSpeedLow );
144
138
furi_hal_gpio_write (& gpio_nfc_irq_rfid_pull , false);
145
139
146
- furi_hal_gpio_init (RFID_PIN_OUT , GpioModeOutputPushPull , GpioPullNo , GpioSpeedLow );
140
+ furi_hal_gpio_init (& gpio_rfid_carrier_out , GpioModeOutputPushPull , GpioPullNo , GpioSpeedLow );
147
141
148
142
furi_delay_ms (300 );
149
143
}
150
144
151
145
void tx_deinit_rfid () {
152
146
// reset RFID system
153
- furi_hal_gpio_write (RFID_PIN_OUT , 0 );
147
+ furi_hal_gpio_write (& gpio_rfid_carrier_out , 0 );
154
148
155
149
furi_hal_rfid_pins_reset ();
156
150
}
@@ -187,11 +181,23 @@ bool tx_init(MagState* state) {
187
181
break ;
188
182
case MagTxStateGPIO :
189
183
// gpio_item_configure_all_pins(GpioModeOutputPushPull);
190
- furi_hal_gpio_init (GPIO_PIN_A , GpioModeOutputPushPull , GpioPullNo , GpioSpeedLow );
191
- furi_hal_gpio_init (GPIO_PIN_B , GpioModeOutputPushPull , GpioPullNo , GpioSpeedLow );
192
- furi_hal_gpio_init (GPIO_PIN_ENABLE , GpioModeOutputPushPull , GpioPullNo , GpioSpeedLow );
193
-
194
- furi_hal_gpio_write (GPIO_PIN_ENABLE , 1 );
184
+ furi_hal_gpio_init (
185
+ mag_state_enum_to_pin (state -> pin_input ),
186
+ GpioModeOutputPushPull ,
187
+ GpioPullNo ,
188
+ GpioSpeedLow );
189
+ furi_hal_gpio_init (
190
+ mag_state_enum_to_pin (state -> pin_output ),
191
+ GpioModeOutputPushPull ,
192
+ GpioPullNo ,
193
+ GpioSpeedLow );
194
+ furi_hal_gpio_init (
195
+ mag_state_enum_to_pin (state -> pin_enable ),
196
+ GpioModeOutputPushPull ,
197
+ GpioPullNo ,
198
+ GpioSpeedLow );
199
+
200
+ furi_hal_gpio_write (mag_state_enum_to_pin (state -> pin_enable ), 1 );
195
201
196
202
// had some issues with ~300; bumped higher temporarily
197
203
furi_delay_ms (500 );
@@ -226,14 +232,17 @@ bool tx_deinit(MagState* state) {
226
232
tx_deinit_rfid ();
227
233
break ;
228
234
case MagTxStateGPIO :
229
- furi_hal_gpio_write (GPIO_PIN_A , 0 );
230
- furi_hal_gpio_write (GPIO_PIN_B , 0 );
231
- furi_hal_gpio_write (GPIO_PIN_ENABLE , 0 );
235
+ furi_hal_gpio_write (mag_state_enum_to_pin ( state -> pin_input ) , 0 );
236
+ furi_hal_gpio_write (mag_state_enum_to_pin ( state -> pin_output ) , 0 );
237
+ furi_hal_gpio_write (mag_state_enum_to_pin ( state -> pin_enable ) , 0 );
232
238
233
239
// set back to analog output mode? - YES
234
- furi_hal_gpio_init (GPIO_PIN_A , GpioModeAnalog , GpioPullNo , GpioSpeedLow );
235
- furi_hal_gpio_init (GPIO_PIN_B , GpioModeAnalog , GpioPullNo , GpioSpeedLow );
236
- furi_hal_gpio_init (GPIO_PIN_ENABLE , GpioModeAnalog , GpioPullNo , GpioSpeedLow );
240
+ furi_hal_gpio_init (
241
+ mag_state_enum_to_pin (state -> pin_input ), GpioModeAnalog , GpioPullNo , GpioSpeedLow );
242
+ furi_hal_gpio_init (
243
+ mag_state_enum_to_pin (state -> pin_output ), GpioModeAnalog , GpioPullNo , GpioSpeedLow );
244
+ furi_hal_gpio_init (
245
+ mag_state_enum_to_pin (state -> pin_enable ), GpioModeAnalog , GpioPullNo , GpioSpeedLow );
237
246
238
247
//gpio_item_configure_all_pins(GpioModeAnalog);
239
248
break ;
0 commit comments