Remove USB pull-up code

This commit is contained in:
fruchti 2021-04-04 20:17:12 +02:00
parent 3ca6ea3e9e
commit fc91c5a032
3 changed files with 4 additions and 12 deletions

View file

@ -1 +1 @@
434 436

View file

@ -7,10 +7,9 @@
#define PIN_UART_RX 10 // PA10 - USART1_RX #define PIN_UART_RX 10 // PA10 - USART1_RX
#define PIN_USB_DM 11 // PA11 - USB_DM #define PIN_USB_DM 11 // PA11 - USB_DM
#define PIN_USB_DP 12 // PA12 - USB_DP #define PIN_USB_DP 12 // PA12 - USB_DP
#define PIN_USB_PULLUP 15 // PA15 - 1.5 kΩ to D+
// Port B // Port B
#define PIN_LED 0 // PB0 - Status LED #define PIN_LED 0 // PB0 - Status LED
#define PIN_SELECT 4 // PB4 - Bus select line #define PIN_SELECT 4 // PB4 - Bus select line
#define PIN_SCL 6 // PB6 - I2C1_SCL #define PIN_SCL 6 // PB6 - I2C1_SCL
#define PIN_SDA 7 // PB7 - I2C1_SDA #define PIN_SDA 7 // PB7 - I2C1_SDA

View file

@ -6,7 +6,6 @@
#include "ownership.h" #include "ownership.h"
MODULE_OWNS_PERIPHERAL(USB); MODULE_OWNS_PERIPHERAL(USB);
MODULE_OWNS_PIN(GPIOA, PIN_USB_PULLUP);
MODULE_OWNS_PIN(GPIOA, PIN_USB_DM); MODULE_OWNS_PIN(GPIOA, PIN_USB_DM);
MODULE_OWNS_PIN(GPIOA, PIN_USB_DP); MODULE_OWNS_PIN(GPIOA, PIN_USB_DP);
@ -15,19 +14,13 @@ volatile unsigned int USB_Address = 0;
void USB_Init(void) void USB_Init(void)
{ {
// Free PA15 (pullup for D+) for use as GPIO // Initialise USB GPIOs to AF mode
AFIO->MAPR = AFIO_MAPR_SWJ_CFG_JTAGDISABLE;
// Initialise USB GPIOs to AF mode, set pullup high
// Note: This will reset the test point pin to an input without pullup // Note: This will reset the test point pin to an input without pullup
GPIOA->ODR = 1 << PIN_USB_PULLUP;
GPIOA->CRH = (0x44444444 GPIOA->CRH = (0x44444444
& ~(0x0f << (PIN_USB_DM * 4 - 32)) & ~(0x0f << (PIN_USB_DM * 4 - 32))
& ~(0x0f << (PIN_USB_DP * 4 - 32)) & ~(0x0f << (PIN_USB_DP * 4 - 32)))
& ~(0x0f << (PIN_USB_PULLUP * 4 - 32)))
| (0x0b << (PIN_USB_DM * 4 - 32)) // AF mode, 50 MHz | (0x0b << (PIN_USB_DM * 4 - 32)) // AF mode, 50 MHz
| (0x0b << (PIN_USB_DP * 4 - 32)) // AF mode, 50 MHz | (0x0b << (PIN_USB_DP * 4 - 32)) // AF mode, 50 MHz
| (0x01 << (PIN_USB_PULLUP * 4 - 32)) // Push-pull output, 10 MHz
; ;
Util_Delay(100000); Util_Delay(100000);