6
6
7
7
#pragma once
8
8
9
- #include "soc/soc_caps.h"
10
- /*
11
- This header is shared across all targets. Resolve to an empty header for targets
12
- that don't support USB OTG.
13
- */
14
- #if SOC_USB_OTG_SUPPORTED
15
9
#include <stdint.h>
16
10
#include <stdbool.h>
17
11
#include "soc/usb_dwc_struct.h"
18
12
#include "soc/usb_dwc_cfg.h"
19
13
#include "hal/usb_dwc_types.h"
20
14
#include "hal/misc.h"
21
- #endif // SOC_USB_OTG_SUPPORTED
22
15
23
16
#ifdef __cplusplus
24
17
extern "C" {
25
18
#endif
26
19
27
- #if SOC_USB_OTG_SUPPORTED
20
+ /* ----------------------------- Helper Macros ------------------------------ */
21
+
22
+ // Get USB hardware instance
23
+ // TODO: extend this macros when we have support for both FS and HS hardware on P4
24
+ #define USB_DWC_LL_GET_HW (num ) (&USB_DWC_HS)
28
25
29
26
/* -----------------------------------------------------------------------------
30
27
--------------------------------- DWC Constants --------------------------------
@@ -222,14 +219,14 @@ static inline void usb_dwc_ll_gusbcfg_set_timeout_cal(usb_dwc_dev_t *hw, uint8_t
222
219
hw -> gusbcfg_reg .toutcal = tout_cal ;
223
220
}
224
221
225
- #if (OTG_HSPHY_INTERFACE != 0 )
226
222
static inline void usb_dwc_ll_gusbcfg_set_utmi_phy (usb_dwc_dev_t * hw )
227
223
{
224
+ #if (OTG_HSPHY_INTERFACE != 0 )
228
225
hw -> gusbcfg_reg .phyif = 1 ; // 16 bits interface
229
226
hw -> gusbcfg_reg .ulpiutmisel = 0 ; // UTMI+
230
227
hw -> gusbcfg_reg .physel = 0 ; // HS PHY
231
- }
232
228
#endif // (OTG_HSPHY_INTERFACE != 0)
229
+ }
233
230
234
231
// --------------------------- GRSTCTL Register --------------------------------
235
232
@@ -356,9 +353,9 @@ static inline uint32_t usb_dwc_ll_gsnpsid_get_id(usb_dwc_dev_t *hw)
356
353
// --------------------------- GHWCFGx Register --------------------------------
357
354
358
355
/**
359
- * @brief Get the hardware configuration regiters of the DWC_OTG controller
356
+ * @brief Get the hardware configuration registers of the DWC_OTG controller
360
357
*
361
- * The hardware configuraiton regitsers are read only and indicate the various
358
+ * The hardware configuration regitsers are read only and indicate the various
362
359
* features of the DWC_OTG core.
363
360
*
364
361
* @param hw Start address of the DWC_OTG registers
@@ -405,7 +402,7 @@ static inline void usb_dwc_ll_hcfg_dis_perio_sched(usb_dwc_dev_t *hw)
405
402
/**
406
403
* Sets the length of the frame list
407
404
*
408
- * @param num_entires Number of entires in the frame list
405
+ * @param num_entires Number of entries in the frame list
409
406
*/
410
407
static inline void usb_dwc_ll_hcfg_set_num_frame_list_entries (usb_dwc_dev_t * hw , usb_hal_frame_list_len_t num_entries )
411
408
{
@@ -903,7 +900,7 @@ static inline usb_dwc_host_chan_regs_t *usb_dwc_ll_chan_get_regs(usb_dwc_dev_t *
903
900
// ------------------------------ QTD related ----------------------------------
904
901
905
902
#define USB_DWC_LL_QTD_STATUS_SUCCESS 0x0 //If QTD was processed, it indicates the data was transmitted/received successfully
906
- #define USB_DWC_LL_QTD_STATUS_PKTERR 0x1 //Data trasnmitted /received with errors (CRC/Timeout/Stuff/False EOP/Excessive NAK).
903
+ #define USB_DWC_LL_QTD_STATUS_PKTERR 0x1 //Data transmitted /received with errors (CRC/Timeout/Stuff/False EOP/Excessive NAK).
907
904
//Note: 0x2 is reserved
908
905
#define USB_DWC_LL_QTD_STATUS_BUFFER 0x3 //AHB error occurred.
909
906
#define USB_DWC_LL_QTD_STATUS_NOT_EXECUTED 0x4 //QTD as never processed
@@ -914,7 +911,7 @@ static inline usb_dwc_host_chan_regs_t *usb_dwc_ll_chan_get_regs(usb_dwc_dev_t *
914
911
* @param qtd Pointer to the QTD
915
912
* @param data_buff Pointer to buffer containing the data to transfer
916
913
* @param xfer_len Number of bytes in transfer. Setting 0 will do a zero length IN transfer.
917
- * Non zero length must be mulitple of the endpoint's MPS.
914
+ * Non zero length must be multiple of the endpoint's MPS.
918
915
* @param hoc Halt on complete (will generate an interrupt and halt the channel)
919
916
*/
920
917
static inline void usb_dwc_ll_qtd_set_in (usb_dwc_ll_dma_qtd_t * qtd , uint8_t * data_buff , int xfer_len , bool hoc )
@@ -932,7 +929,7 @@ static inline void usb_dwc_ll_qtd_set_in(usb_dwc_ll_dma_qtd_t *qtd, uint8_t *dat
932
929
/**
933
930
* @brief Set a QTD for a non isochronous OUT transfer
934
931
*
935
- * @param qtd Poitner to the QTD
932
+ * @param qtd Pointer to the QTD
936
933
* @param data_buff Pointer to buffer containing the data to transfer
937
934
* @param xfer_len Number of bytes to transfer. Setting 0 will do a zero length transfer.
938
935
* For ctrl setup packets, this should be set to 8.
@@ -972,9 +969,9 @@ static inline void usb_dwc_ll_qtd_set_null(usb_dwc_ll_dma_qtd_t *qtd)
972
969
/**
973
970
* @brief Get the status of a QTD
974
971
*
975
- * When a channel get's halted, call this to check whether each QTD was executed successfully
972
+ * When a channel gets halted, call this to check whether each QTD was executed successfully
976
973
*
977
- * @param qtd Poitner to the QTD
974
+ * @param qtd Pointer to the QTD
978
975
* @param[out] rem_len Number of bytes ramining in the QTD
979
976
* @param[out] status Status of the QTD
980
977
*/
@@ -992,8 +989,6 @@ static inline void usb_dwc_ll_qtd_get_status(usb_dwc_ll_dma_qtd_t *qtd, int *rem
992
989
qtd -> buffer_status_val = 0 ;
993
990
}
994
991
995
- #endif // SOC_USB_OTG_SUPPORTED
996
-
997
992
#ifdef __cplusplus
998
993
}
999
994
#endif
0 commit comments