77#define analog_function_enable(_reg,_pin) (_reg |= 1U << _pin)
85#define alternate_function_enable(_pin) (GPIO_PORTB_AHB_AFSEL_R |= 1U << _pin)
90#define GPIO_PORTB_PIN0 (0)
91#define GPIO_PORTB_PIN1 (1)
92#define GPIO_PORTL_PIN6 (6)
93#define GPIO_PORTL_PIN7 (7)
94#define USB_DP_PIN GPIO_PORTL_PIN6
95#define USB_DN_PIN GPIO_PORTL_PIN7
96#define USB_ID_PIN GPIO_PORTB_PIN0
97#define USB_VBUS_PIN GPIO_PORTB_PIN1
109static const unsigned long assumed_mosc_value = 25;
111static unsigned long get_vco_in_mhz(
void){
112 unsigned long result = 480;
113 const unsigned long sysctl_rsclkcfg_pllsrc24_mask = (0xFUL << 24),
114 mfrac = (SYSCTL_PLLFREQ0_R >> 10) & 0x3FF,
115 mint = SYSCTL_PLLFREQ0_R & 0x3FF,
116 q = (SYSCTL_PLLFREQ1_R >> 8) & 0x1F,
117 n = SYSCTL_PLLFREQ1_R & 0x1F;
119 if ( SYSCTL_RSCLKCFG_R & SYSCTL_RSCLKCFG_USEPLL ){
120 if ( ( SYSCTL_RSCLKCFG_R & sysctl_rsclkcfg_pllsrc24_mask ) == 0 ) {
121 result = ( 16 * ( mint + ( mfrac / 1024 ) ) ) / ( ( q + 1 ) * ( n + 1 ) );
122 }
else if ( ( SYSCTL_RSCLKCFG_R & sysctl_rsclkcfg_pllsrc24_mask ) == ( 3UL << 24 ) ) {
127 result = ( assumed_mosc_value * ( mint + ( mfrac / 1024 ) ) ) / ( ( q + 1 ) * ( n + 1 ) );
134static void usb_set_cc(
void){
135 unsigned long reg = USB0_CC_R,
136 clkdiv = (get_vco_in_mhz() / 60 - 1);
138 reg &= ~(0xFUL | USB_CC_CSD);
139 reg |= (clkdiv & 0xF) | USB_CC_CLKEN;
151static inline void usb_hw_init(
void) {
153 SYSCTL_RCGCGPIO_R |= SYSCTL_RCGCGPIO_R1;
155 SYSCTL_RCGCGPIO_R |= SYSCTL_RCGCGPIO_R10;
172 SYSCTL_RCGCUSB_R |= SYSCTL_RCGCUSB_R0;
#define GPIO_PORTB_PIN0
Pin numbers.
Definition usb_hw.h:89
#define alternate_function_enable(_pin)
Enable alternate functionality.
Definition usb_hw.h:84
#define analog_function_enable(_pin)
Enable analog functionality.
Definition usb_hw.h:77