USB CDC on STM32G0B1 works

This commit is contained in:
Edward Emelianov
2026-03-04 23:02:47 +03:00
parent 8f6a80e2c7
commit b5a4a21f51
46 changed files with 4407 additions and 20 deletions

View File

@@ -0,0 +1,32 @@
/*
* This file is part of the test project.
* Copyright 2026 Edward V. Emelianov <edward.emelianoff@gmail.com>.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "hardware.h"
void gpio_setup(){
RCC->IOPENR = RCC_IOPENR_GPIOCEN | RCC_IOPENR_GPIOBEN | RCC_IOPENR_GPIOAEN;
// set PC8 as opendrain output, PC0 is pullup input, other as default (AIN)
GPIOC->MODER = (0xffffffff & ~(GPIO_MODER_MODE6 | GPIO_MODER_MODE13)) | GPIO_MODER_MODER6_O; // GPIO_MODER_MODER13_I == 0
GPIOC->PUPDR = GPIO_PUPDR13_PD; // pull down
// USART1: PB6 - Tx (AF0), PB7 - Rx (AF0)
GPIOB->MODER = (0xffffffff & ~(GPIO_MODER_MODE6 | GPIO_MODER_MODE7)) | MODER_AF(6) | MODER_AF(7);
GPIOB->AFR[0] = 0;
// RCC->CCIPR = 0; // default -> sysclk/pclk source
// USB: PA11/PA12 - AIN
//GPIOA->MODER = (0xffffffff & ~(GPIO_MODER_MODE11 | GPIO_MODER_MODE12)) | MODER_AI(11) | MODER_AI(12);
}