@@ -215,16 +215,21 @@ static max3421_data_t _hcd_data;
215
215
// API: SPI transfer with MAX3421E, must be implemented by application
216
216
//--------------------------------------------------------------------+
217
217
218
- void tuh_max3421_spi_cs_api (uint8_t rhport , bool active );
219
- bool tuh_max3421_spi_xfer_api (uint8_t rhport , uint8_t const * tx_buf , size_t tx_len , uint8_t * rx_buf , size_t rx_len );
220
- void tuh_max3421_int_api (uint8_t rhport , bool enabled );
218
+ // API to control MAX3421 SPI CS
219
+ extern void tuh_max3421_spi_cs_api (uint8_t rhport , bool active );
221
220
222
- static void handle_connect_irq (uint8_t rhport , bool in_isr );
223
- static inline void hirq_write (uint8_t rhport , uint8_t data , bool in_isr );
221
+ // API to transfer data with MAX3421 SPI
222
+ // Either tx_buf or rx_buf can be NULL, which means transfer is write or read only
223
+ extern bool tuh_max3421_spi_xfer_api (uint8_t rhport , uint8_t const * tx_buf , uint8_t * rx_buf , size_t xfer_bytes );
224
+
225
+ // API to enable/disable MAX3421 INTR pin interrupt
226
+ extern void tuh_max3421_int_api (uint8_t rhport , bool enabled );
224
227
225
228
//--------------------------------------------------------------------+
226
229
// SPI Helper
227
230
//--------------------------------------------------------------------+
231
+ static void handle_connect_irq (uint8_t rhport , bool in_isr );
232
+ static inline void hirq_write (uint8_t rhport , uint8_t data , bool in_isr );
228
233
229
234
static void max3421_spi_lock (uint8_t rhport , bool in_isr ) {
230
235
// disable interrupt and mutex lock (for pre-emptive RTOS) if not in_isr
@@ -254,9 +259,9 @@ static void fifo_write(uint8_t rhport, uint8_t reg, uint8_t const * buffer, uint
254
259
255
260
max3421_spi_lock (rhport , in_isr );
256
261
257
- tuh_max3421_spi_xfer_api (rhport , & reg , 1 , & hirq , 1 );
262
+ tuh_max3421_spi_xfer_api (rhport , & reg , & hirq , 1 );
258
263
_hcd_data .hirq = hirq ;
259
- tuh_max3421_spi_xfer_api (rhport , buffer , len , NULL , 0 );
264
+ tuh_max3421_spi_xfer_api (rhport , buffer , NULL , len );
260
265
261
266
max3421_spi_unlock (rhport , in_isr );
262
267
@@ -268,9 +273,9 @@ static void fifo_read(uint8_t rhport, uint8_t * buffer, uint16_t len, bool in_is
268
273
269
274
max3421_spi_lock (rhport , in_isr );
270
275
271
- tuh_max3421_spi_xfer_api (rhport , & reg , 1 , & hirq , 1 );
276
+ tuh_max3421_spi_xfer_api (rhport , & reg , & hirq , 1 );
272
277
_hcd_data .hirq = hirq ;
273
- tuh_max3421_spi_xfer_api (rhport , NULL , 0 , buffer , len );
278
+ tuh_max3421_spi_xfer_api (rhport , NULL , buffer , len );
274
279
275
280
max3421_spi_unlock (rhport , in_isr );
276
281
}
@@ -281,7 +286,7 @@ static void reg_write(uint8_t rhport, uint8_t reg, uint8_t data, bool in_isr) {
281
286
282
287
max3421_spi_lock (rhport , in_isr );
283
288
284
- tuh_max3421_spi_xfer_api (rhport , tx_buf , 2 , rx_buf , 2 );
289
+ tuh_max3421_spi_xfer_api (rhport , tx_buf , rx_buf , 2 );
285
290
286
291
max3421_spi_unlock (rhport , in_isr );
287
292
@@ -295,7 +300,7 @@ static uint8_t reg_read(uint8_t rhport, uint8_t reg, bool in_isr) {
295
300
296
301
max3421_spi_lock (rhport , in_isr );
297
302
298
- bool ret = tuh_max3421_spi_xfer_api (rhport , tx_buf , 2 , rx_buf , 2 );
303
+ bool ret = tuh_max3421_spi_xfer_api (rhport , tx_buf , rx_buf , 2 );
299
304
300
305
max3421_spi_unlock (rhport , in_isr );
301
306
0 commit comments