From bd521ef8799ccd88f24606cd6cb05d63d5d296f8 Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 17 Mar 2020 15:58:31 +0100 Subject: [PATCH 001/286] first stab at mkII OWL Pedal firmware --- OwlPedal2/Inc/FreeRTOSConfig.h | 181 ++++++ OwlPedal2/Inc/hardware.h | 38 ++ OwlPedal2/Inc/main.h | 165 +++++ OwlPedal2/Inc/stm32f4xx_hal_conf.h | 443 +++++++++++++ OwlPedal2/Inc/stm32f4xx_it.h | 82 +++ OwlPedal2/Inc/usb_device.h | 105 +++ OwlPedal2/Inc/usbd_conf.h | 176 +++++ OwlPedal2/Inc/usbd_desc.h | 145 +++++ OwlPedal2/Makefile | 28 + OwlPedal2/OwlPedal2.ioc | 650 +++++++++++++++++++ OwlPedal2/Src/freertos.c | 136 ++++ OwlPedal2/Src/main.c | 966 ++++++++++++++++++++++++++++ OwlPedal2/Src/startup_stm32f427xx.s | 553 ++++++++++++++++ OwlPedal2/Src/stm32f4xx_hal_msp.c | 963 +++++++++++++++++++++++++++ OwlPedal2/Src/stm32f4xx_it.c | 206 ++++++ OwlPedal2/Src/system_stm32f4xx.c | 763 ++++++++++++++++++++++ OwlPedal2/Src/usb_device.c | 103 +++ OwlPedal2/Src/usbd_conf.c | 641 ++++++++++++++++++ OwlPedal2/Src/usbd_desc.c | 446 +++++++++++++ 19 files changed, 6790 insertions(+) create mode 100644 OwlPedal2/Inc/FreeRTOSConfig.h create mode 100644 OwlPedal2/Inc/hardware.h create mode 100644 OwlPedal2/Inc/main.h create mode 100644 OwlPedal2/Inc/stm32f4xx_hal_conf.h create mode 100644 OwlPedal2/Inc/stm32f4xx_it.h create mode 100644 OwlPedal2/Inc/usb_device.h create mode 100644 OwlPedal2/Inc/usbd_conf.h create mode 100644 OwlPedal2/Inc/usbd_desc.h create mode 100644 OwlPedal2/Makefile create mode 100644 OwlPedal2/OwlPedal2.ioc create mode 100644 OwlPedal2/Src/freertos.c create mode 100644 OwlPedal2/Src/main.c create mode 100644 OwlPedal2/Src/startup_stm32f427xx.s create mode 100644 OwlPedal2/Src/stm32f4xx_hal_msp.c create mode 100644 OwlPedal2/Src/stm32f4xx_it.c create mode 100644 OwlPedal2/Src/system_stm32f4xx.c create mode 100644 OwlPedal2/Src/usb_device.c create mode 100644 OwlPedal2/Src/usbd_conf.c create mode 100644 OwlPedal2/Src/usbd_desc.c diff --git a/OwlPedal2/Inc/FreeRTOSConfig.h b/OwlPedal2/Inc/FreeRTOSConfig.h new file mode 100644 index 00000000..f26c5ee5 --- /dev/null +++ b/OwlPedal2/Inc/FreeRTOSConfig.h @@ -0,0 +1,181 @@ +/* USER CODE BEGIN Header */ +/* + FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd. + All rights reserved + + VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. + + *************************************************************************** + >>! NOTE: The modification to the GPL is included to allow you to !<< + >>! distribute a combined work that includes FreeRTOS without being !<< + >>! obliged to provide the source code for proprietary components !<< + >>! outside of the FreeRTOS kernel. !<< + *************************************************************************** + + FreeRTOS 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. Full license text is available on the following + link: http://www.freertos.org/a00114.html + + *************************************************************************** + * * + * FreeRTOS provides completely free yet professionally developed, * + * robust, strictly quality controlled, supported, and cross * + * platform software that is more than just the market leader, it * + * is the industry's de facto standard. * + * * + * Help yourself get started quickly while simultaneously helping * + * to support the FreeRTOS project by purchasing a FreeRTOS * + * tutorial book, reference manual, or both: * + * http://www.FreeRTOS.org/Documentation * + * * + *************************************************************************** + + http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading + the FAQ page "My application does not run, what could be wrong?". Have you + defined configASSERT()? + + http://www.FreeRTOS.org/support - In return for receiving this top quality + embedded software for free we request you assist our global community by + participating in the support forum. + + http://www.FreeRTOS.org/training - Investing in training allows your team to + be as productive as possible as early as possible. Now you can receive + FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers + Ltd, and the world's leading authority on the world's leading RTOS. + + http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, + including FreeRTOS+Trace - an indispensable productivity tool, a DOS + compatible FAT file system, and our tiny thread aware UDP/IP stack. + + http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. + Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. + + http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High + Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS + licenses offer ticketed support, indemnification and commercial middleware. + + http://www.SafeRTOS.com - High Integrity Systems also provide a safety + engineered and independently SIL3 certified version for use in safety and + mission critical applications that require provable dependability. + + 1 tab == 4 spaces! +*/ +/* USER CODE END Header */ + +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +/*----------------------------------------------------------- + * Application specific definitions. + * + * These definitions should be adjusted for your particular hardware and + * application requirements. + * + * These parameters and more are described within the 'configuration' section of the + * FreeRTOS API documentation available on the FreeRTOS.org web site. + * + * See http://www.freertos.org/a00110.html + *----------------------------------------------------------*/ + +/* USER CODE BEGIN Includes */ + +#include "device.h" +#ifdef DEBUG_STACK +#define configUSE_TRACE_FACILITY 1 +#define INCLUDE_uxTaskGetStackHighWaterMark 1 +#endif /* DEBUG_STACK */ + +/* USER CODE END Includes */ + +/* Ensure definitions are only used by the compiler, and not by the assembler. */ +#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) + #include + extern uint32_t SystemCoreClock; + void xPortSysTickHandler(void); +#endif +#define configUSE_PREEMPTION 0 +#define configSUPPORT_STATIC_ALLOCATION 1 +#define configSUPPORT_DYNAMIC_ALLOCATION 1 +#define configUSE_IDLE_HOOK 0 +#define configUSE_TICK_HOOK 0 +#define configCPU_CLOCK_HZ ( SystemCoreClock ) +#define configTICK_RATE_HZ ((TickType_t)1000) +#define configMAX_PRIORITIES ( 7 ) +#define configMINIMAL_STACK_SIZE ((uint16_t)128) +#define configTOTAL_HEAP_SIZE ((size_t)15360) +#define configMAX_TASK_NAME_LEN ( 16 ) +#define configUSE_16_BIT_TICKS 0 +#define configQUEUE_REGISTRY_SIZE 8 +#define configCHECK_FOR_STACK_OVERFLOW 2 +#define configUSE_MALLOC_FAILED_HOOK 1 +#define configENABLE_BACKWARD_COMPATIBILITY 0 +#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 + +/* Co-routine definitions. */ +#define configUSE_CO_ROUTINES 0 +#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) + +/* Set the following definitions to 1 to include the API function, or zero +to exclude the API function. */ +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskCleanUpResources 0 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_xTaskGetSchedulerState 1 + +/* Cortex-M specific definitions. */ +#ifdef __NVIC_PRIO_BITS + /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */ + #define configPRIO_BITS __NVIC_PRIO_BITS +#else + #define configPRIO_BITS 4 +#endif + +/* The lowest interrupt priority that can be used in a call to a "set priority" +function. */ +#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15 + +/* The highest interrupt priority that can be used by any interrupt service +routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL +INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER +PRIORITY THAN THIS! (higher priorities are lower numeric values. */ +#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5 + +/* Interrupt priorities used by the kernel port layer itself. These are generic +to all Cortex-M ports, and do not rely on any particular library functions. */ +#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) +/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!! +See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ +#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) + +/* Normal assert() semantics without relying on the provision of an assert.h +header file. */ +/* USER CODE BEGIN 1 */ +#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );} +/* USER CODE END 1 */ + +/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS +standard names. */ +#define vPortSVCHandler SVC_Handler +#define xPortPendSVHandler PendSV_Handler + +/* IMPORTANT: This define is commented when used with STM32Cube firmware, when the timebase source is SysTick, + to prevent overwriting SysTick_Handler defined within STM32Cube HAL */ + +/* #define xPortSysTickHandler SysTick_Handler */ + +/* USER CODE BEGIN Defines */ +/* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */ +/* USER CODE END Defines */ + +#endif /* FREERTOS_CONFIG_H */ diff --git a/OwlPedal2/Inc/hardware.h b/OwlPedal2/Inc/hardware.h new file mode 100644 index 00000000..059f355b --- /dev/null +++ b/OwlPedal2/Inc/hardware.h @@ -0,0 +1,38 @@ +#include "main.h" +#include "stm32f4xx_hal.h" + +/* #define OWL_ALCHEMIST_LED */ +#define OWL_ALCHEMIST +#define HARDWARE_ID OWLPEDAL_HARDWARE +#define HARDWARE_VERSION "OWL Pedal mkII" + +#define USE_USBD_AUDIO +#define USE_USBD_AUDIO_TX // microphone +#define USE_USBD_AUDIO_RX // speaker +#define USE_USBD_MIDI +#define USE_USBD_FS +#define USBD_HANDLE hUsbDeviceFS + +#define USE_BKPSRAM + +#define USE_MODE_BUTTON +#define MODE_BUTTON_PIN SW3_Pin +#define MODE_BUTTON_PORT SW3_GPIO_Port +#define MODE_BUTTON_GAIN ADC_C +#define MODE_BUTTON_PATCH ADC_D + +#define USE_RGB_LED +#define USE_ADC +#define ADC_PERIPH hadc3 +#define ADC_A 2 +#define ADC_B 3 +#define ADC_C 0 +#define ADC_D 1 +#define USE_CODEC +#define USE_CS4271 +#define CODEC_HP_FILTER +#define CODEC_SPI hspi4 + +#define NOF_ADC_VALUES 4 +#define NOF_PARAMETERS 40 +#define NOF_BUTTONS (2+4) diff --git a/OwlPedal2/Inc/main.h b/OwlPedal2/Inc/main.h new file mode 100644 index 00000000..cf07674e --- /dev/null +++ b/OwlPedal2/Inc/main.h @@ -0,0 +1,165 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : main.h + * @brief : Header for main.c file. + * This file contains the common defines of the application. + ****************************************************************************** + * This notice applies to any and all portions of this file + * that are not between comment pairs USER CODE BEGIN and + * USER CODE END. Other portions of this file, whether + * inserted by the user or by software development tools + * are owned by their respective copyright owners. + * + * Copyright (c) 2019 STMicroelectronics International N.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __MAIN_H +#define __MAIN_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f4xx_hal.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* Exported macro ------------------------------------------------------------*/ +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); + +/* Exported functions prototypes ---------------------------------------------*/ +void Error_Handler(void); + +/* USER CODE BEGIN EFP */ + +/* USER CODE END EFP */ + +/* Private defines -----------------------------------------------------------*/ +#define CS_SCK_Pin GPIO_PIN_2 +#define CS_SCK_GPIO_Port GPIOE +#define CS_SDOUT_Pin GPIO_PIN_3 +#define CS_SDOUT_GPIO_Port GPIOE +#define CS_LRCK_Pin GPIO_PIN_4 +#define CS_LRCK_GPIO_Port GPIOE +#define CS_SCKE5_Pin GPIO_PIN_5 +#define CS_SCKE5_GPIO_Port GPIOE +#define CS_SDA_Pin GPIO_PIN_6 +#define CS_SDA_GPIO_Port GPIOE +#define EXTSPI_nCS_Pin GPIO_PIN_15 +#define EXTSPI_nCS_GPIO_Port GPIOC +#define EXTSPI_SCK_Pin GPIO_PIN_7 +#define EXTSPI_SCK_GPIO_Port GPIOF +#define EXTSPI_MISO_Pin GPIO_PIN_8 +#define EXTSPI_MISO_GPIO_Port GPIOF +#define EXTSPI_MOSI_Pin GPIO_PIN_9 +#define EXTSPI_MOSI_GPIO_Port GPIOF +#define ADC4_Pin GPIO_PIN_10 +#define ADC4_GPIO_Port GPIOF +#define ADC3_Pin GPIO_PIN_1 +#define ADC3_GPIO_Port GPIOC +#define ADC2_Pin GPIO_PIN_2 +#define ADC2_GPIO_Port GPIOC +#define ADC1_Pin GPIO_PIN_3 +#define ADC1_GPIO_Port GPIOC +#define PWM1_Pin GPIO_PIN_0 +#define PWM1_GPIO_Port GPIOA +#define PWM2_Pin GPIO_PIN_1 +#define PWM2_GPIO_Port GPIOA +#define FLASH_MISO_Pin GPIO_PIN_6 +#define FLASH_MISO_GPIO_Port GPIOA +#define FLASH_MOSI_Pin GPIO_PIN_7 +#define FLASH_MOSI_GPIO_Port GPIOA +#define FLASH_HOLD_Pin GPIO_PIN_4 +#define FLASH_HOLD_GPIO_Port GPIOC +#define FLASH_nCS_Pin GPIO_PIN_5 +#define FLASH_nCS_GPIO_Port GPIOC +#define PWM3_Pin GPIO_PIN_1 +#define PWM3_GPIO_Port GPIOB +#define SW2_Pin GPIO_PIN_2 +#define SW2_GPIO_Port GPIOB +#define SW2_EXTI_IRQn EXTI2_IRQn +#define CS_nCS_Pin GPIO_PIN_10 +#define CS_nCS_GPIO_Port GPIOB +#define CS_nRST_Pin GPIO_PIN_11 +#define CS_nRST_GPIO_Port GPIOB +#define CS_SDIN_Pin GPIO_PIN_6 +#define CS_SDIN_GPIO_Port GPIOD +#define FLASH_SCK_Pin GPIO_PIN_3 +#define FLASH_SCK_GPIO_Port GPIOB +#define SW3_Pin GPIO_PIN_8 +#define SW3_GPIO_Port GPIOB +#define SW3_EXTI_IRQn EXTI9_5_IRQn +#define SW1_Pin GPIO_PIN_9 +#define SW1_GPIO_Port GPIOB +#define SW1_EXTI_IRQn EXTI9_5_IRQn +/* USER CODE BEGIN Private defines */ + +#define CS_CS_Pin GPIO_PIN_10 +#define CS_CS_GPIO_Port GPIOB +#define CS_RST_Pin GPIO_PIN_11 +#define CS_RST_GPIO_Port GPIOB + +/* USER CODE END Private defines */ + +#ifdef __cplusplus +} +#endif + +#endif /* __MAIN_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Inc/stm32f4xx_hal_conf.h b/OwlPedal2/Inc/stm32f4xx_hal_conf.h new file mode 100644 index 00000000..dceb54c5 --- /dev/null +++ b/OwlPedal2/Inc/stm32f4xx_hal_conf.h @@ -0,0 +1,443 @@ +/** + ****************************************************************************** + * @file stm32f4xx_hal_conf_template.h + * @author MCD Application Team + * @brief HAL configuration template file. + * This file should be copied to the application folder and renamed + * to stm32f4xx_hal_conf.h. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F4xx_HAL_CONF_H +#define __STM32F4xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED + + #define HAL_ADC_MODULE_ENABLED +/* #define HAL_CRYP_MODULE_ENABLED */ +/* #define HAL_CAN_MODULE_ENABLED */ +/* #define HAL_CRC_MODULE_ENABLED */ +/* #define HAL_CRYP_MODULE_ENABLED */ +/* #define HAL_DAC_MODULE_ENABLED */ +/* #define HAL_DCMI_MODULE_ENABLED */ +/* #define HAL_DMA2D_MODULE_ENABLED */ +/* #define HAL_ETH_MODULE_ENABLED */ +/* #define HAL_NAND_MODULE_ENABLED */ +/* #define HAL_NOR_MODULE_ENABLED */ +/* #define HAL_PCCARD_MODULE_ENABLED */ +/* #define HAL_SRAM_MODULE_ENABLED */ +#define HAL_SDRAM_MODULE_ENABLED +/* #define HAL_HASH_MODULE_ENABLED */ +/* #define HAL_I2C_MODULE_ENABLED */ +/* #define HAL_I2S_MODULE_ENABLED */ +/* #define HAL_IWDG_MODULE_ENABLED */ +/* #define HAL_LTDC_MODULE_ENABLED */ +/* #define HAL_RNG_MODULE_ENABLED */ +#define HAL_RTC_MODULE_ENABLED +#define HAL_SAI_MODULE_ENABLED +/* #define HAL_SD_MODULE_ENABLED */ +/* #define HAL_MMC_MODULE_ENABLED */ +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +/* #define HAL_USART_MODULE_ENABLED */ +/* #define HAL_IRDA_MODULE_ENABLED */ +/* #define HAL_SMARTCARD_MODULE_ENABLED */ +/* #define HAL_SMBUS_MODULE_ENABLED */ +/* #define HAL_WWDG_MODULE_ENABLED */ +#define HAL_PCD_MODULE_ENABLED +/* #define HAL_HCD_MODULE_ENABLED */ +/* #define HAL_DSI_MODULE_ENABLED */ +/* #define HAL_QSPI_MODULE_ENABLED */ +/* #define HAL_QSPI_MODULE_ENABLED */ +/* #define HAL_CEC_MODULE_ENABLED */ +/* #define HAL_FMPI2C_MODULE_ENABLED */ +/* #define HAL_SPDIFRX_MODULE_ENABLED */ +/* #define HAL_DFSDM_MODULE_ENABLED */ +/* #define HAL_LPTIM_MODULE_ENABLED */ +#define HAL_GPIO_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) + #define HSE_VALUE ((uint32_t)25000000U) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) + #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature.*/ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) + #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY ((uint32_t)15U) /*!< tick interrupt priority */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 1U +#define INSTRUCTION_CACHE_ENABLE 1U +#define DATA_CACHE_ENABLE 1U + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ + #define USE_FULL_ASSERT 1U + +/* ################## Ethernet peripheral configuration ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ + +/* DP83848_PHY_ADDRESS Address*/ +#define DP83848_PHY_ADDRESS 0x01U +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY ((uint32_t)0x000000FFU) +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU) + +#define PHY_READ_TO ((uint32_t)0x0000FFFFU) +#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU) + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ +#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ + +#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver +* Activated: CRC code is present inside driver +* Deactivated: CRC code cleaned from driver +*/ + +#define USE_SPI_CRC 0U + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32f4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32f4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32f4xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32f4xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32f4xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32f4xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED + #include "stm32f4xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32f4xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED + #include "stm32f4xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED +#include "stm32f4xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED + #include "stm32f4xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32f4xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED + #include "stm32f4xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED + #include "stm32f4xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32f4xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32f4xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED + #include "stm32f4xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_PCCARD_MODULE_ENABLED + #include "stm32f4xx_hal_pccard.h" +#endif /* HAL_PCCARD_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED + #include "stm32f4xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32f4xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32f4xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32f4xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED + #include "stm32f4xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32f4xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED + #include "stm32f4xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32f4xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED + #include "stm32f4xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED + #include "stm32f4xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED + #include "stm32f4xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32f4xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32f4xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32f4xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32f4xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32f4xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32f4xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32f4xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32f4xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED + #include "stm32f4xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED + #include "stm32f4xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED + #include "stm32f4xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED + #include "stm32f4xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_FMPI2C_MODULE_ENABLED + #include "stm32f4xx_hal_fmpi2c.h" +#endif /* HAL_FMPI2C_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED + #include "stm32f4xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED + #include "stm32f4xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED + #include "stm32f4xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t* file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F4xx_HAL_CONF_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Inc/stm32f4xx_it.h b/OwlPedal2/Inc/stm32f4xx_it.h new file mode 100644 index 00000000..2eaddf75 --- /dev/null +++ b/OwlPedal2/Inc/stm32f4xx_it.h @@ -0,0 +1,82 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32f4xx_it.h + * @brief This file contains the headers of the interrupt handlers. + ****************************************************************************** + * + * COPYRIGHT(c) 2019 STMicroelectronics + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F4xx_IT_H +#define __STM32F4xx_IT_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* Exported macro ------------------------------------------------------------*/ +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +/* Exported functions prototypes ---------------------------------------------*/ +void SysTick_Handler(void); +void EXTI2_IRQHandler(void); +void EXTI9_5_IRQHandler(void); +void DMA2_Stream0_IRQHandler(void); +void DMA2_Stream1_IRQHandler(void); +void DMA2_Stream4_IRQHandler(void); +void SAI1_IRQHandler(void); +/* USER CODE BEGIN EFP */ + +/* USER CODE END EFP */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F4xx_IT_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Inc/usb_device.h b/OwlPedal2/Inc/usb_device.h new file mode 100644 index 00000000..98cf5857 --- /dev/null +++ b/OwlPedal2/Inc/usb_device.h @@ -0,0 +1,105 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usb_device.h + * @version : v1.0_Cube + * @brief : Header for usb_device.c file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USB_DEVICE__H__ +#define __USB_DEVICE__H__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f4xx.h" +#include "stm32f4xx_hal.h" +#include "usbd_def.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/** @addtogroup USBD_OTG_DRIVER + * @{ + */ + +/** @defgroup USBD_DEVICE USBD_DEVICE + * @brief Device file for Usb otg low level driver. + * @{ + */ + +/** @defgroup USBD_DEVICE_Exported_Variables USBD_DEVICE_Exported_Variables + * @brief Public variables. + * @{ + */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* + * -- Insert your variables declaration here -- + */ +/* USER CODE BEGIN VARIABLES */ + +/* USER CODE END VARIABLES */ +/** + * @} + */ + +/** @defgroup USBD_DEVICE_Exported_FunctionsPrototype USBD_DEVICE_Exported_FunctionsPrototype + * @brief Declaration of public functions for Usb device. + * @{ + */ + +/** USB Device initialization function. */ +void MX_USB_DEVICE_Init(void); + +/* + * -- Insert functions declaration here -- + */ +/* USER CODE BEGIN FD */ + +/* USER CODE END FD */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __USB_DEVICE__H__ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Inc/usbd_conf.h b/OwlPedal2/Inc/usbd_conf.h new file mode 100644 index 00000000..e477378e --- /dev/null +++ b/OwlPedal2/Inc/usbd_conf.h @@ -0,0 +1,176 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usbd_conf.h + * @version : v1.0_Cube + * @brief : Header for usbd_conf.c file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USBD_CONF__H__ +#define __USBD_CONF__H__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include +#include +#include +#include "main.h" +#include "stm32f4xx.h" +#include "stm32f4xx_hal.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/** @addtogroup USBD_OTG_DRIVER + * @brief Driver for Usb device. + * @{ + */ + +/** @defgroup USBD_CONF USBD_CONF + * @brief Configuration file for Usb otg low level driver. + * @{ + */ + +/** @defgroup USBD_CONF_Exported_Variables USBD_CONF_Exported_Variables + * @brief Public variables. + * @{ + */ + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_Defines USBD_CONF_Exported_Defines + * @brief Defines for configuration of the Usb device. + * @{ + */ + +/*---------- -----------*/ +#define USBD_MAX_NUM_INTERFACES 5U +/*---------- -----------*/ +#define USBD_MAX_NUM_CONFIGURATION 2U +/*---------- -----------*/ +#define USBD_MAX_STR_DESC_SIZ 512U +/*---------- -----------*/ +#define USBD_DEBUG_LEVEL 0U +/*---------- -----------*/ +#define USBD_LPM_ENABLED 0U +/*---------- -----------*/ +#define USBD_SELF_POWERED 1U +/*---------- -----------*/ +#define USBD_AUDIO_FREQ 48000U + +/****************************************/ +/* #define for FS and HS identification */ +#define DEVICE_FS 0 +#define DEVICE_HS 1 + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_Macros USBD_CONF_Exported_Macros + * @brief Aliases. + * @{ + */ + +/* Memory management macros */ + +/** Alias for memory allocation. */ +#define USBD_malloc malloc + +/** Alias for memory release. */ +#define USBD_free free + +/** Alias for memory set. */ +#define USBD_memset memset + +/** Alias for memory copy. */ +#define USBD_memcpy memcpy + +/** Alias for delay. */ +#define USBD_Delay HAL_Delay + +/* DEBUG macros */ + +#if (USBD_DEBUG_LEVEL > 0) +#define USBD_UsrLog(...) printf(__VA_ARGS__);\ + printf("\n"); +#else +#define USBD_UsrLog(...) +#endif + +#if (USBD_DEBUG_LEVEL > 1) + +#define USBD_ErrLog(...) printf("ERROR: ") ;\ + printf(__VA_ARGS__);\ + printf("\n"); +#else +#define USBD_ErrLog(...) +#endif + +#if (USBD_DEBUG_LEVEL > 2) +#define USBD_DbgLog(...) printf("DEBUG : ") ;\ + printf(__VA_ARGS__);\ + printf("\n"); +#else +#define USBD_DbgLog(...) +#endif + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_Types USBD_CONF_Exported_Types + * @brief Types. + * @{ + */ + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_FunctionsPrototype USBD_CONF_Exported_FunctionsPrototype + * @brief Declaration of public functions for Usb device. + * @{ + */ + +/* Exported functions -------------------------------------------------------*/ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __USBD_CONF__H__ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Inc/usbd_desc.h b/OwlPedal2/Inc/usbd_desc.h new file mode 100644 index 00000000..122f582b --- /dev/null +++ b/OwlPedal2/Inc/usbd_desc.h @@ -0,0 +1,145 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usbd_desc.c + * @version : v1.0_Cube + * @brief : Header for usbd_conf.c file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USBD_DESC__C__ +#define __USBD_DESC__C__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "usbd_def.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY + * @{ + */ + +/** @defgroup USBD_DESC USBD_DESC + * @brief Usb device descriptors module. + * @{ + */ + +/** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants + * @brief Constants. + * @{ + */ +#define DEVICE_ID1 (UID_BASE) +#define DEVICE_ID2 (UID_BASE + 0x4) +#define DEVICE_ID3 (UID_BASE + 0x8) + +#define USB_SIZ_STRING_SERIAL 0x1A + +/* USER CODE BEGIN EXPORTED_CONSTANTS */ + +/* USER CODE END EXPORTED_CONSTANTS */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_Defines USBD_DESC_Exported_Defines + * @brief Defines. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_DEFINES */ + +/* USER CODE END EXPORTED_DEFINES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_TypesDefinitions USBD_DESC_Exported_TypesDefinitions + * @brief Types. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_TYPES */ + +/* USER CODE END EXPORTED_TYPES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_Macros USBD_DESC_Exported_Macros + * @brief Aliases. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_MACRO */ + +/* USER CODE END EXPORTED_MACRO */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_Variables USBD_DESC_Exported_Variables + * @brief Public variables. + * @{ + */ + +/** Descriptor for the Usb device. */ +extern USBD_DescriptorsTypeDef FS_Desc; + +/* USER CODE BEGIN EXPORTED_VARIABLES */ + +/* USER CODE END EXPORTED_VARIABLES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_FunctionsPrototype USBD_DESC_Exported_FunctionsPrototype + * @brief Public functions declaration. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_FUNCTIONS */ + +/* USER CODE END EXPORTED_FUNCTIONS */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __USBD_DESC__C__ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Makefile b/OwlPedal2/Makefile new file mode 100644 index 00000000..a1c46212 --- /dev/null +++ b/OwlPedal2/Makefile @@ -0,0 +1,28 @@ +PROJECT = OwlPedal2 +BUILDROOT = . +OPENWARE ?= $(BUILDROOT)/.. + +include $(OPENWARE)/Hardware/owl2.mk + +C_SRC = $(notdir $(wildcard Src/*.c)) +CPP_SRC = $(notdir $(wildcard Src/*.cpp)) +C_SRC += sdram.c +C_SRC += cs4272.c +C_SRC += usbd_midi.c +C_SRC += usbd_midi_if.c + +include $(OPENWARE)/Hardware/sources.mk + +OBJS = $(C_SRC:%.c=Build/%.o) +OBJS += $(CPP_SRC:%.cpp=Build/%.o) +OBJS += $(S_SRC:%.s=Build/%.o) + +OBJS += $(OBJS_SAI) +OBJS += $(OBJS_SDRAM) +OBJS += $(OBJS_USBD) +OBJS += $(OBJS_DSP) +OBJS += $(OBJS_OS) +OBJS += $(OBJS_UART) +OBJS += $(OBJS_RTC) + +include $(OPENWARE)/Hardware/f4.mk diff --git a/OwlPedal2/OwlPedal2.ioc b/OwlPedal2/OwlPedal2.ioc new file mode 100644 index 00000000..eec3596c --- /dev/null +++ b/OwlPedal2/OwlPedal2.ioc @@ -0,0 +1,650 @@ +#MicroXplorer Configuration settings - do not modify +ADC3.Channel-31\#ChannelRegularConversion=ADC_CHANNEL_13 +ADC3.Channel-32\#ChannelRegularConversion=ADC_CHANNEL_12 +ADC3.Channel-33\#ChannelRegularConversion=ADC_CHANNEL_11 +ADC3.Channel-34\#ChannelRegularConversion=ADC_CHANNEL_8 +ADC3.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV8 +ADC3.ContinuousConvMode=ENABLE +ADC3.DMAContinuousRequests=ENABLE +ADC3.DataAlign=ADC_DATAALIGN_RIGHT +ADC3.DiscontinuousConvMode=DISABLE +ADC3.EOCSelection=ADC_EOC_SEQ_CONV +ADC3.EnableAnalogWatchDog=false +ADC3.ExternalTrigConv=ADC_SOFTWARE_START +ADC3.ExternalTrigConvEdge=ADC_EXTERNALTRIGCONVEDGE_NONE +ADC3.IPParameters=Rank-31\#ChannelRegularConversion,Channel-31\#ChannelRegularConversion,SamplingTime-31\#ChannelRegularConversion,NbrOfConversionFlag,ScanConvMode,ContinuousConvMode,DMAContinuousRequests,EOCSelection,InjNumberOfConversion,EnableAnalogWatchDog,ExternalTrigConv,Rank-32\#ChannelRegularConversion,Channel-32\#ChannelRegularConversion,SamplingTime-32\#ChannelRegularConversion,Rank-33\#ChannelRegularConversion,Channel-33\#ChannelRegularConversion,SamplingTime-33\#ChannelRegularConversion,Rank-34\#ChannelRegularConversion,Channel-34\#ChannelRegularConversion,SamplingTime-34\#ChannelRegularConversion,NbrOfConversion,ClockPrescaler,Resolution,DataAlign,DiscontinuousConvMode,ExternalTrigConvEdge +ADC3.InjNumberOfConversion=0 +ADC3.NbrOfConversion=4 +ADC3.NbrOfConversionFlag=1 +ADC3.Rank-31\#ChannelRegularConversion=1 +ADC3.Rank-32\#ChannelRegularConversion=2 +ADC3.Rank-33\#ChannelRegularConversion=3 +ADC3.Rank-34\#ChannelRegularConversion=4 +ADC3.Resolution=ADC_RESOLUTION_12B +ADC3.SamplingTime-31\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-32\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-33\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-34\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.ScanConvMode=ENABLE +Dma.ADC3.0.Direction=DMA_PERIPH_TO_MEMORY +Dma.ADC3.0.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.ADC3.0.Instance=DMA2_Stream0 +Dma.ADC3.0.MemDataAlignment=DMA_MDATAALIGN_HALFWORD +Dma.ADC3.0.MemInc=DMA_MINC_ENABLE +Dma.ADC3.0.Mode=DMA_CIRCULAR +Dma.ADC3.0.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD +Dma.ADC3.0.PeriphInc=DMA_PINC_DISABLE +Dma.ADC3.0.Priority=DMA_PRIORITY_LOW +Dma.ADC3.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +Dma.Request0=ADC3 +Dma.Request1=SAI1_A +Dma.Request2=SAI1_B +Dma.RequestsNb=3 +Dma.SAI1_A.1.Direction=DMA_MEMORY_TO_PERIPH +Dma.SAI1_A.1.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SAI1_A.1.Instance=DMA2_Stream1 +Dma.SAI1_A.1.MemDataAlignment=DMA_MDATAALIGN_WORD +Dma.SAI1_A.1.MemInc=DMA_MINC_ENABLE +Dma.SAI1_A.1.Mode=DMA_CIRCULAR +Dma.SAI1_A.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD +Dma.SAI1_A.1.PeriphInc=DMA_PINC_DISABLE +Dma.SAI1_A.1.Priority=DMA_PRIORITY_VERY_HIGH +Dma.SAI1_A.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +Dma.SAI1_B.2.Direction=DMA_PERIPH_TO_MEMORY +Dma.SAI1_B.2.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SAI1_B.2.Instance=DMA2_Stream4 +Dma.SAI1_B.2.MemDataAlignment=DMA_MDATAALIGN_WORD +Dma.SAI1_B.2.MemInc=DMA_MINC_ENABLE +Dma.SAI1_B.2.Mode=DMA_CIRCULAR +Dma.SAI1_B.2.PeriphDataAlignment=DMA_PDATAALIGN_WORD +Dma.SAI1_B.2.PeriphInc=DMA_PINC_DISABLE +Dma.SAI1_B.2.Priority=DMA_PRIORITY_VERY_HIGH +Dma.SAI1_B.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_3 +FMC.ExitSelfRefreshDelay1=6 +FMC.IPParameters=ReadPipeDelay1,ReadBurst1,ReadBurst2,SDClockPeriod1,SDClockPeriod2,CASLatency1,LoadToActiveDelay1,ExitSelfRefreshDelay1,SelfRefreshTime1,RowCycleDelay1,RowCycleDelay2,WriteRecoveryTime1,RPDelay1,RPDelay2,RCDDelay1 +FMC.LoadToActiveDelay1=2 +FMC.RCDDelay1=2 +FMC.RPDelay1=2 +FMC.RPDelay2=2 +FMC.ReadBurst1=FMC_SDRAM_RBURST_ENABLE +FMC.ReadBurst2=FMC_SDRAM_RBURST_ENABLE +FMC.ReadPipeDelay1=FMC_SDRAM_RPIPE_DELAY_0 +FMC.RowCycleDelay1=6 +FMC.RowCycleDelay2=6 +FMC.SDClockPeriod1=FMC_SDRAM_CLOCK_PERIOD_2 +FMC.SDClockPeriod2=FMC_SDRAM_CLOCK_PERIOD_2 +FMC.SelfRefreshTime1=4 +FMC.WriteRecoveryTime1=2 +FREERTOS.FootprintOK=true +FREERTOS.INCLUDE_vTaskDelayUntil=1 +FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configENABLE_BACKWARD_COMPATIBILITY,configUSE_MUTEXES,FootprintOK,MEMORY_ALLOCATION,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,INCLUDE_vTaskDelayUntil +FREERTOS.MEMORY_ALLOCATION=2 +FREERTOS.Tasks01=defaultTask,0,128,StartDefaultTask,Default,NULL +FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 +FREERTOS.configENABLE_BACKWARD_COMPATIBILITY=0 +FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 +FREERTOS.configUSE_MUTEXES=0 +FREERTOS.configUSE_PREEMPTION=0 +File.Version=6 +KeepUserPlacement=false +Mcu.Family=STM32F4 +Mcu.IP0=ADC3 +Mcu.IP1=DMA +Mcu.IP10=SPI5 +Mcu.IP11=SYS +Mcu.IP12=TIM2 +Mcu.IP13=TIM3 +Mcu.IP14=USART2 +Mcu.IP15=USB_DEVICE +Mcu.IP16=USB_OTG_FS +Mcu.IP2=FMC +Mcu.IP3=FREERTOS +Mcu.IP4=NVIC +Mcu.IP5=RCC +Mcu.IP6=RTC +Mcu.IP7=SAI1 +Mcu.IP8=SPI1 +Mcu.IP9=SPI4 +Mcu.IPNb=17 +Mcu.Name=STM32F427Z(G-I)Tx +Mcu.Package=LQFP144 +Mcu.Pin0=PE2 +Mcu.Pin1=PE3 +Mcu.Pin10=PF4 +Mcu.Pin11=PF5 +Mcu.Pin12=PF7 +Mcu.Pin13=PF8 +Mcu.Pin14=PF9 +Mcu.Pin15=PF10 +Mcu.Pin16=PH0/OSC_IN +Mcu.Pin17=PH1/OSC_OUT +Mcu.Pin18=PC0 +Mcu.Pin19=PC1 +Mcu.Pin2=PE4 +Mcu.Pin20=PC2 +Mcu.Pin21=PC3 +Mcu.Pin22=PA0/WKUP +Mcu.Pin23=PA1 +Mcu.Pin24=PA2 +Mcu.Pin25=PA3 +Mcu.Pin26=PA6 +Mcu.Pin27=PA7 +Mcu.Pin28=PC4 +Mcu.Pin29=PC5 +Mcu.Pin3=PE5 +Mcu.Pin30=PB1 +Mcu.Pin31=PB2/BOOT1 +Mcu.Pin32=PF11 +Mcu.Pin33=PF12 +Mcu.Pin34=PF13 +Mcu.Pin35=PF14 +Mcu.Pin36=PF15 +Mcu.Pin37=PG0 +Mcu.Pin38=PG1 +Mcu.Pin39=PE7 +Mcu.Pin4=PE6 +Mcu.Pin40=PE8 +Mcu.Pin41=PE9 +Mcu.Pin42=PE10 +Mcu.Pin43=PE11 +Mcu.Pin44=PE12 +Mcu.Pin45=PE13 +Mcu.Pin46=PE14 +Mcu.Pin47=PE15 +Mcu.Pin48=PB10 +Mcu.Pin49=PB11 +Mcu.Pin5=PC15/OSC32_OUT +Mcu.Pin50=PD8 +Mcu.Pin51=PD9 +Mcu.Pin52=PD10 +Mcu.Pin53=PD14 +Mcu.Pin54=PD15 +Mcu.Pin55=PG4 +Mcu.Pin56=PG5 +Mcu.Pin57=PG8 +Mcu.Pin58=PA9 +Mcu.Pin59=PA11 +Mcu.Pin6=PF0 +Mcu.Pin60=PA12 +Mcu.Pin61=PA13 +Mcu.Pin62=PA14 +Mcu.Pin63=PD0 +Mcu.Pin64=PD1 +Mcu.Pin65=PD6 +Mcu.Pin66=PG15 +Mcu.Pin67=PB3 +Mcu.Pin68=PB5 +Mcu.Pin69=PB6 +Mcu.Pin7=PF1 +Mcu.Pin70=PB8 +Mcu.Pin71=PB9 +Mcu.Pin72=PE0 +Mcu.Pin73=PE1 +Mcu.Pin74=VP_FREERTOS_VS_CMSIS_V1 +Mcu.Pin75=VP_RTC_VS_RTC_Activate +Mcu.Pin76=VP_SYS_VS_Systick +Mcu.Pin77=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS +Mcu.Pin8=PF2 +Mcu.Pin9=PF3 +Mcu.PinsNb=78 +Mcu.ThirdPartyNb=0 +Mcu.UserConstants= +Mcu.UserName=STM32F427ZITx +MxCube.Version=5.5.0 +MxDb.Version=DB.5.0.50 +NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.DMA2_Stream0_IRQn=true\:10\:0\:true\:false\:true\:true\:true\:true +NVIC.DMA2_Stream1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true +NVIC.DMA2_Stream4_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true +NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.EXTI2_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true +NVIC.EXTI9_5_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true +NVIC.ForceEnableDMAVector=true +NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false +NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 +NVIC.SAI1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true +NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:true\:true +NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +PA0/WKUP.GPIOParameters=GPIO_Label +PA0/WKUP.GPIO_Label=PWM1 +PA0/WKUP.Signal=S_TIM2_CH1_ETR +PA1.GPIOParameters=GPIO_Label +PA1.GPIO_Label=PWM2 +PA1.Signal=S_TIM2_CH2 +PA11.Mode=Device_Only +PA11.Signal=USB_OTG_FS_DM +PA12.Mode=Device_Only +PA12.Signal=USB_OTG_FS_DP +PA13.Mode=Serial_Wire +PA13.Signal=SYS_JTMS-SWDIO +PA14.Mode=Serial_Wire +PA14.Signal=SYS_JTCK-SWCLK +PA2.Locked=true +PA2.Mode=Asynchronous +PA2.Signal=USART2_TX +PA3.Mode=Asynchronous +PA3.Signal=USART2_RX +PA6.GPIOParameters=GPIO_Label +PA6.GPIO_Label=FLASH_MISO +PA6.Mode=Full_Duplex_Master +PA6.Signal=SPI1_MISO +PA7.GPIOParameters=GPIO_Label +PA7.GPIO_Label=FLASH_MOSI +PA7.Mode=Full_Duplex_Master +PA7.Signal=SPI1_MOSI +PA9.Mode=Activate_VBUS +PA9.Signal=USB_OTG_FS_VBUS +PB1.GPIOParameters=GPIO_Label +PB1.GPIO_Label=PWM3 +PB1.Signal=S_TIM3_CH4 +PB10.GPIOParameters=GPIO_Label +PB10.GPIO_Label=CS_nCS +PB10.Locked=true +PB10.Signal=GPIO_Output +PB11.GPIOParameters=GPIO_Label +PB11.GPIO_Label=CS_nRST +PB11.Locked=true +PB11.Signal=GPIO_Output +PB2/BOOT1.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PB2/BOOT1.GPIO_Label=SW2 +PB2/BOOT1.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PB2/BOOT1.GPIO_PuPd=GPIO_PULLUP +PB2/BOOT1.Locked=true +PB2/BOOT1.Signal=GPXTI2 +PB3.GPIOParameters=GPIO_Label +PB3.GPIO_Label=FLASH_SCK +PB3.Locked=true +PB3.Mode=Full_Duplex_Master +PB3.Signal=SPI1_SCK +PB5.Mode=SdramChipSelect2_1 +PB5.Signal=FMC_SDCKE1 +PB6.Mode=SdramChipSelect2_1 +PB6.Signal=FMC_SDNE1 +PB8.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PB8.GPIO_Label=SW3 +PB8.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PB8.GPIO_PuPd=GPIO_PULLUP +PB8.Locked=true +PB8.Signal=GPXTI8 +PB9.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PB9.GPIO_Label=SW1 +PB9.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PB9.GPIO_PuPd=GPIO_PULLUP +PB9.Locked=true +PB9.Signal=GPXTI9 +PC0.Signal=FMC_SDNWE +PC1.GPIOParameters=GPIO_Label +PC1.GPIO_Label=ADC3 +PC1.Locked=true +PC1.Signal=ADCx_IN11 +PC15/OSC32_OUT.GPIOParameters=GPIO_Label +PC15/OSC32_OUT.GPIO_Label=EXTSPI_nCS +PC15/OSC32_OUT.Locked=true +PC15/OSC32_OUT.Signal=GPIO_Output +PC2.GPIOParameters=GPIO_Label +PC2.GPIO_Label=ADC2 +PC2.Locked=true +PC2.Signal=ADCx_IN12 +PC3.GPIOParameters=GPIO_Label +PC3.GPIO_Label=ADC1 +PC3.Locked=true +PC3.Signal=ADCx_IN13 +PC4.GPIOParameters=GPIO_Label +PC4.GPIO_Label=FLASH_HOLD +PC4.Locked=true +PC4.Signal=GPIO_Output +PC5.GPIOParameters=GPIO_Label +PC5.GPIO_Label=FLASH_nCS +PC5.Locked=true +PC5.Signal=GPIO_Output +PCC.Checker=false +PCC.Line=STM32F427/437 +PCC.MCU=STM32F427Z(G-I)Tx +PCC.PartNumber=STM32F427ZITx +PCC.Seq0=0 +PCC.Series=STM32F4 +PCC.Temperature=25 +PCC.Vdd=3.3 +PD0.Signal=FMC_D2_DA2 +PD1.Signal=FMC_D3_DA3 +PD10.Signal=FMC_D15_DA15 +PD14.Signal=FMC_D0_DA0 +PD15.Signal=FMC_D1_DA1 +PD6.GPIOParameters=GPIO_Label +PD6.GPIO_Label=CS_SDIN +PD6.Mode=SAI_A_AsyncSlave +PD6.Signal=SAI1_SD_A +PD8.Signal=FMC_D13_DA13 +PD9.Signal=FMC_D14_DA14 +PE0.Signal=FMC_NBL0 +PE1.Signal=FMC_NBL1 +PE10.Signal=FMC_D7_DA7 +PE11.Signal=FMC_D8_DA8 +PE12.Signal=FMC_D9_DA9 +PE13.Signal=FMC_D10_DA10 +PE14.Signal=FMC_D11_DA11 +PE15.Signal=FMC_D12_DA12 +PE2.GPIOParameters=GPIO_Label +PE2.GPIO_Label=CS_SCK +PE2.Mode=TX_Only_Simplex_Unidirect_Master +PE2.Signal=SPI4_SCK +PE3.GPIOParameters=GPIO_Label +PE3.GPIO_Label=CS_SDOUT +PE3.Mode=SAI_B_SyncSlave +PE3.Signal=SAI1_SD_B +PE4.GPIOParameters=GPIO_Label +PE4.GPIO_Label=CS_LRCK +PE4.Mode=SAI_A_AsyncSlave +PE4.Signal=SAI1_FS_A +PE5.GPIOParameters=GPIO_Label +PE5.GPIO_Label=CS_SCK +PE5.Mode=SAI_A_AsyncSlave +PE5.Signal=SAI1_SCK_A +PE6.GPIOParameters=GPIO_Label +PE6.GPIO_Label=CS_SDA +PE6.Mode=TX_Only_Simplex_Unidirect_Master +PE6.Signal=SPI4_MOSI +PE7.Signal=FMC_D4_DA4 +PE8.Signal=FMC_D5_DA5 +PE9.Signal=FMC_D6_DA6 +PF0.Signal=FMC_A0 +PF1.Signal=FMC_A1 +PF10.GPIOParameters=GPIO_Label +PF10.GPIO_Label=ADC4 +PF10.Locked=true +PF10.Mode=IN8 +PF10.Signal=ADC3_IN8 +PF11.Signal=FMC_SDNRAS +PF12.Signal=FMC_A6 +PF13.Signal=FMC_A7 +PF14.Signal=FMC_A8 +PF15.Signal=FMC_A9 +PF2.Signal=FMC_A2 +PF3.Signal=FMC_A3 +PF4.Signal=FMC_A4 +PF5.Signal=FMC_A5 +PF7.GPIOParameters=GPIO_Label +PF7.GPIO_Label=EXTSPI_SCK +PF7.Mode=Full_Duplex_Master +PF7.Signal=SPI5_SCK +PF8.GPIOParameters=GPIO_Label +PF8.GPIO_Label=EXTSPI_MISO +PF8.Mode=Full_Duplex_Master +PF8.Signal=SPI5_MISO +PF9.GPIOParameters=GPIO_Label +PF9.GPIO_Label=EXTSPI_MOSI +PF9.Mode=Full_Duplex_Master +PF9.Signal=SPI5_MOSI +PG0.Signal=FMC_A10 +PG1.Signal=FMC_A11 +PG15.Signal=FMC_SDNCAS +PG4.Signal=FMC_A14_BA0 +PG5.Signal=FMC_A15_BA1 +PG8.Signal=FMC_SDCLK +PH0/OSC_IN.Mode=HSE-External-Oscillator +PH0/OSC_IN.Signal=RCC_OSC_IN +PH1/OSC_OUT.Mode=HSE-External-Oscillator +PH1/OSC_OUT.Signal=RCC_OSC_OUT +PinOutPanel.RotationAngle=0 +ProjectManager.AskForMigrate=true +ProjectManager.BackupPrevious=false +ProjectManager.CompilerOptimize=6 +ProjectManager.ComputerToolchain=false +ProjectManager.CoupleFile=false +ProjectManager.CustomerFirmwarePackage= +ProjectManager.DefaultFWLocation=true +ProjectManager.DeletePrevious=true +ProjectManager.DeviceId=STM32F427ZITx +ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.24.2 +ProjectManager.FreePins=true +ProjectManager.HalAssertFull=true +ProjectManager.HeapSize=0x200 +ProjectManager.KeepUserCode=true +ProjectManager.LastFirmware=true +ProjectManager.LibraryCopy=0 +ProjectManager.MainLocation=Src +ProjectManager.NoMain=false +ProjectManager.PreviousToolchain= +ProjectManager.ProjectBuild=false +ProjectManager.ProjectFileName=OwlPedal2.ioc +ProjectManager.ProjectName=OwlPedal2 +ProjectManager.StackSize=0x400 +ProjectManager.TargetToolchain=Makefile +ProjectManager.ToolChainLocation= +ProjectManager.UnderRoot=false +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-MX_SPI5_Init-SPI5-false-HAL-true,9-MX_TIM2_Init-TIM2-false-HAL-true,10-MX_USART2_UART_Init-USART2-false-HAL-true,11-SystemClock_Config-RCC-false-HAL-true,12-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-true,13-MX_TIM3_Init-TIM3-false-HAL-true,14-MX_RTC_Init-RTC-false-HAL-true +RCC.48MHZClocksFreq_Value=48000000 +RCC.AHBFreq_Value=168000000 +RCC.APB1CLKDivider=RCC_HCLK_DIV4 +RCC.APB1Freq_Value=42000000 +RCC.APB1TimFreq_Value=84000000 +RCC.APB2CLKDivider=RCC_HCLK_DIV2 +RCC.APB2Freq_Value=84000000 +RCC.APB2TimFreq_Value=168000000 +RCC.CECFreq_Value=32786.88524590164 +RCC.CortexFreq_Value=168000000 +RCC.EthernetFreq_Value=168000000 +RCC.FCLKCortexFreq_Value=168000000 +RCC.FamilyName=M +RCC.HCLKFreq_Value=168000000 +RCC.HSE_VALUE=25000000 +RCC.HSI_VALUE=16000000 +RCC.I2C1Freq_Value=54000000 +RCC.I2C2Freq_Value=54000000 +RCC.I2C3Freq_Value=54000000 +RCC.I2C4Freq_Value=54000000 +RCC.I2SClocksFreq_Value=96000000 +RCC.I2SFreq_Value=96000000 +RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CECFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SClocksFreq_Value,I2SFreq_Value,LCDTFToutputFreq_Value,LPTIM1Freq_Value,LSE_VALUE,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLI2SPCLKFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLI2SRoutputFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLQoutputFreq_Value,PLLSAIN,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIRCLKFreq_Value,PLLSAIoutputFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SAI1Freq_Value,SAI2Freq_Value,SAI_AClocksFreq_Value,SAI_BClocksFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,UART4Freq_Value,UART5Freq_Value,UART7Freq_Value,UART8Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USART6Freq_Value,USBFreq_Value,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value,VCOSAIOutputFreq_ValueQ,VcooutputI2S,VcooutputI2SQ +RCC.LCDTFToutputFreq_Value=25000000 +RCC.LPTIM1Freq_Value=54000000 +RCC.LSE_VALUE=32768 +RCC.LSI_VALUE=32000 +RCC.MCO2PinFreq_Value=168000000 +RCC.PLLCLKFreq_Value=168000000 +RCC.PLLI2SPCLKFreq_Value=96000000 +RCC.PLLI2SQCLKFreq_Value=96000000 +RCC.PLLI2SRCLKFreq_Value=96000000 +RCC.PLLI2SRoutputFreq_Value=96000000 +RCC.PLLM=25 +RCC.PLLN=336 +RCC.PLLQ=7 +RCC.PLLQCLKFreq_Value=48000000 +RCC.PLLQoutputFreq_Value=48000000 +RCC.PLLSAIN=100 +RCC.PLLSAIPCLKFreq_Value=50000000 +RCC.PLLSAIQCLKFreq_Value=50000000 +RCC.PLLSAIRCLKFreq_Value=50000000 +RCC.PLLSAIoutputFreq_Value=50000000 +RCC.RTCFreq_Value=32000 +RCC.RTCHSEDivFreq_Value=12500000 +RCC.SAI1Freq_Value=50000000 +RCC.SAI2Freq_Value=50000000 +RCC.SAI_AClocksFreq_Value=25000000 +RCC.SAI_BClocksFreq_Value=25000000 +RCC.SDMMCFreq_Value=216000000 +RCC.SPDIFRXFreq_Value=96000000 +RCC.SYSCLKFreq_VALUE=168000000 +RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK +RCC.UART4Freq_Value=54000000 +RCC.UART5Freq_Value=54000000 +RCC.UART7Freq_Value=54000000 +RCC.UART8Freq_Value=54000000 +RCC.USART1Freq_Value=108000000 +RCC.USART2Freq_Value=54000000 +RCC.USART3Freq_Value=54000000 +RCC.USART6Freq_Value=108000000 +RCC.USBFreq_Value=48000000 +RCC.VCOI2SOutputFreq_Value=192000000 +RCC.VCOInputFreq_Value=1000000 +RCC.VCOOutputFreq_Value=336000000 +RCC.VCOSAIOutputFreq_Value=100000000 +RCC.VCOSAIOutputFreq_ValueQ=25000000 +RCC.VcooutputI2S=96000000 +RCC.VcooutputI2SQ=96000000 +SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX +SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_RX +SAI1.DataSize-SAI_A_AsyncSlave=SAI_DATASIZE_24 +SAI1.FSDefinition-SAI_A_AsyncSlave=SAI_FS_CHANNEL_IDENTIFICATION +SAI1.FSDefinition-SAI_B_SyncSlave=SAI_FS_CHANNEL_IDENTIFICATION +SAI1.FrameLength-SAI_A_AsyncSlave=64 +SAI1.FrameLength-SAI_B_SyncSlave=64 +SAI1.IPParameters=Instance-SAI_A_AsyncSlave,VirtualMode-SAI_A_AsyncSlave,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,Synchro-SAI_B_SyncSlave,FrameLength-SAI_B_SyncSlave,SlotSize-SAI_B_SyncSlave,AudioMode-SAI_B_SyncSlave,AudioMode-SAI_A_AsyncSlave,DataSize-SAI_A_AsyncSlave,FrameLength-SAI_A_AsyncSlave,SlotSize-SAI_A_AsyncSlave,SlotNumber-SAI_A_AsyncSlave,FSDefinition-SAI_A_AsyncSlave,FSDefinition-SAI_B_SyncSlave,Synchro-SAI_A_AsyncSlave,Synchro_A,Synchro_B +SAI1.Instance-SAI_A_AsyncSlave=SAI$Index_Block_A +SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B +SAI1.SlotNumber-SAI_A_AsyncSlave=2 +SAI1.SlotSize-SAI_A_AsyncSlave=SAI_SLOTSIZE_32B +SAI1.SlotSize-SAI_B_SyncSlave=SAI_SLOTSIZE_32B +SAI1.Synchro-SAI_A_AsyncSlave=SAI_ASYNCHRONOUS +SAI1.Synchro-SAI_B_SyncSlave=SAI_SYNCHRONOUS +SAI1.Synchro_A=SAI_ASYNCHRONOUS +SAI1.Synchro_B=SAI_SYNCHRONOUS +SAI1.VirtualMode-SAI_A_AsyncSlave=VM_SLAVE +SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE +SH.ADCx_IN11.0=ADC3_IN11,IN11 +SH.ADCx_IN11.ConfNb=1 +SH.ADCx_IN12.0=ADC3_IN12,IN12 +SH.ADCx_IN12.ConfNb=1 +SH.ADCx_IN13.0=ADC3_IN13,IN13 +SH.ADCx_IN13.ConfNb=1 +SH.FMC_A0.0=FMC_A0,12b-sda1 +SH.FMC_A0.ConfNb=1 +SH.FMC_A1.0=FMC_A1,12b-sda1 +SH.FMC_A1.ConfNb=1 +SH.FMC_A10.0=FMC_A10,12b-sda1 +SH.FMC_A10.ConfNb=1 +SH.FMC_A11.0=FMC_A11,12b-sda1 +SH.FMC_A11.ConfNb=1 +SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 +SH.FMC_A14_BA0.ConfNb=1 +SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 +SH.FMC_A15_BA1.ConfNb=1 +SH.FMC_A2.0=FMC_A2,12b-sda1 +SH.FMC_A2.ConfNb=1 +SH.FMC_A3.0=FMC_A3,12b-sda1 +SH.FMC_A3.ConfNb=1 +SH.FMC_A4.0=FMC_A4,12b-sda1 +SH.FMC_A4.ConfNb=1 +SH.FMC_A5.0=FMC_A5,12b-sda1 +SH.FMC_A5.ConfNb=1 +SH.FMC_A6.0=FMC_A6,12b-sda1 +SH.FMC_A6.ConfNb=1 +SH.FMC_A7.0=FMC_A7,12b-sda1 +SH.FMC_A7.ConfNb=1 +SH.FMC_A8.0=FMC_A8,12b-sda1 +SH.FMC_A8.ConfNb=1 +SH.FMC_A9.0=FMC_A9,12b-sda1 +SH.FMC_A9.ConfNb=1 +SH.FMC_D0_DA0.0=FMC_D0,sd-16b-d1 +SH.FMC_D0_DA0.ConfNb=1 +SH.FMC_D10_DA10.0=FMC_D10,sd-16b-d1 +SH.FMC_D10_DA10.ConfNb=1 +SH.FMC_D11_DA11.0=FMC_D11,sd-16b-d1 +SH.FMC_D11_DA11.ConfNb=1 +SH.FMC_D12_DA12.0=FMC_D12,sd-16b-d1 +SH.FMC_D12_DA12.ConfNb=1 +SH.FMC_D13_DA13.0=FMC_D13,sd-16b-d1 +SH.FMC_D13_DA13.ConfNb=1 +SH.FMC_D14_DA14.0=FMC_D14,sd-16b-d1 +SH.FMC_D14_DA14.ConfNb=1 +SH.FMC_D15_DA15.0=FMC_D15,sd-16b-d1 +SH.FMC_D15_DA15.ConfNb=1 +SH.FMC_D1_DA1.0=FMC_D1,sd-16b-d1 +SH.FMC_D1_DA1.ConfNb=1 +SH.FMC_D2_DA2.0=FMC_D2,sd-16b-d1 +SH.FMC_D2_DA2.ConfNb=1 +SH.FMC_D3_DA3.0=FMC_D3,sd-16b-d1 +SH.FMC_D3_DA3.ConfNb=1 +SH.FMC_D4_DA4.0=FMC_D4,sd-16b-d1 +SH.FMC_D4_DA4.ConfNb=1 +SH.FMC_D5_DA5.0=FMC_D5,sd-16b-d1 +SH.FMC_D5_DA5.ConfNb=1 +SH.FMC_D6_DA6.0=FMC_D6,sd-16b-d1 +SH.FMC_D6_DA6.ConfNb=1 +SH.FMC_D7_DA7.0=FMC_D7,sd-16b-d1 +SH.FMC_D7_DA7.ConfNb=1 +SH.FMC_D8_DA8.0=FMC_D8,sd-16b-d1 +SH.FMC_D8_DA8.ConfNb=1 +SH.FMC_D9_DA9.0=FMC_D9,sd-16b-d1 +SH.FMC_D9_DA9.ConfNb=1 +SH.FMC_NBL0.0=FMC_NBL0,Sd2ByteEnable1 +SH.FMC_NBL0.ConfNb=1 +SH.FMC_NBL1.0=FMC_NBL1,Sd2ByteEnable1 +SH.FMC_NBL1.ConfNb=1 +SH.FMC_SDCLK.0=FMC_SDCLK,12b-sda1 +SH.FMC_SDCLK.ConfNb=1 +SH.FMC_SDNCAS.0=FMC_SDNCAS,12b-sda1 +SH.FMC_SDNCAS.ConfNb=1 +SH.FMC_SDNRAS.0=FMC_SDNRAS,12b-sda1 +SH.FMC_SDNRAS.ConfNb=1 +SH.FMC_SDNWE.0=FMC_SDNWE,12b-sda1 +SH.FMC_SDNWE.ConfNb=1 +SH.GPXTI2.0=GPIO_EXTI2 +SH.GPXTI2.ConfNb=1 +SH.GPXTI8.0=GPIO_EXTI8 +SH.GPXTI8.ConfNb=1 +SH.GPXTI9.0=GPIO_EXTI9 +SH.GPXTI9.ConfNb=1 +SH.S_TIM2_CH1_ETR.0=TIM2_CH1,PWM Generation1 CH1 +SH.S_TIM2_CH1_ETR.ConfNb=1 +SH.S_TIM2_CH2.0=TIM2_CH2,PWM Generation2 CH2 +SH.S_TIM2_CH2.ConfNb=1 +SH.S_TIM3_CH4.0=TIM3_CH4,PWM Generation4 CH4 +SH.S_TIM3_CH4.ConfNb=1 +SPI1.CalculateBaudRate=42.0 MBits/s +SPI1.Direction=SPI_DIRECTION_2LINES +SPI1.IPParameters=Mode,CalculateBaudRate,VirtualType,Direction +SPI1.Mode=SPI_MODE_MASTER +SPI1.VirtualType=VM_MASTER +SPI4.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128 +SPI4.CalculateBaudRate=656.25 KBits/s +SPI4.Direction=SPI_DIRECTION_2LINES +SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,VirtualType,Direction +SPI4.Mode=SPI_MODE_MASTER +SPI4.VirtualType=VM_MASTER +SPI5.CalculateBaudRate=42.0 MBits/s +SPI5.Direction=SPI_DIRECTION_2LINES +SPI5.IPParameters=Mode,CalculateBaudRate,VirtualType,Direction +SPI5.Mode=SPI_MODE_MASTER +SPI5.VirtualType=VM_MASTER +TIM2.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 +TIM2.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2 +TIM2.IPParameters=Period,Prescaler,Pulse-PWM Generation1 CH1,Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2,Pulse-PWM Generation2 CH2 +TIM2.Period=1023 +TIM2.Prescaler=16 +TIM2.Pulse-PWM\ Generation1\ CH1=1023 +TIM2.Pulse-PWM\ Generation2\ CH2=1023 +TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4 +TIM3.IPParameters=Channel-PWM Generation4 CH4,Prescaler,Period,Pulse-PWM Generation4 CH4 +TIM3.Period=1023 +TIM3.Prescaler=16 +TIM3.Pulse-PWM\ Generation4\ CH4=1023 +USART2.IPParameters=VirtualMode +USART2.VirtualMode=VM_ASYNC +USB_DEVICE.CLASS_NAME_FS=AUDIO +USB_DEVICE.IPParameters=VirtualMode-AUDIO_FS,VirtualModeFS,CLASS_NAME_FS,PID_AUDIO_FS,MANUFACTURER_STRING-AUDIO_FS,VID-AUDIO_FS,PRODUCT_STRING_AUDIO_FS,USBD_MAX_NUM_INTERFACES-AUDIO_FS,USBD_MAX_NUM_CONFIGURATION-AUDIO_FS,USBD_AUDIO_FREQ-AUDIO_FS +USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology +USB_DEVICE.PID_AUDIO_FS=0xdada +USB_DEVICE.PRODUCT_STRING_AUDIO_FS=OWL-PEDAL +USB_DEVICE.USBD_AUDIO_FREQ-AUDIO_FS=48000 +USB_DEVICE.USBD_MAX_NUM_CONFIGURATION-AUDIO_FS=2 +USB_DEVICE.USBD_MAX_NUM_INTERFACES-AUDIO_FS=5 +USB_DEVICE.VID-AUDIO_FS=0x1209 +USB_DEVICE.VirtualMode-AUDIO_FS=Audio +USB_DEVICE.VirtualModeFS=Audio_FS +USB_OTG_FS.IPParameters=VirtualMode +USB_OTG_FS.VirtualMode=Device_Only +VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 +VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 +VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled +VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate +VP_SYS_VS_Systick.Mode=SysTick +VP_SYS_VS_Systick.Signal=SYS_VS_Systick +VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Mode=AUDIO_FS +VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_FS +board=Alchemist diff --git a/OwlPedal2/Src/freertos.c b/OwlPedal2/Src/freertos.c new file mode 100644 index 00000000..ad5906e2 --- /dev/null +++ b/OwlPedal2/Src/freertos.c @@ -0,0 +1,136 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * File Name : freertos.c + * Description : Code for freertos applications + ****************************************************************************** + * This notice applies to any and all portions of this file + * that are not between comment pairs USER CODE BEGIN and + * USER CODE END. Other portions of this file, whether + * inserted by the user or by software development tools + * are owned by their respective copyright owners. + * + * Copyright (c) 2019 STMicroelectronics International N.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "FreeRTOS.h" +#include "task.h" +#include "main.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN PTD */ + +/* USER CODE END PTD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ + +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN Variables */ + +/* USER CODE END Variables */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN FunctionPrototypes */ + +/* USER CODE END FunctionPrototypes */ + +/* GetIdleTaskMemory prototype (linked to static allocation support) */ +void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ); + +/* Hook prototypes */ +void vApplicationStackOverflowHook(TaskHandle_t xTask, signed char *pcTaskName); +void vApplicationMallocFailedHook(void); + +/* USER CODE BEGIN 4 */ +__weak void vApplicationStackOverflowHook(TaskHandle_t xTask, signed char *pcTaskName) +{ + /* Run time stack overflow checking is performed if + configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is + called if a stack overflow is detected. */ +} +/* USER CODE END 4 */ + +/* USER CODE BEGIN 5 */ +__weak void vApplicationMallocFailedHook(void) +{ + /* vApplicationMallocFailedHook() will only be called if + configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook + function that will get called if a call to pvPortMalloc() fails. + pvPortMalloc() is called internally by the kernel whenever a task, queue, + timer or semaphore is created. It is also called by various parts of the + demo application. If heap_1.c or heap_2.c are used, then the size of the + heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in + FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used + to query the size of free heap space that remains (although it does not + provide information on how the remaining heap might be fragmented). */ +} +/* USER CODE END 5 */ + +/* USER CODE BEGIN GET_IDLE_TASK_MEMORY */ +static StaticTask_t xIdleTaskTCBBuffer; +static StackType_t xIdleStack[configMINIMAL_STACK_SIZE]; + +void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ) +{ + *ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer; + *ppxIdleTaskStackBuffer = &xIdleStack[0]; + *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; + /* place for user code */ +} +/* USER CODE END GET_IDLE_TASK_MEMORY */ + +/* Private application code --------------------------------------------------*/ +/* USER CODE BEGIN Application */ + +/* USER CODE END Application */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Src/main.c b/OwlPedal2/Src/main.c new file mode 100644 index 00000000..f14747b4 --- /dev/null +++ b/OwlPedal2/Src/main.c @@ -0,0 +1,966 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : main.c + * @brief : Main program body + ****************************************************************************** + * This notice applies to any and all portions of this file + * that are not between comment pairs USER CODE BEGIN and + * USER CODE END. Other portions of this file, whether + * inserted by the user or by software development tools + * are owned by their respective copyright owners. + * + * Copyright (c) 2019 STMicroelectronics International N.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "cmsis_os.h" +#include "usb_device.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN PTD */ + +/* USER CODE END PTD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ + +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +ADC_HandleTypeDef hadc3; +DMA_HandleTypeDef hdma_adc3; + +RTC_HandleTypeDef hrtc; + +SAI_HandleTypeDef hsai_BlockA1; +SAI_HandleTypeDef hsai_BlockB1; +DMA_HandleTypeDef hdma_sai1_a; +DMA_HandleTypeDef hdma_sai1_b; + +SPI_HandleTypeDef hspi1; +SPI_HandleTypeDef hspi4; +SPI_HandleTypeDef hspi5; + +TIM_HandleTypeDef htim2; +TIM_HandleTypeDef htim3; + +UART_HandleTypeDef huart2; + +SDRAM_HandleTypeDef hsdram1; + +osThreadId defaultTaskHandle; +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +void SystemClock_Config(void); +static void MX_GPIO_Init(void); +static void MX_DMA_Init(void); +static void MX_ADC3_Init(void); +static void MX_FMC_Init(void); +static void MX_SAI1_Init(void); +static void MX_SPI1_Init(void); +static void MX_SPI4_Init(void); +static void MX_SPI5_Init(void); +static void MX_TIM2_Init(void); +static void MX_USART2_UART_Init(void); +static void MX_TIM3_Init(void); +static void MX_RTC_Init(void); +void StartDefaultTask(void const * argument); + +/* USER CODE BEGIN PFP */ +/* Private function prototypes -----------------------------------------------*/ + +void setup(); +void loop(void); +void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram); + +/* USER CODE END PFP */ + +/* Private user code ---------------------------------------------------------*/ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/** + * @brief The application entry point. + * @retval int + */ +int main(void) +{ + /* USER CODE BEGIN 1 */ + + /* USER CODE END 1 */ + + + /* MCU Configuration--------------------------------------------------------*/ + + /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ + HAL_Init(); + + /* USER CODE BEGIN Init */ + + /* USER CODE END Init */ + + /* Configure the system clock */ + SystemClock_Config(); + + /* USER CODE BEGIN SysInit */ + + /* USER CODE END SysInit */ + + /* Initialize all configured peripherals */ + MX_GPIO_Init(); + MX_DMA_Init(); + MX_ADC3_Init(); + MX_FMC_Init(); + MX_SAI1_Init(); + MX_SPI1_Init(); + MX_SPI4_Init(); + MX_SPI5_Init(); + MX_TIM2_Init(); + MX_USART2_UART_Init(); + MX_TIM3_Init(); + MX_RTC_Init(); + /* USER CODE BEGIN 2 */ + + HAL_SAI_DeInit(&hsai_BlockA1); + HAL_SAI_DeInit(&hsai_BlockB1); + hsai_BlockA1.Instance = SAI1_Block_A; + hsai_BlockA1.Init.AudioMode = SAI_MODESLAVE_TX; + hsai_BlockA1.Init.Synchro = SAI_ASYNCHRONOUS; + hsai_BlockA1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; + hsai_BlockA1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; + hsai_BlockA1.Init.SynchroExt = SAI_SYNCEXT_DISABLE; + hsai_BlockA1.Init.MonoStereoMode = SAI_STEREOMODE; + hsai_BlockA1.Init.CompandingMode = SAI_NOCOMPANDING; + hsai_BlockA1.Init.TriState = SAI_OUTPUT_NOTRELEASED; + if (HAL_SAI_InitProtocol(&hsai_BlockA1, SAI_I2S_STANDARD, SAI_PROTOCOL_DATASIZE_24BIT, 2) != HAL_OK) + Error_Handler(); + hsai_BlockB1.Instance = SAI1_Block_B; + hsai_BlockB1.Init.AudioMode = SAI_MODESLAVE_RX; + hsai_BlockB1.Init.Synchro = SAI_SYNCHRONOUS; + hsai_BlockB1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; + hsai_BlockB1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; + hsai_BlockB1.Init.SynchroExt = SAI_SYNCEXT_DISABLE; + hsai_BlockB1.Init.MonoStereoMode = SAI_STEREOMODE; + hsai_BlockB1.Init.CompandingMode = SAI_NOCOMPANDING; + hsai_BlockB1.Init.TriState = SAI_OUTPUT_NOTRELEASED; + if (HAL_SAI_InitProtocol(&hsai_BlockB1, SAI_I2S_STANDARD, SAI_PROTOCOL_DATASIZE_24BIT, 2) != HAL_OK) + Error_Handler(); + + SDRAM_Initialization_Sequence(&hsdram1); + + /* USER CODE END 2 */ + + /* USER CODE BEGIN RTOS_MUTEX */ + /* add mutexes, ... */ + /* USER CODE END RTOS_MUTEX */ + + /* USER CODE BEGIN RTOS_SEMAPHORES */ + /* add semaphores, ... */ + /* USER CODE END RTOS_SEMAPHORES */ + + /* USER CODE BEGIN RTOS_TIMERS */ + /* start timers, add new ones, ... */ + /* USER CODE END RTOS_TIMERS */ + + /* USER CODE BEGIN RTOS_QUEUES */ + /* add queues, ... */ + /* USER CODE END RTOS_QUEUES */ + + /* Create the thread(s) */ + /* definition and creation of defaultTask */ + osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128); + defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL); + + /* USER CODE BEGIN RTOS_THREADS */ + /* add threads, ... */ + /* USER CODE END RTOS_THREADS */ + + /* Start scheduler */ + osKernelStart(); + + /* We should never get here as control is now taken by the scheduler */ + + /* Infinite loop */ + /* USER CODE BEGIN WHILE */ + while (1) + { + /* USER CODE END WHILE */ + + /* USER CODE BEGIN 3 */ + + } + /* USER CODE END 3 */ +} + +/** + * @brief System Clock Configuration + * @retval None + */ +void SystemClock_Config(void) +{ + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + + /** Macro to configure SAI1BlockB clock source selection + */ + __HAL_RCC_SAI_BLOCKBCLKSOURCE_CONFIG(SAI_CLKSOURCE_PLLSAI); + /** Macro to configure SAI1BlockA clock source selection + */ + __HAL_RCC_SAI_BLOCKACLKSOURCE_CONFIG(SAI_CLKSOURCE_PLLSAI); + /** Configure the main internal regulator output voltage + */ + __HAL_RCC_PWR_CLK_ENABLE(); + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); + /** Initializes the CPU, AHB and APB busses clocks + */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.LSIState = RCC_LSI_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 25; + RCC_OscInitStruct.PLL.PLLN = 336; + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; + RCC_OscInitStruct.PLL.PLLQ = 7; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) + { + Error_Handler(); + } + /** Initializes the CPU, AHB and APB busses clocks + */ + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK + |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; + + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) + { + Error_Handler(); + } + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SAI_PLLSAI|RCC_PERIPHCLK_RTC; + PeriphClkInitStruct.PLLSAI.PLLSAIN = 100; + PeriphClkInitStruct.PLLSAI.PLLSAIQ = 4; + PeriphClkInitStruct.PLLSAIDivQ = 1; + PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } +} + +/** + * @brief ADC3 Initialization Function + * @param None + * @retval None + */ +static void MX_ADC3_Init(void) +{ + + /* USER CODE BEGIN ADC3_Init 0 */ + + /* USER CODE END ADC3_Init 0 */ + + ADC_ChannelConfTypeDef sConfig = {0}; + + /* USER CODE BEGIN ADC3_Init 1 */ + + /* USER CODE END ADC3_Init 1 */ + /** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion) + */ + hadc3.Instance = ADC3; + hadc3.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV8; + hadc3.Init.Resolution = ADC_RESOLUTION_12B; + hadc3.Init.ScanConvMode = ENABLE; + hadc3.Init.ContinuousConvMode = ENABLE; + hadc3.Init.DiscontinuousConvMode = DISABLE; + hadc3.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; + hadc3.Init.ExternalTrigConv = ADC_SOFTWARE_START; + hadc3.Init.DataAlign = ADC_DATAALIGN_RIGHT; + hadc3.Init.NbrOfConversion = 4; + hadc3.Init.DMAContinuousRequests = ENABLE; + hadc3.Init.EOCSelection = ADC_EOC_SEQ_CONV; + if (HAL_ADC_Init(&hadc3) != HAL_OK) + { + Error_Handler(); + } + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + */ + sConfig.Channel = ADC_CHANNEL_13; + sConfig.Rank = 1; + sConfig.SamplingTime = ADC_SAMPLETIME_144CYCLES; + if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + */ + sConfig.Channel = ADC_CHANNEL_12; + sConfig.Rank = 2; + if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + */ + sConfig.Channel = ADC_CHANNEL_11; + sConfig.Rank = 3; + if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + */ + sConfig.Channel = ADC_CHANNEL_8; + sConfig.Rank = 4; + if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN ADC3_Init 2 */ + + /* USER CODE END ADC3_Init 2 */ + +} + +/** + * @brief RTC Initialization Function + * @param None + * @retval None + */ +static void MX_RTC_Init(void) +{ + + /* USER CODE BEGIN RTC_Init 0 */ + + /* USER CODE END RTC_Init 0 */ + + /* USER CODE BEGIN RTC_Init 1 */ + + /* USER CODE END RTC_Init 1 */ + /** Initialize RTC Only + */ + hrtc.Instance = RTC; + hrtc.Init.HourFormat = RTC_HOURFORMAT_24; + hrtc.Init.AsynchPrediv = 127; + hrtc.Init.SynchPrediv = 255; + hrtc.Init.OutPut = RTC_OUTPUT_DISABLE; + hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH; + hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN; + if (HAL_RTC_Init(&hrtc) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN RTC_Init 2 */ + + /* USER CODE END RTC_Init 2 */ + +} + +/** + * @brief SAI1 Initialization Function + * @param None + * @retval None + */ +static void MX_SAI1_Init(void) +{ + + /* USER CODE BEGIN SAI1_Init 0 */ + + /* USER CODE END SAI1_Init 0 */ + + /* USER CODE BEGIN SAI1_Init 1 */ + + /* USER CODE END SAI1_Init 1 */ + hsai_BlockA1.Instance = SAI1_Block_A; + hsai_BlockA1.Init.Protocol = SAI_FREE_PROTOCOL; + hsai_BlockA1.Init.AudioMode = SAI_MODESLAVE_TX; + hsai_BlockA1.Init.DataSize = SAI_DATASIZE_24; + hsai_BlockA1.Init.FirstBit = SAI_FIRSTBIT_MSB; + hsai_BlockA1.Init.ClockStrobing = SAI_CLOCKSTROBING_FALLINGEDGE; + hsai_BlockA1.Init.Synchro = SAI_ASYNCHRONOUS; + hsai_BlockA1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; + hsai_BlockA1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; + hsai_BlockA1.FrameInit.FrameLength = 64; + hsai_BlockA1.FrameInit.ActiveFrameLength = 1; + hsai_BlockA1.FrameInit.FSDefinition = SAI_FS_CHANNEL_IDENTIFICATION; + hsai_BlockA1.FrameInit.FSPolarity = SAI_FS_ACTIVE_LOW; + hsai_BlockA1.FrameInit.FSOffset = SAI_FS_FIRSTBIT; + hsai_BlockA1.SlotInit.FirstBitOffset = 0; + hsai_BlockA1.SlotInit.SlotSize = SAI_SLOTSIZE_32B; + hsai_BlockA1.SlotInit.SlotNumber = 2; + hsai_BlockA1.SlotInit.SlotActive = 0x00000000; + if (HAL_SAI_Init(&hsai_BlockA1) != HAL_OK) + { + Error_Handler(); + } + hsai_BlockB1.Instance = SAI1_Block_B; + hsai_BlockB1.Init.Protocol = SAI_FREE_PROTOCOL; + hsai_BlockB1.Init.AudioMode = SAI_MODESLAVE_RX; + hsai_BlockB1.Init.DataSize = SAI_DATASIZE_24; + hsai_BlockB1.Init.FirstBit = SAI_FIRSTBIT_MSB; + hsai_BlockB1.Init.ClockStrobing = SAI_CLOCKSTROBING_FALLINGEDGE; + hsai_BlockB1.Init.Synchro = SAI_SYNCHRONOUS; + hsai_BlockB1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; + hsai_BlockB1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; + hsai_BlockB1.FrameInit.FrameLength = 64; + hsai_BlockB1.FrameInit.ActiveFrameLength = 1; + hsai_BlockB1.FrameInit.FSDefinition = SAI_FS_CHANNEL_IDENTIFICATION; + hsai_BlockB1.FrameInit.FSPolarity = SAI_FS_ACTIVE_LOW; + hsai_BlockB1.FrameInit.FSOffset = SAI_FS_FIRSTBIT; + hsai_BlockB1.SlotInit.FirstBitOffset = 0; + hsai_BlockB1.SlotInit.SlotSize = SAI_SLOTSIZE_32B; + hsai_BlockB1.SlotInit.SlotNumber = 2; + hsai_BlockB1.SlotInit.SlotActive = 0x00000000; + if (HAL_SAI_Init(&hsai_BlockB1) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN SAI1_Init 2 */ + + /* USER CODE END SAI1_Init 2 */ + +} + +/** + * @brief SPI1 Initialization Function + * @param None + * @retval None + */ +static void MX_SPI1_Init(void) +{ + + /* USER CODE BEGIN SPI1_Init 0 */ + + /* USER CODE END SPI1_Init 0 */ + + /* USER CODE BEGIN SPI1_Init 1 */ + + /* USER CODE END SPI1_Init 1 */ + /* SPI1 parameter configuration*/ + hspi1.Instance = SPI1; + hspi1.Init.Mode = SPI_MODE_MASTER; + hspi1.Init.Direction = SPI_DIRECTION_2LINES; + hspi1.Init.DataSize = SPI_DATASIZE_8BIT; + hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; + hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; + hspi1.Init.NSS = SPI_NSS_SOFT; + hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2; + hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; + hspi1.Init.TIMode = SPI_TIMODE_DISABLE; + hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; + hspi1.Init.CRCPolynomial = 10; + if (HAL_SPI_Init(&hspi1) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN SPI1_Init 2 */ + + /* USER CODE END SPI1_Init 2 */ + +} + +/** + * @brief SPI4 Initialization Function + * @param None + * @retval None + */ +static void MX_SPI4_Init(void) +{ + + /* USER CODE BEGIN SPI4_Init 0 */ + + /* USER CODE END SPI4_Init 0 */ + + /* USER CODE BEGIN SPI4_Init 1 */ + + /* USER CODE END SPI4_Init 1 */ + /* SPI4 parameter configuration*/ + hspi4.Instance = SPI4; + hspi4.Init.Mode = SPI_MODE_MASTER; + hspi4.Init.Direction = SPI_DIRECTION_2LINES; + hspi4.Init.DataSize = SPI_DATASIZE_8BIT; + hspi4.Init.CLKPolarity = SPI_POLARITY_LOW; + hspi4.Init.CLKPhase = SPI_PHASE_1EDGE; + hspi4.Init.NSS = SPI_NSS_SOFT; + hspi4.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_128; + hspi4.Init.FirstBit = SPI_FIRSTBIT_MSB; + hspi4.Init.TIMode = SPI_TIMODE_DISABLE; + hspi4.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; + hspi4.Init.CRCPolynomial = 10; + if (HAL_SPI_Init(&hspi4) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN SPI4_Init 2 */ + + /* USER CODE END SPI4_Init 2 */ + +} + +/** + * @brief SPI5 Initialization Function + * @param None + * @retval None + */ +static void MX_SPI5_Init(void) +{ + + /* USER CODE BEGIN SPI5_Init 0 */ + + /* USER CODE END SPI5_Init 0 */ + + /* USER CODE BEGIN SPI5_Init 1 */ + + /* USER CODE END SPI5_Init 1 */ + /* SPI5 parameter configuration*/ + hspi5.Instance = SPI5; + hspi5.Init.Mode = SPI_MODE_MASTER; + hspi5.Init.Direction = SPI_DIRECTION_2LINES; + hspi5.Init.DataSize = SPI_DATASIZE_8BIT; + hspi5.Init.CLKPolarity = SPI_POLARITY_LOW; + hspi5.Init.CLKPhase = SPI_PHASE_1EDGE; + hspi5.Init.NSS = SPI_NSS_SOFT; + hspi5.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2; + hspi5.Init.FirstBit = SPI_FIRSTBIT_MSB; + hspi5.Init.TIMode = SPI_TIMODE_DISABLE; + hspi5.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; + hspi5.Init.CRCPolynomial = 10; + if (HAL_SPI_Init(&hspi5) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN SPI5_Init 2 */ + + /* USER CODE END SPI5_Init 2 */ + +} + +/** + * @brief TIM2 Initialization Function + * @param None + * @retval None + */ +static void MX_TIM2_Init(void) +{ + + /* USER CODE BEGIN TIM2_Init 0 */ + + /* USER CODE END TIM2_Init 0 */ + + TIM_MasterConfigTypeDef sMasterConfig = {0}; + TIM_OC_InitTypeDef sConfigOC = {0}; + + /* USER CODE BEGIN TIM2_Init 1 */ + + /* USER CODE END TIM2_Init 1 */ + htim2.Instance = TIM2; + htim2.Init.Prescaler = 16; + htim2.Init.CounterMode = TIM_COUNTERMODE_UP; + htim2.Init.Period = 1023; + htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; + htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; + if (HAL_TIM_PWM_Init(&htim2) != HAL_OK) + { + Error_Handler(); + } + sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; + sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; + if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK) + { + Error_Handler(); + } + sConfigOC.OCMode = TIM_OCMODE_PWM1; + sConfigOC.Pulse = 1023; + sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; + sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; + if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) + { + Error_Handler(); + } + if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_2) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN TIM2_Init 2 */ + + /* USER CODE END TIM2_Init 2 */ + HAL_TIM_MspPostInit(&htim2); + +} + +/** + * @brief TIM3 Initialization Function + * @param None + * @retval None + */ +static void MX_TIM3_Init(void) +{ + + /* USER CODE BEGIN TIM3_Init 0 */ + + /* USER CODE END TIM3_Init 0 */ + + TIM_MasterConfigTypeDef sMasterConfig = {0}; + TIM_OC_InitTypeDef sConfigOC = {0}; + + /* USER CODE BEGIN TIM3_Init 1 */ + + /* USER CODE END TIM3_Init 1 */ + htim3.Instance = TIM3; + htim3.Init.Prescaler = 16; + htim3.Init.CounterMode = TIM_COUNTERMODE_UP; + htim3.Init.Period = 1023; + htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; + htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; + if (HAL_TIM_PWM_Init(&htim3) != HAL_OK) + { + Error_Handler(); + } + sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; + sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; + if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK) + { + Error_Handler(); + } + sConfigOC.OCMode = TIM_OCMODE_PWM1; + sConfigOC.Pulse = 1023; + sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; + sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; + if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_4) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN TIM3_Init 2 */ + + /* USER CODE END TIM3_Init 2 */ + HAL_TIM_MspPostInit(&htim3); + +} + +/** + * @brief USART2 Initialization Function + * @param None + * @retval None + */ +static void MX_USART2_UART_Init(void) +{ + + /* USER CODE BEGIN USART2_Init 0 */ + + /* USER CODE END USART2_Init 0 */ + + /* USER CODE BEGIN USART2_Init 1 */ + + /* USER CODE END USART2_Init 1 */ + huart2.Instance = USART2; + huart2.Init.BaudRate = 115200; + huart2.Init.WordLength = UART_WORDLENGTH_8B; + huart2.Init.StopBits = UART_STOPBITS_1; + huart2.Init.Parity = UART_PARITY_NONE; + huart2.Init.Mode = UART_MODE_TX_RX; + huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE; + huart2.Init.OverSampling = UART_OVERSAMPLING_16; + if (HAL_UART_Init(&huart2) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN USART2_Init 2 */ + + /* USER CODE END USART2_Init 2 */ + +} + +/** + * Enable DMA controller clock + */ +static void MX_DMA_Init(void) +{ + + /* DMA controller clock enable */ + __HAL_RCC_DMA2_CLK_ENABLE(); + + /* DMA interrupt init */ + /* DMA2_Stream0_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 10, 0); + HAL_NVIC_EnableIRQ(DMA2_Stream0_IRQn); + /* DMA2_Stream1_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA2_Stream1_IRQn); + /* DMA2_Stream4_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA2_Stream4_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA2_Stream4_IRQn); + +} + +/* FMC initialization function */ +static void MX_FMC_Init(void) +{ + + /* USER CODE BEGIN FMC_Init 0 */ + + /* USER CODE END FMC_Init 0 */ + + FMC_SDRAM_TimingTypeDef SdramTiming = {0}; + + /* USER CODE BEGIN FMC_Init 1 */ + + /* USER CODE END FMC_Init 1 */ + + /** Perform the SDRAM1 memory initialization sequence + */ + hsdram1.Instance = FMC_SDRAM_DEVICE; + /* hsdram1.Init */ + hsdram1.Init.SDBank = FMC_SDRAM_BANK2; + hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8; + hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_12; + hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_16; + hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4; + hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3; + hsdram1.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE; + hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2; + hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE; + hsdram1.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0; + /* SdramTiming */ + SdramTiming.LoadToActiveDelay = 2; + SdramTiming.ExitSelfRefreshDelay = 6; + SdramTiming.SelfRefreshTime = 4; + SdramTiming.RowCycleDelay = 6; + SdramTiming.WriteRecoveryTime = 2; + SdramTiming.RPDelay = 2; + SdramTiming.RCDDelay = 2; + + if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK) + { + Error_Handler( ); + } + + /* USER CODE BEGIN FMC_Init 2 */ + + /* USER CODE END FMC_Init 2 */ +} + +/** + * @brief GPIO Initialization Function + * @param None + * @retval None + */ +static void MX_GPIO_Init(void) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + + /* GPIO Ports Clock Enable */ + __HAL_RCC_GPIOE_CLK_ENABLE(); + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOF_CLK_ENABLE(); + __HAL_RCC_GPIOH_CLK_ENABLE(); + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + __HAL_RCC_GPIOG_CLK_ENABLE(); + __HAL_RCC_GPIOD_CLK_ENABLE(); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(GPIOC, EXTSPI_nCS_Pin|FLASH_HOLD_Pin|FLASH_nCS_Pin, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(GPIOB, CS_nCS_Pin|CS_nRST_Pin, GPIO_PIN_RESET); + + /*Configure GPIO pins : PC13 PC14 PC6 PC7 + PC8 PC9 PC10 PC11 + PC12 */ + GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_6|GPIO_PIN_7 + |GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11 + |GPIO_PIN_12; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /*Configure GPIO pins : EXTSPI_nCS_Pin FLASH_HOLD_Pin FLASH_nCS_Pin */ + GPIO_InitStruct.Pin = EXTSPI_nCS_Pin|FLASH_HOLD_Pin|FLASH_nCS_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /*Configure GPIO pin : PF6 */ + GPIO_InitStruct.Pin = GPIO_PIN_6; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + + /*Configure GPIO pins : PA4 PA5 PA8 PA10 + PA15 */ + GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_8|GPIO_PIN_10 + |GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /*Configure GPIO pins : PB0 PB12 PB13 PB14 + PB15 PB4 PB7 */ + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 + |GPIO_PIN_15|GPIO_PIN_4|GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /*Configure GPIO pins : SW2_Pin SW3_Pin SW1_Pin */ + GPIO_InitStruct.Pin = SW2_Pin|SW3_Pin|SW1_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; + GPIO_InitStruct.Pull = GPIO_PULLUP; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /*Configure GPIO pins : CS_nCS_Pin CS_nRST_Pin */ + GPIO_InitStruct.Pin = CS_nCS_Pin|CS_nRST_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /*Configure GPIO pins : PD11 PD12 PD13 PD2 + PD3 PD4 PD5 PD7 */ + GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_2 + |GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + /*Configure GPIO pins : PG2 PG3 PG6 PG7 + PG9 PG10 PG11 PG12 + PG13 PG14 */ + GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_6|GPIO_PIN_7 + |GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12 + |GPIO_PIN_13|GPIO_PIN_14; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + + /* EXTI interrupt init*/ + HAL_NVIC_SetPriority(EXTI2_IRQn, 15, 0); + HAL_NVIC_EnableIRQ(EXTI2_IRQn); + + HAL_NVIC_SetPriority(EXTI9_5_IRQn, 15, 0); + HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); + +} + +/* USER CODE BEGIN 4 */ + +/* USER CODE END 4 */ + +/* USER CODE BEGIN Header_StartDefaultTask */ +/** + * @brief Function implementing the defaultTask thread. + * @param argument: Not used + * @retval None + */ +/* USER CODE END Header_StartDefaultTask */ +void StartDefaultTask(void const * argument) +{ + /* init code for USB_DEVICE */ + MX_USB_DEVICE_Init(); + /* USER CODE BEGIN 5 */ + setup(); + + /* Infinite loop */ + for(;;) + { + loop(); + /* osDelay(1); */ + } + /* USER CODE END 5 */ +} + +/** + * @brief This function is executed in case of error occurrence. + * @retval None + */ +void Error_Handler(void) +{ + /* USER CODE BEGIN Error_Handler_Debug */ + /* User can add his own implementation to report the HAL error return state */ +#ifdef DEBUG + __asm__("BKPT"); +#else + NVIC_SystemReset(); +#endif + /* USER CODE END Error_Handler_Debug */ +} + +#ifdef USE_FULL_ASSERT +/** + * @brief Reports the name of the source file and the source line number + * where the assert_param error has occurred. + * @param file: pointer to the source file name + * @param line: assert_param error line source number + * @retval None + */ +void assert_failed(uint8_t *file, uint32_t line) +{ + /* USER CODE BEGIN 6 */ + /* User can add his own implementation to report the file name and line number, + ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ +#ifdef DEBUG + __asm__("BKPT"); +#else + NVIC_SystemReset(); +#endif + /* USER CODE END 6 */ +} +#endif /* USE_FULL_ASSERT */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Src/startup_stm32f427xx.s b/OwlPedal2/Src/startup_stm32f427xx.s new file mode 100644 index 00000000..7ddee113 --- /dev/null +++ b/OwlPedal2/Src/startup_stm32f427xx.s @@ -0,0 +1,553 @@ +/** + ****************************************************************************** + * @file startup_stm32f427xx.s + * @author MCD Application Team + * @version V2.6.1 + * @date 14-February-2017 + * @brief STM32F427xx Devices vector table for GCC based toolchains. + * This module performs: + * - Set the initial SP + * - Set the initial PC == Reset_Handler, + * - Set the vector table entries with the exceptions ISR address + * - Branches to main in the C library (which eventually + * calls main()). + * After Reset the Cortex-M4 processor is in Thread mode, + * priority is Privileged, and the Stack is set to Main. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2017 STMicroelectronics

+ * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + + .syntax unified + .cpu cortex-m4 + .fpu softvfp + .thumb + +.global g_pfnVectors +.global Default_Handler + +/* start address for the initialization values of the .data section. +defined in linker script */ +.word _sidata +/* start address for the .data section. defined in linker script */ +.word _sdata +/* end address for the .data section. defined in linker script */ +.word _edata +/* start address for the .bss section. defined in linker script */ +.word _sbss +/* end address for the .bss section. defined in linker script */ +.word _ebss +/* stack used for SystemInit_ExtMemCtl; always internal RAM used */ + +/** + * @brief This is the code that gets called when the processor first + * starts execution following a reset event. Only the absolutely + * necessary set is performed, after which the application + * supplied main() routine is called. + * @param None + * @retval : None +*/ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + ldr sp, =_estack /* set stack pointer */ + +/* Copy the data segment initializers from flash to SRAM */ + movs r1, #0 + b LoopCopyDataInit + +CopyDataInit: + ldr r3, =_sidata + ldr r3, [r3, r1] + str r3, [r0, r1] + adds r1, r1, #4 + +LoopCopyDataInit: + ldr r0, =_sdata + ldr r3, =_edata + adds r2, r0, r1 + cmp r2, r3 + bcc CopyDataInit + ldr r2, =_sbss + b LoopFillZerobss +/* Zero fill the bss segment. */ +FillZerobss: + movs r3, #0 + str r3, [r2], #4 + +LoopFillZerobss: + ldr r3, = _ebss + cmp r2, r3 + bcc FillZerobss + +/* Call the clock system intitialization function.*/ + bl SystemInit +/* Call static constructors */ + bl __libc_init_array +/* Call the application's entry point.*/ + bl main + bx lr +.size Reset_Handler, .-Reset_Handler + +/** + * @brief This is the code that gets called when the processor receives an + * unexpected interrupt. This simply enters an infinite loop, preserving + * the system state for examination by a debugger. + * @param None + * @retval None +*/ + .section .text.Default_Handler,"ax",%progbits +Default_Handler: +Infinite_Loop: + b Infinite_Loop + .size Default_Handler, .-Default_Handler +/****************************************************************************** +* +* The minimal vector table for a Cortex M3. Note that the proper constructs +* must be placed on this to ensure that it ends up at physical address +* 0x0000.0000. +* +*******************************************************************************/ + .section .isr_vector,"a",%progbits + .type g_pfnVectors, %object + .size g_pfnVectors, .-g_pfnVectors + + +g_pfnVectors: + .word _estack + .word Reset_Handler + + .word NMI_Handler + .word HardFault_Handler + .word MemManage_Handler + .word BusFault_Handler + .word UsageFault_Handler + .word 0 + .word 0 + .word 0 + .word 0 + .word SVC_Handler + .word DebugMon_Handler + .word 0 + .word PendSV_Handler + .word SysTick_Handler + + /* External Interrupts */ + .word WWDG_IRQHandler /* Window WatchDog */ + .word PVD_IRQHandler /* PVD through EXTI Line detection */ + .word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */ + .word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */ + .word FLASH_IRQHandler /* FLASH */ + .word RCC_IRQHandler /* RCC */ + .word EXTI0_IRQHandler /* EXTI Line0 */ + .word EXTI1_IRQHandler /* EXTI Line1 */ + .word EXTI2_IRQHandler /* EXTI Line2 */ + .word EXTI3_IRQHandler /* EXTI Line3 */ + .word EXTI4_IRQHandler /* EXTI Line4 */ + .word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */ + .word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */ + .word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */ + .word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */ + .word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */ + .word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */ + .word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */ + .word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */ + .word CAN1_TX_IRQHandler /* CAN1 TX */ + .word CAN1_RX0_IRQHandler /* CAN1 RX0 */ + .word CAN1_RX1_IRQHandler /* CAN1 RX1 */ + .word CAN1_SCE_IRQHandler /* CAN1 SCE */ + .word EXTI9_5_IRQHandler /* External Line[9:5]s */ + .word TIM1_BRK_TIM9_IRQHandler /* TIM1 Break and TIM9 */ + .word TIM1_UP_TIM10_IRQHandler /* TIM1 Update and TIM10 */ + .word TIM1_TRG_COM_TIM11_IRQHandler /* TIM1 Trigger and Commutation and TIM11 */ + .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */ + .word TIM2_IRQHandler /* TIM2 */ + .word TIM3_IRQHandler /* TIM3 */ + .word TIM4_IRQHandler /* TIM4 */ + .word I2C1_EV_IRQHandler /* I2C1 Event */ + .word I2C1_ER_IRQHandler /* I2C1 Error */ + .word I2C2_EV_IRQHandler /* I2C2 Event */ + .word I2C2_ER_IRQHandler /* I2C2 Error */ + .word SPI1_IRQHandler /* SPI1 */ + .word SPI2_IRQHandler /* SPI2 */ + .word USART1_IRQHandler /* USART1 */ + .word USART2_IRQHandler /* USART2 */ + .word USART3_IRQHandler /* USART3 */ + .word EXTI15_10_IRQHandler /* External Line[15:10]s */ + .word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */ + .word OTG_FS_WKUP_IRQHandler /* USB OTG FS Wakeup through EXTI line */ + .word TIM8_BRK_TIM12_IRQHandler /* TIM8 Break and TIM12 */ + .word TIM8_UP_TIM13_IRQHandler /* TIM8 Update and TIM13 */ + .word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */ + .word TIM8_CC_IRQHandler /* TIM8 Capture Compare */ + .word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */ + .word FMC_IRQHandler /* FMC */ + .word SDIO_IRQHandler /* SDIO */ + .word TIM5_IRQHandler /* TIM5 */ + .word SPI3_IRQHandler /* SPI3 */ + .word UART4_IRQHandler /* UART4 */ + .word UART5_IRQHandler /* UART5 */ + .word TIM6_DAC_IRQHandler /* TIM6 and DAC1&2 underrun errors */ + .word TIM7_IRQHandler /* TIM7 */ + .word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */ + .word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */ + .word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */ + .word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */ + .word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */ + .word ETH_IRQHandler /* Ethernet */ + .word ETH_WKUP_IRQHandler /* Ethernet Wakeup through EXTI line */ + .word CAN2_TX_IRQHandler /* CAN2 TX */ + .word CAN2_RX0_IRQHandler /* CAN2 RX0 */ + .word CAN2_RX1_IRQHandler /* CAN2 RX1 */ + .word CAN2_SCE_IRQHandler /* CAN2 SCE */ + .word OTG_FS_IRQHandler /* USB OTG FS */ + .word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */ + .word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */ + .word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */ + .word USART6_IRQHandler /* USART6 */ + .word I2C3_EV_IRQHandler /* I2C3 event */ + .word I2C3_ER_IRQHandler /* I2C3 error */ + .word OTG_HS_EP1_OUT_IRQHandler /* USB OTG HS End Point 1 Out */ + .word OTG_HS_EP1_IN_IRQHandler /* USB OTG HS End Point 1 In */ + .word OTG_HS_WKUP_IRQHandler /* USB OTG HS Wakeup through EXTI */ + .word OTG_HS_IRQHandler /* USB OTG HS */ + .word DCMI_IRQHandler /* DCMI */ + .word 0 /* Reserved */ + .word HASH_RNG_IRQHandler /* Hash and Rng */ + .word FPU_IRQHandler /* FPU */ + .word UART7_IRQHandler /* UART7 */ + .word UART8_IRQHandler /* UART8 */ + .word SPI4_IRQHandler /* SPI4 */ + .word SPI5_IRQHandler /* SPI5 */ + .word SPI6_IRQHandler /* SPI6 */ + .word SAI1_IRQHandler /* SAI1 */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word DMA2D_IRQHandler /* DMA2D */ +/******************************************************************************* +* +* Provide weak aliases for each Exception handler to the Default_Handler. +* As they are weak aliases, any function with the same name will override +* this definition. +* +*******************************************************************************/ + .weak NMI_Handler + .thumb_set NMI_Handler,Default_Handler + + .weak HardFault_Handler + .thumb_set HardFault_Handler,Default_Handler + + .weak MemManage_Handler + .thumb_set MemManage_Handler,Default_Handler + + .weak BusFault_Handler + .thumb_set BusFault_Handler,Default_Handler + + .weak UsageFault_Handler + .thumb_set UsageFault_Handler,Default_Handler + + .weak SVC_Handler + .thumb_set SVC_Handler,Default_Handler + + .weak DebugMon_Handler + .thumb_set DebugMon_Handler,Default_Handler + + .weak PendSV_Handler + .thumb_set PendSV_Handler,Default_Handler + + .weak SysTick_Handler + .thumb_set SysTick_Handler,Default_Handler + + .weak WWDG_IRQHandler + .thumb_set WWDG_IRQHandler,Default_Handler + + .weak PVD_IRQHandler + .thumb_set PVD_IRQHandler,Default_Handler + + .weak TAMP_STAMP_IRQHandler + .thumb_set TAMP_STAMP_IRQHandler,Default_Handler + + .weak RTC_WKUP_IRQHandler + .thumb_set RTC_WKUP_IRQHandler,Default_Handler + + .weak FLASH_IRQHandler + .thumb_set FLASH_IRQHandler,Default_Handler + + .weak RCC_IRQHandler + .thumb_set RCC_IRQHandler,Default_Handler + + .weak EXTI0_IRQHandler + .thumb_set EXTI0_IRQHandler,Default_Handler + + .weak EXTI1_IRQHandler + .thumb_set EXTI1_IRQHandler,Default_Handler + + .weak EXTI2_IRQHandler + .thumb_set EXTI2_IRQHandler,Default_Handler + + .weak EXTI3_IRQHandler + .thumb_set EXTI3_IRQHandler,Default_Handler + + .weak EXTI4_IRQHandler + .thumb_set EXTI4_IRQHandler,Default_Handler + + .weak DMA1_Stream0_IRQHandler + .thumb_set DMA1_Stream0_IRQHandler,Default_Handler + + .weak DMA1_Stream1_IRQHandler + .thumb_set DMA1_Stream1_IRQHandler,Default_Handler + + .weak DMA1_Stream2_IRQHandler + .thumb_set DMA1_Stream2_IRQHandler,Default_Handler + + .weak DMA1_Stream3_IRQHandler + .thumb_set DMA1_Stream3_IRQHandler,Default_Handler + + .weak DMA1_Stream4_IRQHandler + .thumb_set DMA1_Stream4_IRQHandler,Default_Handler + + .weak DMA1_Stream5_IRQHandler + .thumb_set DMA1_Stream5_IRQHandler,Default_Handler + + .weak DMA1_Stream6_IRQHandler + .thumb_set DMA1_Stream6_IRQHandler,Default_Handler + + .weak ADC_IRQHandler + .thumb_set ADC_IRQHandler,Default_Handler + + .weak CAN1_TX_IRQHandler + .thumb_set CAN1_TX_IRQHandler,Default_Handler + + .weak CAN1_RX0_IRQHandler + .thumb_set CAN1_RX0_IRQHandler,Default_Handler + + .weak CAN1_RX1_IRQHandler + .thumb_set CAN1_RX1_IRQHandler,Default_Handler + + .weak CAN1_SCE_IRQHandler + .thumb_set CAN1_SCE_IRQHandler,Default_Handler + + .weak EXTI9_5_IRQHandler + .thumb_set EXTI9_5_IRQHandler,Default_Handler + + .weak TIM1_BRK_TIM9_IRQHandler + .thumb_set TIM1_BRK_TIM9_IRQHandler,Default_Handler + + .weak TIM1_UP_TIM10_IRQHandler + .thumb_set TIM1_UP_TIM10_IRQHandler,Default_Handler + + .weak TIM1_TRG_COM_TIM11_IRQHandler + .thumb_set TIM1_TRG_COM_TIM11_IRQHandler,Default_Handler + + .weak TIM1_CC_IRQHandler + .thumb_set TIM1_CC_IRQHandler,Default_Handler + + .weak TIM2_IRQHandler + .thumb_set TIM2_IRQHandler,Default_Handler + + .weak TIM3_IRQHandler + .thumb_set TIM3_IRQHandler,Default_Handler + + .weak TIM4_IRQHandler + .thumb_set TIM4_IRQHandler,Default_Handler + + .weak I2C1_EV_IRQHandler + .thumb_set I2C1_EV_IRQHandler,Default_Handler + + .weak I2C1_ER_IRQHandler + .thumb_set I2C1_ER_IRQHandler,Default_Handler + + .weak I2C2_EV_IRQHandler + .thumb_set I2C2_EV_IRQHandler,Default_Handler + + .weak I2C2_ER_IRQHandler + .thumb_set I2C2_ER_IRQHandler,Default_Handler + + .weak SPI1_IRQHandler + .thumb_set SPI1_IRQHandler,Default_Handler + + .weak SPI2_IRQHandler + .thumb_set SPI2_IRQHandler,Default_Handler + + .weak USART1_IRQHandler + .thumb_set USART1_IRQHandler,Default_Handler + + .weak USART2_IRQHandler + .thumb_set USART2_IRQHandler,Default_Handler + + .weak USART3_IRQHandler + .thumb_set USART3_IRQHandler,Default_Handler + + .weak EXTI15_10_IRQHandler + .thumb_set EXTI15_10_IRQHandler,Default_Handler + + .weak RTC_Alarm_IRQHandler + .thumb_set RTC_Alarm_IRQHandler,Default_Handler + + .weak OTG_FS_WKUP_IRQHandler + .thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler + + .weak TIM8_BRK_TIM12_IRQHandler + .thumb_set TIM8_BRK_TIM12_IRQHandler,Default_Handler + + .weak TIM8_UP_TIM13_IRQHandler + .thumb_set TIM8_UP_TIM13_IRQHandler,Default_Handler + + .weak TIM8_TRG_COM_TIM14_IRQHandler + .thumb_set TIM8_TRG_COM_TIM14_IRQHandler,Default_Handler + + .weak TIM8_CC_IRQHandler + .thumb_set TIM8_CC_IRQHandler,Default_Handler + + .weak DMA1_Stream7_IRQHandler + .thumb_set DMA1_Stream7_IRQHandler,Default_Handler + + .weak FMC_IRQHandler + .thumb_set FMC_IRQHandler,Default_Handler + + .weak SDIO_IRQHandler + .thumb_set SDIO_IRQHandler,Default_Handler + + .weak TIM5_IRQHandler + .thumb_set TIM5_IRQHandler,Default_Handler + + .weak SPI3_IRQHandler + .thumb_set SPI3_IRQHandler,Default_Handler + + .weak UART4_IRQHandler + .thumb_set UART4_IRQHandler,Default_Handler + + .weak UART5_IRQHandler + .thumb_set UART5_IRQHandler,Default_Handler + + .weak TIM6_DAC_IRQHandler + .thumb_set TIM6_DAC_IRQHandler,Default_Handler + + .weak TIM7_IRQHandler + .thumb_set TIM7_IRQHandler,Default_Handler + + .weak DMA2_Stream0_IRQHandler + .thumb_set DMA2_Stream0_IRQHandler,Default_Handler + + .weak DMA2_Stream1_IRQHandler + .thumb_set DMA2_Stream1_IRQHandler,Default_Handler + + .weak DMA2_Stream2_IRQHandler + .thumb_set DMA2_Stream2_IRQHandler,Default_Handler + + .weak DMA2_Stream3_IRQHandler + .thumb_set DMA2_Stream3_IRQHandler,Default_Handler + + .weak DMA2_Stream4_IRQHandler + .thumb_set DMA2_Stream4_IRQHandler,Default_Handler + + .weak ETH_IRQHandler + .thumb_set ETH_IRQHandler,Default_Handler + + .weak ETH_WKUP_IRQHandler + .thumb_set ETH_WKUP_IRQHandler,Default_Handler + + .weak CAN2_TX_IRQHandler + .thumb_set CAN2_TX_IRQHandler,Default_Handler + + .weak CAN2_RX0_IRQHandler + .thumb_set CAN2_RX0_IRQHandler,Default_Handler + + .weak CAN2_RX1_IRQHandler + .thumb_set CAN2_RX1_IRQHandler,Default_Handler + + .weak CAN2_SCE_IRQHandler + .thumb_set CAN2_SCE_IRQHandler,Default_Handler + + .weak OTG_FS_IRQHandler + .thumb_set OTG_FS_IRQHandler,Default_Handler + + .weak DMA2_Stream5_IRQHandler + .thumb_set DMA2_Stream5_IRQHandler,Default_Handler + + .weak DMA2_Stream6_IRQHandler + .thumb_set DMA2_Stream6_IRQHandler,Default_Handler + + .weak DMA2_Stream7_IRQHandler + .thumb_set DMA2_Stream7_IRQHandler,Default_Handler + + .weak USART6_IRQHandler + .thumb_set USART6_IRQHandler,Default_Handler + + .weak I2C3_EV_IRQHandler + .thumb_set I2C3_EV_IRQHandler,Default_Handler + + .weak I2C3_ER_IRQHandler + .thumb_set I2C3_ER_IRQHandler,Default_Handler + + .weak OTG_HS_EP1_OUT_IRQHandler + .thumb_set OTG_HS_EP1_OUT_IRQHandler,Default_Handler + + .weak OTG_HS_EP1_IN_IRQHandler + .thumb_set OTG_HS_EP1_IN_IRQHandler,Default_Handler + + .weak OTG_HS_WKUP_IRQHandler + .thumb_set OTG_HS_WKUP_IRQHandler,Default_Handler + + .weak OTG_HS_IRQHandler + .thumb_set OTG_HS_IRQHandler,Default_Handler + + .weak DCMI_IRQHandler + .thumb_set DCMI_IRQHandler,Default_Handler + + .weak HASH_RNG_IRQHandler + .thumb_set HASH_RNG_IRQHandler,Default_Handler + + .weak FPU_IRQHandler + .thumb_set FPU_IRQHandler,Default_Handler + + .weak UART7_IRQHandler + .thumb_set UART7_IRQHandler,Default_Handler + + .weak UART8_IRQHandler + .thumb_set UART8_IRQHandler,Default_Handler + + .weak SPI4_IRQHandler + .thumb_set SPI4_IRQHandler,Default_Handler + + .weak SPI5_IRQHandler + .thumb_set SPI5_IRQHandler,Default_Handler + + .weak SPI6_IRQHandler + .thumb_set SPI6_IRQHandler,Default_Handler + + .weak SAI1_IRQHandler + .thumb_set SAI1_IRQHandler,Default_Handler + + .weak DMA2D_IRQHandler + .thumb_set DMA2D_IRQHandler,Default_Handler + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ + diff --git a/OwlPedal2/Src/stm32f4xx_hal_msp.c b/OwlPedal2/Src/stm32f4xx_hal_msp.c new file mode 100644 index 00000000..e716d151 --- /dev/null +++ b/OwlPedal2/Src/stm32f4xx_hal_msp.c @@ -0,0 +1,963 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * File Name : stm32f4xx_hal_msp.c + * Description : This file provides code for the MSP Initialization + * and de-Initialization codes. + ****************************************************************************** + * This notice applies to any and all portions of this file + * that are not between comment pairs USER CODE BEGIN and + * USER CODE END. Other portions of this file, whether + * inserted by the user or by software development tools + * are owned by their respective copyright owners. + * + * Copyright (c) 2019 STMicroelectronics International N.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ +extern DMA_HandleTypeDef hdma_adc3; + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN TD */ + +/* USER CODE END TD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN Define */ + +/* USER CODE END Define */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN Macro */ + +/* USER CODE END Macro */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* External functions --------------------------------------------------------*/ +/* USER CODE BEGIN ExternalFunctions */ + +/* USER CODE END ExternalFunctions */ + +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); + /** + * Initializes the Global MSP. + */ +void HAL_MspInit(void) +{ + /* USER CODE BEGIN MspInit 0 */ + + /* USER CODE END MspInit 0 */ + + __HAL_RCC_SYSCFG_CLK_ENABLE(); + __HAL_RCC_PWR_CLK_ENABLE(); + + /* System interrupt init*/ + /* PendSV_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0); + + /* USER CODE BEGIN MspInit 1 */ + + /* USER CODE END MspInit 1 */ +} + +/** +* @brief ADC MSP Initialization +* This function configures the hardware resources used in this example +* @param hadc: ADC handle pointer +* @retval None +*/ +void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(hadc->Instance==ADC3) + { + /* USER CODE BEGIN ADC3_MspInit 0 */ + + /* USER CODE END ADC3_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_ADC3_CLK_ENABLE(); + + __HAL_RCC_GPIOF_CLK_ENABLE(); + __HAL_RCC_GPIOC_CLK_ENABLE(); + /**ADC3 GPIO Configuration + PF10 ------> ADC3_IN8 + PC1 ------> ADC3_IN11 + PC2 ------> ADC3_IN12 + PC3 ------> ADC3_IN13 + */ + GPIO_InitStruct.Pin = ADC4_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(ADC4_GPIO_Port, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = ADC3_Pin|ADC2_Pin|ADC1_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /* ADC3 DMA Init */ + /* ADC3 Init */ + hdma_adc3.Instance = DMA2_Stream0; + hdma_adc3.Init.Channel = DMA_CHANNEL_2; + hdma_adc3.Init.Direction = DMA_PERIPH_TO_MEMORY; + hdma_adc3.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_adc3.Init.MemInc = DMA_MINC_ENABLE; + hdma_adc3.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; + hdma_adc3.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; + hdma_adc3.Init.Mode = DMA_CIRCULAR; + hdma_adc3.Init.Priority = DMA_PRIORITY_LOW; + hdma_adc3.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + if (HAL_DMA_Init(&hdma_adc3) != HAL_OK) + { + Error_Handler(); + } + + __HAL_LINKDMA(hadc,DMA_Handle,hdma_adc3); + + /* USER CODE BEGIN ADC3_MspInit 1 */ + + /* USER CODE END ADC3_MspInit 1 */ + } + +} + +/** +* @brief ADC MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hadc: ADC handle pointer +* @retval None +*/ +void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) +{ + if(hadc->Instance==ADC3) + { + /* USER CODE BEGIN ADC3_MspDeInit 0 */ + + /* USER CODE END ADC3_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_ADC3_CLK_DISABLE(); + + /**ADC3 GPIO Configuration + PF10 ------> ADC3_IN8 + PC1 ------> ADC3_IN11 + PC2 ------> ADC3_IN12 + PC3 ------> ADC3_IN13 + */ + HAL_GPIO_DeInit(ADC4_GPIO_Port, ADC4_Pin); + + HAL_GPIO_DeInit(GPIOC, ADC3_Pin|ADC2_Pin|ADC1_Pin); + + /* ADC3 DMA DeInit */ + HAL_DMA_DeInit(hadc->DMA_Handle); + /* USER CODE BEGIN ADC3_MspDeInit 1 */ + + /* USER CODE END ADC3_MspDeInit 1 */ + } + +} + +/** +* @brief RTC MSP Initialization +* This function configures the hardware resources used in this example +* @param hrtc: RTC handle pointer +* @retval None +*/ +void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc) +{ + if(hrtc->Instance==RTC) + { + /* USER CODE BEGIN RTC_MspInit 0 */ + + /* USER CODE END RTC_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_RTC_ENABLE(); + /* USER CODE BEGIN RTC_MspInit 1 */ + + /* USER CODE END RTC_MspInit 1 */ + } + +} + +/** +* @brief RTC MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hrtc: RTC handle pointer +* @retval None +*/ +void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc) +{ + if(hrtc->Instance==RTC) + { + /* USER CODE BEGIN RTC_MspDeInit 0 */ + + /* USER CODE END RTC_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_RTC_DISABLE(); + /* USER CODE BEGIN RTC_MspDeInit 1 */ + + /* USER CODE END RTC_MspDeInit 1 */ + } + +} + +/** +* @brief SPI MSP Initialization +* This function configures the hardware resources used in this example +* @param hspi: SPI handle pointer +* @retval None +*/ +void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(hspi->Instance==SPI1) + { + /* USER CODE BEGIN SPI1_MspInit 0 */ + + /* USER CODE END SPI1_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_SPI1_CLK_ENABLE(); + + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**SPI1 GPIO Configuration + PA6 ------> SPI1_MISO + PA7 ------> SPI1_MOSI + PB3 ------> SPI1_SCK + */ + GPIO_InitStruct.Pin = FLASH_MISO_Pin|FLASH_MOSI_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = FLASH_SCK_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; + HAL_GPIO_Init(FLASH_SCK_GPIO_Port, &GPIO_InitStruct); + + /* USER CODE BEGIN SPI1_MspInit 1 */ + + /* USER CODE END SPI1_MspInit 1 */ + } + else if(hspi->Instance==SPI4) + { + /* USER CODE BEGIN SPI4_MspInit 0 */ + + /* USER CODE END SPI4_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_SPI4_CLK_ENABLE(); + + __HAL_RCC_GPIOE_CLK_ENABLE(); + /**SPI4 GPIO Configuration + PE2 ------> SPI4_SCK + PE6 ------> SPI4_MOSI + */ + GPIO_InitStruct.Pin = CS_SCK_Pin|CS_SDA_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF5_SPI4; + HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + + /* USER CODE BEGIN SPI4_MspInit 1 */ + + /* USER CODE END SPI4_MspInit 1 */ + } + else if(hspi->Instance==SPI5) + { + /* USER CODE BEGIN SPI5_MspInit 0 */ + + /* USER CODE END SPI5_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_SPI5_CLK_ENABLE(); + + __HAL_RCC_GPIOF_CLK_ENABLE(); + /**SPI5 GPIO Configuration + PF7 ------> SPI5_SCK + PF8 ------> SPI5_MISO + PF9 ------> SPI5_MOSI + */ + GPIO_InitStruct.Pin = EXTSPI_SCK_Pin|EXTSPI_MISO_Pin|EXTSPI_MOSI_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF5_SPI5; + HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + + /* USER CODE BEGIN SPI5_MspInit 1 */ + + /* USER CODE END SPI5_MspInit 1 */ + } + +} + +/** +* @brief SPI MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hspi: SPI handle pointer +* @retval None +*/ +void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) +{ + if(hspi->Instance==SPI1) + { + /* USER CODE BEGIN SPI1_MspDeInit 0 */ + + /* USER CODE END SPI1_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_SPI1_CLK_DISABLE(); + + /**SPI1 GPIO Configuration + PA6 ------> SPI1_MISO + PA7 ------> SPI1_MOSI + PB3 ------> SPI1_SCK + */ + HAL_GPIO_DeInit(GPIOA, FLASH_MISO_Pin|FLASH_MOSI_Pin); + + HAL_GPIO_DeInit(FLASH_SCK_GPIO_Port, FLASH_SCK_Pin); + + /* USER CODE BEGIN SPI1_MspDeInit 1 */ + + /* USER CODE END SPI1_MspDeInit 1 */ + } + else if(hspi->Instance==SPI4) + { + /* USER CODE BEGIN SPI4_MspDeInit 0 */ + + /* USER CODE END SPI4_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_SPI4_CLK_DISABLE(); + + /**SPI4 GPIO Configuration + PE2 ------> SPI4_SCK + PE6 ------> SPI4_MOSI + */ + HAL_GPIO_DeInit(GPIOE, CS_SCK_Pin|CS_SDA_Pin); + + /* USER CODE BEGIN SPI4_MspDeInit 1 */ + + /* USER CODE END SPI4_MspDeInit 1 */ + } + else if(hspi->Instance==SPI5) + { + /* USER CODE BEGIN SPI5_MspDeInit 0 */ + + /* USER CODE END SPI5_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_SPI5_CLK_DISABLE(); + + /**SPI5 GPIO Configuration + PF7 ------> SPI5_SCK + PF8 ------> SPI5_MISO + PF9 ------> SPI5_MOSI + */ + HAL_GPIO_DeInit(GPIOF, EXTSPI_SCK_Pin|EXTSPI_MISO_Pin|EXTSPI_MOSI_Pin); + + /* USER CODE BEGIN SPI5_MspDeInit 1 */ + + /* USER CODE END SPI5_MspDeInit 1 */ + } + +} + +/** +* @brief TIM_PWM MSP Initialization +* This function configures the hardware resources used in this example +* @param htim_pwm: TIM_PWM handle pointer +* @retval None +*/ +void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm) +{ + if(htim_pwm->Instance==TIM2) + { + /* USER CODE BEGIN TIM2_MspInit 0 */ + + /* USER CODE END TIM2_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_TIM2_CLK_ENABLE(); + /* USER CODE BEGIN TIM2_MspInit 1 */ + + /* USER CODE END TIM2_MspInit 1 */ + } + else if(htim_pwm->Instance==TIM3) + { + /* USER CODE BEGIN TIM3_MspInit 0 */ + + /* USER CODE END TIM3_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_TIM3_CLK_ENABLE(); + /* USER CODE BEGIN TIM3_MspInit 1 */ + + /* USER CODE END TIM3_MspInit 1 */ + } + +} + +void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(htim->Instance==TIM2) + { + /* USER CODE BEGIN TIM2_MspPostInit 0 */ + + /* USER CODE END TIM2_MspPostInit 0 */ + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**TIM2 GPIO Configuration + PA0/WKUP ------> TIM2_CH1 + PA1 ------> TIM2_CH2 + */ + GPIO_InitStruct.Pin = PWM1_Pin|PWM2_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF1_TIM2; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* USER CODE BEGIN TIM2_MspPostInit 1 */ + + /* USER CODE END TIM2_MspPostInit 1 */ + } + else if(htim->Instance==TIM3) + { + /* USER CODE BEGIN TIM3_MspPostInit 0 */ + + /* USER CODE END TIM3_MspPostInit 0 */ + + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**TIM3 GPIO Configuration + PB1 ------> TIM3_CH4 + */ + GPIO_InitStruct.Pin = PWM3_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF2_TIM3; + HAL_GPIO_Init(PWM3_GPIO_Port, &GPIO_InitStruct); + + /* USER CODE BEGIN TIM3_MspPostInit 1 */ + + /* USER CODE END TIM3_MspPostInit 1 */ + } + +} +/** +* @brief TIM_PWM MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param htim_pwm: TIM_PWM handle pointer +* @retval None +*/ +void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm) +{ + if(htim_pwm->Instance==TIM2) + { + /* USER CODE BEGIN TIM2_MspDeInit 0 */ + + /* USER CODE END TIM2_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_TIM2_CLK_DISABLE(); + /* USER CODE BEGIN TIM2_MspDeInit 1 */ + + /* USER CODE END TIM2_MspDeInit 1 */ + } + else if(htim_pwm->Instance==TIM3) + { + /* USER CODE BEGIN TIM3_MspDeInit 0 */ + + /* USER CODE END TIM3_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_TIM3_CLK_DISABLE(); + /* USER CODE BEGIN TIM3_MspDeInit 1 */ + + /* USER CODE END TIM3_MspDeInit 1 */ + } + +} + +/** +* @brief UART MSP Initialization +* This function configures the hardware resources used in this example +* @param huart: UART handle pointer +* @retval None +*/ +void HAL_UART_MspInit(UART_HandleTypeDef* huart) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(huart->Instance==USART2) + { + /* USER CODE BEGIN USART2_MspInit 0 */ + + /* USER CODE END USART2_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_USART2_CLK_ENABLE(); + + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**USART2 GPIO Configuration + PA2 ------> USART2_TX + PA3 ------> USART2_RX + */ + GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF7_USART2; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* USER CODE BEGIN USART2_MspInit 1 */ + + /* USER CODE END USART2_MspInit 1 */ + } + +} + +/** +* @brief UART MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param huart: UART handle pointer +* @retval None +*/ +void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) +{ + if(huart->Instance==USART2) + { + /* USER CODE BEGIN USART2_MspDeInit 0 */ + + /* USER CODE END USART2_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_USART2_CLK_DISABLE(); + + /**USART2 GPIO Configuration + PA2 ------> USART2_TX + PA3 ------> USART2_RX + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3); + + /* USER CODE BEGIN USART2_MspDeInit 1 */ + + /* USER CODE END USART2_MspDeInit 1 */ + } + +} + +static uint32_t FMC_Initialized = 0; + +static void HAL_FMC_MspInit(void){ + /* USER CODE BEGIN FMC_MspInit 0 */ + + /* USER CODE END FMC_MspInit 0 */ + GPIO_InitTypeDef GPIO_InitStruct ={0}; + if (FMC_Initialized) { + return; + } + FMC_Initialized = 1; + + /* Peripheral clock enable */ + __HAL_RCC_FMC_CLK_ENABLE(); + + /** FMC GPIO Configuration + PF0 ------> FMC_A0 + PF1 ------> FMC_A1 + PF2 ------> FMC_A2 + PF3 ------> FMC_A3 + PF4 ------> FMC_A4 + PF5 ------> FMC_A5 + PC0 ------> FMC_SDNWE + PF11 ------> FMC_SDNRAS + PF12 ------> FMC_A6 + PF13 ------> FMC_A7 + PF14 ------> FMC_A8 + PF15 ------> FMC_A9 + PG0 ------> FMC_A10 + PG1 ------> FMC_A11 + PE7 ------> FMC_D4 + PE8 ------> FMC_D5 + PE9 ------> FMC_D6 + PE10 ------> FMC_D7 + PE11 ------> FMC_D8 + PE12 ------> FMC_D9 + PE13 ------> FMC_D10 + PE14 ------> FMC_D11 + PE15 ------> FMC_D12 + PD8 ------> FMC_D13 + PD9 ------> FMC_D14 + PD10 ------> FMC_D15 + PD14 ------> FMC_D0 + PD15 ------> FMC_D1 + PG4 ------> FMC_BA0 + PG5 ------> FMC_BA1 + PG8 ------> FMC_SDCLK + PD0 ------> FMC_D2 + PD1 ------> FMC_D3 + PG15 ------> FMC_SDNCAS + PB5 ------> FMC_SDCKE1 + PB6 ------> FMC_SDNE1 + PE0 ------> FMC_NBL0 + PE1 ------> FMC_NBL1 + */ + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 + |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_11|GPIO_PIN_12 + |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_0; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5 + |GPIO_PIN_8|GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 + |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 + |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14 + |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* USER CODE BEGIN FMC_MspInit 1 */ + + /* USER CODE END FMC_MspInit 1 */ +} + +void HAL_SDRAM_MspInit(SDRAM_HandleTypeDef* hsdram){ + /* USER CODE BEGIN SDRAM_MspInit 0 */ + + /* USER CODE END SDRAM_MspInit 0 */ + HAL_FMC_MspInit(); + /* USER CODE BEGIN SDRAM_MspInit 1 */ + + /* USER CODE END SDRAM_MspInit 1 */ +} + +static uint32_t FMC_DeInitialized = 0; + +static void HAL_FMC_MspDeInit(void){ + /* USER CODE BEGIN FMC_MspDeInit 0 */ + + /* USER CODE END FMC_MspDeInit 0 */ + if (FMC_DeInitialized) { + return; + } + FMC_DeInitialized = 1; + /* Peripheral clock enable */ + __HAL_RCC_FMC_CLK_DISABLE(); + + /** FMC GPIO Configuration + PF0 ------> FMC_A0 + PF1 ------> FMC_A1 + PF2 ------> FMC_A2 + PF3 ------> FMC_A3 + PF4 ------> FMC_A4 + PF5 ------> FMC_A5 + PC0 ------> FMC_SDNWE + PF11 ------> FMC_SDNRAS + PF12 ------> FMC_A6 + PF13 ------> FMC_A7 + PF14 ------> FMC_A8 + PF15 ------> FMC_A9 + PG0 ------> FMC_A10 + PG1 ------> FMC_A11 + PE7 ------> FMC_D4 + PE8 ------> FMC_D5 + PE9 ------> FMC_D6 + PE10 ------> FMC_D7 + PE11 ------> FMC_D8 + PE12 ------> FMC_D9 + PE13 ------> FMC_D10 + PE14 ------> FMC_D11 + PE15 ------> FMC_D12 + PD8 ------> FMC_D13 + PD9 ------> FMC_D14 + PD10 ------> FMC_D15 + PD14 ------> FMC_D0 + PD15 ------> FMC_D1 + PG4 ------> FMC_BA0 + PG5 ------> FMC_BA1 + PG8 ------> FMC_SDCLK + PD0 ------> FMC_D2 + PD1 ------> FMC_D3 + PG15 ------> FMC_SDNCAS + PB5 ------> FMC_SDCKE1 + PB6 ------> FMC_SDNE1 + PE0 ------> FMC_NBL0 + PE1 ------> FMC_NBL1 + */ + HAL_GPIO_DeInit(GPIOF, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 + |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_11|GPIO_PIN_12 + |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15); + + HAL_GPIO_DeInit(GPIOC, GPIO_PIN_0); + + HAL_GPIO_DeInit(GPIOG, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5 + |GPIO_PIN_8|GPIO_PIN_15); + + HAL_GPIO_DeInit(GPIOE, GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 + |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 + |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1); + + HAL_GPIO_DeInit(GPIOD, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14 + |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1); + + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_5|GPIO_PIN_6); + + /* USER CODE BEGIN FMC_MspDeInit 1 */ + + /* USER CODE END FMC_MspDeInit 1 */ +} + +void HAL_SDRAM_MspDeInit(SDRAM_HandleTypeDef* hsdram){ + /* USER CODE BEGIN SDRAM_MspDeInit 0 */ + + /* USER CODE END SDRAM_MspDeInit 0 */ + HAL_FMC_MspDeInit(); + /* USER CODE BEGIN SDRAM_MspDeInit 1 */ + + /* USER CODE END SDRAM_MspDeInit 1 */ +} + +extern DMA_HandleTypeDef hdma_sai1_a; + +extern DMA_HandleTypeDef hdma_sai1_b; + +static uint32_t SAI1_client =0; + +void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) +{ + + GPIO_InitTypeDef GPIO_InitStruct; +/* SAI1 */ + if(hsai->Instance==SAI1_Block_A) + { + /* Peripheral clock enable */ + if (SAI1_client == 0) + { + __HAL_RCC_SAI1_CLK_ENABLE(); + + /* Peripheral interrupt init*/ + HAL_NVIC_SetPriority(SAI1_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(SAI1_IRQn); + } + SAI1_client ++; + + /**SAI1_A_Block_A GPIO Configuration + PE4 ------> SAI1_FS_A + PE5 ------> SAI1_SCK_A + PD6 ------> SAI1_SD_A + */ + GPIO_InitStruct.Pin = CS_LRCK_Pin|CS_SCKE5_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; + HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = CS_SDIN_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; + HAL_GPIO_Init(CS_SDIN_GPIO_Port, &GPIO_InitStruct); + + /* Peripheral DMA init*/ + + hdma_sai1_a.Instance = DMA2_Stream1; + hdma_sai1_a.Init.Channel = DMA_CHANNEL_0; + hdma_sai1_a.Init.Direction = DMA_MEMORY_TO_PERIPH; + hdma_sai1_a.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_sai1_a.Init.MemInc = DMA_MINC_ENABLE; + hdma_sai1_a.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; + hdma_sai1_a.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; + hdma_sai1_a.Init.Mode = DMA_CIRCULAR; + hdma_sai1_a.Init.Priority = DMA_PRIORITY_VERY_HIGH; + hdma_sai1_a.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + if (HAL_DMA_Init(&hdma_sai1_a) != HAL_OK) + { + Error_Handler(); + } + + /* Several peripheral DMA handle pointers point to the same DMA handle. + Be aware that there is only one stream to perform all the requested DMAs. */ + __HAL_LINKDMA(hsai,hdmarx,hdma_sai1_a); + + __HAL_LINKDMA(hsai,hdmatx,hdma_sai1_a); + + } + if(hsai->Instance==SAI1_Block_B) + { + /* Peripheral clock enable */ + if (SAI1_client == 0) + { + __HAL_RCC_SAI1_CLK_ENABLE(); + + /* Peripheral interrupt init*/ + HAL_NVIC_SetPriority(SAI1_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(SAI1_IRQn); + } + SAI1_client ++; + + /**SAI1_B_Block_B GPIO Configuration + PE3 ------> SAI1_SD_B + */ + GPIO_InitStruct.Pin = CS_SDOUT_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; + HAL_GPIO_Init(CS_SDOUT_GPIO_Port, &GPIO_InitStruct); + + /* Peripheral DMA init*/ + + hdma_sai1_b.Instance = DMA2_Stream4; + hdma_sai1_b.Init.Channel = DMA_CHANNEL_1; + hdma_sai1_b.Init.Direction = DMA_PERIPH_TO_MEMORY; + hdma_sai1_b.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_sai1_b.Init.MemInc = DMA_MINC_ENABLE; + hdma_sai1_b.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; + hdma_sai1_b.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; + hdma_sai1_b.Init.Mode = DMA_CIRCULAR; + hdma_sai1_b.Init.Priority = DMA_PRIORITY_VERY_HIGH; + hdma_sai1_b.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + if (HAL_DMA_Init(&hdma_sai1_b) != HAL_OK) + { + Error_Handler(); + } + + /* Several peripheral DMA handle pointers point to the same DMA handle. + Be aware that there is only one stream to perform all the requested DMAs. */ + __HAL_LINKDMA(hsai,hdmarx,hdma_sai1_b); + __HAL_LINKDMA(hsai,hdmatx,hdma_sai1_b); + } +} + +void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) +{ +/* SAI1 */ + if(hsai->Instance==SAI1_Block_A) + { + SAI1_client --; + if (SAI1_client == 0) + { + /* Peripheral clock disable */ + __HAL_RCC_SAI1_CLK_DISABLE(); + HAL_NVIC_DisableIRQ(SAI1_IRQn); + } + + /**SAI1_A_Block_A GPIO Configuration + PE4 ------> SAI1_FS_A + PE5 ------> SAI1_SCK_A + PD6 ------> SAI1_SD_A + */ + HAL_GPIO_DeInit(GPIOE, CS_LRCK_Pin|CS_SCKE5_Pin); + + HAL_GPIO_DeInit(CS_SDIN_GPIO_Port, CS_SDIN_Pin); + + HAL_DMA_DeInit(hsai->hdmarx); + HAL_DMA_DeInit(hsai->hdmatx); + } + if(hsai->Instance==SAI1_Block_B) + { + SAI1_client --; + if (SAI1_client == 0) + { + /* Peripheral clock disable */ + __HAL_RCC_SAI1_CLK_DISABLE(); + HAL_NVIC_DisableIRQ(SAI1_IRQn); + } + + /**SAI1_B_Block_B GPIO Configuration + PE3 ------> SAI1_SD_B + */ + HAL_GPIO_DeInit(CS_SDOUT_GPIO_Port, CS_SDOUT_Pin); + + HAL_DMA_DeInit(hsai->hdmarx); + HAL_DMA_DeInit(hsai->hdmatx); + } +} + +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Src/stm32f4xx_it.c b/OwlPedal2/Src/stm32f4xx_it.c new file mode 100644 index 00000000..000f992a --- /dev/null +++ b/OwlPedal2/Src/stm32f4xx_it.c @@ -0,0 +1,206 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32f4xx_it.c + * @brief Interrupt Service Routines. + ****************************************************************************** + * + * COPYRIGHT(c) 2019 STMicroelectronics + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "stm32f4xx_it.h" +#include "FreeRTOS.h" +#include "task.h" +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN TD */ + +/* USER CODE END TD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ + +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* Private user code ---------------------------------------------------------*/ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* External variables --------------------------------------------------------*/ +extern DMA_HandleTypeDef hdma_adc3; +extern DMA_HandleTypeDef hdma_sai1_a; +extern DMA_HandleTypeDef hdma_sai1_b; +extern SAI_HandleTypeDef hsai_BlockA1; +extern SAI_HandleTypeDef hsai_BlockB1; +/* USER CODE BEGIN EV */ + +/* USER CODE END EV */ + +/******************************************************************************/ +/* Cortex-M4 Processor Interruption and Exception Handlers */ +/******************************************************************************/ +/** + * @brief This function handles System tick timer. + */ +void SysTick_Handler(void) +{ + /* USER CODE BEGIN SysTick_IRQn 0 */ + + /* USER CODE END SysTick_IRQn 0 */ + HAL_IncTick(); +#if (INCLUDE_xTaskGetSchedulerState == 1 ) + if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) + { +#endif /* INCLUDE_xTaskGetSchedulerState */ + xPortSysTickHandler(); +#if (INCLUDE_xTaskGetSchedulerState == 1 ) + } +#endif /* INCLUDE_xTaskGetSchedulerState */ + /* USER CODE BEGIN SysTick_IRQn 1 */ + + /* USER CODE END SysTick_IRQn 1 */ +} + +/******************************************************************************/ +/* STM32F4xx Peripheral Interrupt Handlers */ +/* Add here the Interrupt Handlers for the used peripherals. */ +/* For the available peripheral interrupt handler names, */ +/* please refer to the startup file (startup_stm32f4xx.s). */ +/******************************************************************************/ + +/** + * @brief This function handles EXTI line2 interrupt. + */ +void EXTI2_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI2_IRQn 0 */ + + /* USER CODE END EXTI2_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2); + /* USER CODE BEGIN EXTI2_IRQn 1 */ + + /* USER CODE END EXTI2_IRQn 1 */ +} + +/** + * @brief This function handles EXTI line[9:5] interrupts. + */ +void EXTI9_5_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI9_5_IRQn 0 */ + + /* USER CODE END EXTI9_5_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8); + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_9); + /* USER CODE BEGIN EXTI9_5_IRQn 1 */ + + /* USER CODE END EXTI9_5_IRQn 1 */ +} + +/** + * @brief This function handles DMA2 stream0 global interrupt. + */ +void DMA2_Stream0_IRQHandler(void) +{ + /* USER CODE BEGIN DMA2_Stream0_IRQn 0 */ + + /* USER CODE END DMA2_Stream0_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_adc3); + /* USER CODE BEGIN DMA2_Stream0_IRQn 1 */ + + /* USER CODE END DMA2_Stream0_IRQn 1 */ +} + +/** + * @brief This function handles DMA2 stream1 global interrupt. + */ +void DMA2_Stream1_IRQHandler(void) +{ + /* USER CODE BEGIN DMA2_Stream1_IRQn 0 */ + + /* USER CODE END DMA2_Stream1_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_sai1_a); + /* USER CODE BEGIN DMA2_Stream1_IRQn 1 */ + + /* USER CODE END DMA2_Stream1_IRQn 1 */ +} + +/** + * @brief This function handles DMA2 stream4 global interrupt. + */ +void DMA2_Stream4_IRQHandler(void) +{ + /* USER CODE BEGIN DMA2_Stream4_IRQn 0 */ + + /* USER CODE END DMA2_Stream4_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_sai1_b); + /* USER CODE BEGIN DMA2_Stream4_IRQn 1 */ + + /* USER CODE END DMA2_Stream4_IRQn 1 */ +} + +/** + * @brief This function handles SAI1 global interrupt. + */ +void SAI1_IRQHandler(void) +{ + /* USER CODE BEGIN SAI1_IRQn 0 */ + + /* USER CODE END SAI1_IRQn 0 */ + HAL_SAI_IRQHandler(&hsai_BlockA1); + HAL_SAI_IRQHandler(&hsai_BlockB1); + /* USER CODE BEGIN SAI1_IRQn 1 */ + + /* USER CODE END SAI1_IRQn 1 */ +} + +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Src/system_stm32f4xx.c b/OwlPedal2/Src/system_stm32f4xx.c new file mode 100644 index 00000000..adcddf9b --- /dev/null +++ b/OwlPedal2/Src/system_stm32f4xx.c @@ -0,0 +1,763 @@ +/** + ****************************************************************************** + * @file system_stm32f4xx.c + * @author MCD Application Team + * @version V2.6.1 + * @date 14-February-2017 + * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File. + * + * This file provides two functions and one global variable to be called from + * user application: + * - SystemInit(): This function is called at startup just after reset and + * before branch to main program. This call is made inside + * the "startup_stm32f4xx.s" file. + * + * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used + * by the user application to setup the SysTick + * timer or configure other parameters. + * + * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must + * be called whenever the core clock is changed + * during program execution. + * + * + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2017 STMicroelectronics

+ * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup stm32f4xx_system + * @{ + */ + +/** @addtogroup STM32F4xx_System_Private_Includes + * @{ + */ + + +#include "stm32f4xx.h" + +#if !defined (HSE_VALUE) + #define HSE_VALUE ((uint32_t)25000000) /*!< Default value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_Defines + * @{ + */ + +/************************* Miscellaneous Configuration ************************/ +/*!< Uncomment the following line if you need to use external SRAM or SDRAM as data memory */ +#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)\ + || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ + || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) +/* #define DATA_IN_ExtSRAM */ +#endif /* STM32F40xxx || STM32F41xxx || STM32F42xxx || STM32F43xxx || STM32F469xx || STM32F479xx ||\ + STM32F412Zx || STM32F412Vx */ + +#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ + || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) +/* #define DATA_IN_ExtSDRAM */ +#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx ||\ + STM32F479xx */ + +/*!< Uncomment the following line if you need to relocate your vector Table in + Internal SRAM. */ +/* #define VECT_TAB_SRAM */ +#define VECT_TAB_OFFSET 0x00010000 /*!< Vector Table base offset field. + This value must be a multiple of 0x200. */ +/******************************************************************************/ + +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_Variables + * @{ + */ + /* This variable is updated in three ways: + 1) by calling CMSIS function SystemCoreClockUpdate() + 2) by calling HAL API function HAL_RCC_GetHCLKFreq() + 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency + Note: If you use this function to configure the system clock; then there + is no need to call the 2 first functions listed above, since SystemCoreClock + variable is updated automatically. + */ +uint32_t SystemCoreClock = 16000000; +const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; +const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4}; +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_FunctionPrototypes + * @{ + */ + +#if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM) + static void SystemInit_ExtMemCtl(void); +#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */ + +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system + * Initialize the FPU setting, vector table location and External memory + * configuration. + * @param None + * @retval None + */ +void SystemInit(void) +{ + /* FPU settings ------------------------------------------------------------*/ + #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) + SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */ + #endif + /* Reset the RCC clock configuration to the default reset state ------------*/ + /* Set HSION bit */ + RCC->CR |= (uint32_t)0x00000001; + + /* Reset CFGR register */ + RCC->CFGR = 0x00000000; + + /* Reset HSEON, CSSON and PLLON bits */ + RCC->CR &= (uint32_t)0xFEF6FFFF; + + /* Reset PLLCFGR register */ + RCC->PLLCFGR = 0x24003010; + + /* Reset HSEBYP bit */ + RCC->CR &= (uint32_t)0xFFFBFFFF; + + /* Disable all interrupts */ + RCC->CIR = 0x00000000; + +#if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM) + SystemInit_ExtMemCtl(); +#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */ + + /* Configure the Vector Table location add offset address ------------------*/ +#ifdef VECT_TAB_SRAM + SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ +#else + SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ +#endif +} + +/** + * @brief Update SystemCoreClock variable according to Clock Register Values. + * The SystemCoreClock variable contains the core clock (HCLK), it can + * be used by the user application to setup the SysTick timer or configure + * other parameters. + * + * @note Each time the core clock (HCLK) changes, this function must be called + * to update SystemCoreClock variable value. Otherwise, any configuration + * based on this variable will be incorrect. + * + * @note - The system frequency computed by this function is not the real + * frequency in the chip. It is calculated based on the predefined + * constant and the selected clock source: + * + * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) + * + * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) + * + * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) + * or HSI_VALUE(*) multiplied/divided by the PLL factors. + * + * (*) HSI_VALUE is a constant defined in stm32f4xx_hal_conf.h file (default value + * 16 MHz) but the real value may vary depending on the variations + * in voltage and temperature. + * + * (**) HSE_VALUE is a constant defined in stm32f4xx_hal_conf.h file (its value + * depends on the application requirements), user has to ensure that HSE_VALUE + * is same as the real frequency of the crystal used. Otherwise, this function + * may have wrong result. + * + * - The result of this function could be not correct when using fractional + * value for HSE crystal. + * + * @param None + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2; + + /* Get SYSCLK source -------------------------------------------------------*/ + tmp = RCC->CFGR & RCC_CFGR_SWS; + + switch (tmp) + { + case 0x00: /* HSI used as system clock source */ + SystemCoreClock = HSI_VALUE; + break; + case 0x04: /* HSE used as system clock source */ + SystemCoreClock = HSE_VALUE; + break; + case 0x08: /* PLL used as system clock source */ + + /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N + SYSCLK = PLL_VCO / PLL_P + */ + pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22; + pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM; + + if (pllsource != 0) + { + /* HSE used as PLL clock source */ + pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6); + } + else + { + /* HSI used as PLL clock source */ + pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6); + } + + pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2; + SystemCoreClock = pllvco/pllp; + break; + default: + SystemCoreClock = HSI_VALUE; + break; + } + /* Compute HCLK frequency --------------------------------------------------*/ + /* Get HCLK prescaler */ + tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; + /* HCLK frequency */ + SystemCoreClock >>= tmp; +} + +#if defined (DATA_IN_ExtSRAM) && defined (DATA_IN_ExtSDRAM) +#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ + || defined(STM32F469xx) || defined(STM32F479xx) +/** + * @brief Setup the external memory controller. + * Called in startup_stm32f4xx.s before jump to main. + * This function configures the external memories (SRAM/SDRAM) + * This SRAM/SDRAM will be used as program data memory (including heap and stack). + * @param None + * @retval None + */ +void SystemInit_ExtMemCtl(void) +{ + __IO uint32_t tmp = 0x00; + + register uint32_t tmpreg = 0, timeout = 0xFFFF; + register __IO uint32_t index; + + /* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface clock */ + RCC->AHB1ENR |= 0x000001F8; + + /* Delay after an RCC peripheral clock enabling */ + tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN); + + /* Connect PDx pins to FMC Alternate function */ + GPIOD->AFR[0] = 0x00CCC0CC; + GPIOD->AFR[1] = 0xCCCCCCCC; + /* Configure PDx pins in Alternate function mode */ + GPIOD->MODER = 0xAAAA0A8A; + /* Configure PDx pins speed to 100 MHz */ + GPIOD->OSPEEDR = 0xFFFF0FCF; + /* Configure PDx pins Output type to push-pull */ + GPIOD->OTYPER = 0x00000000; + /* No pull-up, pull-down for PDx pins */ + GPIOD->PUPDR = 0x00000000; + + /* Connect PEx pins to FMC Alternate function */ + GPIOE->AFR[0] = 0xC00CC0CC; + GPIOE->AFR[1] = 0xCCCCCCCC; + /* Configure PEx pins in Alternate function mode */ + GPIOE->MODER = 0xAAAA828A; + /* Configure PEx pins speed to 100 MHz */ + GPIOE->OSPEEDR = 0xFFFFC3CF; + /* Configure PEx pins Output type to push-pull */ + GPIOE->OTYPER = 0x00000000; + /* No pull-up, pull-down for PEx pins */ + GPIOE->PUPDR = 0x00000000; + + /* Connect PFx pins to FMC Alternate function */ + GPIOF->AFR[0] = 0xCCCCCCCC; + GPIOF->AFR[1] = 0xCCCCCCCC; + /* Configure PFx pins in Alternate function mode */ + GPIOF->MODER = 0xAA800AAA; + /* Configure PFx pins speed to 50 MHz */ + GPIOF->OSPEEDR = 0xAA800AAA; + /* Configure PFx pins Output type to push-pull */ + GPIOF->OTYPER = 0x00000000; + /* No pull-up, pull-down for PFx pins */ + GPIOF->PUPDR = 0x00000000; + + /* Connect PGx pins to FMC Alternate function */ + GPIOG->AFR[0] = 0xCCCCCCCC; + GPIOG->AFR[1] = 0xCCCCCCCC; + /* Configure PGx pins in Alternate function mode */ + GPIOG->MODER = 0xAAAAAAAA; + /* Configure PGx pins speed to 50 MHz */ + GPIOG->OSPEEDR = 0xAAAAAAAA; + /* Configure PGx pins Output type to push-pull */ + GPIOG->OTYPER = 0x00000000; + /* No pull-up, pull-down for PGx pins */ + GPIOG->PUPDR = 0x00000000; + + /* Connect PHx pins to FMC Alternate function */ + GPIOH->AFR[0] = 0x00C0CC00; + GPIOH->AFR[1] = 0xCCCCCCCC; + /* Configure PHx pins in Alternate function mode */ + GPIOH->MODER = 0xAAAA08A0; + /* Configure PHx pins speed to 50 MHz */ + GPIOH->OSPEEDR = 0xAAAA08A0; + /* Configure PHx pins Output type to push-pull */ + GPIOH->OTYPER = 0x00000000; + /* No pull-up, pull-down for PHx pins */ + GPIOH->PUPDR = 0x00000000; + + /* Connect PIx pins to FMC Alternate function */ + GPIOI->AFR[0] = 0xCCCCCCCC; + GPIOI->AFR[1] = 0x00000CC0; + /* Configure PIx pins in Alternate function mode */ + GPIOI->MODER = 0x0028AAAA; + /* Configure PIx pins speed to 50 MHz */ + GPIOI->OSPEEDR = 0x0028AAAA; + /* Configure PIx pins Output type to push-pull */ + GPIOI->OTYPER = 0x00000000; + /* No pull-up, pull-down for PIx pins */ + GPIOI->PUPDR = 0x00000000; + +/*-- FMC Configuration -------------------------------------------------------*/ + /* Enable the FMC interface clock */ + RCC->AHB3ENR |= 0x00000001; + /* Delay after an RCC peripheral clock enabling */ + tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN); + + FMC_Bank5_6->SDCR[0] = 0x000019E4; + FMC_Bank5_6->SDTR[0] = 0x01115351; + + /* SDRAM initialization sequence */ + /* Clock enable command */ + FMC_Bank5_6->SDCMR = 0x00000011; + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + while((tmpreg != 0) && (timeout-- > 0)) + { + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + } + + /* Delay */ + for (index = 0; index<1000; index++); + + /* PALL command */ + FMC_Bank5_6->SDCMR = 0x00000012; + timeout = 0xFFFF; + while((tmpreg != 0) && (timeout-- > 0)) + { + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + } + + /* Auto refresh command */ + FMC_Bank5_6->SDCMR = 0x00000073; + timeout = 0xFFFF; + while((tmpreg != 0) && (timeout-- > 0)) + { + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + } + + /* MRD register program */ + FMC_Bank5_6->SDCMR = 0x00046014; + timeout = 0xFFFF; + while((tmpreg != 0) && (timeout-- > 0)) + { + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + } + + /* Set refresh count */ + tmpreg = FMC_Bank5_6->SDRTR; + FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C<<1)); + + /* Disable write protection */ + tmpreg = FMC_Bank5_6->SDCR[0]; + FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF); + +#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) + /* Configure and enable Bank1_SRAM2 */ + FMC_Bank1->BTCR[2] = 0x00001011; + FMC_Bank1->BTCR[3] = 0x00000201; + FMC_Bank1E->BWTR[2] = 0x0fffffff; +#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ +#if defined(STM32F469xx) || defined(STM32F479xx) + /* Configure and enable Bank1_SRAM2 */ + FMC_Bank1->BTCR[2] = 0x00001091; + FMC_Bank1->BTCR[3] = 0x00110212; + FMC_Bank1E->BWTR[2] = 0x0fffffff; +#endif /* STM32F469xx || STM32F479xx */ + + (void)(tmp); +} +#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */ +#elif defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM) +/** + * @brief Setup the external memory controller. + * Called in startup_stm32f4xx.s before jump to main. + * This function configures the external memories (SRAM/SDRAM) + * This SRAM/SDRAM will be used as program data memory (including heap and stack). + * @param None + * @retval None + */ +void SystemInit_ExtMemCtl(void) +{ + __IO uint32_t tmp = 0x00; +#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ + || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) +#if defined (DATA_IN_ExtSDRAM) + register uint32_t tmpreg = 0, timeout = 0xFFFF; + register __IO uint32_t index; + +#if defined(STM32F446xx) + /* Enable GPIOA, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG interface + clock */ + RCC->AHB1ENR |= 0x0000007D; +#else + /* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface + clock */ + RCC->AHB1ENR |= 0x000001F8; +#endif /* STM32F446xx */ + /* Delay after an RCC peripheral clock enabling */ + tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN); + +#if defined(STM32F446xx) + /* Connect PAx pins to FMC Alternate function */ + GPIOA->AFR[0] |= 0xC0000000; + GPIOA->AFR[1] |= 0x00000000; + /* Configure PDx pins in Alternate function mode */ + GPIOA->MODER |= 0x00008000; + /* Configure PDx pins speed to 50 MHz */ + GPIOA->OSPEEDR |= 0x00008000; + /* Configure PDx pins Output type to push-pull */ + GPIOA->OTYPER |= 0x00000000; + /* No pull-up, pull-down for PDx pins */ + GPIOA->PUPDR |= 0x00000000; + + /* Connect PCx pins to FMC Alternate function */ + GPIOC->AFR[0] |= 0x00CC0000; + GPIOC->AFR[1] |= 0x00000000; + /* Configure PDx pins in Alternate function mode */ + GPIOC->MODER |= 0x00000A00; + /* Configure PDx pins speed to 50 MHz */ + GPIOC->OSPEEDR |= 0x00000A00; + /* Configure PDx pins Output type to push-pull */ + GPIOC->OTYPER |= 0x00000000; + /* No pull-up, pull-down for PDx pins */ + GPIOC->PUPDR |= 0x00000000; +#endif /* STM32F446xx */ + + /* Connect PDx pins to FMC Alternate function */ + GPIOD->AFR[0] = 0x000000CC; + GPIOD->AFR[1] = 0xCC000CCC; + /* Configure PDx pins in Alternate function mode */ + GPIOD->MODER = 0xA02A000A; + /* Configure PDx pins speed to 50 MHz */ + GPIOD->OSPEEDR = 0xA02A000A; + /* Configure PDx pins Output type to push-pull */ + GPIOD->OTYPER = 0x00000000; + /* No pull-up, pull-down for PDx pins */ + GPIOD->PUPDR = 0x00000000; + + /* Connect PEx pins to FMC Alternate function */ + GPIOE->AFR[0] = 0xC00000CC; + GPIOE->AFR[1] = 0xCCCCCCCC; + /* Configure PEx pins in Alternate function mode */ + GPIOE->MODER = 0xAAAA800A; + /* Configure PEx pins speed to 50 MHz */ + GPIOE->OSPEEDR = 0xAAAA800A; + /* Configure PEx pins Output type to push-pull */ + GPIOE->OTYPER = 0x00000000; + /* No pull-up, pull-down for PEx pins */ + GPIOE->PUPDR = 0x00000000; + + /* Connect PFx pins to FMC Alternate function */ + GPIOF->AFR[0] = 0xCCCCCCCC; + GPIOF->AFR[1] = 0xCCCCCCCC; + /* Configure PFx pins in Alternate function mode */ + GPIOF->MODER = 0xAA800AAA; + /* Configure PFx pins speed to 50 MHz */ + GPIOF->OSPEEDR = 0xAA800AAA; + /* Configure PFx pins Output type to push-pull */ + GPIOF->OTYPER = 0x00000000; + /* No pull-up, pull-down for PFx pins */ + GPIOF->PUPDR = 0x00000000; + + /* Connect PGx pins to FMC Alternate function */ + GPIOG->AFR[0] = 0xCCCCCCCC; + GPIOG->AFR[1] = 0xCCCCCCCC; + /* Configure PGx pins in Alternate function mode */ + GPIOG->MODER = 0xAAAAAAAA; + /* Configure PGx pins speed to 50 MHz */ + GPIOG->OSPEEDR = 0xAAAAAAAA; + /* Configure PGx pins Output type to push-pull */ + GPIOG->OTYPER = 0x00000000; + /* No pull-up, pull-down for PGx pins */ + GPIOG->PUPDR = 0x00000000; + +#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ + || defined(STM32F469xx) || defined(STM32F479xx) + /* Connect PHx pins to FMC Alternate function */ + GPIOH->AFR[0] = 0x00C0CC00; + GPIOH->AFR[1] = 0xCCCCCCCC; + /* Configure PHx pins in Alternate function mode */ + GPIOH->MODER = 0xAAAA08A0; + /* Configure PHx pins speed to 50 MHz */ + GPIOH->OSPEEDR = 0xAAAA08A0; + /* Configure PHx pins Output type to push-pull */ + GPIOH->OTYPER = 0x00000000; + /* No pull-up, pull-down for PHx pins */ + GPIOH->PUPDR = 0x00000000; + + /* Connect PIx pins to FMC Alternate function */ + GPIOI->AFR[0] = 0xCCCCCCCC; + GPIOI->AFR[1] = 0x00000CC0; + /* Configure PIx pins in Alternate function mode */ + GPIOI->MODER = 0x0028AAAA; + /* Configure PIx pins speed to 50 MHz */ + GPIOI->OSPEEDR = 0x0028AAAA; + /* Configure PIx pins Output type to push-pull */ + GPIOI->OTYPER = 0x00000000; + /* No pull-up, pull-down for PIx pins */ + GPIOI->PUPDR = 0x00000000; +#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */ + +/*-- FMC Configuration -------------------------------------------------------*/ + /* Enable the FMC interface clock */ + RCC->AHB3ENR |= 0x00000001; + /* Delay after an RCC peripheral clock enabling */ + tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN); + + /* Configure and enable SDRAM bank1 */ +#if defined(STM32F446xx) + FMC_Bank5_6->SDCR[0] = 0x00001954; +#else + FMC_Bank5_6->SDCR[0] = 0x000019E4; +#endif /* STM32F446xx */ + FMC_Bank5_6->SDTR[0] = 0x01115351; + + /* SDRAM initialization sequence */ + /* Clock enable command */ + FMC_Bank5_6->SDCMR = 0x00000011; + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + while((tmpreg != 0) && (timeout-- > 0)) + { + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + } + + /* Delay */ + for (index = 0; index<1000; index++); + + /* PALL command */ + FMC_Bank5_6->SDCMR = 0x00000012; + timeout = 0xFFFF; + while((tmpreg != 0) && (timeout-- > 0)) + { + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + } + + /* Auto refresh command */ +#if defined(STM32F446xx) + FMC_Bank5_6->SDCMR = 0x000000F3; +#else + FMC_Bank5_6->SDCMR = 0x00000073; +#endif /* STM32F446xx */ + timeout = 0xFFFF; + while((tmpreg != 0) && (timeout-- > 0)) + { + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + } + + /* MRD register program */ +#if defined(STM32F446xx) + FMC_Bank5_6->SDCMR = 0x00044014; +#else + FMC_Bank5_6->SDCMR = 0x00046014; +#endif /* STM32F446xx */ + timeout = 0xFFFF; + while((tmpreg != 0) && (timeout-- > 0)) + { + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + } + + /* Set refresh count */ + tmpreg = FMC_Bank5_6->SDRTR; +#if defined(STM32F446xx) + FMC_Bank5_6->SDRTR = (tmpreg | (0x0000050C<<1)); +#else + FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C<<1)); +#endif /* STM32F446xx */ + + /* Disable write protection */ + tmpreg = FMC_Bank5_6->SDCR[0]; + FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF); +#endif /* DATA_IN_ExtSDRAM */ +#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */ + +#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)\ + || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ + || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) + +#if defined(DATA_IN_ExtSRAM) +/*-- GPIOs Configuration -----------------------------------------------------*/ + /* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */ + RCC->AHB1ENR |= 0x00000078; + /* Delay after an RCC peripheral clock enabling */ + tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIODEN); + + /* Connect PDx pins to FMC Alternate function */ + GPIOD->AFR[0] = 0x00CCC0CC; + GPIOD->AFR[1] = 0xCCCCCCCC; + /* Configure PDx pins in Alternate function mode */ + GPIOD->MODER = 0xAAAA0A8A; + /* Configure PDx pins speed to 100 MHz */ + GPIOD->OSPEEDR = 0xFFFF0FCF; + /* Configure PDx pins Output type to push-pull */ + GPIOD->OTYPER = 0x00000000; + /* No pull-up, pull-down for PDx pins */ + GPIOD->PUPDR = 0x00000000; + + /* Connect PEx pins to FMC Alternate function */ + GPIOE->AFR[0] = 0xC00CC0CC; + GPIOE->AFR[1] = 0xCCCCCCCC; + /* Configure PEx pins in Alternate function mode */ + GPIOE->MODER = 0xAAAA828A; + /* Configure PEx pins speed to 100 MHz */ + GPIOE->OSPEEDR = 0xFFFFC3CF; + /* Configure PEx pins Output type to push-pull */ + GPIOE->OTYPER = 0x00000000; + /* No pull-up, pull-down for PEx pins */ + GPIOE->PUPDR = 0x00000000; + + /* Connect PFx pins to FMC Alternate function */ + GPIOF->AFR[0] = 0x00CCCCCC; + GPIOF->AFR[1] = 0xCCCC0000; + /* Configure PFx pins in Alternate function mode */ + GPIOF->MODER = 0xAA000AAA; + /* Configure PFx pins speed to 100 MHz */ + GPIOF->OSPEEDR = 0xFF000FFF; + /* Configure PFx pins Output type to push-pull */ + GPIOF->OTYPER = 0x00000000; + /* No pull-up, pull-down for PFx pins */ + GPIOF->PUPDR = 0x00000000; + + /* Connect PGx pins to FMC Alternate function */ + GPIOG->AFR[0] = 0x00CCCCCC; + GPIOG->AFR[1] = 0x000000C0; + /* Configure PGx pins in Alternate function mode */ + GPIOG->MODER = 0x00085AAA; + /* Configure PGx pins speed to 100 MHz */ + GPIOG->OSPEEDR = 0x000CAFFF; + /* Configure PGx pins Output type to push-pull */ + GPIOG->OTYPER = 0x00000000; + /* No pull-up, pull-down for PGx pins */ + GPIOG->PUPDR = 0x00000000; + +/*-- FMC/FSMC Configuration --------------------------------------------------*/ + /* Enable the FMC/FSMC interface clock */ + RCC->AHB3ENR |= 0x00000001; + +#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) + /* Delay after an RCC peripheral clock enabling */ + tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN); + /* Configure and enable Bank1_SRAM2 */ + FMC_Bank1->BTCR[2] = 0x00001011; + FMC_Bank1->BTCR[3] = 0x00000201; + FMC_Bank1E->BWTR[2] = 0x0fffffff; +#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ +#if defined(STM32F469xx) || defined(STM32F479xx) + /* Delay after an RCC peripheral clock enabling */ + tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN); + /* Configure and enable Bank1_SRAM2 */ + FMC_Bank1->BTCR[2] = 0x00001091; + FMC_Bank1->BTCR[3] = 0x00110212; + FMC_Bank1E->BWTR[2] = 0x0fffffff; +#endif /* STM32F469xx || STM32F479xx */ +#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx)\ + || defined(STM32F412Zx) || defined(STM32F412Vx) + /* Delay after an RCC peripheral clock enabling */ + tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FSMCEN); + /* Configure and enable Bank1_SRAM2 */ + FSMC_Bank1->BTCR[2] = 0x00001011; + FSMC_Bank1->BTCR[3] = 0x00000201; + FSMC_Bank1E->BWTR[2] = 0x0FFFFFFF; +#endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx */ + +#endif /* DATA_IN_ExtSRAM */ +#endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx ||\ + STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx */ + (void)(tmp); +} +#endif /* DATA_IN_ExtSRAM && DATA_IN_ExtSDRAM */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Src/usb_device.c b/OwlPedal2/Src/usb_device.c new file mode 100644 index 00000000..f6703e5e --- /dev/null +++ b/OwlPedal2/Src/usb_device.c @@ -0,0 +1,103 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usb_device.c + * @version : v1.0_Cube + * @brief : This file implements the USB Device + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ + +#include "usb_device.h" +#include "usbd_core.h" +#include "usbd_desc.h" +#include "usbd_audio.h" +#include "usbd_audio_if.h" + +/* USER CODE BEGIN Includes */ +#include "usbd_midi.h" +#include "usbd_midi_if.h" +/* USER CODE END Includes */ + +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +/* USER CODE BEGIN PFP */ +/* Private function prototypes -----------------------------------------------*/ + +/* USER CODE END PFP */ + +/* USB Device Core handle declaration. */ +USBD_HandleTypeDef hUsbDeviceFS; + +/* + * -- Insert your variables declaration here -- + */ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* + * -- Insert your external function declaration here -- + */ +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ + +/** + * Init USB device Library, add supported class and start the library + * @retval None + */ +void MX_USB_DEVICE_Init(void) +{ + /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */ + + /* USER CODE END USB_DEVICE_Init_PreTreatment */ + + /* Init Device Library, add supported class and start the library. */ + if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK) + { + Error_Handler(); + } + if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_AUDIO) != USBD_OK) + { + Error_Handler(); + } + if (USBD_AUDIO_RegisterInterface(&hUsbDeviceFS, &USBD_AUDIO_fops_FS) != USBD_OK) + { + Error_Handler(); + } + if (USBD_Start(&hUsbDeviceFS) != USBD_OK) + { + Error_Handler(); + } + + /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */ + + /* USER CODE END USB_DEVICE_Init_PostTreatment */ +} + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Src/usbd_conf.c b/OwlPedal2/Src/usbd_conf.c new file mode 100644 index 00000000..aca9f353 --- /dev/null +++ b/OwlPedal2/Src/usbd_conf.c @@ -0,0 +1,641 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usbd_conf.c + * @version : v1.0_Cube + * @brief : This file implements the board support package for the USB device library + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f4xx.h" +#include "stm32f4xx_hal.h" +#include "usbd_def.h" +#include "usbd_core.h" + +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ + +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +PCD_HandleTypeDef hpcd_USB_OTG_FS; +void Error_Handler(void); + +/* External functions --------------------------------------------------------*/ +void SystemClock_Config(void); + +/* USER CODE BEGIN 0 */ +/* USER CODE END 0 */ + +/* USER CODE BEGIN PFP */ +/* Private function prototypes -----------------------------------------------*/ + +USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status); + +/* USER CODE END PFP */ + +/* Private functions ---------------------------------------------------------*/ + +/* USER CODE BEGIN 1 */ +/* USER CODE END 1 */ + +/******************************************************************************* + LL Driver Callbacks (PCD -> USB Device Library) +*******************************************************************************/ +/* MSP Init */ + +void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(pcdHandle->Instance==USB_OTG_FS) + { + /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */ + + /* USER CODE END USB_OTG_FS_MspInit 0 */ + + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**USB_OTG_FS GPIO Configuration + PA9 ------> USB_OTG_FS_VBUS + PA11 ------> USB_OTG_FS_DM + PA12 ------> USB_OTG_FS_DP + */ + GPIO_InitStruct.Pin = GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* Peripheral clock enable */ + __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); + /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */ + + /* USER CODE END USB_OTG_FS_MspInit 1 */ + } +} + +void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) +{ + if(pcdHandle->Instance==USB_OTG_FS) + { + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */ + + /* USER CODE END USB_OTG_FS_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); + + /**USB_OTG_FS GPIO Configuration + PA9 ------> USB_OTG_FS_VBUS + PA11 ------> USB_OTG_FS_DM + PA12 ------> USB_OTG_FS_DP + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_12); + + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */ + + /* USER CODE END USB_OTG_FS_MspDeInit 1 */ + } +} + +/** + * @brief Setup stage callback + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_SetupStage((USBD_HandleTypeDef*)hpcd->pData, (uint8_t *)hpcd->Setup); +} + +/** + * @brief Data Out stage callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#else +void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_DataOutStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff); +} + +/** + * @brief Data In stage callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#else +void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_DataInStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff); +} + +/** + * @brief SOF callback. + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_SOFCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_SOF((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief Reset callback. + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ResetCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_SpeedTypeDef speed = USBD_SPEED_FULL; + + if ( hpcd->Init.speed == PCD_SPEED_HIGH) + { + speed = USBD_SPEED_HIGH; + } + else if ( hpcd->Init.speed == PCD_SPEED_FULL) + { + speed = USBD_SPEED_FULL; + } + else + { + Error_Handler(); + } + /* Set Speed. */ + USBD_LL_SetSpeed((USBD_HandleTypeDef*)hpcd->pData, speed); + + /* Reset Device. */ + USBD_LL_Reset((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief Suspend callback. + * When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it) + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + /* Inform USB library that core enters in suspend Mode. */ + USBD_LL_Suspend((USBD_HandleTypeDef*)hpcd->pData); + __HAL_PCD_GATE_PHYCLOCK(hpcd); + /* Enter in STOP mode. */ + /* USER CODE BEGIN 2 */ + if (hpcd->Init.low_power_enable) + { + /* Set SLEEPDEEP bit and SleepOnExit of Cortex System Control Register */ + SCB->SCR |= (uint32_t)((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk)); + } + /* USER CODE END 2 */ +} + +/** + * @brief Resume callback. + * When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it) + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + /* USER CODE BEGIN 3 */ + /* USER CODE END 3 */ + USBD_LL_Resume((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief ISOOUTIncomplete callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#else +void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_IsoOUTIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); +} + +/** + * @brief ISOINIncomplete callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#else +void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_IsoINIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); +} + +/** + * @brief Connect callback. + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_DevConnected((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief Disconnect callback. + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_DevDisconnected((USBD_HandleTypeDef*)hpcd->pData); +} + +/******************************************************************************* + LL Driver Interface (USB Device Library --> PCD) +*******************************************************************************/ + +/** + * @brief Initializes the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) +{ + /* Init USB Ip. */ + if (pdev->id == DEVICE_FS) { + /* Link the driver to the stack. */ + hpcd_USB_OTG_FS.pData = pdev; + pdev->pData = &hpcd_USB_OTG_FS; + + hpcd_USB_OTG_FS.Instance = USB_OTG_FS; + hpcd_USB_OTG_FS.Init.dev_endpoints = 4; + hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; + hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; + hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; + hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; + hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; + hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; + hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE; + hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE; + if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) + { + Error_Handler( ); + } + +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) + /* Register USB PCD CallBacks */ + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SOF_CB_ID, PCD_SOFCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SETUPSTAGE_CB_ID, PCD_SetupStageCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESET_CB_ID, PCD_ResetCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SUSPEND_CB_ID, PCD_SuspendCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESUME_CB_ID, PCD_ResumeCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_CONNECT_CB_ID, PCD_ConnectCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_DISCONNECT_CB_ID, PCD_DisconnectCallback); + + HAL_PCD_RegisterDataOutStageCallback(&hpcd_USB_OTG_FS, PCD_DataOutStageCallback); + HAL_PCD_RegisterDataInStageCallback(&hpcd_USB_OTG_FS, PCD_DataInStageCallback); + HAL_PCD_RegisterIsoOutIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOOUTIncompleteCallback); + HAL_PCD_RegisterIsoInIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOINIncompleteCallback); +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ + HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_FS, 0x80); + HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x40); + HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x80); + } + return USBD_OK; +} + +/** + * @brief De-Initializes the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_DeInit(pdev->pData); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Starts the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_Start(pdev->pData); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Stops the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_Stop(pdev->pData); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Opens an endpoint of the low level driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @param ep_type: Endpoint type + * @param ep_mps: Endpoint max packet size + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Open(pdev->pData, ep_addr, ep_mps, ep_type); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Closes an endpoint of the low level driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Close(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Flushes an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Flush(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Sets a Stall condition on an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_SetStall(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Clears a Stall condition on an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_ClrStall(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Returns Stall condition. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval Stall (1: Yes, 0: No) + */ +uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef*) pdev->pData; + + if((ep_addr & 0x80) == 0x80) + { + return hpcd->IN_ep[ep_addr & 0x7F].is_stall; + } + else + { + return hpcd->OUT_ep[ep_addr & 0x7F].is_stall; + } +} + +/** + * @brief Assigns a USB address to the device. + * @param pdev: Device handle + * @param dev_addr: Device address + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_SetAddress(pdev->pData, dev_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Transmits data over an endpoint. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @param pbuf: Pointer to data to be sent + * @param size: Data size + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint16_t size) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Transmit(pdev->pData, ep_addr, pbuf, size); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Prepares an endpoint for reception. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @param pbuf: Pointer to data to be received + * @param size: Data size + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint16_t size) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Receive(pdev->pData, ep_addr, pbuf, size); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Returns the last transfered packet size. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval Recived Data Size + */ +uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef*) pdev->pData, ep_addr); +} + +/** + * @brief Delays routine for the USB Device Library. + * @param Delay: Delay in ms + * @retval None + */ +void USBD_LL_Delay(uint32_t Delay) +{ + HAL_Delay(Delay); +} + +/** + * @brief Retuns the USB status depending on the HAL status: + * @param hal_status: HAL status + * @retval USB status + */ +USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status) +{ + USBD_StatusTypeDef usb_status = USBD_OK; + + switch (hal_status) + { + case HAL_OK : + usb_status = USBD_OK; + break; + case HAL_ERROR : + usb_status = USBD_FAIL; + break; + case HAL_BUSY : + usb_status = USBD_BUSY; + break; + case HAL_TIMEOUT : + usb_status = USBD_FAIL; + break; + default : + usb_status = USBD_FAIL; + break; + } + return usb_status; +} + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Src/usbd_desc.c b/OwlPedal2/Src/usbd_desc.c new file mode 100644 index 00000000..016cba0a --- /dev/null +++ b/OwlPedal2/Src/usbd_desc.c @@ -0,0 +1,446 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usbd_desc.c + * @version : v1.0_Cube + * @brief : This file implements the USB device descriptors. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "usbd_core.h" +#include "usbd_desc.h" +#include "usbd_conf.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ + +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY + * @{ + */ + +/** @addtogroup USBD_DESC + * @{ + */ + +/** @defgroup USBD_DESC_Private_TypesDefinitions USBD_DESC_Private_TypesDefinitions + * @brief Private types. + * @{ + */ + +/* USER CODE BEGIN PRIVATE_TYPES */ + +/* USER CODE END PRIVATE_TYPES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Defines USBD_DESC_Private_Defines + * @brief Private defines. + * @{ + */ + +#define USBD_VID 0x1209 +#define USBD_LANGID_STRING 1033 +#define USBD_MANUFACTURER_STRING "Rebel Technology" +#define USBD_PID_FS 0xdada +#define USBD_PRODUCT_STRING_FS "OWL-PEDAL" +#define USBD_CONFIGURATION_STRING_FS "AUDIO Config" +#define USBD_INTERFACE_STRING_FS "AUDIO Interface" + +#define USB_SIZ_BOS_DESC 0x0C + +/* USER CODE BEGIN PRIVATE_DEFINES */ + +/* USER CODE END PRIVATE_DEFINES */ + +/** + * @} + */ + +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/** @defgroup USBD_DESC_Private_Macros USBD_DESC_Private_Macros + * @brief Private macros. + * @{ + */ + +/* USER CODE BEGIN PRIVATE_MACRO */ + +/* USER CODE END PRIVATE_MACRO */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes + * @brief Private functions declaration. + * @{ + */ + +static void Get_SerialNum(void); +static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len); + +/** + * @} + */ + + +/** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes + * @brief Private functions declaration for FS. + * @{ + */ + +uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +#if (USBD_LPM_ENABLED == 1) +uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +#endif /* (USBD_LPM_ENABLED == 1) */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables + * @brief Private variables. + * @{ + */ + +USBD_DescriptorsTypeDef FS_Desc = +{ + USBD_FS_DeviceDescriptor +, USBD_FS_LangIDStrDescriptor +, USBD_FS_ManufacturerStrDescriptor +, USBD_FS_ProductStrDescriptor +, USBD_FS_SerialStrDescriptor +, USBD_FS_ConfigStrDescriptor +, USBD_FS_InterfaceStrDescriptor +#if (USBD_LPM_ENABLED == 1) +, USBD_FS_USR_BOSDescriptor +#endif /* (USBD_LPM_ENABLED == 1) */ +}; + +#if defined ( __ICCARM__ ) /* IAR Compiler */ + #pragma data_alignment=4 +#endif /* defined ( __ICCARM__ ) */ +/** USB standard device descriptor. */ +__ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = +{ + 0x12, /*bLength */ + USB_DESC_TYPE_DEVICE, /*bDescriptorType*/ +#if (USBD_LPM_ENABLED == 1) + 0x01, /*bcdUSB */ /* changed to USB version 2.01 + in order to support LPM L1 suspend + resume test of USBCV3.0*/ +#else + 0x00, /*bcdUSB */ +#endif /* (USBD_LPM_ENABLED == 1) */ + 0x02, + 0x00, /*bDeviceClass*/ + 0x00, /*bDeviceSubClass*/ + 0x00, /*bDeviceProtocol*/ + USB_MAX_EP0_SIZE, /*bMaxPacketSize*/ + LOBYTE(USBD_VID), /*idVendor*/ + HIBYTE(USBD_VID), /*idVendor*/ + LOBYTE(USBD_PID_FS), /*idProduct*/ + HIBYTE(USBD_PID_FS), /*idProduct*/ + 0x00, /*bcdDevice rel. 2.00*/ + 0x02, + USBD_IDX_MFC_STR, /*Index of manufacturer string*/ + USBD_IDX_PRODUCT_STR, /*Index of product string*/ + USBD_IDX_SERIAL_STR, /*Index of serial number string*/ + USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/ +}; + +/* USB_DeviceDescriptor */ +/** BOS descriptor. */ +#if (USBD_LPM_ENABLED == 1) +#if defined ( __ICCARM__ ) /* IAR Compiler */ + #pragma data_alignment=4 +#endif /* defined ( __ICCARM__ ) */ +__ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = +{ + 0x5, + USB_DESC_TYPE_BOS, + 0xC, + 0x0, + 0x1, /* 1 device capability*/ + /* device capability*/ + 0x7, + USB_DEVICE_CAPABITY_TYPE, + 0x2, + 0x2, /* LPM capability bit set*/ + 0x0, + 0x0, + 0x0 +}; +#endif /* (USBD_LPM_ENABLED == 1) */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables + * @brief Private variables. + * @{ + */ + +#if defined ( __ICCARM__ ) /* IAR Compiler */ + #pragma data_alignment=4 +#endif /* defined ( __ICCARM__ ) */ + +/** USB lang indentifier descriptor. */ +__ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = +{ + USB_LEN_LANGID_STR_DESC, + USB_DESC_TYPE_STRING, + LOBYTE(USBD_LANGID_STRING), + HIBYTE(USBD_LANGID_STRING) +}; + +#if defined ( __ICCARM__ ) /* IAR Compiler */ + #pragma data_alignment=4 +#endif /* defined ( __ICCARM__ ) */ +/* Internal string descriptor. */ +__ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END; + +#if defined ( __ICCARM__ ) /*!< IAR Compiler */ + #pragma data_alignment=4 +#endif +__ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { + USB_SIZ_STRING_SERIAL, + USB_DESC_TYPE_STRING, +}; + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Functions USBD_DESC_Private_Functions + * @brief Private functions. + * @{ + */ + +/** + * @brief Return the device descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = sizeof(USBD_FS_DeviceDesc); + return USBD_FS_DeviceDesc; +} + +/** + * @brief Return the LangID string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = sizeof(USBD_LangIDDesc); + return USBD_LangIDDesc; +} + +/** + * @brief Return the product string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == 0) + { + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +/** + * @brief Return the manufacturer string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length); + return USBD_StrDesc; +} + +/** + * @brief Return the serial number string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = USB_SIZ_STRING_SERIAL; + + /* Update the serial number string descriptor with the data from the unique + * ID */ + Get_SerialNum(); + /* USER CODE BEGIN USBD_FS_SerialStrDescriptor */ + + /* USER CODE END USBD_FS_SerialStrDescriptor */ + return (uint8_t *) USBD_StringSerial; +} + +/** + * @brief Return the configuration string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == USBD_SPEED_HIGH) + { + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +/** + * @brief Return the interface string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == 0) + { + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +#if (USBD_LPM_ENABLED == 1) +/** + * @brief Return the BOS descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = sizeof(USBD_FS_BOSDesc); + return (uint8_t*)USBD_FS_BOSDesc; +} +#endif /* (USBD_LPM_ENABLED == 1) */ + +/** + * @brief Create the serial number string descriptor + * @param None + * @retval None + */ +static void Get_SerialNum(void) +{ + uint32_t deviceserial0, deviceserial1, deviceserial2; + + deviceserial0 = *(uint32_t *) DEVICE_ID1; + deviceserial1 = *(uint32_t *) DEVICE_ID2; + deviceserial2 = *(uint32_t *) DEVICE_ID3; + + deviceserial0 += deviceserial2; + + if (deviceserial0 != 0) + { + IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8); + IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4); + } +} + +/** + * @brief Convert Hex 32Bits value into char + * @param value: value to convert + * @param pbuf: pointer to the buffer + * @param len: buffer length + * @retval None + */ +static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len) +{ + uint8_t idx = 0; + + for (idx = 0; idx < len; idx++) + { + if (((value >> 28)) < 0xA) + { + pbuf[2 * idx] = (value >> 28) + '0'; + } + else + { + pbuf[2 * idx] = (value >> 28) + 'A' - 10; + } + + value = value << 4; + + pbuf[2 * idx + 1] = 0; + } +} +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ From e776a0eeeb014f684736397f5bc376f653219140 Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 17 Mar 2020 16:06:53 +0100 Subject: [PATCH 002/286] updated USB config --- OwlPedal2/Inc/hardware.h | 13 ++++++++++++- OwlPedal2/Inc/usbd_conf.h | 24 ++++++++++++++---------- OwlPedal2/Makefile | 3 +-- OwlPedal2/OwlPedal2.ioc | 9 ++++++++- OwlPedal2/Src/usb_device.c | 7 ++----- OwlPedal2/Src/usbd_conf.c | 19 +++++++++++++++++-- OwlPedal2/Src/usbd_desc.c | 2 +- 7 files changed, 55 insertions(+), 22 deletions(-) diff --git a/OwlPedal2/Inc/hardware.h b/OwlPedal2/Inc/hardware.h index 059f355b..3435a1c7 100644 --- a/OwlPedal2/Inc/hardware.h +++ b/OwlPedal2/Inc/hardware.h @@ -3,7 +3,7 @@ /* #define OWL_ALCHEMIST_LED */ #define OWL_ALCHEMIST -#define HARDWARE_ID OWLPEDAL_HARDWARE +#define HARDWARE_ID OWL_PEDAL_HARDWARE #define HARDWARE_VERSION "OWL Pedal mkII" #define USE_USBD_AUDIO @@ -13,6 +13,17 @@ #define USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS +/* USB audio settings */ +#define AUDIO_BITS_PER_SAMPLE 16 +#define AUDIO_BYTES_PER_SAMPLE (AUDIO_BITS_PER_SAMPLE/8) +#define AUDIO_CHANNELS 8 +#define USB_AUDIO_CHANNELS 4 +#define AUDIO_RINGBUFFER_SIZE (CODEC_BLOCKSIZE*USB_AUDIO_CHANNELS*4) +/* #define AUDIO_INT32_TO_SAMPLE(x) (__REV16((x)>>8)) */ +/* #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(__REV16(x))<<8) */ +#define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) +#define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) + #define USE_BKPSRAM #define USE_MODE_BUTTON diff --git a/OwlPedal2/Inc/usbd_conf.h b/OwlPedal2/Inc/usbd_conf.h index e477378e..85bae835 100644 --- a/OwlPedal2/Inc/usbd_conf.h +++ b/OwlPedal2/Inc/usbd_conf.h @@ -36,7 +36,11 @@ #include "stm32f4xx_hal.h" /* USER CODE BEGIN INCLUDE */ - +#ifdef DEBUG +#define DEBUG_LEVEL 3 +#else +#define DEBUG_LEVEL 0 +#endif /* USER CODE END INCLUDE */ /** @addtogroup USBD_OTG_DRIVER @@ -66,17 +70,17 @@ /*---------- -----------*/ #define USBD_MAX_NUM_INTERFACES 5U /*---------- -----------*/ -#define USBD_MAX_NUM_CONFIGURATION 2U +#define USBD_MAX_NUM_CONFIGURATION 5U /*---------- -----------*/ #define USBD_MAX_STR_DESC_SIZ 512U /*---------- -----------*/ -#define USBD_DEBUG_LEVEL 0U +#define USBD_DEBUG_LEVEL DEBUG_LEVEL /*---------- -----------*/ #define USBD_LPM_ENABLED 0U /*---------- -----------*/ #define USBD_SELF_POWERED 1U /*---------- -----------*/ -#define USBD_AUDIO_FREQ 48000U +#define USBD_AUDIO_FREQ AUDIO_SAMPLINGRATE /****************************************/ /* #define for FS and HS identification */ @@ -112,25 +116,25 @@ /* DEBUG macros */ #if (USBD_DEBUG_LEVEL > 0) -#define USBD_UsrLog(...) printf(__VA_ARGS__);\ - printf("\n"); +#define USBD_UsrLog(...) do { printf(__VA_ARGS__); \ + printf("\n"); } while(0) #else #define USBD_UsrLog(...) #endif #if (USBD_DEBUG_LEVEL > 1) -#define USBD_ErrLog(...) printf("ERROR: ") ;\ +#define USBD_ErrLog(...) do { printf("ERROR: ") ;\ printf(__VA_ARGS__);\ - printf("\n"); + printf("\n"); } while(0) #else #define USBD_ErrLog(...) #endif #if (USBD_DEBUG_LEVEL > 2) -#define USBD_DbgLog(...) printf("DEBUG : ") ;\ +#define USBD_DbgLog(...) do { printf("DEBUG : ") ; \ printf(__VA_ARGS__);\ - printf("\n"); + printf("\n"); } while(0) #else #define USBD_DbgLog(...) #endif diff --git a/OwlPedal2/Makefile b/OwlPedal2/Makefile index a1c46212..edc877f1 100644 --- a/OwlPedal2/Makefile +++ b/OwlPedal2/Makefile @@ -8,8 +8,7 @@ C_SRC = $(notdir $(wildcard Src/*.c)) CPP_SRC = $(notdir $(wildcard Src/*.cpp)) C_SRC += sdram.c C_SRC += cs4272.c -C_SRC += usbd_midi.c -C_SRC += usbd_midi_if.c +C_SRC += usbd_audio.c include $(OPENWARE)/Hardware/sources.mk diff --git a/OwlPedal2/OwlPedal2.ioc b/OwlPedal2/OwlPedal2.ioc index eec3596c..ce95f024 100644 --- a/OwlPedal2/OwlPedal2.ioc +++ b/OwlPedal2/OwlPedal2.ioc @@ -204,6 +204,7 @@ NVIC.ForceEnableDMAVector=true NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.OTG_FS_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 NVIC.SAI1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true @@ -216,8 +217,12 @@ PA0/WKUP.Signal=S_TIM2_CH1_ETR PA1.GPIOParameters=GPIO_Label PA1.GPIO_Label=PWM2 PA1.Signal=S_TIM2_CH2 +PA11.GPIOParameters=GPIO_Label +PA11.GPIO_Label=USBD_DM PA11.Mode=Device_Only PA11.Signal=USB_OTG_FS_DM +PA12.GPIOParameters=GPIO_Label +PA12.GPIO_Label=USBD_DP PA12.Mode=Device_Only PA12.Signal=USB_OTG_FS_DP PA13.Mode=Serial_Wire @@ -237,6 +242,8 @@ PA7.GPIOParameters=GPIO_Label PA7.GPIO_Label=FLASH_MOSI PA7.Mode=Full_Duplex_Master PA7.Signal=SPI1_MOSI +PA9.GPIOParameters=GPIO_Label +PA9.GPIO_Label=USBD_VBUS PA9.Mode=Activate_VBUS PA9.Signal=USB_OTG_FS_VBUS PB1.GPIOParameters=GPIO_Label @@ -417,7 +424,7 @@ ProjectManager.StackSize=0x400 ProjectManager.TargetToolchain=Makefile ProjectManager.ToolChainLocation= ProjectManager.UnderRoot=false -ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-MX_SPI5_Init-SPI5-false-HAL-true,9-MX_TIM2_Init-TIM2-false-HAL-true,10-MX_USART2_UART_Init-USART2-false-HAL-true,11-SystemClock_Config-RCC-false-HAL-true,12-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-true,13-MX_TIM3_Init-TIM3-false-HAL-true,14-MX_RTC_Init-RTC-false-HAL-true +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-MX_SPI5_Init-SPI5-false-HAL-true,9-MX_TIM2_Init-TIM2-false-HAL-true,10-MX_USART2_UART_Init-USART2-false-HAL-true,11-SystemClock_Config-RCC-false-HAL-true,12-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,13-MX_TIM3_Init-TIM3-false-HAL-true,14-MX_RTC_Init-RTC-false-HAL-true RCC.48MHZClocksFreq_Value=48000000 RCC.AHBFreq_Value=168000000 RCC.APB1CLKDivider=RCC_HCLK_DIV4 diff --git a/OwlPedal2/Src/usb_device.c b/OwlPedal2/Src/usb_device.c index f6703e5e..95ded99c 100644 --- a/OwlPedal2/Src/usb_device.c +++ b/OwlPedal2/Src/usb_device.c @@ -7,7 +7,7 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2019 STMicroelectronics. + *

© Copyright (c) 2020 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under Ultimate Liberty license @@ -25,11 +25,8 @@ #include "usbd_core.h" #include "usbd_desc.h" #include "usbd_audio.h" -#include "usbd_audio_if.h" /* USER CODE BEGIN Includes */ -#include "usbd_midi.h" -#include "usbd_midi_if.h" /* USER CODE END Includes */ /* USER CODE BEGIN PV */ @@ -78,7 +75,7 @@ void MX_USB_DEVICE_Init(void) { Error_Handler(); } - if (USBD_AUDIO_RegisterInterface(&hUsbDeviceFS, &USBD_AUDIO_fops_FS) != USBD_OK) + if (USBD_AUDIO_RegisterInterface(&hUsbDeviceFS, NULL) != USBD_OK) { Error_Handler(); } diff --git a/OwlPedal2/Src/usbd_conf.c b/OwlPedal2/Src/usbd_conf.c index aca9f353..a541d41e 100644 --- a/OwlPedal2/Src/usbd_conf.c +++ b/OwlPedal2/Src/usbd_conf.c @@ -26,7 +26,7 @@ #include "usbd_core.h" /* USER CODE BEGIN Includes */ - +#include "device.h" /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -93,6 +93,10 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) /* Peripheral clock enable */ __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); + + /* Peripheral interrupt init */ + HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(OTG_FS_IRQn); /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */ /* USER CODE END USB_OTG_FS_MspInit 1 */ @@ -116,6 +120,9 @@ void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) */ HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_12); + /* Peripheral interrupt Deinit*/ + HAL_NVIC_DisableIRQ(OTG_FS_IRQn); + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */ /* USER CODE END USB_OTG_FS_MspDeInit 1 */ @@ -359,9 +366,17 @@ USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) HAL_PCD_RegisterIsoOutIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOOUTIncompleteCallback); HAL_PCD_RegisterIsoInIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOINIncompleteCallback); #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +#ifdef USE_USBD_AUDIO_TX HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_FS, 0x80); + HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x20); + HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x60); + HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 2, 0x40); +#else + HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_FS, 0xa0); HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x40); - HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x80); + HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x60); +#endif + /* total 0x140 words available for rx and tx fifos */ } return USBD_OK; } diff --git a/OwlPedal2/Src/usbd_desc.c b/OwlPedal2/Src/usbd_desc.c index 016cba0a..292a5847 100644 --- a/OwlPedal2/Src/usbd_desc.c +++ b/OwlPedal2/Src/usbd_desc.c @@ -67,7 +67,7 @@ #define USBD_LANGID_STRING 1033 #define USBD_MANUFACTURER_STRING "Rebel Technology" #define USBD_PID_FS 0xdada -#define USBD_PRODUCT_STRING_FS "OWL-PEDAL" +#define USBD_PRODUCT_STRING_FS "OWL-MIDI" #define USBD_CONFIGURATION_STRING_FS "AUDIO Config" #define USBD_INTERFACE_STRING_FS "AUDIO Interface" From 6357b10c5149aef1565aab5b0bb767fb7fc5e737 Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 17 Mar 2020 16:13:50 +0100 Subject: [PATCH 003/286] added openocd targets --- OwlPedal2/Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/OwlPedal2/Makefile b/OwlPedal2/Makefile index edc877f1..6a9e34d0 100644 --- a/OwlPedal2/Makefile +++ b/OwlPedal2/Makefile @@ -25,3 +25,12 @@ OBJS += $(OBJS_UART) OBJS += $(OBJS_RTC) include $(OPENWARE)/Hardware/f4.mk + +flash: + openocd -f openocd.cfg -c "program Build/$(PROJECT).elf verify reset exit" + +debug: $(ELF) + @$(GDB) -ex "target extended-remote localhost:3333" -ex "monitor reset hard" -ex "monitor arm semihosting enable" -ex "load" $(ELF) + +attach: $(ELF) + @$(GDB) -ex "target extended-remote localhost:3333" -ex "monitor reset hard" -ex "monitor arm semihosting enable" $(ELF) From fb69924baac9a0db3672ad6cf7abc92065f5a007 Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 17 Mar 2020 16:21:12 +0100 Subject: [PATCH 004/286] configuration updates --- OwlPedal2/Inc/FreeRTOSConfig.h | 2 +- OwlPedal2/Inc/hardware.h | 14 ++- OwlPedal2/OwlPedal2.ioc | 191 ++++++++++++--------------------- 3 files changed, 73 insertions(+), 134 deletions(-) diff --git a/OwlPedal2/Inc/FreeRTOSConfig.h b/OwlPedal2/Inc/FreeRTOSConfig.h index f26c5ee5..79a1b42a 100644 --- a/OwlPedal2/Inc/FreeRTOSConfig.h +++ b/OwlPedal2/Inc/FreeRTOSConfig.h @@ -109,7 +109,7 @@ #define configTICK_RATE_HZ ((TickType_t)1000) #define configMAX_PRIORITIES ( 7 ) #define configMINIMAL_STACK_SIZE ((uint16_t)128) -#define configTOTAL_HEAP_SIZE ((size_t)15360) +#define configTOTAL_HEAP_SIZE ((size_t)8192) #define configMAX_TASK_NAME_LEN ( 16 ) #define configUSE_16_BIT_TICKS 0 #define configQUEUE_REGISTRY_SIZE 8 diff --git a/OwlPedal2/Inc/hardware.h b/OwlPedal2/Inc/hardware.h index 3435a1c7..ac07f889 100644 --- a/OwlPedal2/Inc/hardware.h +++ b/OwlPedal2/Inc/hardware.h @@ -1,8 +1,7 @@ #include "main.h" #include "stm32f4xx_hal.h" -/* #define OWL_ALCHEMIST_LED */ -#define OWL_ALCHEMIST +#define OWL_PEDAL_MKII #define HARDWARE_ID OWL_PEDAL_HARDWARE #define HARDWARE_VERSION "OWL Pedal mkII" @@ -26,13 +25,12 @@ #define USE_BKPSRAM -#define USE_MODE_BUTTON -#define MODE_BUTTON_PIN SW3_Pin -#define MODE_BUTTON_PORT SW3_GPIO_Port -#define MODE_BUTTON_GAIN ADC_C -#define MODE_BUTTON_PATCH ADC_D +/* #define USE_MODE_BUTTON */ +/* #define MODE_BUTTON_PIN SW3_Pin */ +/* #define MODE_BUTTON_PORT SW3_GPIO_Port */ +/* #define MODE_BUTTON_GAIN ADC_C */ +/* #define MODE_BUTTON_PATCH ADC_D */ -#define USE_RGB_LED #define USE_ADC #define ADC_PERIPH hadc3 #define ADC_A 2 diff --git a/OwlPedal2/OwlPedal2.ioc b/OwlPedal2/OwlPedal2.ioc index ce95f024..efa1d973 100644 --- a/OwlPedal2/OwlPedal2.ioc +++ b/OwlPedal2/OwlPedal2.ioc @@ -78,11 +78,12 @@ FMC.SelfRefreshTime1=4 FMC.WriteRecoveryTime1=2 FREERTOS.FootprintOK=true FREERTOS.INCLUDE_vTaskDelayUntil=1 -FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configENABLE_BACKWARD_COMPATIBILITY,configUSE_MUTEXES,FootprintOK,MEMORY_ALLOCATION,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,INCLUDE_vTaskDelayUntil +FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configENABLE_BACKWARD_COMPATIBILITY,configUSE_MUTEXES,FootprintOK,MEMORY_ALLOCATION,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,INCLUDE_vTaskDelayUntil,configTOTAL_HEAP_SIZE FREERTOS.MEMORY_ALLOCATION=2 FREERTOS.Tasks01=defaultTask,0,128,StartDefaultTask,Default,NULL FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 FREERTOS.configENABLE_BACKWARD_COMPATIBILITY=0 +FREERTOS.configTOTAL_HEAP_SIZE=8192 FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 FREERTOS.configUSE_MUTEXES=0 FREERTOS.configUSE_PREEMPTION=0 @@ -91,13 +92,9 @@ KeepUserPlacement=false Mcu.Family=STM32F4 Mcu.IP0=ADC3 Mcu.IP1=DMA -Mcu.IP10=SPI5 -Mcu.IP11=SYS -Mcu.IP12=TIM2 -Mcu.IP13=TIM3 -Mcu.IP14=USART2 -Mcu.IP15=USB_DEVICE -Mcu.IP16=USB_OTG_FS +Mcu.IP10=SYS +Mcu.IP11=USB_DEVICE +Mcu.IP12=USB_OTG_FS Mcu.IP2=FMC Mcu.IP3=FREERTOS Mcu.IP4=NVIC @@ -106,88 +103,81 @@ Mcu.IP6=RTC Mcu.IP7=SAI1 Mcu.IP8=SPI1 Mcu.IP9=SPI4 -Mcu.IPNb=17 +Mcu.IPNb=13 Mcu.Name=STM32F427Z(G-I)Tx Mcu.Package=LQFP144 Mcu.Pin0=PE2 Mcu.Pin1=PE3 Mcu.Pin10=PF4 Mcu.Pin11=PF5 -Mcu.Pin12=PF7 -Mcu.Pin13=PF8 -Mcu.Pin14=PF9 -Mcu.Pin15=PF10 -Mcu.Pin16=PH0/OSC_IN -Mcu.Pin17=PH1/OSC_OUT -Mcu.Pin18=PC0 -Mcu.Pin19=PC1 +Mcu.Pin12=PF10 +Mcu.Pin13=PH0/OSC_IN +Mcu.Pin14=PH1/OSC_OUT +Mcu.Pin15=PC0 +Mcu.Pin16=PC1 +Mcu.Pin17=PC2 +Mcu.Pin18=PC3 +Mcu.Pin19=PA2 Mcu.Pin2=PE4 -Mcu.Pin20=PC2 -Mcu.Pin21=PC3 -Mcu.Pin22=PA0/WKUP -Mcu.Pin23=PA1 -Mcu.Pin24=PA2 -Mcu.Pin25=PA3 -Mcu.Pin26=PA6 -Mcu.Pin27=PA7 -Mcu.Pin28=PC4 -Mcu.Pin29=PC5 +Mcu.Pin20=PA6 +Mcu.Pin21=PA7 +Mcu.Pin22=PC4 +Mcu.Pin23=PC5 +Mcu.Pin24=PB2/BOOT1 +Mcu.Pin25=PF11 +Mcu.Pin26=PF12 +Mcu.Pin27=PF13 +Mcu.Pin28=PF14 +Mcu.Pin29=PF15 Mcu.Pin3=PE5 -Mcu.Pin30=PB1 -Mcu.Pin31=PB2/BOOT1 -Mcu.Pin32=PF11 -Mcu.Pin33=PF12 -Mcu.Pin34=PF13 -Mcu.Pin35=PF14 -Mcu.Pin36=PF15 -Mcu.Pin37=PG0 -Mcu.Pin38=PG1 -Mcu.Pin39=PE7 +Mcu.Pin30=PG0 +Mcu.Pin31=PG1 +Mcu.Pin32=PE7 +Mcu.Pin33=PE8 +Mcu.Pin34=PE9 +Mcu.Pin35=PE10 +Mcu.Pin36=PE11 +Mcu.Pin37=PE12 +Mcu.Pin38=PE13 +Mcu.Pin39=PE14 Mcu.Pin4=PE6 -Mcu.Pin40=PE8 -Mcu.Pin41=PE9 -Mcu.Pin42=PE10 -Mcu.Pin43=PE11 -Mcu.Pin44=PE12 -Mcu.Pin45=PE13 -Mcu.Pin46=PE14 -Mcu.Pin47=PE15 -Mcu.Pin48=PB10 -Mcu.Pin49=PB11 +Mcu.Pin40=PE15 +Mcu.Pin41=PB10 +Mcu.Pin42=PB11 +Mcu.Pin43=PD8 +Mcu.Pin44=PD9 +Mcu.Pin45=PD10 +Mcu.Pin46=PD14 +Mcu.Pin47=PD15 +Mcu.Pin48=PG4 +Mcu.Pin49=PG5 Mcu.Pin5=PC15/OSC32_OUT -Mcu.Pin50=PD8 -Mcu.Pin51=PD9 -Mcu.Pin52=PD10 -Mcu.Pin53=PD14 -Mcu.Pin54=PD15 -Mcu.Pin55=PG4 -Mcu.Pin56=PG5 -Mcu.Pin57=PG8 -Mcu.Pin58=PA9 -Mcu.Pin59=PA11 +Mcu.Pin50=PG8 +Mcu.Pin51=PA9 +Mcu.Pin52=PA11 +Mcu.Pin53=PA12 +Mcu.Pin54=PA13 +Mcu.Pin55=PA14 +Mcu.Pin56=PD0 +Mcu.Pin57=PD1 +Mcu.Pin58=PD6 +Mcu.Pin59=PG15 Mcu.Pin6=PF0 -Mcu.Pin60=PA12 -Mcu.Pin61=PA13 -Mcu.Pin62=PA14 -Mcu.Pin63=PD0 -Mcu.Pin64=PD1 -Mcu.Pin65=PD6 -Mcu.Pin66=PG15 -Mcu.Pin67=PB3 -Mcu.Pin68=PB5 -Mcu.Pin69=PB6 +Mcu.Pin60=PB3 +Mcu.Pin61=PB5 +Mcu.Pin62=PB6 +Mcu.Pin63=PB8 +Mcu.Pin64=PB9 +Mcu.Pin65=PE0 +Mcu.Pin66=PE1 +Mcu.Pin67=VP_FREERTOS_VS_CMSIS_V1 +Mcu.Pin68=VP_RTC_VS_RTC_Activate +Mcu.Pin69=VP_SYS_VS_Systick Mcu.Pin7=PF1 -Mcu.Pin70=PB8 -Mcu.Pin71=PB9 -Mcu.Pin72=PE0 -Mcu.Pin73=PE1 -Mcu.Pin74=VP_FREERTOS_VS_CMSIS_V1 -Mcu.Pin75=VP_RTC_VS_RTC_Activate -Mcu.Pin76=VP_SYS_VS_Systick -Mcu.Pin77=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS +Mcu.Pin70=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS Mcu.Pin8=PF2 Mcu.Pin9=PF3 -Mcu.PinsNb=78 +Mcu.PinsNb=71 Mcu.ThirdPartyNb=0 Mcu.UserConstants= Mcu.UserName=STM32F427ZITx @@ -211,12 +201,6 @@ NVIC.SAI1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:true\:true NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -PA0/WKUP.GPIOParameters=GPIO_Label -PA0/WKUP.GPIO_Label=PWM1 -PA0/WKUP.Signal=S_TIM2_CH1_ETR -PA1.GPIOParameters=GPIO_Label -PA1.GPIO_Label=PWM2 -PA1.Signal=S_TIM2_CH2 PA11.GPIOParameters=GPIO_Label PA11.GPIO_Label=USBD_DM PA11.Mode=Device_Only @@ -230,10 +214,7 @@ PA13.Signal=SYS_JTMS-SWDIO PA14.Mode=Serial_Wire PA14.Signal=SYS_JTCK-SWCLK PA2.Locked=true -PA2.Mode=Asynchronous PA2.Signal=USART2_TX -PA3.Mode=Asynchronous -PA3.Signal=USART2_RX PA6.GPIOParameters=GPIO_Label PA6.GPIO_Label=FLASH_MISO PA6.Mode=Full_Duplex_Master @@ -246,9 +227,6 @@ PA9.GPIOParameters=GPIO_Label PA9.GPIO_Label=USBD_VBUS PA9.Mode=Activate_VBUS PA9.Signal=USB_OTG_FS_VBUS -PB1.GPIOParameters=GPIO_Label -PB1.GPIO_Label=PWM3 -PB1.Signal=S_TIM3_CH4 PB10.GPIOParameters=GPIO_Label PB10.GPIO_Label=CS_nCS PB10.Locked=true @@ -375,18 +353,6 @@ PF2.Signal=FMC_A2 PF3.Signal=FMC_A3 PF4.Signal=FMC_A4 PF5.Signal=FMC_A5 -PF7.GPIOParameters=GPIO_Label -PF7.GPIO_Label=EXTSPI_SCK -PF7.Mode=Full_Duplex_Master -PF7.Signal=SPI5_SCK -PF8.GPIOParameters=GPIO_Label -PF8.GPIO_Label=EXTSPI_MISO -PF8.Mode=Full_Duplex_Master -PF8.Signal=SPI5_MISO -PF9.GPIOParameters=GPIO_Label -PF9.GPIO_Label=EXTSPI_MOSI -PF9.Mode=Full_Duplex_Master -PF9.Signal=SPI5_MOSI PG0.Signal=FMC_A10 PG1.Signal=FMC_A11 PG15.Signal=FMC_SDNCAS @@ -597,12 +563,6 @@ SH.GPXTI8.0=GPIO_EXTI8 SH.GPXTI8.ConfNb=1 SH.GPXTI9.0=GPIO_EXTI9 SH.GPXTI9.ConfNb=1 -SH.S_TIM2_CH1_ETR.0=TIM2_CH1,PWM Generation1 CH1 -SH.S_TIM2_CH1_ETR.ConfNb=1 -SH.S_TIM2_CH2.0=TIM2_CH2,PWM Generation2 CH2 -SH.S_TIM2_CH2.ConfNb=1 -SH.S_TIM3_CH4.0=TIM3_CH4,PWM Generation4 CH4 -SH.S_TIM3_CH4.ConfNb=1 SPI1.CalculateBaudRate=42.0 MBits/s SPI1.Direction=SPI_DIRECTION_2LINES SPI1.IPParameters=Mode,CalculateBaudRate,VirtualType,Direction @@ -614,25 +574,6 @@ SPI4.Direction=SPI_DIRECTION_2LINES SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,VirtualType,Direction SPI4.Mode=SPI_MODE_MASTER SPI4.VirtualType=VM_MASTER -SPI5.CalculateBaudRate=42.0 MBits/s -SPI5.Direction=SPI_DIRECTION_2LINES -SPI5.IPParameters=Mode,CalculateBaudRate,VirtualType,Direction -SPI5.Mode=SPI_MODE_MASTER -SPI5.VirtualType=VM_MASTER -TIM2.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 -TIM2.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2 -TIM2.IPParameters=Period,Prescaler,Pulse-PWM Generation1 CH1,Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2,Pulse-PWM Generation2 CH2 -TIM2.Period=1023 -TIM2.Prescaler=16 -TIM2.Pulse-PWM\ Generation1\ CH1=1023 -TIM2.Pulse-PWM\ Generation2\ CH2=1023 -TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4 -TIM3.IPParameters=Channel-PWM Generation4 CH4,Prescaler,Period,Pulse-PWM Generation4 CH4 -TIM3.Period=1023 -TIM3.Prescaler=16 -TIM3.Pulse-PWM\ Generation4\ CH4=1023 -USART2.IPParameters=VirtualMode -USART2.VirtualMode=VM_ASYNC USB_DEVICE.CLASS_NAME_FS=AUDIO USB_DEVICE.IPParameters=VirtualMode-AUDIO_FS,VirtualModeFS,CLASS_NAME_FS,PID_AUDIO_FS,MANUFACTURER_STRING-AUDIO_FS,VID-AUDIO_FS,PRODUCT_STRING_AUDIO_FS,USBD_MAX_NUM_INTERFACES-AUDIO_FS,USBD_MAX_NUM_CONFIGURATION-AUDIO_FS,USBD_AUDIO_FREQ-AUDIO_FS USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology From 283829b53c45ee81b66147549e4666a2fe879ebc Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 17 Mar 2020 16:23:52 +0100 Subject: [PATCH 005/286] updated from cube --- OwlPedal2/Src/usbd_desc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OwlPedal2/Src/usbd_desc.c b/OwlPedal2/Src/usbd_desc.c index 292a5847..016cba0a 100644 --- a/OwlPedal2/Src/usbd_desc.c +++ b/OwlPedal2/Src/usbd_desc.c @@ -67,7 +67,7 @@ #define USBD_LANGID_STRING 1033 #define USBD_MANUFACTURER_STRING "Rebel Technology" #define USBD_PID_FS 0xdada -#define USBD_PRODUCT_STRING_FS "OWL-MIDI" +#define USBD_PRODUCT_STRING_FS "OWL-PEDAL" #define USBD_CONFIGURATION_STRING_FS "AUDIO Config" #define USBD_INTERFACE_STRING_FS "AUDIO Interface" From 5e59831e988b309178dfe8b325b5afda20325dc7 Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 17 Mar 2020 16:25:50 +0100 Subject: [PATCH 006/286] disabled unused peripherals --- OwlPedal2/Inc/main.h | 20 +-- OwlPedal2/Inc/stm32f4xx_hal_conf.h | 4 +- OwlPedal2/Inc/stm32f4xx_it.h | 1 + OwlPedal2/Src/main.c | 215 +++------------------------ OwlPedal2/Src/stm32f4xx_hal_msp.c | 226 +---------------------------- OwlPedal2/Src/stm32f4xx_it.c | 15 ++ 6 files changed, 43 insertions(+), 438 deletions(-) diff --git a/OwlPedal2/Inc/main.h b/OwlPedal2/Inc/main.h index cf07674e..0a912e90 100644 --- a/OwlPedal2/Inc/main.h +++ b/OwlPedal2/Inc/main.h @@ -80,8 +80,6 @@ extern "C" { /* USER CODE END EM */ -void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); - /* Exported functions prototypes ---------------------------------------------*/ void Error_Handler(void); @@ -102,12 +100,6 @@ void Error_Handler(void); #define CS_SDA_GPIO_Port GPIOE #define EXTSPI_nCS_Pin GPIO_PIN_15 #define EXTSPI_nCS_GPIO_Port GPIOC -#define EXTSPI_SCK_Pin GPIO_PIN_7 -#define EXTSPI_SCK_GPIO_Port GPIOF -#define EXTSPI_MISO_Pin GPIO_PIN_8 -#define EXTSPI_MISO_GPIO_Port GPIOF -#define EXTSPI_MOSI_Pin GPIO_PIN_9 -#define EXTSPI_MOSI_GPIO_Port GPIOF #define ADC4_Pin GPIO_PIN_10 #define ADC4_GPIO_Port GPIOF #define ADC3_Pin GPIO_PIN_1 @@ -116,10 +108,6 @@ void Error_Handler(void); #define ADC2_GPIO_Port GPIOC #define ADC1_Pin GPIO_PIN_3 #define ADC1_GPIO_Port GPIOC -#define PWM1_Pin GPIO_PIN_0 -#define PWM1_GPIO_Port GPIOA -#define PWM2_Pin GPIO_PIN_1 -#define PWM2_GPIO_Port GPIOA #define FLASH_MISO_Pin GPIO_PIN_6 #define FLASH_MISO_GPIO_Port GPIOA #define FLASH_MOSI_Pin GPIO_PIN_7 @@ -128,8 +116,6 @@ void Error_Handler(void); #define FLASH_HOLD_GPIO_Port GPIOC #define FLASH_nCS_Pin GPIO_PIN_5 #define FLASH_nCS_GPIO_Port GPIOC -#define PWM3_Pin GPIO_PIN_1 -#define PWM3_GPIO_Port GPIOB #define SW2_Pin GPIO_PIN_2 #define SW2_GPIO_Port GPIOB #define SW2_EXTI_IRQn EXTI2_IRQn @@ -137,6 +123,12 @@ void Error_Handler(void); #define CS_nCS_GPIO_Port GPIOB #define CS_nRST_Pin GPIO_PIN_11 #define CS_nRST_GPIO_Port GPIOB +#define USBD_VBUS_Pin GPIO_PIN_9 +#define USBD_VBUS_GPIO_Port GPIOA +#define USBD_DM_Pin GPIO_PIN_11 +#define USBD_DM_GPIO_Port GPIOA +#define USBD_DP_Pin GPIO_PIN_12 +#define USBD_DP_GPIO_Port GPIOA #define CS_SDIN_Pin GPIO_PIN_6 #define CS_SDIN_GPIO_Port GPIOD #define FLASH_SCK_Pin GPIO_PIN_3 diff --git a/OwlPedal2/Inc/stm32f4xx_hal_conf.h b/OwlPedal2/Inc/stm32f4xx_hal_conf.h index dceb54c5..e1a6d820 100644 --- a/OwlPedal2/Inc/stm32f4xx_hal_conf.h +++ b/OwlPedal2/Inc/stm32f4xx_hal_conf.h @@ -61,8 +61,8 @@ /* #define HAL_SD_MODULE_ENABLED */ /* #define HAL_MMC_MODULE_ENABLED */ #define HAL_SPI_MODULE_ENABLED -#define HAL_TIM_MODULE_ENABLED -#define HAL_UART_MODULE_ENABLED +/* #define HAL_TIM_MODULE_ENABLED */ +/* #define HAL_UART_MODULE_ENABLED */ /* #define HAL_USART_MODULE_ENABLED */ /* #define HAL_IRDA_MODULE_ENABLED */ /* #define HAL_SMARTCARD_MODULE_ENABLED */ diff --git a/OwlPedal2/Inc/stm32f4xx_it.h b/OwlPedal2/Inc/stm32f4xx_it.h index 2eaddf75..a9bbcc2a 100644 --- a/OwlPedal2/Inc/stm32f4xx_it.h +++ b/OwlPedal2/Inc/stm32f4xx_it.h @@ -68,6 +68,7 @@ void EXTI9_5_IRQHandler(void); void DMA2_Stream0_IRQHandler(void); void DMA2_Stream1_IRQHandler(void); void DMA2_Stream4_IRQHandler(void); +void OTG_FS_IRQHandler(void); void SAI1_IRQHandler(void); /* USER CODE BEGIN EFP */ diff --git a/OwlPedal2/Src/main.c b/OwlPedal2/Src/main.c index f14747b4..eda86841 100644 --- a/OwlPedal2/Src/main.c +++ b/OwlPedal2/Src/main.c @@ -86,12 +86,6 @@ DMA_HandleTypeDef hdma_sai1_b; SPI_HandleTypeDef hspi1; SPI_HandleTypeDef hspi4; -SPI_HandleTypeDef hspi5; - -TIM_HandleTypeDef htim2; -TIM_HandleTypeDef htim3; - -UART_HandleTypeDef huart2; SDRAM_HandleTypeDef hsdram1; @@ -110,10 +104,6 @@ static void MX_FMC_Init(void); static void MX_SAI1_Init(void); static void MX_SPI1_Init(void); static void MX_SPI4_Init(void); -static void MX_SPI5_Init(void); -static void MX_TIM2_Init(void); -static void MX_USART2_UART_Init(void); -static void MX_TIM3_Init(void); static void MX_RTC_Init(void); void StartDefaultTask(void const * argument); @@ -166,10 +156,6 @@ int main(void) MX_SAI1_Init(); MX_SPI1_Init(); MX_SPI4_Init(); - MX_SPI5_Init(); - MX_TIM2_Init(); - MX_USART2_UART_Init(); - MX_TIM3_Init(); MX_RTC_Init(); /* USER CODE BEGIN 2 */ @@ -552,179 +538,6 @@ static void MX_SPI4_Init(void) } -/** - * @brief SPI5 Initialization Function - * @param None - * @retval None - */ -static void MX_SPI5_Init(void) -{ - - /* USER CODE BEGIN SPI5_Init 0 */ - - /* USER CODE END SPI5_Init 0 */ - - /* USER CODE BEGIN SPI5_Init 1 */ - - /* USER CODE END SPI5_Init 1 */ - /* SPI5 parameter configuration*/ - hspi5.Instance = SPI5; - hspi5.Init.Mode = SPI_MODE_MASTER; - hspi5.Init.Direction = SPI_DIRECTION_2LINES; - hspi5.Init.DataSize = SPI_DATASIZE_8BIT; - hspi5.Init.CLKPolarity = SPI_POLARITY_LOW; - hspi5.Init.CLKPhase = SPI_PHASE_1EDGE; - hspi5.Init.NSS = SPI_NSS_SOFT; - hspi5.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2; - hspi5.Init.FirstBit = SPI_FIRSTBIT_MSB; - hspi5.Init.TIMode = SPI_TIMODE_DISABLE; - hspi5.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; - hspi5.Init.CRCPolynomial = 10; - if (HAL_SPI_Init(&hspi5) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN SPI5_Init 2 */ - - /* USER CODE END SPI5_Init 2 */ - -} - -/** - * @brief TIM2 Initialization Function - * @param None - * @retval None - */ -static void MX_TIM2_Init(void) -{ - - /* USER CODE BEGIN TIM2_Init 0 */ - - /* USER CODE END TIM2_Init 0 */ - - TIM_MasterConfigTypeDef sMasterConfig = {0}; - TIM_OC_InitTypeDef sConfigOC = {0}; - - /* USER CODE BEGIN TIM2_Init 1 */ - - /* USER CODE END TIM2_Init 1 */ - htim2.Instance = TIM2; - htim2.Init.Prescaler = 16; - htim2.Init.CounterMode = TIM_COUNTERMODE_UP; - htim2.Init.Period = 1023; - htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; - htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; - if (HAL_TIM_PWM_Init(&htim2) != HAL_OK) - { - Error_Handler(); - } - sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; - sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; - if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK) - { - Error_Handler(); - } - sConfigOC.OCMode = TIM_OCMODE_PWM1; - sConfigOC.Pulse = 1023; - sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; - sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; - if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) - { - Error_Handler(); - } - if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_2) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN TIM2_Init 2 */ - - /* USER CODE END TIM2_Init 2 */ - HAL_TIM_MspPostInit(&htim2); - -} - -/** - * @brief TIM3 Initialization Function - * @param None - * @retval None - */ -static void MX_TIM3_Init(void) -{ - - /* USER CODE BEGIN TIM3_Init 0 */ - - /* USER CODE END TIM3_Init 0 */ - - TIM_MasterConfigTypeDef sMasterConfig = {0}; - TIM_OC_InitTypeDef sConfigOC = {0}; - - /* USER CODE BEGIN TIM3_Init 1 */ - - /* USER CODE END TIM3_Init 1 */ - htim3.Instance = TIM3; - htim3.Init.Prescaler = 16; - htim3.Init.CounterMode = TIM_COUNTERMODE_UP; - htim3.Init.Period = 1023; - htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; - htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; - if (HAL_TIM_PWM_Init(&htim3) != HAL_OK) - { - Error_Handler(); - } - sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; - sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; - if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK) - { - Error_Handler(); - } - sConfigOC.OCMode = TIM_OCMODE_PWM1; - sConfigOC.Pulse = 1023; - sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; - sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; - if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_4) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN TIM3_Init 2 */ - - /* USER CODE END TIM3_Init 2 */ - HAL_TIM_MspPostInit(&htim3); - -} - -/** - * @brief USART2 Initialization Function - * @param None - * @retval None - */ -static void MX_USART2_UART_Init(void) -{ - - /* USER CODE BEGIN USART2_Init 0 */ - - /* USER CODE END USART2_Init 0 */ - - /* USER CODE BEGIN USART2_Init 1 */ - - /* USER CODE END USART2_Init 1 */ - huart2.Instance = USART2; - huart2.Init.BaudRate = 115200; - huart2.Init.WordLength = UART_WORDLENGTH_8B; - huart2.Init.StopBits = UART_STOPBITS_1; - huart2.Init.Parity = UART_PARITY_NONE; - huart2.Init.Mode = UART_MODE_TX_RX; - huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE; - huart2.Init.OverSampling = UART_OVERSAMPLING_16; - if (HAL_UART_Init(&huart2) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN USART2_Init 2 */ - - /* USER CODE END USART2_Init 2 */ - -} - /** * Enable DMA controller clock */ @@ -836,24 +649,32 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - /*Configure GPIO pin : PF6 */ - GPIO_InitStruct.Pin = GPIO_PIN_6; + /*Configure GPIO pins : PF6 PF7 PF8 PF9 */ + GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); - /*Configure GPIO pins : PA4 PA5 PA8 PA10 - PA15 */ - GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_8|GPIO_PIN_10 - |GPIO_PIN_15; + /*Configure GPIO pins : PA0 PA1 PA3 PA4 + PA5 PA8 PA10 PA15 */ + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_3|GPIO_PIN_4 + |GPIO_PIN_5|GPIO_PIN_8|GPIO_PIN_10|GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - /*Configure GPIO pins : PB0 PB12 PB13 PB14 - PB15 PB4 PB7 */ - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 - |GPIO_PIN_15|GPIO_PIN_4|GPIO_PIN_7; + /*Configure GPIO pin : PA2 */ + GPIO_InitStruct.Pin = GPIO_PIN_2; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF7_USART2; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /*Configure GPIO pins : PB0 PB1 PB12 PB13 + PB14 PB15 PB4 PB7 */ + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_12|GPIO_PIN_13 + |GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_4|GPIO_PIN_7; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); diff --git a/OwlPedal2/Src/stm32f4xx_hal_msp.c b/OwlPedal2/Src/stm32f4xx_hal_msp.c index e716d151..604e802b 100644 --- a/OwlPedal2/Src/stm32f4xx_hal_msp.c +++ b/OwlPedal2/Src/stm32f4xx_hal_msp.c @@ -89,9 +89,7 @@ extern DMA_HandleTypeDef hdma_adc3; /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ - -void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); - /** +/** * Initializes the Global MSP. */ void HAL_MspInit(void) @@ -318,31 +316,6 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) /* USER CODE END SPI4_MspInit 1 */ } - else if(hspi->Instance==SPI5) - { - /* USER CODE BEGIN SPI5_MspInit 0 */ - - /* USER CODE END SPI5_MspInit 0 */ - /* Peripheral clock enable */ - __HAL_RCC_SPI5_CLK_ENABLE(); - - __HAL_RCC_GPIOF_CLK_ENABLE(); - /**SPI5 GPIO Configuration - PF7 ------> SPI5_SCK - PF8 ------> SPI5_MISO - PF9 ------> SPI5_MOSI - */ - GPIO_InitStruct.Pin = EXTSPI_SCK_Pin|EXTSPI_MISO_Pin|EXTSPI_MOSI_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF5_SPI5; - HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); - - /* USER CODE BEGIN SPI5_MspInit 1 */ - - /* USER CODE END SPI5_MspInit 1 */ - } } @@ -393,203 +366,6 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) /* USER CODE END SPI4_MspDeInit 1 */ } - else if(hspi->Instance==SPI5) - { - /* USER CODE BEGIN SPI5_MspDeInit 0 */ - - /* USER CODE END SPI5_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_SPI5_CLK_DISABLE(); - - /**SPI5 GPIO Configuration - PF7 ------> SPI5_SCK - PF8 ------> SPI5_MISO - PF9 ------> SPI5_MOSI - */ - HAL_GPIO_DeInit(GPIOF, EXTSPI_SCK_Pin|EXTSPI_MISO_Pin|EXTSPI_MOSI_Pin); - - /* USER CODE BEGIN SPI5_MspDeInit 1 */ - - /* USER CODE END SPI5_MspDeInit 1 */ - } - -} - -/** -* @brief TIM_PWM MSP Initialization -* This function configures the hardware resources used in this example -* @param htim_pwm: TIM_PWM handle pointer -* @retval None -*/ -void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm) -{ - if(htim_pwm->Instance==TIM2) - { - /* USER CODE BEGIN TIM2_MspInit 0 */ - - /* USER CODE END TIM2_MspInit 0 */ - /* Peripheral clock enable */ - __HAL_RCC_TIM2_CLK_ENABLE(); - /* USER CODE BEGIN TIM2_MspInit 1 */ - - /* USER CODE END TIM2_MspInit 1 */ - } - else if(htim_pwm->Instance==TIM3) - { - /* USER CODE BEGIN TIM3_MspInit 0 */ - - /* USER CODE END TIM3_MspInit 0 */ - /* Peripheral clock enable */ - __HAL_RCC_TIM3_CLK_ENABLE(); - /* USER CODE BEGIN TIM3_MspInit 1 */ - - /* USER CODE END TIM3_MspInit 1 */ - } - -} - -void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - if(htim->Instance==TIM2) - { - /* USER CODE BEGIN TIM2_MspPostInit 0 */ - - /* USER CODE END TIM2_MspPostInit 0 */ - __HAL_RCC_GPIOA_CLK_ENABLE(); - /**TIM2 GPIO Configuration - PA0/WKUP ------> TIM2_CH1 - PA1 ------> TIM2_CH2 - */ - GPIO_InitStruct.Pin = PWM1_Pin|PWM2_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF1_TIM2; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* USER CODE BEGIN TIM2_MspPostInit 1 */ - - /* USER CODE END TIM2_MspPostInit 1 */ - } - else if(htim->Instance==TIM3) - { - /* USER CODE BEGIN TIM3_MspPostInit 0 */ - - /* USER CODE END TIM3_MspPostInit 0 */ - - __HAL_RCC_GPIOB_CLK_ENABLE(); - /**TIM3 GPIO Configuration - PB1 ------> TIM3_CH4 - */ - GPIO_InitStruct.Pin = PWM3_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF2_TIM3; - HAL_GPIO_Init(PWM3_GPIO_Port, &GPIO_InitStruct); - - /* USER CODE BEGIN TIM3_MspPostInit 1 */ - - /* USER CODE END TIM3_MspPostInit 1 */ - } - -} -/** -* @brief TIM_PWM MSP De-Initialization -* This function freeze the hardware resources used in this example -* @param htim_pwm: TIM_PWM handle pointer -* @retval None -*/ -void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm) -{ - if(htim_pwm->Instance==TIM2) - { - /* USER CODE BEGIN TIM2_MspDeInit 0 */ - - /* USER CODE END TIM2_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_TIM2_CLK_DISABLE(); - /* USER CODE BEGIN TIM2_MspDeInit 1 */ - - /* USER CODE END TIM2_MspDeInit 1 */ - } - else if(htim_pwm->Instance==TIM3) - { - /* USER CODE BEGIN TIM3_MspDeInit 0 */ - - /* USER CODE END TIM3_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_TIM3_CLK_DISABLE(); - /* USER CODE BEGIN TIM3_MspDeInit 1 */ - - /* USER CODE END TIM3_MspDeInit 1 */ - } - -} - -/** -* @brief UART MSP Initialization -* This function configures the hardware resources used in this example -* @param huart: UART handle pointer -* @retval None -*/ -void HAL_UART_MspInit(UART_HandleTypeDef* huart) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - if(huart->Instance==USART2) - { - /* USER CODE BEGIN USART2_MspInit 0 */ - - /* USER CODE END USART2_MspInit 0 */ - /* Peripheral clock enable */ - __HAL_RCC_USART2_CLK_ENABLE(); - - __HAL_RCC_GPIOA_CLK_ENABLE(); - /**USART2 GPIO Configuration - PA2 ------> USART2_TX - PA3 ------> USART2_RX - */ - GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF7_USART2; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* USER CODE BEGIN USART2_MspInit 1 */ - - /* USER CODE END USART2_MspInit 1 */ - } - -} - -/** -* @brief UART MSP De-Initialization -* This function freeze the hardware resources used in this example -* @param huart: UART handle pointer -* @retval None -*/ -void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) -{ - if(huart->Instance==USART2) - { - /* USER CODE BEGIN USART2_MspDeInit 0 */ - - /* USER CODE END USART2_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_USART2_CLK_DISABLE(); - - /**USART2 GPIO Configuration - PA2 ------> USART2_TX - PA3 ------> USART2_RX - */ - HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3); - - /* USER CODE BEGIN USART2_MspDeInit 1 */ - - /* USER CODE END USART2_MspDeInit 1 */ - } } diff --git a/OwlPedal2/Src/stm32f4xx_it.c b/OwlPedal2/Src/stm32f4xx_it.c index 000f992a..afca18e1 100644 --- a/OwlPedal2/Src/stm32f4xx_it.c +++ b/OwlPedal2/Src/stm32f4xx_it.c @@ -73,6 +73,7 @@ /* USER CODE END 0 */ /* External variables --------------------------------------------------------*/ +extern PCD_HandleTypeDef hpcd_USB_OTG_FS; extern DMA_HandleTypeDef hdma_adc3; extern DMA_HandleTypeDef hdma_sai1_a; extern DMA_HandleTypeDef hdma_sai1_b; @@ -185,6 +186,20 @@ void DMA2_Stream4_IRQHandler(void) /* USER CODE END DMA2_Stream4_IRQn 1 */ } +/** + * @brief This function handles USB On The Go FS global interrupt. + */ +void OTG_FS_IRQHandler(void) +{ + /* USER CODE BEGIN OTG_FS_IRQn 0 */ + + /* USER CODE END OTG_FS_IRQn 0 */ + HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS); + /* USER CODE BEGIN OTG_FS_IRQn 1 */ + + /* USER CODE END OTG_FS_IRQn 1 */ +} + /** * @brief This function handles SAI1 global interrupt. */ From 9cc585d880db6a9e75c5697ee28e8412475d2235 Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 17 Mar 2020 18:01:29 +0100 Subject: [PATCH 007/286] fixed ADC order --- OwlPedal2/Inc/hardware.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/OwlPedal2/Inc/hardware.h b/OwlPedal2/Inc/hardware.h index ac07f889..ac0eb4ab 100644 --- a/OwlPedal2/Inc/hardware.h +++ b/OwlPedal2/Inc/hardware.h @@ -20,7 +20,7 @@ #define AUDIO_RINGBUFFER_SIZE (CODEC_BLOCKSIZE*USB_AUDIO_CHANNELS*4) /* #define AUDIO_INT32_TO_SAMPLE(x) (__REV16((x)>>8)) */ /* #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(__REV16(x))<<8) */ -#define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) +#define AUDIO_INT32_TO_SAMPLE(x) ((x)>>4) #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) #define USE_BKPSRAM @@ -33,10 +33,10 @@ #define USE_ADC #define ADC_PERIPH hadc3 -#define ADC_A 2 -#define ADC_B 3 -#define ADC_C 0 -#define ADC_D 1 +#define ADC_A 0 +#define ADC_B 1 +#define ADC_C 2 +#define ADC_D 3 #define USE_CODEC #define USE_CS4271 #define CODEC_HP_FILTER From 40003dad6ef94b7301d1c81a3656c947bdb1b801 Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 28 Apr 2020 02:44:14 +0200 Subject: [PATCH 008/286] fixed config --- OwlPedal2/Inc/hardware.h | 7 +++---- OwlPedal2/Makefile | 9 --------- OwlPedal2/Src/main.c | 8 +++++++- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/OwlPedal2/Inc/hardware.h b/OwlPedal2/Inc/hardware.h index ac0eb4ab..bd692b74 100644 --- a/OwlPedal2/Inc/hardware.h +++ b/OwlPedal2/Inc/hardware.h @@ -15,12 +15,11 @@ /* USB audio settings */ #define AUDIO_BITS_PER_SAMPLE 16 #define AUDIO_BYTES_PER_SAMPLE (AUDIO_BITS_PER_SAMPLE/8) -#define AUDIO_CHANNELS 8 -#define USB_AUDIO_CHANNELS 4 -#define AUDIO_RINGBUFFER_SIZE (CODEC_BLOCKSIZE*USB_AUDIO_CHANNELS*4) +#define AUDIO_CHANNELS 2 +#define USB_AUDIO_CHANNELS 2 /* #define AUDIO_INT32_TO_SAMPLE(x) (__REV16((x)>>8)) */ /* #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(__REV16(x))<<8) */ -#define AUDIO_INT32_TO_SAMPLE(x) ((x)>>4) +#define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) #define USE_BKPSRAM diff --git a/OwlPedal2/Makefile b/OwlPedal2/Makefile index 6a9e34d0..edc877f1 100644 --- a/OwlPedal2/Makefile +++ b/OwlPedal2/Makefile @@ -25,12 +25,3 @@ OBJS += $(OBJS_UART) OBJS += $(OBJS_RTC) include $(OPENWARE)/Hardware/f4.mk - -flash: - openocd -f openocd.cfg -c "program Build/$(PROJECT).elf verify reset exit" - -debug: $(ELF) - @$(GDB) -ex "target extended-remote localhost:3333" -ex "monitor reset hard" -ex "monitor arm semihosting enable" -ex "load" $(ELF) - -attach: $(ELF) - @$(GDB) -ex "target extended-remote localhost:3333" -ex "monitor reset hard" -ex "monitor arm semihosting enable" $(ELF) diff --git a/OwlPedal2/Src/main.c b/OwlPedal2/Src/main.c index eda86841..f3457f34 100644 --- a/OwlPedal2/Src/main.c +++ b/OwlPedal2/Src/main.c @@ -113,6 +113,7 @@ void StartDefaultTask(void const * argument); void setup(); void loop(void); void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram); +void initialise_monitor_handles(void); /* USER CODE END PFP */ @@ -128,7 +129,12 @@ void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram); int main(void) { /* USER CODE BEGIN 1 */ - +#ifdef DEBUG +#warning "DEBUG uses printf and semihosting!" + if(CoreDebug->DHCSR & 0x01) + initialise_monitor_handles(); // remove when not semi-hosting + printf("showtime\n"); +#endif /* USER CODE END 1 */ From 73653469cf63e9e37d93cb0f892927f87100122a Mon Sep 17 00:00:00 2001 From: Martin Date: Wed, 29 Apr 2020 16:11:29 +0200 Subject: [PATCH 009/286] updated notes --- openware-notes.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openware-notes.txt b/openware-notes.txt index 5572dd77..2d9b2e1d 100644 --- a/openware-notes.txt +++ b/openware-notes.txt @@ -355,6 +355,9 @@ DC Offset removed with 48dB 10Hz hpf todo: - bootloader verify +- send and receive error messages +- send error messages without polling +- bootloader message with reason for bootloader mode (watchdog, magic, no/invalid firmware) - disable all: sysex rule - IWDG->KR = 0xaaaa only if watchog is enabled, otherwise it hangs - fix Noctua bootloader From c163fc6a964f3827434f76c294ba5b35ef619672 Mon Sep 17 00:00:00 2001 From: Martin Date: Wed, 29 Apr 2020 16:11:38 +0200 Subject: [PATCH 010/286] debug stack allocations --- OwlPedal2/Inc/hardware.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OwlPedal2/Inc/hardware.h b/OwlPedal2/Inc/hardware.h index bd692b74..22bb8627 100644 --- a/OwlPedal2/Inc/hardware.h +++ b/OwlPedal2/Inc/hardware.h @@ -1,6 +1,8 @@ #include "main.h" #include "stm32f4xx_hal.h" +#define DEBUG_STACK + #define OWL_PEDAL_MKII #define HARDWARE_ID OWL_PEDAL_HARDWARE #define HARDWARE_VERSION "OWL Pedal mkII" From ab2e809100f58a61dc117887f5048e78f21ba2c0 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 13 Oct 2020 14:27:13 +0200 Subject: [PATCH 011/286] cube and code updates --- OwlPedalMkII/Inc/FreeRTOSConfig.h | 189 ++++++ OwlPedalMkII/Inc/hardware.h | 48 ++ OwlPedalMkII/Inc/main.h | 162 +++++ OwlPedalMkII/Inc/stm32f4xx_hal_conf.h | 486 ++++++++++++++ OwlPedalMkII/Inc/stm32f4xx_it.h | 82 +++ OwlPedalMkII/Inc/usb_device.h | 105 ++++ OwlPedalMkII/Inc/usbd_conf.h | 180 ++++++ OwlPedalMkII/Inc/usbd_desc.h | 145 +++++ OwlPedalMkII/Makefile | 23 + OwlPedalMkII/OwlPedal2.ioc | 613 ++++++++++++++++++ OwlPedalMkII/Src/OwlPedal.cpp | 24 + OwlPedalMkII/Src/freertos.c | 136 ++++ OwlPedalMkII/Src/main.c | 839 +++++++++++++++++++++++++ OwlPedalMkII/Src/startup_stm32f427xx.s | 553 ++++++++++++++++ OwlPedalMkII/Src/stm32f4xx_hal_msp.c | 777 +++++++++++++++++++++++ OwlPedalMkII/Src/stm32f4xx_it.c | 207 ++++++ OwlPedalMkII/Src/system_stm32f4xx.c | 763 ++++++++++++++++++++++ OwlPedalMkII/Src/usb_device.c | 100 +++ OwlPedalMkII/Src/usbd_conf.c | 656 +++++++++++++++++++ OwlPedalMkII/Src/usbd_desc.c | 445 +++++++++++++ 20 files changed, 6533 insertions(+) create mode 100644 OwlPedalMkII/Inc/FreeRTOSConfig.h create mode 100644 OwlPedalMkII/Inc/hardware.h create mode 100644 OwlPedalMkII/Inc/main.h create mode 100644 OwlPedalMkII/Inc/stm32f4xx_hal_conf.h create mode 100644 OwlPedalMkII/Inc/stm32f4xx_it.h create mode 100644 OwlPedalMkII/Inc/usb_device.h create mode 100644 OwlPedalMkII/Inc/usbd_conf.h create mode 100644 OwlPedalMkII/Inc/usbd_desc.h create mode 100644 OwlPedalMkII/Makefile create mode 100644 OwlPedalMkII/OwlPedal2.ioc create mode 100644 OwlPedalMkII/Src/OwlPedal.cpp create mode 100644 OwlPedalMkII/Src/freertos.c create mode 100644 OwlPedalMkII/Src/main.c create mode 100644 OwlPedalMkII/Src/startup_stm32f427xx.s create mode 100644 OwlPedalMkII/Src/stm32f4xx_hal_msp.c create mode 100644 OwlPedalMkII/Src/stm32f4xx_it.c create mode 100644 OwlPedalMkII/Src/system_stm32f4xx.c create mode 100644 OwlPedalMkII/Src/usb_device.c create mode 100644 OwlPedalMkII/Src/usbd_conf.c create mode 100644 OwlPedalMkII/Src/usbd_desc.c diff --git a/OwlPedalMkII/Inc/FreeRTOSConfig.h b/OwlPedalMkII/Inc/FreeRTOSConfig.h new file mode 100644 index 00000000..c32c853a --- /dev/null +++ b/OwlPedalMkII/Inc/FreeRTOSConfig.h @@ -0,0 +1,189 @@ +/* USER CODE BEGIN Header */ +/* + FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd. + All rights reserved + + VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. + + *************************************************************************** + >>! NOTE: The modification to the GPL is included to allow you to !<< + >>! distribute a combined work that includes FreeRTOS without being !<< + >>! obliged to provide the source code for proprietary components !<< + >>! outside of the FreeRTOS kernel. !<< + *************************************************************************** + + FreeRTOS 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. Full license text is available on the following + link: http://www.freertos.org/a00114.html + + *************************************************************************** + * * + * FreeRTOS provides completely free yet professionally developed, * + * robust, strictly quality controlled, supported, and cross * + * platform software that is more than just the market leader, it * + * is the industry's de facto standard. * + * * + * Help yourself get started quickly while simultaneously helping * + * to support the FreeRTOS project by purchasing a FreeRTOS * + * tutorial book, reference manual, or both: * + * http://www.FreeRTOS.org/Documentation * + * * + *************************************************************************** + + http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading + the FAQ page "My application does not run, what could be wrong?". Have you + defined configASSERT()? + + http://www.FreeRTOS.org/support - In return for receiving this top quality + embedded software for free we request you assist our global community by + participating in the support forum. + + http://www.FreeRTOS.org/training - Investing in training allows your team to + be as productive as possible as early as possible. Now you can receive + FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers + Ltd, and the world's leading authority on the world's leading RTOS. + + http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, + including FreeRTOS+Trace - an indispensable productivity tool, a DOS + compatible FAT file system, and our tiny thread aware UDP/IP stack. + + http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. + Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. + + http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High + Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS + licenses offer ticketed support, indemnification and commercial middleware. + + http://www.SafeRTOS.com - High Integrity Systems also provide a safety + engineered and independently SIL3 certified version for use in safety and + mission critical applications that require provable dependability. + + 1 tab == 4 spaces! +*/ +/* USER CODE END Header */ + +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +/*----------------------------------------------------------- + * Application specific definitions. + * + * These definitions should be adjusted for your particular hardware and + * application requirements. + * + * These parameters and more are described within the 'configuration' section of the + * FreeRTOS API documentation available on the FreeRTOS.org web site. + * + * See http://www.freertos.org/a00110.html + *----------------------------------------------------------*/ + +/* USER CODE BEGIN Includes */ + +#include "device.h" +#ifdef DEBUG_STACK +#define configUSE_TRACE_FACILITY 1 +#define INCLUDE_uxTaskGetStackHighWaterMark 1 +#endif /* DEBUG_STACK */ + +/* USER CODE END Includes */ + +/* Ensure definitions are only used by the compiler, and not by the assembler. */ +#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) + #include + extern uint32_t SystemCoreClock; + void xPortSysTickHandler(void); +#endif +#define configENABLE_FPU 0 +#define configENABLE_MPU 0 + +#define configUSE_PREEMPTION 0 +#define configSUPPORT_STATIC_ALLOCATION 1 +#define configSUPPORT_DYNAMIC_ALLOCATION 1 +#define configUSE_IDLE_HOOK 0 +#define configUSE_TICK_HOOK 0 +#define configCPU_CLOCK_HZ ( SystemCoreClock ) +#define configTICK_RATE_HZ ((TickType_t)1000) +#define configMAX_PRIORITIES ( 7 ) +#define configMINIMAL_STACK_SIZE ((uint16_t)128) +#define configTOTAL_HEAP_SIZE ((size_t)8192) +#define configMAX_TASK_NAME_LEN ( 16 ) +#define configUSE_16_BIT_TICKS 0 +#define configQUEUE_REGISTRY_SIZE 8 +#define configCHECK_FOR_STACK_OVERFLOW 2 +#define configUSE_MALLOC_FAILED_HOOK 1 +#define configENABLE_BACKWARD_COMPATIBILITY 0 +#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 +/* USER CODE BEGIN MESSAGE_BUFFER_LENGTH_TYPE */ +/* Defaults to size_t for backward compatibility, but can be changed + if lengths will always be less than the number of bytes in a size_t. */ +#define configMESSAGE_BUFFER_LENGTH_TYPE size_t +/* USER CODE END MESSAGE_BUFFER_LENGTH_TYPE */ + +/* Co-routine definitions. */ +#define configUSE_CO_ROUTINES 0 +#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) + +/* Set the following definitions to 1 to include the API function, or zero +to exclude the API function. */ +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskCleanUpResources 0 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_xTaskGetSchedulerState 1 + +/* Cortex-M specific definitions. */ +#ifdef __NVIC_PRIO_BITS + /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */ + #define configPRIO_BITS __NVIC_PRIO_BITS +#else + #define configPRIO_BITS 4 +#endif + +/* The lowest interrupt priority that can be used in a call to a "set priority" +function. */ +#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15 + +/* The highest interrupt priority that can be used by any interrupt service +routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL +INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER +PRIORITY THAN THIS! (higher priorities are lower numeric values. */ +#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5 + +/* Interrupt priorities used by the kernel port layer itself. These are generic +to all Cortex-M ports, and do not rely on any particular library functions. */ +#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) +/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!! +See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ +#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) + +/* Normal assert() semantics without relying on the provision of an assert.h +header file. */ +/* USER CODE BEGIN 1 */ +#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );} +/* USER CODE END 1 */ + +/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS +standard names. */ +#define vPortSVCHandler SVC_Handler +#define xPortPendSVHandler PendSV_Handler + +/* IMPORTANT: This define is commented when used with STM32Cube firmware, when the timebase source is SysTick, + to prevent overwriting SysTick_Handler defined within STM32Cube HAL */ + +/* #define xPortSysTickHandler SysTick_Handler */ + +/* USER CODE BEGIN Defines */ +/* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */ +/* USER CODE END Defines */ + +#endif /* FREERTOS_CONFIG_H */ diff --git a/OwlPedalMkII/Inc/hardware.h b/OwlPedalMkII/Inc/hardware.h new file mode 100644 index 00000000..22bb8627 --- /dev/null +++ b/OwlPedalMkII/Inc/hardware.h @@ -0,0 +1,48 @@ +#include "main.h" +#include "stm32f4xx_hal.h" + +#define DEBUG_STACK + +#define OWL_PEDAL_MKII +#define HARDWARE_ID OWL_PEDAL_HARDWARE +#define HARDWARE_VERSION "OWL Pedal mkII" + +#define USE_USBD_AUDIO +#define USE_USBD_AUDIO_TX // microphone +#define USE_USBD_AUDIO_RX // speaker +#define USE_USBD_MIDI +#define USE_USBD_FS +#define USBD_HANDLE hUsbDeviceFS + +/* USB audio settings */ +#define AUDIO_BITS_PER_SAMPLE 16 +#define AUDIO_BYTES_PER_SAMPLE (AUDIO_BITS_PER_SAMPLE/8) +#define AUDIO_CHANNELS 2 +#define USB_AUDIO_CHANNELS 2 +/* #define AUDIO_INT32_TO_SAMPLE(x) (__REV16((x)>>8)) */ +/* #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(__REV16(x))<<8) */ +#define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) +#define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) + +#define USE_BKPSRAM + +/* #define USE_MODE_BUTTON */ +/* #define MODE_BUTTON_PIN SW3_Pin */ +/* #define MODE_BUTTON_PORT SW3_GPIO_Port */ +/* #define MODE_BUTTON_GAIN ADC_C */ +/* #define MODE_BUTTON_PATCH ADC_D */ + +#define USE_ADC +#define ADC_PERIPH hadc3 +#define ADC_A 0 +#define ADC_B 1 +#define ADC_C 2 +#define ADC_D 3 +#define USE_CODEC +#define USE_CS4271 +#define CODEC_HP_FILTER +#define CODEC_SPI hspi4 + +#define NOF_ADC_VALUES 4 +#define NOF_PARAMETERS 40 +#define NOF_BUTTONS (2+4) diff --git a/OwlPedalMkII/Inc/main.h b/OwlPedalMkII/Inc/main.h new file mode 100644 index 00000000..15723bbd --- /dev/null +++ b/OwlPedalMkII/Inc/main.h @@ -0,0 +1,162 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : main.h + * @brief : Header for main.c file. + * This file contains the common defines of the application. + ****************************************************************************** + * This notice applies to any and all portions of this file + * that are not between comment pairs USER CODE BEGIN and + * USER CODE END. Other portions of this file, whether + * inserted by the user or by software development tools + * are owned by their respective copyright owners. + * + * Copyright (c) 2019 STMicroelectronics International N.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __MAIN_H +#define __MAIN_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f4xx_hal.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* Exported macro ------------------------------------------------------------*/ +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +/* Exported functions prototypes ---------------------------------------------*/ +void Error_Handler(void); + +/* USER CODE BEGIN EFP */ + +/* USER CODE END EFP */ + +/* Private defines -----------------------------------------------------------*/ +#define CS_SCK_Pin GPIO_PIN_2 +#define CS_SCK_GPIO_Port GPIOE +#define CS_SDOUT_Pin GPIO_PIN_3 +#define CS_SDOUT_GPIO_Port GPIOE +#define CS_LRCK_Pin GPIO_PIN_4 +#define CS_LRCK_GPIO_Port GPIOE +#define CS_SCKE5_Pin GPIO_PIN_5 +#define CS_SCKE5_GPIO_Port GPIOE +#define CS_SDA_Pin GPIO_PIN_6 +#define CS_SDA_GPIO_Port GPIOE +#define EXTSPI_nCS_Pin GPIO_PIN_15 +#define EXTSPI_nCS_GPIO_Port GPIOC +#define ADC4_Pin GPIO_PIN_10 +#define ADC4_GPIO_Port GPIOF +#define ADC3_Pin GPIO_PIN_1 +#define ADC3_GPIO_Port GPIOC +#define ADC2_Pin GPIO_PIN_2 +#define ADC2_GPIO_Port GPIOC +#define ADC1_Pin GPIO_PIN_3 +#define ADC1_GPIO_Port GPIOC +#define SW4_Pin GPIO_PIN_2 +#define SW4_GPIO_Port GPIOA +#define SW3_Pin GPIO_PIN_3 +#define SW3_GPIO_Port GPIOA +#define SW1_Pin GPIO_PIN_5 +#define SW1_GPIO_Port GPIOA +#define SW1_EXTI_IRQn EXTI9_5_IRQn +#define FLASH_MISO_Pin GPIO_PIN_6 +#define FLASH_MISO_GPIO_Port GPIOA +#define FLASH_MOSI_Pin GPIO_PIN_7 +#define FLASH_MOSI_GPIO_Port GPIOA +#define FLASH_HOLD_Pin GPIO_PIN_4 +#define FLASH_HOLD_GPIO_Port GPIOC +#define FLASH_nCS_Pin GPIO_PIN_5 +#define FLASH_nCS_GPIO_Port GPIOC +#define EXP_RING_Pin GPIO_PIN_1 +#define EXP_RING_GPIO_Port GPIOB +#define EXP_TIP_Pin GPIO_PIN_2 +#define EXP_TIP_GPIO_Port GPIOB +#define CS_nCS_Pin GPIO_PIN_10 +#define CS_nCS_GPIO_Port GPIOB +#define CS_nRST_Pin GPIO_PIN_11 +#define CS_nRST_GPIO_Port GPIOB +#define USBD_VBUS_Pin GPIO_PIN_9 +#define USBD_VBUS_GPIO_Port GPIOA +#define USBD_DM_Pin GPIO_PIN_11 +#define USBD_DM_GPIO_Port GPIOA +#define USBD_DP_Pin GPIO_PIN_12 +#define USBD_DP_GPIO_Port GPIOA +#define CS_SDIN_Pin GPIO_PIN_6 +#define CS_SDIN_GPIO_Port GPIOD +#define FLASH_SCK_Pin GPIO_PIN_3 +#define FLASH_SCK_GPIO_Port GPIOB +#define SW2_Pin GPIO_PIN_8 +#define SW2_GPIO_Port GPIOB +#define SW2_EXTI_IRQn EXTI9_5_IRQn +/* USER CODE BEGIN Private defines */ + +#define CS_CS_Pin GPIO_PIN_10 +#define CS_CS_GPIO_Port GPIOB +#define CS_RST_Pin GPIO_PIN_11 +#define CS_RST_GPIO_Port GPIOB + +/* USER CODE END Private defines */ + +#ifdef __cplusplus +} +#endif + +#endif /* __MAIN_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedalMkII/Inc/stm32f4xx_hal_conf.h b/OwlPedalMkII/Inc/stm32f4xx_hal_conf.h new file mode 100644 index 00000000..2ce794db --- /dev/null +++ b/OwlPedalMkII/Inc/stm32f4xx_hal_conf.h @@ -0,0 +1,486 @@ +/** + ****************************************************************************** + * @file stm32f4xx_hal_conf_template.h + * @author MCD Application Team + * @brief HAL configuration template file. + * This file should be copied to the application folder and renamed + * to stm32f4xx_hal_conf.h. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F4xx_HAL_CONF_H +#define __STM32F4xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED + + #define HAL_ADC_MODULE_ENABLED +/* #define HAL_CRYP_MODULE_ENABLED */ +/* #define HAL_CAN_MODULE_ENABLED */ +/* #define HAL_CRC_MODULE_ENABLED */ +/* #define HAL_CAN_LEGACY_MODULE_ENABLED */ +/* #define HAL_CRYP_MODULE_ENABLED */ +/* #define HAL_DAC_MODULE_ENABLED */ +/* #define HAL_DCMI_MODULE_ENABLED */ +/* #define HAL_DMA2D_MODULE_ENABLED */ +/* #define HAL_ETH_MODULE_ENABLED */ +/* #define HAL_NAND_MODULE_ENABLED */ +/* #define HAL_NOR_MODULE_ENABLED */ +/* #define HAL_PCCARD_MODULE_ENABLED */ +/* #define HAL_SRAM_MODULE_ENABLED */ +#define HAL_SDRAM_MODULE_ENABLED +/* #define HAL_HASH_MODULE_ENABLED */ +/* #define HAL_I2C_MODULE_ENABLED */ +/* #define HAL_I2S_MODULE_ENABLED */ +/* #define HAL_IWDG_MODULE_ENABLED */ +/* #define HAL_LTDC_MODULE_ENABLED */ +/* #define HAL_RNG_MODULE_ENABLED */ +#define HAL_RTC_MODULE_ENABLED +#define HAL_SAI_MODULE_ENABLED +/* #define HAL_SD_MODULE_ENABLED */ +/* #define HAL_MMC_MODULE_ENABLED */ +#define HAL_SPI_MODULE_ENABLED +/* #define HAL_TIM_MODULE_ENABLED */ +/* #define HAL_UART_MODULE_ENABLED */ +/* #define HAL_USART_MODULE_ENABLED */ +/* #define HAL_IRDA_MODULE_ENABLED */ +/* #define HAL_SMARTCARD_MODULE_ENABLED */ +/* #define HAL_SMBUS_MODULE_ENABLED */ +/* #define HAL_WWDG_MODULE_ENABLED */ +#define HAL_PCD_MODULE_ENABLED +/* #define HAL_HCD_MODULE_ENABLED */ +/* #define HAL_DSI_MODULE_ENABLED */ +/* #define HAL_QSPI_MODULE_ENABLED */ +/* #define HAL_QSPI_MODULE_ENABLED */ +/* #define HAL_CEC_MODULE_ENABLED */ +/* #define HAL_FMPI2C_MODULE_ENABLED */ +/* #define HAL_SPDIFRX_MODULE_ENABLED */ +/* #define HAL_DFSDM_MODULE_ENABLED */ +/* #define HAL_LPTIM_MODULE_ENABLED */ +#define HAL_GPIO_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) + #define HSE_VALUE ((uint32_t)25000000U) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) + #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature.*/ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) + #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY ((uint32_t)15U) /*!< tick interrupt priority */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 1U +#define INSTRUCTION_CACHE_ENABLE 1U +#define DATA_CACHE_ENABLE 1U + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ + #define USE_FULL_ASSERT 1U + +/* ################## Ethernet peripheral configuration ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ + +/* DP83848_PHY_ADDRESS Address*/ +#define DP83848_PHY_ADDRESS 0x01U +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY ((uint32_t)0x000000FFU) +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU) + +#define PHY_READ_TO ((uint32_t)0x0000FFFFU) +#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU) + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ +#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ + +#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver +* Activated: CRC code is present inside driver +* Deactivated: CRC code cleaned from driver +*/ + +#define USE_SPI_CRC 0U + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32f4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32f4xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32f4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32f4xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32f4xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32f4xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED + #include "stm32f4xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CAN_LEGACY_MODULE_ENABLED + #include "stm32f4xx_hal_can_legacy.h" +#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32f4xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED + #include "stm32f4xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED + #include "stm32f4xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32f4xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED + #include "stm32f4xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED + #include "stm32f4xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32f4xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32f4xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED + #include "stm32f4xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_PCCARD_MODULE_ENABLED + #include "stm32f4xx_hal_pccard.h" +#endif /* HAL_PCCARD_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED + #include "stm32f4xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32f4xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED + #include "stm32f4xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32f4xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32f4xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED + #include "stm32f4xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32f4xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED + #include "stm32f4xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32f4xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED + #include "stm32f4xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED + #include "stm32f4xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32f4xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32f4xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32f4xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32f4xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32f4xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32f4xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32f4xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32f4xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED + #include "stm32f4xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED + #include "stm32f4xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED + #include "stm32f4xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED + #include "stm32f4xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_FMPI2C_MODULE_ENABLED + #include "stm32f4xx_hal_fmpi2c.h" +#endif /* HAL_FMPI2C_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED + #include "stm32f4xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED + #include "stm32f4xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED + #include "stm32f4xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED + #include "stm32f4xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t* file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F4xx_HAL_CONF_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedalMkII/Inc/stm32f4xx_it.h b/OwlPedalMkII/Inc/stm32f4xx_it.h new file mode 100644 index 00000000..daf83bd9 --- /dev/null +++ b/OwlPedalMkII/Inc/stm32f4xx_it.h @@ -0,0 +1,82 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32f4xx_it.h + * @brief This file contains the headers of the interrupt handlers. + ****************************************************************************** + * + * COPYRIGHT(c) 2019 STMicroelectronics + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F4xx_IT_H +#define __STM32F4xx_IT_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* Exported macro ------------------------------------------------------------*/ +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +/* Exported functions prototypes ---------------------------------------------*/ +void SysTick_Handler(void); +void EXTI9_5_IRQHandler(void); +void DMA2_Stream0_IRQHandler(void); +void DMA2_Stream1_IRQHandler(void); +void DMA2_Stream4_IRQHandler(void); +void OTG_FS_IRQHandler(void); +void SAI1_IRQHandler(void); +/* USER CODE BEGIN EFP */ + +/* USER CODE END EFP */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F4xx_IT_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedalMkII/Inc/usb_device.h b/OwlPedalMkII/Inc/usb_device.h new file mode 100644 index 00000000..98cf5857 --- /dev/null +++ b/OwlPedalMkII/Inc/usb_device.h @@ -0,0 +1,105 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usb_device.h + * @version : v1.0_Cube + * @brief : Header for usb_device.c file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USB_DEVICE__H__ +#define __USB_DEVICE__H__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f4xx.h" +#include "stm32f4xx_hal.h" +#include "usbd_def.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/** @addtogroup USBD_OTG_DRIVER + * @{ + */ + +/** @defgroup USBD_DEVICE USBD_DEVICE + * @brief Device file for Usb otg low level driver. + * @{ + */ + +/** @defgroup USBD_DEVICE_Exported_Variables USBD_DEVICE_Exported_Variables + * @brief Public variables. + * @{ + */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* + * -- Insert your variables declaration here -- + */ +/* USER CODE BEGIN VARIABLES */ + +/* USER CODE END VARIABLES */ +/** + * @} + */ + +/** @defgroup USBD_DEVICE_Exported_FunctionsPrototype USBD_DEVICE_Exported_FunctionsPrototype + * @brief Declaration of public functions for Usb device. + * @{ + */ + +/** USB Device initialization function. */ +void MX_USB_DEVICE_Init(void); + +/* + * -- Insert functions declaration here -- + */ +/* USER CODE BEGIN FD */ + +/* USER CODE END FD */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __USB_DEVICE__H__ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedalMkII/Inc/usbd_conf.h b/OwlPedalMkII/Inc/usbd_conf.h new file mode 100644 index 00000000..85bae835 --- /dev/null +++ b/OwlPedalMkII/Inc/usbd_conf.h @@ -0,0 +1,180 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usbd_conf.h + * @version : v1.0_Cube + * @brief : Header for usbd_conf.c file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USBD_CONF__H__ +#define __USBD_CONF__H__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include +#include +#include +#include "main.h" +#include "stm32f4xx.h" +#include "stm32f4xx_hal.h" + +/* USER CODE BEGIN INCLUDE */ +#ifdef DEBUG +#define DEBUG_LEVEL 3 +#else +#define DEBUG_LEVEL 0 +#endif +/* USER CODE END INCLUDE */ + +/** @addtogroup USBD_OTG_DRIVER + * @brief Driver for Usb device. + * @{ + */ + +/** @defgroup USBD_CONF USBD_CONF + * @brief Configuration file for Usb otg low level driver. + * @{ + */ + +/** @defgroup USBD_CONF_Exported_Variables USBD_CONF_Exported_Variables + * @brief Public variables. + * @{ + */ + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_Defines USBD_CONF_Exported_Defines + * @brief Defines for configuration of the Usb device. + * @{ + */ + +/*---------- -----------*/ +#define USBD_MAX_NUM_INTERFACES 5U +/*---------- -----------*/ +#define USBD_MAX_NUM_CONFIGURATION 5U +/*---------- -----------*/ +#define USBD_MAX_STR_DESC_SIZ 512U +/*---------- -----------*/ +#define USBD_DEBUG_LEVEL DEBUG_LEVEL +/*---------- -----------*/ +#define USBD_LPM_ENABLED 0U +/*---------- -----------*/ +#define USBD_SELF_POWERED 1U +/*---------- -----------*/ +#define USBD_AUDIO_FREQ AUDIO_SAMPLINGRATE + +/****************************************/ +/* #define for FS and HS identification */ +#define DEVICE_FS 0 +#define DEVICE_HS 1 + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_Macros USBD_CONF_Exported_Macros + * @brief Aliases. + * @{ + */ + +/* Memory management macros */ + +/** Alias for memory allocation. */ +#define USBD_malloc malloc + +/** Alias for memory release. */ +#define USBD_free free + +/** Alias for memory set. */ +#define USBD_memset memset + +/** Alias for memory copy. */ +#define USBD_memcpy memcpy + +/** Alias for delay. */ +#define USBD_Delay HAL_Delay + +/* DEBUG macros */ + +#if (USBD_DEBUG_LEVEL > 0) +#define USBD_UsrLog(...) do { printf(__VA_ARGS__); \ + printf("\n"); } while(0) +#else +#define USBD_UsrLog(...) +#endif + +#if (USBD_DEBUG_LEVEL > 1) + +#define USBD_ErrLog(...) do { printf("ERROR: ") ;\ + printf(__VA_ARGS__);\ + printf("\n"); } while(0) +#else +#define USBD_ErrLog(...) +#endif + +#if (USBD_DEBUG_LEVEL > 2) +#define USBD_DbgLog(...) do { printf("DEBUG : ") ; \ + printf(__VA_ARGS__);\ + printf("\n"); } while(0) +#else +#define USBD_DbgLog(...) +#endif + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_Types USBD_CONF_Exported_Types + * @brief Types. + * @{ + */ + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_FunctionsPrototype USBD_CONF_Exported_FunctionsPrototype + * @brief Declaration of public functions for Usb device. + * @{ + */ + +/* Exported functions -------------------------------------------------------*/ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __USBD_CONF__H__ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedalMkII/Inc/usbd_desc.h b/OwlPedalMkII/Inc/usbd_desc.h new file mode 100644 index 00000000..2348ea1c --- /dev/null +++ b/OwlPedalMkII/Inc/usbd_desc.h @@ -0,0 +1,145 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usbd_desc.c + * @version : v1.0_Cube + * @brief : Header for usbd_conf.c file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USBD_DESC__C__ +#define __USBD_DESC__C__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "usbd_def.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY + * @{ + */ + +/** @defgroup USBD_DESC USBD_DESC + * @brief Usb device descriptors module. + * @{ + */ + +/** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants + * @brief Constants. + * @{ + */ +#define DEVICE_ID1 (UID_BASE) +#define DEVICE_ID2 (UID_BASE + 0x4) +#define DEVICE_ID3 (UID_BASE + 0x8) + +#define USB_SIZ_STRING_SERIAL 0x1A + +/* USER CODE BEGIN EXPORTED_CONSTANTS */ + +/* USER CODE END EXPORTED_CONSTANTS */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_Defines USBD_DESC_Exported_Defines + * @brief Defines. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_DEFINES */ + +/* USER CODE END EXPORTED_DEFINES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_TypesDefinitions USBD_DESC_Exported_TypesDefinitions + * @brief Types. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_TYPES */ + +/* USER CODE END EXPORTED_TYPES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_Macros USBD_DESC_Exported_Macros + * @brief Aliases. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_MACRO */ + +/* USER CODE END EXPORTED_MACRO */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_Variables USBD_DESC_Exported_Variables + * @brief Public variables. + * @{ + */ + +/** Descriptor for the Usb device. */ +extern USBD_DescriptorsTypeDef FS_Desc; + +/* USER CODE BEGIN EXPORTED_VARIABLES */ + +/* USER CODE END EXPORTED_VARIABLES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_FunctionsPrototype USBD_DESC_Exported_FunctionsPrototype + * @brief Public functions declaration. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_FUNCTIONS */ + +/* USER CODE END EXPORTED_FUNCTIONS */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __USBD_DESC__C__ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedalMkII/Makefile b/OwlPedalMkII/Makefile new file mode 100644 index 00000000..0fe62592 --- /dev/null +++ b/OwlPedalMkII/Makefile @@ -0,0 +1,23 @@ +PROJECT = OwlPedal2 +BUILDROOT = . +OPENWARE ?= $(BUILDROOT)/.. + +include $(OPENWARE)/Hardware/owl2.mk + +C_SRC = $(wildcard Src/*.c) +CPP_SRC = $(wildcard Src/*.cpp) +C_SRC += $(OPENWARE)/Source/sdram.c +C_SRC += $(OPENWARE)/Source/cs4272.c +C_SRC += $(OPENWARE)/Source/usbd_audio.c + +include $(OPENWARE)/Hardware/sources.mk + +C_SRC += $(C_SRC_SAI) +C_SRC += $(C_SRC_SDRAM) +C_SRC += $(C_SRC_USBD) +C_SRC += $(C_SRC_DSP) +C_SRC += $(C_SRC_OS) +C_SRC += $(C_SRC_UART) +C_SRC += $(C_SRC_RTC) + +include $(OPENWARE)/Hardware/f4.mk diff --git a/OwlPedalMkII/OwlPedal2.ioc b/OwlPedalMkII/OwlPedal2.ioc new file mode 100644 index 00000000..6b160fe4 --- /dev/null +++ b/OwlPedalMkII/OwlPedal2.ioc @@ -0,0 +1,613 @@ +#MicroXplorer Configuration settings - do not modify +SH.FMC_D7_DA7.0=FMC_D7,sd-16b-d1 +Dma.ADC3.0.FIFOMode=DMA_FIFOMODE_DISABLE +SH.FMC_D0_DA0.ConfNb=1 +RCC.USART1Freq_Value=108000000 +Dma.ADC3.0.Priority=DMA_PRIORITY_LOW +SH.FMC_A8.ConfNb=1 +SH.FMC_A4.ConfNb=1 +SPI4.VirtualType=VM_MASTER +SH.FMC_A0.ConfNb=1 +SH.FMC_D6_DA6.ConfNb=1 +SAI1.VirtualMode-SAI_A_AsyncSlave=VM_SLAVE +FMC.SDClockPeriod2=FMC_SDRAM_CLOCK_PERIOD_2 +SH.FMC_D9_DA9.ConfNb=1 +FMC.RCDDelay1=2 +FMC.SDClockPeriod1=FMC_SDRAM_CLOCK_PERIOD_2 +SH.FMC_A0.0=FMC_A0,12b-sda1 +SPI1.VirtualType=VM_MASTER +Dma.SAI1_B.2.MemDataAlignment=DMA_MDATAALIGN_WORD +PG4.Signal=FMC_A14_BA0 +PG8.Signal=FMC_SDCLK +RCC.PLLCLKFreq_Value=168000000 +RCC.PLLQCLKFreq_Value=48000000 +PG0.Signal=FMC_A10 +FMC.LoadToActiveDelay1=2 +VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled +PC3.Locked=true +RCC.RTCFreq_Value=32000 +PA3.GPIOParameters=GPIO_Label +PA6.GPIO_Label=FLASH_MISO +Dma.SAI1_A.1.Mode=DMA_CIRCULAR +SH.FMC_SDNWE.ConfNb=1 +SH.FMC_D5_DA5.0=FMC_D5,sd-16b-d1 +Dma.SAI1_A.1.MemDataAlignment=DMA_MDATAALIGN_WORD +PD6.GPIO_Label=CS_SDIN +PA2.GPIOParameters=GPIO_Label +Dma.SAI1_B.2.Mode=DMA_CIRCULAR +PinOutPanel.RotationAngle=0 +PE6.GPIO_Label=CS_SDA +RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK +SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 +SH.FMC_D9_DA9.0=FMC_D9,sd-16b-d1 +RCC.LPTIM1Freq_Value=54000000 +USB_DEVICE.PID_AUDIO_FS=0xdada +NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +SAI1.FSDefinition-SAI_B_SyncSlave=SAI_FS_CHANNEL_IDENTIFICATION +SH.GPXTI3.ConfNb=1 +SH.FMC_SDNWE.0=FMC_SDNWE,12b-sda1 +SPI1.Direction=SPI_DIRECTION_2LINES +SH.FMC_D11_DA11.0=FMC_D11,sd-16b-d1 +Dma.SAI1_A.1.Instance=DMA2_Stream1 +RCC.I2C4Freq_Value=54000000 +PE2.Mode=TX_Only_Simplex_Unidirect_Master +RCC.APB2TimFreq_Value=168000000 +PB2/BOOT1.GPIO_Label=EXP_TIP +PB6.Signal=FMC_SDNE1 +Dma.ADC3.0.Direction=DMA_PERIPH_TO_MEMORY +SH.FMC_D10_DA10.ConfNb=1 +PH1/OSC_OUT.Signal=RCC_OSC_OUT +PB6.Mode=SdramChipSelect2_1 +SPI1.CalculateBaudRate=42.0 MBits/s +PC3.Signal=ADCx_IN13 +PD0.Signal=FMC_D2_DA2 +ADC3.ScanConvMode=ENABLE +RCC.SAI2Freq_Value=50000000 +PD8.Signal=FMC_D13_DA13 +PE5.Signal=SAI1_SCK_A +Dma.SAI1_A.1.FIFOMode=DMA_FIFOMODE_DISABLE +PE1.Signal=FMC_NBL1 +PF10.GPIO_Label=ADC4 +Dma.SAI1_A.1.MemInc=DMA_MINC_ENABLE +RCC.USART3Freq_Value=54000000 +RCC.PLLSAIRCLKFreq_Value=50000000 +ProjectManager.ProjectBuild=false +NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +PB3.Mode=Full_Duplex_Master +Dma.ADC3.0.PeriphInc=DMA_PINC_DISABLE +ADC3.ExternalTrigConv=ADC_SOFTWARE_START +FMC.SelfRefreshTime1=4 +ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.25.1 +MxDb.Version=DB.6.0.0 +USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology +USB_DEVICE.USBD_MAX_NUM_CONFIGURATION-AUDIO_FS=2 +ProjectManager.BackupPrevious=false +SAI1.SlotNumber-SAI_A_AsyncSlave=2 +PC4.GPIO_Label=FLASH_HOLD +PE9.Signal=FMC_D6_DA6 +SH.FMC_A2.0=FMC_A2,12b-sda1 +PB1.GPIO_Label=EXP_RING +SH.FMC_D15_DA15.ConfNb=1 +ADC3.ContinuousConvMode=ENABLE +PE4.GPIO_Label=CS_LRCK +PF10.Locked=true +ADC3.IPParameters=Rank-31\#ChannelRegularConversion,Channel-31\#ChannelRegularConversion,SamplingTime-31\#ChannelRegularConversion,NbrOfConversionFlag,ScanConvMode,ContinuousConvMode,DMAContinuousRequests,EOCSelection,InjNumberOfConversion,EnableAnalogWatchDog,ExternalTrigConv,Rank-32\#ChannelRegularConversion,Channel-32\#ChannelRegularConversion,SamplingTime-32\#ChannelRegularConversion,Rank-33\#ChannelRegularConversion,Channel-33\#ChannelRegularConversion,SamplingTime-33\#ChannelRegularConversion,Rank-34\#ChannelRegularConversion,Channel-34\#ChannelRegularConversion,SamplingTime-34\#ChannelRegularConversion,NbrOfConversion,ClockPrescaler,Resolution,DataAlign,DiscontinuousConvMode,ExternalTrigConvEdge +SH.ADCx_IN11.ConfNb=1 +PE2.Signal=SPI4_SCK +ADC3.Channel-33\#ChannelRegularConversion=ADC_CHANNEL_11 +SH.FMC_D1_DA1.0=FMC_D1,sd-16b-d1 +NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false +PC15/OSC32_OUT.Locked=true +PF3.Signal=FMC_A3 +VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 +NVIC.SAI1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true +PE10.Signal=FMC_D7_DA7 +ProjectManager.HalAssertFull=true +ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_3CYCLES +RCC.MCO2PinFreq_Value=168000000 +Mcu.Package=LQFP144 +PB1.Signal=ADCx_IN9 +PA5.Locked=true +SH.GPXTI8.0=GPIO_EXTI8 +Dma.SAI1_A.1.Direction=DMA_MEMORY_TO_PERIPH +SH.FMC_SDNCAS.ConfNb=1 +VP_SYS_VS_Systick.Signal=SYS_VS_Systick +SH.FMC_A11.ConfNb=1 +SH.GPXTI8.ConfNb=1 +FREERTOS.FootprintOK=true +PA5.GPIOParameters=GPIO_Label +FMC.WriteRecoveryTime1=2 +SH.ADCx_IN9.0=ADC1_IN9,IN9 +SH.FMC_A1.0=FMC_A1,12b-sda1 +ADC3.DMAContinuousRequests=ENABLE +RCC.APB2CLKDivider=RCC_HCLK_DIV2 +SH.FMC_SDCLK.0=FMC_SDCLK,12b-sda1 +RCC.CECFreq_Value=32786.88524590164 +ADC3.ExternalTrigConvEdge=ADC_EXTERNALTRIGCONVEDGE_NONE +PF14.Signal=FMC_A8 +RCC.APB1TimFreq_Value=84000000 +Dma.ADC3.0.Instance=DMA2_Stream0 +NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +FMC.RowCycleDelay2=6 +PF10.Mode=IN8 +SH.ADCx_IN9.ConfNb=1 +FMC.RowCycleDelay1=6 +USB_OTG_FS.IPParameters=VirtualMode +PB10.GPIOParameters=GPIO_Label +ADC3.Rank-34\#ChannelRegularConversion=4 +SAI1.SlotSize-SAI_A_AsyncSlave=SAI_SLOTSIZE_32B +PD15.Signal=FMC_D1_DA1 +SH.FMC_D3_DA3.0=FMC_D3,sd-16b-d1 +ProjectManager.CustomerFirmwarePackage= +PC4.GPIOParameters=GPIO_Label +RCC.SAI_AClocksFreq_Value=25000000 +RCC.PLLSAIQCLKFreq_Value=50000000 +USB_DEVICE.USBD_AUDIO_FREQ-AUDIO_FS=48000 +SH.FMC_D3_DA3.ConfNb=1 +PA6.GPIOParameters=GPIO_Label +USB_DEVICE.VID-AUDIO_FS=0x1209 +PD6.GPIOParameters=GPIO_Label +SH.FMC_A4.0=FMC_A4,12b-sda1 +SH.FMC_A7.ConfNb=1 +RCC.PLLQoutputFreq_Value=48000000 +ProjectManager.ProjectFileName=OwlPedal2.ioc +SH.FMC_A5.ConfNb=1 +SH.FMC_A1.ConfNb=1 +FREERTOS.Tasks01=defaultTask,0,128,StartDefaultTask,Default,NULL +ADC1.Rank-0\#ChannelRegularConversion=1 +USB_DEVICE.VirtualMode-AUDIO_FS=Audio +Mcu.PinsNb=73 +Dma.SAI1_B.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +Mcu.Pin71=VP_SYS_VS_Systick +Mcu.Pin72=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS +ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,NbrOfConversionFlag,master,ClockPrescaler +PG5.Signal=FMC_A15_BA1 +SH.FMC_D10_DA10.0=FMC_D10,sd-16b-d1 +PA9.GPIO_Label=USBD_VBUS +FREERTOS.INCLUDE_vTaskDelayUntil=1 +FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 +Mcu.Pin70=VP_RTC_VS_RTC_Activate +PB8.GPIO_PuPd=GPIO_PULLUP +PC2.Signal=ADCx_IN12 +PB11.GPIO_Label=CS_nRST +PD1.Signal=FMC_D3_DA3 +PA11.GPIO_Label=USBD_DM +RCC.VCOSAIOutputFreq_ValueQ=25000000 +NVIC.DMA2_Stream1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true +Mcu.Pin68=PE1 +Mcu.Pin69=VP_FREERTOS_VS_CMSIS_V1 +RCC.UART8Freq_Value=54000000 +PC0.Signal=FMC_SDNWE +RCC.APB1CLKDivider=RCC_HCLK_DIV4 +ADC3.Channel-31\#ChannelRegularConversion=ADC_CHANNEL_13 +PD6.Mode=SAI_A_AsyncSlave +Mcu.Pin62=PG15 +Mcu.Pin63=PB3 +Mcu.Pin60=PD1 +Mcu.Pin61=PD6 +Mcu.Pin66=PB8 +Mcu.Pin67=PE0 +Mcu.Pin64=PB5 +ADC3.Resolution=ADC_RESOLUTION_12B +Mcu.Pin65=PB6 +Dma.SAI1_B.2.PeriphInc=DMA_PINC_DISABLE +PC3.GPIOParameters=GPIO_Label +PD10.Signal=FMC_D15_DA15 +SH.FMC_A3.0=FMC_A3,12b-sda1 +PB8.GPIO_Label=SW2 +Mcu.Pin59=PD0 +FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_3 +SH.GPXTI2.ConfNb=1 +Mcu.Pin57=PA13 +Mcu.Pin58=PA14 +Mcu.Pin51=PG4 +RCC.USART6Freq_Value=108000000 +SH.FMC_D15_DA15.0=FMC_D15,sd-16b-d1 +Mcu.Pin52=PG5 +Dma.SAI1_B.2.PeriphDataAlignment=DMA_PDATAALIGN_WORD +Mcu.Pin50=PD15 +Mcu.Pin55=PA11 +Mcu.Pin56=PA12 +Mcu.Pin53=PG8 +Mcu.Pin54=PA9 +PA9.Signal=USB_OTG_FS_VBUS +PB11.GPIOParameters=GPIO_Label +ADC3.NbrOfConversion=4 +Mcu.Pin48=PD10 +Mcu.Pin49=PD14 +Mcu.Pin46=PD8 +Mcu.Pin47=PD9 +PB10.Signal=GPIO_Output +PA5.Signal=GPXTI5 +Mcu.Pin40=PE12 +Mcu.Pin41=PE13 +FREERTOS.MEMORY_ALLOCATION=2 +Mcu.Pin44=PB10 +Mcu.Pin45=PB11 +Mcu.Pin42=PE14 +Mcu.Pin43=PE15 +ProjectManager.LastFirmware=true +FMC.ReadBurst1=FMC_SDRAM_RBURST_ENABLE +SH.FMC_A6.0=FMC_A6,12b-sda1 +FMC.ReadBurst2=FMC_SDRAM_RBURST_ENABLE +PE14.Signal=FMC_D11_DA11 +PE6.Mode=TX_Only_Simplex_Unidirect_Master +PE15.Signal=FMC_D12_DA12 +Mcu.Pin37=PE9 +Mcu.Pin38=PE10 +Mcu.Pin35=PE7 +RCC.I2C1Freq_Value=54000000 +Mcu.Pin36=PE8 +PE8.Signal=FMC_D5_DA5 +RCC.PLLI2SPCLKFreq_Value=96000000 +SPI1.Mode=SPI_MODE_MASTER +SH.FMC_D14_DA14.ConfNb=1 +Mcu.Pin39=PE11 +PC2.GPIOParameters=GPIO_Label +Mcu.Pin30=PF13 +RCC.EthernetFreq_Value=168000000 +SH.ADCx_IN12.ConfNb=1 +Mcu.Pin33=PG0 +Mcu.Pin34=PG1 +ADC3.SamplingTime-33\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +Mcu.Pin31=PF14 +Mcu.Pin32=PF15 +NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +FREERTOS.configUSE_MUTEXES=0 +PF13.Signal=FMC_A7 +PA13.Mode=Serial_Wire +SH.FMC_SDNCAS.0=FMC_SDNCAS,12b-sda1 +ProjectManager.FreePins=true +Dma.ADC3.0.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD +SH.FMC_NBL1.ConfNb=1 +RCC.PLLI2SQCLKFreq_Value=96000000 +Mcu.Pin26=PB1 +Mcu.Pin27=PB2/BOOT1 +NVIC.DMA2_Stream4_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true +RCC.RTCHSEDivFreq_Value=12500000 +Mcu.Pin24=PC4 +ProjectManager.UnderRoot=false +Mcu.Pin25=PC5 +Mcu.Pin28=PF11 +Mcu.Pin29=PF12 +SH.FMC_D7_DA7.ConfNb=1 +Mcu.Pin22=PA6 +PB5.Signal=FMC_SDCKE1 +Mcu.Pin23=PA7 +Mcu.Pin20=PA3 +ADC1.master=1 +PA3.Locked=true +Mcu.Pin21=PA5 +PA5.GPIO_Label=SW1 +NVIC.ForceEnableDMAVector=true +SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX +NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +SH.FMC_A10.ConfNb=1 +PE5.GPIO_Label=CS_SCK +ProjectManager.CompilerOptimize=6 +SH.FMC_A5.0=FMC_A5,12b-sda1 +PA11.Signal=USB_OTG_FS_DM +SH.FMC_SDNRAS.ConfNb=1 +ProjectManager.HeapSize=0x200 +Mcu.Pin15=PC0 +NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +Mcu.Pin16=PC1 +ADC3.EOCSelection=ADC_EOC_SEQ_CONV +Mcu.Pin13=PH0/OSC_IN +Dma.ADC3.0.Mode=DMA_CIRCULAR +Mcu.Pin14=PH1/OSC_OUT +Mcu.Pin19=PA2 +PF10.GPIOParameters=GPIO_Label +ProjectManager.ComputerToolchain=false +Mcu.Pin17=PC2 +Mcu.Pin18=PC3 +Dma.SAI1_B.2.Instance=DMA2_Stream4 +NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 +Mcu.Pin11=PF5 +Mcu.Pin12=PF10 +Mcu.Pin10=PF4 +Dma.SAI1_A.1.Priority=DMA_PRIORITY_VERY_HIGH +PE3.Signal=SAI1_SD_B +PC3.GPIO_Label=ADC1 +ADC3.Rank-33\#ChannelRegularConversion=3 +Dma.SAI1_A.1.PeriphInc=DMA_PINC_DISABLE +PC15/OSC32_OUT.Signal=GPIO_Output +PF4.Signal=FMC_A4 +Dma.SAI1_B.2.FIFOMode=DMA_FIFOMODE_DISABLE +SH.FMC_D12_DA12.ConfNb=1 +RCC.I2C2Freq_Value=54000000 +SAI1.SlotSize-SAI_B_SyncSlave=SAI_SLOTSIZE_32B +PA7.GPIOParameters=GPIO_Label +PC1.Signal=ADCx_IN11 +ADC3.EnableAnalogWatchDog=false +Mcu.Family=STM32F4 +FMC.IPParameters=ReadPipeDelay1,ReadBurst1,ReadBurst2,SDClockPeriod1,SDClockPeriod2,CASLatency1,LoadToActiveDelay1,ExitSelfRefreshDelay1,SelfRefreshTime1,RowCycleDelay1,RowCycleDelay2,WriteRecoveryTime1,RPDelay1,RPDelay2,RCDDelay1 +ProjectManager.MainLocation=Src +SH.FMC_A6.ConfNb=1 +PA6.Mode=Full_Duplex_Master +USB_DEVICE.CLASS_NAME_FS=AUDIO +SH.FMC_A8.0=FMC_A8,12b-sda1 +RCC.SAI1Freq_Value=50000000 +RCC.CortexFreq_Value=168000000 +SH.FMC_A2.ConfNb=1 +PC15/OSC32_OUT.GPIO_Label=EXTSPI_nCS +ProjectManager.KeepUserCode=true +Mcu.UserName=STM32F427ZITx +SH.FMC_D14_DA14.0=FMC_D14,sd-16b-d1 +Dma.SAI1_A.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +Dma.SAI1_B.2.MemInc=DMA_MINC_ENABLE +SAI1.FrameLength-SAI_A_AsyncSlave=64 +SAI1.FrameLength-SAI_B_SyncSlave=64 +PC5.Locked=true +SPI4.Direction=SPI_DIRECTION_2LINES +SH.FMC_NBL0.0=FMC_NBL0,Sd2ByteEnable1 +PA12.GPIOParameters=GPIO_Label +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-SystemClock_Config-RCC-false-HAL-true,9-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,10-MX_RTC_Init-RTC-false-HAL-true,11-MX_ADC1_Init-ADC1-false-HAL-true +PA9.GPIOParameters=GPIO_Label +PA11.GPIOParameters=GPIO_Label +SH.FMC_D6_DA6.0=FMC_D6,sd-16b-d1 +PA11.Mode=Device_Only +PB2/BOOT1.GPIOParameters=GPIO_Label +RCC.PLLI2SRCLKFreq_Value=96000000 +RCC.USART2Freq_Value=54000000 +SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 +SH.FMC_A11.0=FMC_A11,12b-sda1 +PC1.Locked=true +PB11.Signal=GPIO_Output +ADC3.Channel-32\#ChannelRegularConversion=ADC_CHANNEL_12 +PG15.Signal=FMC_SDNCAS +PE5.GPIOParameters=GPIO_Label +ProjectManager.StackSize=0x400 +SH.GPXTI2.0=GPIO_EXTI2 +RCC.SAI_BClocksFreq_Value=25000000 +ADC3.SamplingTime-32\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +SAI1.Instance-SAI_A_AsyncSlave=SAI$Index_Block_A +RCC.I2C3Freq_Value=54000000 +Mcu.IP4=FREERTOS +Mcu.IP5=NVIC +RCC.FCLKCortexFreq_Value=168000000 +Mcu.IP2=DMA +Mcu.IP3=FMC +Mcu.IP0=ADC1 +SH.FMC_A7.0=FMC_A7,12b-sda1 +Mcu.IP1=ADC3 +PA12.Signal=USB_OTG_FS_DP +PE4.GPIOParameters=GPIO_Label +PB8.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +Mcu.UserConstants= +SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE +SPI4.Mode=SPI_MODE_MASTER +PC1.GPIOParameters=GPIO_Label +RCC.SDMMCFreq_Value=216000000 +Mcu.ThirdPartyNb=0 +PH0/OSC_IN.Mode=HSE-External-Oscillator +RCC.HCLKFreq_Value=168000000 +Mcu.IPNb=14 +RCC.I2SClocksFreq_Value=96000000 +RCC.PLLI2SRoutputFreq_Value=96000000 +ProjectManager.PreviousToolchain= +RCC.SPDIFRXFreq_Value=96000000 +RCC.VcooutputI2S=96000000 +SH.FMC_NBL1.0=FMC_NBL1,Sd2ByteEnable1 +PF12.Signal=FMC_A6 +FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 +Mcu.Pin6=PF0 +Mcu.Pin7=PF1 +NVIC.DMA2_Stream0_IRQn=true\:10\:0\:true\:false\:true\:true\:true\:true +Mcu.Pin8=PF2 +Mcu.Pin9=PF3 +RCC.VCOSAIOutputFreq_Value=100000000 +SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,VirtualType,Direction +Dma.ADC3.0.MemDataAlignment=DMA_MDATAALIGN_HALFWORD +FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configENABLE_BACKWARD_COMPATIBILITY,configUSE_MUTEXES,FootprintOK,MEMORY_ALLOCATION,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,INCLUDE_vTaskDelayUntil,configTOTAL_HEAP_SIZE +SH.FMC_A10.0=FMC_A10,12b-sda1 +RCC.AHBFreq_Value=168000000 +Mcu.Pin0=PE2 +Mcu.Pin1=PE3 +Mcu.Pin2=PE4 +FREERTOS.configUSE_PREEMPTION=0 +Mcu.Pin3=PE5 +Mcu.Pin4=PE6 +Mcu.Pin5=PC15/OSC32_OUT +ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_9 +RCC.HSE_VALUE=25000000 +NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +SH.FMC_A14_BA0.ConfNb=1 +ADC3.InjNumberOfConversion=0 +SH.FMC_D8_DA8.0=FMC_D8,sd-16b-d1 +FMC.ExitSelfRefreshDelay1=6 +FMC.RPDelay2=2 +Mcu.IP10=SPI4 +FMC.RPDelay1=2 +NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:true\:true +Mcu.IP12=USB_DEVICE +Mcu.IP11=SYS +FREERTOS.configENABLE_BACKWARD_COMPATIBILITY=0 +PC15/OSC32_OUT.GPIOParameters=GPIO_Label +SH.FMC_D2_DA2.0=FMC_D2,sd-16b-d1 +Mcu.IP13=USB_OTG_FS +PE13.Signal=FMC_D10_DA10 +RCC.VCOInputFreq_Value=1000000 +PA14.Mode=Serial_Wire +PF11.Signal=FMC_SDNRAS +PB5.Mode=SdramChipSelect2_1 +File.Version=6 +PE3.GPIOParameters=GPIO_Label +ADC3.DataAlign=ADC_DATAALIGN_RIGHT +SH.ADCx_IN13.ConfNb=1 +SH.FMC_D5_DA5.ConfNb=1 +PB3.GPIOParameters=GPIO_Label +Dma.ADC3.0.MemInc=DMA_MINC_ENABLE +SH.FMC_D2_DA2.ConfNb=1 +PB8.Locked=true +FMC.ReadPipeDelay1=FMC_SDRAM_RPIPE_DELAY_0 +PE4.Mode=SAI_A_AsyncSlave +SH.FMC_SDNRAS.0=FMC_SDNRAS,12b-sda1 +PH1/OSC_OUT.Mode=HSE-External-Oscillator +PE4.Signal=SAI1_FS_A +PE6.GPIOParameters=GPIO_Label +Dma.RequestsNb=3 +SPI4.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128 +FREERTOS.configTOTAL_HEAP_SIZE=8192 +ProjectManager.ProjectName=OwlPedal2 +USB_DEVICE.PRODUCT_STRING_AUDIO_FS=OWL-PEDAL +PA6.Signal=SPI1_MISO +SH.FMC_D0_DA0.0=FMC_D0,sd-16b-d1 +SAI1.DataSize-SAI_A_AsyncSlave=SAI_DATASIZE_24 +SH.FMC_D4_DA4.ConfNb=1 +NVIC.OTG_FS_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +ProjectManager.ToolChainLocation= +PA2.GPIO_Label=SW4 +RCC.LSI_VALUE=32000 +SH.GPXTI5.ConfNb=1 +USB_OTG_FS.VirtualMode=Device_Only +SH.FMC_A9.0=FMC_A9,12b-sda1 +SH.FMC_D4_DA4.0=FMC_D4,sd-16b-d1 +ADC3.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV8 +RCC.PLLSAIN=100 +PF5.Signal=FMC_A5 +Dma.Request2=SAI1_B +SAI1.Synchro-SAI_B_SyncSlave=SAI_SYNCHRONOUS +Dma.Request1=SAI1_A +ADC3.Rank-32\#ChannelRegularConversion=2 +PC4.Locked=true +PC5.Signal=GPIO_Output +PF0.Signal=FMC_A0 +PE7.Signal=FMC_D4_DA4 +SH.FMC_NBL0.ConfNb=1 +PD6.Signal=SAI1_SD_A +SAI1.Synchro-SAI_A_AsyncSlave=SAI_ASYNCHRONOUS +Dma.Request0=ADC3 +PE3.Mode=SAI_B_SyncSlave +PE2.GPIO_Label=CS_SCK +PC2.GPIO_Label=ADC2 +PB3.Locked=true +PA3.Signal=GPXTI3 +PA2.Locked=true +PB3.GPIO_Label=FLASH_SCK +SH.FMC_A3.ConfNb=1 +VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate +ADC3.SamplingTime-31\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +RCC.I2SFreq_Value=96000000 +SH.GPXTI5.0=GPIO_EXTI5 +ADC3.DiscontinuousConvMode=DISABLE +SH.ADCx_IN13.0=ADC3_IN13,IN13 +SAI1.Synchro_A=SAI_ASYNCHRONOUS +SH.FMC_A9.ConfNb=1 +SAI1.Synchro_B=SAI_SYNCHRONOUS +PB8.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PA7.Mode=Full_Duplex_Master +RCC.UART7Freq_Value=54000000 +ProjectManager.NoMain=false +SPI1.IPParameters=Mode,CalculateBaudRate,VirtualType,Direction +USB_DEVICE.VirtualModeFS=Audio_FS +PG1.Signal=FMC_A11 +NVIC.SavedSvcallIrqHandlerGenerated=true +SH.FMC_SDCLK.ConfNb=1 +PC4.Signal=GPIO_Output +ProjectManager.DefaultFWLocation=true +PD9.Signal=FMC_D14_DA14 +ProjectManager.DeletePrevious=true +USB_DEVICE.USBD_MAX_NUM_INTERFACES-AUDIO_FS=5 +PB10.Locked=true +RCC.LCDTFToutputFreq_Value=25000000 +USB_DEVICE.IPParameters=VirtualMode-AUDIO_FS,VirtualModeFS,CLASS_NAME_FS,PID_AUDIO_FS,MANUFACTURER_STRING-AUDIO_FS,VID-AUDIO_FS,PRODUCT_STRING_AUDIO_FS,USBD_MAX_NUM_INTERFACES-AUDIO_FS,USBD_MAX_NUM_CONFIGURATION-AUDIO_FS,USBD_AUDIO_FREQ-AUDIO_FS +PA12.GPIO_Label=USBD_DP +RCC.FamilyName=M +PA13.Signal=SYS_JTMS-SWDIO +VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 +SH.ADCx_IN12.0=ADC3_IN12,IN12 +PA9.Mode=Activate_VBUS +SH.FMC_A15_BA1.ConfNb=1 +PB2/BOOT1.Signal=GPIO_Output +ADC3.SamplingTime-34\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ProjectManager.TargetToolchain=Other Toolchains (GPDSC) +PB10.GPIO_Label=CS_nCS +SH.FMC_D13_DA13.0=FMC_D13,sd-16b-d1 +SH.FMC_D1_DA1.ConfNb=1 +PC5.GPIOParameters=GPIO_Label +RCC.VcooutputI2SQ=96000000 +PF2.Signal=FMC_A2 +PE2.GPIOParameters=GPIO_Label +PC2.Locked=true +ProjectManager.RegisterCallBack= +RCC.USBFreq_Value=48000000 +RCC.PLLSAIoutputFreq_Value=50000000 +PE11.Signal=FMC_D8_DA8 +RCC.LSE_VALUE=32768 +PB1.Locked=true +SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_RX +SAI1.FSDefinition-SAI_A_AsyncSlave=SAI_FS_CHANNEL_IDENTIFICATION +RCC.VCOI2SOutputFreq_Value=192000000 +RCC.PLLSAIPCLKFreq_Value=50000000 +board=Alchemist +SAI1.IPParameters=Instance-SAI_A_AsyncSlave,VirtualMode-SAI_A_AsyncSlave,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,Synchro-SAI_B_SyncSlave,FrameLength-SAI_B_SyncSlave,SlotSize-SAI_B_SyncSlave,AudioMode-SAI_B_SyncSlave,AudioMode-SAI_A_AsyncSlave,DataSize-SAI_A_AsyncSlave,FrameLength-SAI_A_AsyncSlave,SlotSize-SAI_A_AsyncSlave,SlotNumber-SAI_A_AsyncSlave,FSDefinition-SAI_A_AsyncSlave,FSDefinition-SAI_B_SyncSlave,Synchro-SAI_A_AsyncSlave,Synchro_A,Synchro_B +SH.GPXTI3.0=GPIO_EXTI3 +RCC.VCOOutputFreq_Value=336000000 +PH0/OSC_IN.Signal=RCC_OSC_IN +NVIC.SavedSystickIrqHandlerGenerated=true +RCC.APB2Freq_Value=84000000 +RCC.UART4Freq_Value=54000000 +SH.ADCx_IN11.0=ADC3_IN11,IN11 +MxCube.Version=6.0.1 +SH.FMC_D13_DA13.ConfNb=1 +PF10.Signal=ADC3_IN8 +PE5.Mode=SAI_A_AsyncSlave +PC1.GPIO_Label=ADC3 +VP_SYS_VS_Systick.Mode=SysTick +SH.FMC_D12_DA12.0=FMC_D12,sd-16b-d1 +PF15.Signal=FMC_A9 +SPI4.CalculateBaudRate=656.25 KBits/s +Dma.SAI1_B.2.Priority=DMA_PRIORITY_VERY_HIGH +PF1.Signal=FMC_A1 +VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_FS +VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Mode=AUDIO_FS +PE6.Signal=SPI4_MOSI +SH.FMC_D11_DA11.ConfNb=1 +RCC.UART5Freq_Value=54000000 +ADC3.Channel-34\#ChannelRegularConversion=ADC_CHANNEL_8 +RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CECFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SClocksFreq_Value,I2SFreq_Value,LCDTFToutputFreq_Value,LPTIM1Freq_Value,LSE_VALUE,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLI2SPCLKFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLI2SRoutputFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLQoutputFreq_Value,PLLSAIN,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIRCLKFreq_Value,PLLSAIoutputFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SAI1Freq_Value,SAI2Freq_Value,SAI_AClocksFreq_Value,SAI_BClocksFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,UART4Freq_Value,UART5Freq_Value,UART7Freq_Value,UART8Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USART6Freq_Value,USBFreq_Value,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value,VCOSAIOutputFreq_ValueQ,VcooutputI2S,VcooutputI2SQ +ProjectManager.AskForMigrate=true +PE0.Signal=FMC_NBL0 +Mcu.Name=STM32F427Z(G-I)Tx +Dma.SAI1_B.2.Direction=DMA_PERIPH_TO_MEMORY +PE12.Signal=FMC_D9_DA9 +NVIC.SavedPendsvIrqHandlerGenerated=true +PA2.Signal=GPXTI2 +Mcu.IP8=SAI1 +Mcu.IP9=SPI1 +PD14.Signal=FMC_D0_DA0 +Mcu.IP6=RCC +Mcu.IP7=RTC +ProjectManager.CoupleFile=false +RCC.48MHZClocksFreq_Value=48000000 +PB3.Signal=SPI1_SCK +RCC.SYSCLKFreq_VALUE=168000000 +PA7.GPIO_Label=FLASH_MOSI +PA12.Mode=Device_Only +KeepUserPlacement=false +PC5.GPIO_Label=FLASH_nCS +SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B +NVIC.EXTI9_5_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true +PA14.Signal=SYS_JTCK-SWCLK +RCC.HSI_VALUE=16000000 +Dma.ADC3.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +RCC.PLLQ=7 +ADC1.NbrOfConversionFlag=1 +RCC.PLLM=25 +RCC.PLLN=336 +PB2/BOOT1.Locked=true +Dma.SAI1_A.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD +PB8.Signal=GPXTI8 +PE3.GPIO_Label=CS_SDOUT +SH.FMC_D8_DA8.ConfNb=1 +RCC.APB1Freq_Value=42000000 +ADC3.NbrOfConversionFlag=1 +ADC1.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV8 +PB11.Locked=true +ProjectManager.DeviceId=STM32F427ZITx +ProjectManager.LibraryCopy=2 +PA3.GPIO_Label=SW3 +ADC3.Rank-31\#ChannelRegularConversion=1 +PB1.GPIOParameters=GPIO_Label +PA7.Signal=SPI1_MOSI diff --git a/OwlPedalMkII/Src/OwlPedal.cpp b/OwlPedalMkII/Src/OwlPedal.cpp new file mode 100644 index 00000000..d77afd23 --- /dev/null +++ b/OwlPedalMkII/Src/OwlPedal.cpp @@ -0,0 +1,24 @@ +#include +#include +#include "device.h" +#include "Owl.h" +#include "errorhandlers.h" +#include "message.h" +#include "ProgramManager.h" +#include "PatchRegistry.h" +#include "OpenWareMidiControl.h" + + +void setGateValue(uint8_t ch, int16_t value){ + // if(ch == PUSHBUTTON) + // HAL_GPIO_WritePin(GATE_OUT_GPIO_Port, GATE_OUT_Pin, value ? GPIO_PIN_RESET : GPIO_PIN_SET); +} + +void setup(){ + HAL_GPIO_WritePin(EXP_TIP_GPIO_Port, EXP_TIP_Pin, GPIO_PIN_SET); + owl_setup(); +} + +void loop(void){ + owl_loop(); +} diff --git a/OwlPedalMkII/Src/freertos.c b/OwlPedalMkII/Src/freertos.c new file mode 100644 index 00000000..ace53e48 --- /dev/null +++ b/OwlPedalMkII/Src/freertos.c @@ -0,0 +1,136 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * File Name : freertos.c + * Description : Code for freertos applications + ****************************************************************************** + * This notice applies to any and all portions of this file + * that are not between comment pairs USER CODE BEGIN and + * USER CODE END. Other portions of this file, whether + * inserted by the user or by software development tools + * are owned by their respective copyright owners. + * + * Copyright (c) 2019 STMicroelectronics International N.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "FreeRTOS.h" +#include "task.h" +#include "main.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN PTD */ + +/* USER CODE END PTD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ + +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN Variables */ + +/* USER CODE END Variables */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN FunctionPrototypes */ + +/* USER CODE END FunctionPrototypes */ + +/* GetIdleTaskMemory prototype (linked to static allocation support) */ +void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ); + +/* Hook prototypes */ +void vApplicationStackOverflowHook(TaskHandle_t xTask, signed char *pcTaskName); +void vApplicationMallocFailedHook(void); + +/* USER CODE BEGIN 4 */ +__weak void vApplicationStackOverflowHook(TaskHandle_t xTask, signed char *pcTaskName) +{ + /* Run time stack overflow checking is performed if + configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is + called if a stack overflow is detected. */ +} +/* USER CODE END 4 */ + +/* USER CODE BEGIN 5 */ +__weak void vApplicationMallocFailedHook(void) +{ + /* vApplicationMallocFailedHook() will only be called if + configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook + function that will get called if a call to pvPortMalloc() fails. + pvPortMalloc() is called internally by the kernel whenever a task, queue, + timer or semaphore is created. It is also called by various parts of the + demo application. If heap_1.c or heap_2.c are used, then the size of the + heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in + FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used + to query the size of free heap space that remains (although it does not + provide information on how the remaining heap might be fragmented). */ +} +/* USER CODE END 5 */ + +/* USER CODE BEGIN GET_IDLE_TASK_MEMORY */ +static StaticTask_t xIdleTaskTCBBuffer; +static StackType_t xIdleStack[configMINIMAL_STACK_SIZE]; + +void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ) +{ + *ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer; + *ppxIdleTaskStackBuffer = &xIdleStack[0]; + *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; + /* place for user code */ +} +/* USER CODE END GET_IDLE_TASK_MEMORY */ + +/* Private application code --------------------------------------------------*/ +/* USER CODE BEGIN Application */ + +/* USER CODE END Application */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedalMkII/Src/main.c b/OwlPedalMkII/Src/main.c new file mode 100644 index 00000000..80043356 --- /dev/null +++ b/OwlPedalMkII/Src/main.c @@ -0,0 +1,839 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : main.c + * @brief : Main program body + ****************************************************************************** + * This notice applies to any and all portions of this file + * that are not between comment pairs USER CODE BEGIN and + * USER CODE END. Other portions of this file, whether + * inserted by the user or by software development tools + * are owned by their respective copyright owners. + * + * Copyright (c) 2019 STMicroelectronics International N.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ +/* USER CODE END Header */ +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "cmsis_os.h" +#include "usb_device.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN PTD */ + +/* USER CODE END PTD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ + +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +ADC_HandleTypeDef hadc1; +ADC_HandleTypeDef hadc3; +DMA_HandleTypeDef hdma_adc3; + +RTC_HandleTypeDef hrtc; + +SAI_HandleTypeDef hsai_BlockA1; +SAI_HandleTypeDef hsai_BlockB1; +DMA_HandleTypeDef hdma_sai1_a; +DMA_HandleTypeDef hdma_sai1_b; + +SPI_HandleTypeDef hspi1; +SPI_HandleTypeDef hspi4; + +SDRAM_HandleTypeDef hsdram1; + +osThreadId defaultTaskHandle; +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +void SystemClock_Config(void); +static void MX_GPIO_Init(void); +static void MX_DMA_Init(void); +static void MX_ADC3_Init(void); +static void MX_FMC_Init(void); +static void MX_SAI1_Init(void); +static void MX_SPI1_Init(void); +static void MX_SPI4_Init(void); +static void MX_RTC_Init(void); +static void MX_ADC1_Init(void); +void StartDefaultTask(void const * argument); + +/* USER CODE BEGIN PFP */ +/* Private function prototypes -----------------------------------------------*/ + +void setup(); +void loop(void); +void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram); +void initialise_monitor_handles(void); + +/* USER CODE END PFP */ + +/* Private user code ---------------------------------------------------------*/ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/** + * @brief The application entry point. + * @retval int + */ +int main(void) +{ + /* USER CODE BEGIN 1 */ +#ifdef DEBUG +#warning "DEBUG uses printf and semihosting!" + if(CoreDebug->DHCSR & 0x01) + initialise_monitor_handles(); // remove when not semi-hosting + printf("showtime\n"); +#endif + /* USER CODE END 1 */ + + /* MCU Configuration--------------------------------------------------------*/ + + /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ + HAL_Init(); + + /* USER CODE BEGIN Init */ + + /* USER CODE END Init */ + + /* Configure the system clock */ + SystemClock_Config(); + + /* USER CODE BEGIN SysInit */ + + /* USER CODE END SysInit */ + + /* Initialize all configured peripherals */ + MX_GPIO_Init(); + MX_DMA_Init(); + MX_ADC3_Init(); + MX_FMC_Init(); + MX_SAI1_Init(); + MX_SPI1_Init(); + MX_SPI4_Init(); + MX_RTC_Init(); + MX_ADC1_Init(); + /* USER CODE BEGIN 2 */ + + HAL_SAI_DeInit(&hsai_BlockA1); + HAL_SAI_DeInit(&hsai_BlockB1); + hsai_BlockA1.Instance = SAI1_Block_A; + hsai_BlockA1.Init.AudioMode = SAI_MODESLAVE_TX; + hsai_BlockA1.Init.Synchro = SAI_ASYNCHRONOUS; + hsai_BlockA1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; + hsai_BlockA1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; + hsai_BlockA1.Init.SynchroExt = SAI_SYNCEXT_DISABLE; + hsai_BlockA1.Init.MonoStereoMode = SAI_STEREOMODE; + hsai_BlockA1.Init.CompandingMode = SAI_NOCOMPANDING; + hsai_BlockA1.Init.TriState = SAI_OUTPUT_NOTRELEASED; + if (HAL_SAI_InitProtocol(&hsai_BlockA1, SAI_I2S_STANDARD, SAI_PROTOCOL_DATASIZE_24BIT, 2) != HAL_OK) + Error_Handler(); + hsai_BlockB1.Instance = SAI1_Block_B; + hsai_BlockB1.Init.AudioMode = SAI_MODESLAVE_RX; + hsai_BlockB1.Init.Synchro = SAI_SYNCHRONOUS; + hsai_BlockB1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; + hsai_BlockB1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; + hsai_BlockB1.Init.SynchroExt = SAI_SYNCEXT_DISABLE; + hsai_BlockB1.Init.MonoStereoMode = SAI_STEREOMODE; + hsai_BlockB1.Init.CompandingMode = SAI_NOCOMPANDING; + hsai_BlockB1.Init.TriState = SAI_OUTPUT_NOTRELEASED; + if (HAL_SAI_InitProtocol(&hsai_BlockB1, SAI_I2S_STANDARD, SAI_PROTOCOL_DATASIZE_24BIT, 2) != HAL_OK) + Error_Handler(); + + SDRAM_Initialization_Sequence(&hsdram1); + + /* USER CODE END 2 */ + + /* USER CODE BEGIN RTOS_MUTEX */ + /* add mutexes, ... */ + /* USER CODE END RTOS_MUTEX */ + + /* USER CODE BEGIN RTOS_SEMAPHORES */ + /* add semaphores, ... */ + /* USER CODE END RTOS_SEMAPHORES */ + + /* USER CODE BEGIN RTOS_TIMERS */ + /* start timers, add new ones, ... */ + /* USER CODE END RTOS_TIMERS */ + + /* USER CODE BEGIN RTOS_QUEUES */ + /* add queues, ... */ + /* USER CODE END RTOS_QUEUES */ + + /* Create the thread(s) */ + /* definition and creation of defaultTask */ + osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128); + defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL); + + /* USER CODE BEGIN RTOS_THREADS */ + /* add threads, ... */ + /* USER CODE END RTOS_THREADS */ + + /* Start scheduler */ + osKernelStart(); + + /* We should never get here as control is now taken by the scheduler */ + /* Infinite loop */ + /* USER CODE BEGIN WHILE */ + while (1) + { + /* USER CODE END WHILE */ + + /* USER CODE BEGIN 3 */ + + } + /* USER CODE END 3 */ +} + +/** + * @brief System Clock Configuration + * @retval None + */ +void SystemClock_Config(void) +{ + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + + /** Macro to configure SAI1BlockB clock source selection + */ + __HAL_RCC_SAI_BLOCKBCLKSOURCE_CONFIG(SAI_CLKSOURCE_PLLSAI); + /** Macro to configure SAI1BlockA clock source selection + */ + __HAL_RCC_SAI_BLOCKACLKSOURCE_CONFIG(SAI_CLKSOURCE_PLLSAI); + /** Configure the main internal regulator output voltage + */ + __HAL_RCC_PWR_CLK_ENABLE(); + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); + /** Initializes the RCC Oscillators according to the specified parameters + * in the RCC_OscInitTypeDef structure. + */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.LSIState = RCC_LSI_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 25; + RCC_OscInitStruct.PLL.PLLN = 336; + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; + RCC_OscInitStruct.PLL.PLLQ = 7; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) + { + Error_Handler(); + } + /** Initializes the CPU, AHB and APB buses clocks + */ + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK + |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; + + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) + { + Error_Handler(); + } + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SAI_PLLSAI|RCC_PERIPHCLK_RTC; + PeriphClkInitStruct.PLLSAI.PLLSAIN = 100; + PeriphClkInitStruct.PLLSAI.PLLSAIQ = 4; + PeriphClkInitStruct.PLLSAIDivQ = 1; + PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } +} + +/** + * @brief ADC1 Initialization Function + * @param None + * @retval None + */ +static void MX_ADC1_Init(void) +{ + + /* USER CODE BEGIN ADC1_Init 0 */ + + /* USER CODE END ADC1_Init 0 */ + + ADC_ChannelConfTypeDef sConfig = {0}; + + /* USER CODE BEGIN ADC1_Init 1 */ + + /* USER CODE END ADC1_Init 1 */ + /** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion) + */ + hadc1.Instance = ADC1; + hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV8; + hadc1.Init.Resolution = ADC_RESOLUTION_12B; + hadc1.Init.ScanConvMode = DISABLE; + hadc1.Init.ContinuousConvMode = DISABLE; + hadc1.Init.DiscontinuousConvMode = DISABLE; + hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; + hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START; + hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT; + hadc1.Init.NbrOfConversion = 1; + hadc1.Init.DMAContinuousRequests = DISABLE; + hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV; + if (HAL_ADC_Init(&hadc1) != HAL_OK) + { + Error_Handler(); + } + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + */ + sConfig.Channel = ADC_CHANNEL_9; + sConfig.Rank = 1; + sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES; + if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN ADC1_Init 2 */ + + /* USER CODE END ADC1_Init 2 */ + +} + +/** + * @brief ADC3 Initialization Function + * @param None + * @retval None + */ +static void MX_ADC3_Init(void) +{ + + /* USER CODE BEGIN ADC3_Init 0 */ + + /* USER CODE END ADC3_Init 0 */ + + ADC_ChannelConfTypeDef sConfig = {0}; + + /* USER CODE BEGIN ADC3_Init 1 */ + + /* USER CODE END ADC3_Init 1 */ + /** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion) + */ + hadc3.Instance = ADC3; + hadc3.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV8; + hadc3.Init.Resolution = ADC_RESOLUTION_12B; + hadc3.Init.ScanConvMode = ENABLE; + hadc3.Init.ContinuousConvMode = ENABLE; + hadc3.Init.DiscontinuousConvMode = DISABLE; + hadc3.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; + hadc3.Init.ExternalTrigConv = ADC_SOFTWARE_START; + hadc3.Init.DataAlign = ADC_DATAALIGN_RIGHT; + hadc3.Init.NbrOfConversion = 4; + hadc3.Init.DMAContinuousRequests = ENABLE; + hadc3.Init.EOCSelection = ADC_EOC_SEQ_CONV; + if (HAL_ADC_Init(&hadc3) != HAL_OK) + { + Error_Handler(); + } + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + */ + sConfig.Channel = ADC_CHANNEL_13; + sConfig.Rank = 1; + sConfig.SamplingTime = ADC_SAMPLETIME_144CYCLES; + if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + */ + sConfig.Channel = ADC_CHANNEL_12; + sConfig.Rank = 2; + if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + */ + sConfig.Channel = ADC_CHANNEL_11; + sConfig.Rank = 3; + if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + */ + sConfig.Channel = ADC_CHANNEL_8; + sConfig.Rank = 4; + if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN ADC3_Init 2 */ + + /* USER CODE END ADC3_Init 2 */ + +} + +/** + * @brief RTC Initialization Function + * @param None + * @retval None + */ +static void MX_RTC_Init(void) +{ + + /* USER CODE BEGIN RTC_Init 0 */ + + /* USER CODE END RTC_Init 0 */ + + /* USER CODE BEGIN RTC_Init 1 */ + + /* USER CODE END RTC_Init 1 */ + /** Initialize RTC Only + */ + hrtc.Instance = RTC; + hrtc.Init.HourFormat = RTC_HOURFORMAT_24; + hrtc.Init.AsynchPrediv = 127; + hrtc.Init.SynchPrediv = 255; + hrtc.Init.OutPut = RTC_OUTPUT_DISABLE; + hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH; + hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN; + if (HAL_RTC_Init(&hrtc) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN RTC_Init 2 */ + + /* USER CODE END RTC_Init 2 */ + +} + +/** + * @brief SAI1 Initialization Function + * @param None + * @retval None + */ +static void MX_SAI1_Init(void) +{ + + /* USER CODE BEGIN SAI1_Init 0 */ + + /* USER CODE END SAI1_Init 0 */ + + /* USER CODE BEGIN SAI1_Init 1 */ + + /* USER CODE END SAI1_Init 1 */ + hsai_BlockA1.Instance = SAI1_Block_A; + hsai_BlockA1.Init.Protocol = SAI_FREE_PROTOCOL; + hsai_BlockA1.Init.AudioMode = SAI_MODESLAVE_TX; + hsai_BlockA1.Init.DataSize = SAI_DATASIZE_24; + hsai_BlockA1.Init.FirstBit = SAI_FIRSTBIT_MSB; + hsai_BlockA1.Init.ClockStrobing = SAI_CLOCKSTROBING_FALLINGEDGE; + hsai_BlockA1.Init.Synchro = SAI_ASYNCHRONOUS; + hsai_BlockA1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; + hsai_BlockA1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; + hsai_BlockA1.FrameInit.FrameLength = 64; + hsai_BlockA1.FrameInit.ActiveFrameLength = 1; + hsai_BlockA1.FrameInit.FSDefinition = SAI_FS_CHANNEL_IDENTIFICATION; + hsai_BlockA1.FrameInit.FSPolarity = SAI_FS_ACTIVE_LOW; + hsai_BlockA1.FrameInit.FSOffset = SAI_FS_FIRSTBIT; + hsai_BlockA1.SlotInit.FirstBitOffset = 0; + hsai_BlockA1.SlotInit.SlotSize = SAI_SLOTSIZE_32B; + hsai_BlockA1.SlotInit.SlotNumber = 2; + hsai_BlockA1.SlotInit.SlotActive = 0x00000000; + if (HAL_SAI_Init(&hsai_BlockA1) != HAL_OK) + { + Error_Handler(); + } + hsai_BlockB1.Instance = SAI1_Block_B; + hsai_BlockB1.Init.Protocol = SAI_FREE_PROTOCOL; + hsai_BlockB1.Init.AudioMode = SAI_MODESLAVE_RX; + hsai_BlockB1.Init.DataSize = SAI_DATASIZE_24; + hsai_BlockB1.Init.FirstBit = SAI_FIRSTBIT_MSB; + hsai_BlockB1.Init.ClockStrobing = SAI_CLOCKSTROBING_FALLINGEDGE; + hsai_BlockB1.Init.Synchro = SAI_SYNCHRONOUS; + hsai_BlockB1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; + hsai_BlockB1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; + hsai_BlockB1.FrameInit.FrameLength = 64; + hsai_BlockB1.FrameInit.ActiveFrameLength = 1; + hsai_BlockB1.FrameInit.FSDefinition = SAI_FS_CHANNEL_IDENTIFICATION; + hsai_BlockB1.FrameInit.FSPolarity = SAI_FS_ACTIVE_LOW; + hsai_BlockB1.FrameInit.FSOffset = SAI_FS_FIRSTBIT; + hsai_BlockB1.SlotInit.FirstBitOffset = 0; + hsai_BlockB1.SlotInit.SlotSize = SAI_SLOTSIZE_32B; + hsai_BlockB1.SlotInit.SlotNumber = 2; + hsai_BlockB1.SlotInit.SlotActive = 0x00000000; + if (HAL_SAI_Init(&hsai_BlockB1) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN SAI1_Init 2 */ + + /* USER CODE END SAI1_Init 2 */ + +} + +/** + * @brief SPI1 Initialization Function + * @param None + * @retval None + */ +static void MX_SPI1_Init(void) +{ + + /* USER CODE BEGIN SPI1_Init 0 */ + + /* USER CODE END SPI1_Init 0 */ + + /* USER CODE BEGIN SPI1_Init 1 */ + + /* USER CODE END SPI1_Init 1 */ + /* SPI1 parameter configuration*/ + hspi1.Instance = SPI1; + hspi1.Init.Mode = SPI_MODE_MASTER; + hspi1.Init.Direction = SPI_DIRECTION_2LINES; + hspi1.Init.DataSize = SPI_DATASIZE_8BIT; + hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; + hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; + hspi1.Init.NSS = SPI_NSS_SOFT; + hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2; + hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; + hspi1.Init.TIMode = SPI_TIMODE_DISABLE; + hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; + hspi1.Init.CRCPolynomial = 10; + if (HAL_SPI_Init(&hspi1) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN SPI1_Init 2 */ + + /* USER CODE END SPI1_Init 2 */ + +} + +/** + * @brief SPI4 Initialization Function + * @param None + * @retval None + */ +static void MX_SPI4_Init(void) +{ + + /* USER CODE BEGIN SPI4_Init 0 */ + + /* USER CODE END SPI4_Init 0 */ + + /* USER CODE BEGIN SPI4_Init 1 */ + + /* USER CODE END SPI4_Init 1 */ + /* SPI4 parameter configuration*/ + hspi4.Instance = SPI4; + hspi4.Init.Mode = SPI_MODE_MASTER; + hspi4.Init.Direction = SPI_DIRECTION_2LINES; + hspi4.Init.DataSize = SPI_DATASIZE_8BIT; + hspi4.Init.CLKPolarity = SPI_POLARITY_LOW; + hspi4.Init.CLKPhase = SPI_PHASE_1EDGE; + hspi4.Init.NSS = SPI_NSS_SOFT; + hspi4.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_128; + hspi4.Init.FirstBit = SPI_FIRSTBIT_MSB; + hspi4.Init.TIMode = SPI_TIMODE_DISABLE; + hspi4.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; + hspi4.Init.CRCPolynomial = 10; + if (HAL_SPI_Init(&hspi4) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN SPI4_Init 2 */ + + /* USER CODE END SPI4_Init 2 */ + +} + +/** + * Enable DMA controller clock + */ +static void MX_DMA_Init(void) +{ + + /* DMA controller clock enable */ + __HAL_RCC_DMA2_CLK_ENABLE(); + + /* DMA interrupt init */ + /* DMA2_Stream0_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 10, 0); + HAL_NVIC_EnableIRQ(DMA2_Stream0_IRQn); + /* DMA2_Stream1_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA2_Stream1_IRQn); + /* DMA2_Stream4_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA2_Stream4_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA2_Stream4_IRQn); + +} + +/* FMC initialization function */ +static void MX_FMC_Init(void) +{ + + /* USER CODE BEGIN FMC_Init 0 */ + + /* USER CODE END FMC_Init 0 */ + + FMC_SDRAM_TimingTypeDef SdramTiming = {0}; + + /* USER CODE BEGIN FMC_Init 1 */ + + /* USER CODE END FMC_Init 1 */ + + /** Perform the SDRAM1 memory initialization sequence + */ + hsdram1.Instance = FMC_SDRAM_DEVICE; + /* hsdram1.Init */ + hsdram1.Init.SDBank = FMC_SDRAM_BANK2; + hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8; + hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_12; + hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_16; + hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4; + hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3; + hsdram1.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE; + hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2; + hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE; + hsdram1.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0; + /* SdramTiming */ + SdramTiming.LoadToActiveDelay = 2; + SdramTiming.ExitSelfRefreshDelay = 6; + SdramTiming.SelfRefreshTime = 4; + SdramTiming.RowCycleDelay = 6; + SdramTiming.WriteRecoveryTime = 2; + SdramTiming.RPDelay = 2; + SdramTiming.RCDDelay = 2; + + if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK) + { + Error_Handler( ); + } + + /* USER CODE BEGIN FMC_Init 2 */ + + /* USER CODE END FMC_Init 2 */ +} + +/** + * @brief GPIO Initialization Function + * @param None + * @retval None + */ +static void MX_GPIO_Init(void) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + + /* GPIO Ports Clock Enable */ + __HAL_RCC_GPIOE_CLK_ENABLE(); + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOF_CLK_ENABLE(); + __HAL_RCC_GPIOH_CLK_ENABLE(); + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + __HAL_RCC_GPIOG_CLK_ENABLE(); + __HAL_RCC_GPIOD_CLK_ENABLE(); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(GPIOC, EXTSPI_nCS_Pin|FLASH_HOLD_Pin|FLASH_nCS_Pin, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(GPIOB, EXP_TIP_Pin|CS_nCS_Pin|CS_nRST_Pin, GPIO_PIN_RESET); + + /*Configure GPIO pins : PC13 PC14 PC6 PC7 + PC8 PC9 PC10 PC11 + PC12 */ + GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_6|GPIO_PIN_7 + |GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11 + |GPIO_PIN_12; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /*Configure GPIO pins : EXTSPI_nCS_Pin FLASH_HOLD_Pin FLASH_nCS_Pin */ + GPIO_InitStruct.Pin = EXTSPI_nCS_Pin|FLASH_HOLD_Pin|FLASH_nCS_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /*Configure GPIO pins : PF6 PF7 PF8 PF9 */ + GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + + /*Configure GPIO pins : PA0 PA1 PA4 PA8 + PA10 PA15 */ + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_8 + |GPIO_PIN_10|GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /*Configure GPIO pins : SW4_Pin SW3_Pin SW1_Pin */ + GPIO_InitStruct.Pin = SW4_Pin|SW3_Pin|SW1_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /*Configure GPIO pins : PB0 PB12 PB13 PB14 + PB15 PB4 PB7 PB9 */ + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 + |GPIO_PIN_15|GPIO_PIN_4|GPIO_PIN_7|GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /*Configure GPIO pins : EXP_TIP_Pin CS_nCS_Pin CS_nRST_Pin */ + GPIO_InitStruct.Pin = EXP_TIP_Pin|CS_nCS_Pin|CS_nRST_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /*Configure GPIO pins : PD11 PD12 PD13 PD2 + PD3 PD4 PD5 PD7 */ + GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_2 + |GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + /*Configure GPIO pins : PG2 PG3 PG6 PG7 + PG9 PG10 PG11 PG12 + PG13 PG14 */ + GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_6|GPIO_PIN_7 + |GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12 + |GPIO_PIN_13|GPIO_PIN_14; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + + /*Configure GPIO pin : SW2_Pin */ + GPIO_InitStruct.Pin = SW2_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; + GPIO_InitStruct.Pull = GPIO_PULLUP; + HAL_GPIO_Init(SW2_GPIO_Port, &GPIO_InitStruct); + + /* EXTI interrupt init*/ + HAL_NVIC_SetPriority(EXTI9_5_IRQn, 15, 0); + HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); + +} + +/* USER CODE BEGIN 4 */ + +/* USER CODE END 4 */ + +/* USER CODE BEGIN Header_StartDefaultTask */ +/** + * @brief Function implementing the defaultTask thread. + * @param argument: Not used + * @retval None + */ +/* USER CODE END Header_StartDefaultTask */ +void StartDefaultTask(void const * argument) +{ + /* init code for USB_DEVICE */ + MX_USB_DEVICE_Init(); + /* USER CODE BEGIN 5 */ + setup(); + + /* Infinite loop */ + for(;;) + { + loop(); + /* osDelay(1); */ + } + /* USER CODE END 5 */ +} + +/** + * @brief This function is executed in case of error occurrence. + * @retval None + */ +void Error_Handler(void) +{ + /* USER CODE BEGIN Error_Handler_Debug */ + /* User can add his own implementation to report the HAL error return state */ +#ifdef DEBUG + __asm__("BKPT"); +#else + NVIC_SystemReset(); +#endif + /* USER CODE END Error_Handler_Debug */ +} + +#ifdef USE_FULL_ASSERT +/** + * @brief Reports the name of the source file and the source line number + * where the assert_param error has occurred. + * @param file: pointer to the source file name + * @param line: assert_param error line source number + * @retval None + */ +void assert_failed(uint8_t *file, uint32_t line) +{ + /* USER CODE BEGIN 6 */ + /* User can add his own implementation to report the file name and line number, + ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ +#ifdef DEBUG + __asm__("BKPT"); +#else + NVIC_SystemReset(); +#endif + /* USER CODE END 6 */ +} +#endif /* USE_FULL_ASSERT */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedalMkII/Src/startup_stm32f427xx.s b/OwlPedalMkII/Src/startup_stm32f427xx.s new file mode 100644 index 00000000..7ddee113 --- /dev/null +++ b/OwlPedalMkII/Src/startup_stm32f427xx.s @@ -0,0 +1,553 @@ +/** + ****************************************************************************** + * @file startup_stm32f427xx.s + * @author MCD Application Team + * @version V2.6.1 + * @date 14-February-2017 + * @brief STM32F427xx Devices vector table for GCC based toolchains. + * This module performs: + * - Set the initial SP + * - Set the initial PC == Reset_Handler, + * - Set the vector table entries with the exceptions ISR address + * - Branches to main in the C library (which eventually + * calls main()). + * After Reset the Cortex-M4 processor is in Thread mode, + * priority is Privileged, and the Stack is set to Main. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2017 STMicroelectronics

+ * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + + .syntax unified + .cpu cortex-m4 + .fpu softvfp + .thumb + +.global g_pfnVectors +.global Default_Handler + +/* start address for the initialization values of the .data section. +defined in linker script */ +.word _sidata +/* start address for the .data section. defined in linker script */ +.word _sdata +/* end address for the .data section. defined in linker script */ +.word _edata +/* start address for the .bss section. defined in linker script */ +.word _sbss +/* end address for the .bss section. defined in linker script */ +.word _ebss +/* stack used for SystemInit_ExtMemCtl; always internal RAM used */ + +/** + * @brief This is the code that gets called when the processor first + * starts execution following a reset event. Only the absolutely + * necessary set is performed, after which the application + * supplied main() routine is called. + * @param None + * @retval : None +*/ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + ldr sp, =_estack /* set stack pointer */ + +/* Copy the data segment initializers from flash to SRAM */ + movs r1, #0 + b LoopCopyDataInit + +CopyDataInit: + ldr r3, =_sidata + ldr r3, [r3, r1] + str r3, [r0, r1] + adds r1, r1, #4 + +LoopCopyDataInit: + ldr r0, =_sdata + ldr r3, =_edata + adds r2, r0, r1 + cmp r2, r3 + bcc CopyDataInit + ldr r2, =_sbss + b LoopFillZerobss +/* Zero fill the bss segment. */ +FillZerobss: + movs r3, #0 + str r3, [r2], #4 + +LoopFillZerobss: + ldr r3, = _ebss + cmp r2, r3 + bcc FillZerobss + +/* Call the clock system intitialization function.*/ + bl SystemInit +/* Call static constructors */ + bl __libc_init_array +/* Call the application's entry point.*/ + bl main + bx lr +.size Reset_Handler, .-Reset_Handler + +/** + * @brief This is the code that gets called when the processor receives an + * unexpected interrupt. This simply enters an infinite loop, preserving + * the system state for examination by a debugger. + * @param None + * @retval None +*/ + .section .text.Default_Handler,"ax",%progbits +Default_Handler: +Infinite_Loop: + b Infinite_Loop + .size Default_Handler, .-Default_Handler +/****************************************************************************** +* +* The minimal vector table for a Cortex M3. Note that the proper constructs +* must be placed on this to ensure that it ends up at physical address +* 0x0000.0000. +* +*******************************************************************************/ + .section .isr_vector,"a",%progbits + .type g_pfnVectors, %object + .size g_pfnVectors, .-g_pfnVectors + + +g_pfnVectors: + .word _estack + .word Reset_Handler + + .word NMI_Handler + .word HardFault_Handler + .word MemManage_Handler + .word BusFault_Handler + .word UsageFault_Handler + .word 0 + .word 0 + .word 0 + .word 0 + .word SVC_Handler + .word DebugMon_Handler + .word 0 + .word PendSV_Handler + .word SysTick_Handler + + /* External Interrupts */ + .word WWDG_IRQHandler /* Window WatchDog */ + .word PVD_IRQHandler /* PVD through EXTI Line detection */ + .word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */ + .word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */ + .word FLASH_IRQHandler /* FLASH */ + .word RCC_IRQHandler /* RCC */ + .word EXTI0_IRQHandler /* EXTI Line0 */ + .word EXTI1_IRQHandler /* EXTI Line1 */ + .word EXTI2_IRQHandler /* EXTI Line2 */ + .word EXTI3_IRQHandler /* EXTI Line3 */ + .word EXTI4_IRQHandler /* EXTI Line4 */ + .word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */ + .word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */ + .word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */ + .word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */ + .word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */ + .word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */ + .word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */ + .word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */ + .word CAN1_TX_IRQHandler /* CAN1 TX */ + .word CAN1_RX0_IRQHandler /* CAN1 RX0 */ + .word CAN1_RX1_IRQHandler /* CAN1 RX1 */ + .word CAN1_SCE_IRQHandler /* CAN1 SCE */ + .word EXTI9_5_IRQHandler /* External Line[9:5]s */ + .word TIM1_BRK_TIM9_IRQHandler /* TIM1 Break and TIM9 */ + .word TIM1_UP_TIM10_IRQHandler /* TIM1 Update and TIM10 */ + .word TIM1_TRG_COM_TIM11_IRQHandler /* TIM1 Trigger and Commutation and TIM11 */ + .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */ + .word TIM2_IRQHandler /* TIM2 */ + .word TIM3_IRQHandler /* TIM3 */ + .word TIM4_IRQHandler /* TIM4 */ + .word I2C1_EV_IRQHandler /* I2C1 Event */ + .word I2C1_ER_IRQHandler /* I2C1 Error */ + .word I2C2_EV_IRQHandler /* I2C2 Event */ + .word I2C2_ER_IRQHandler /* I2C2 Error */ + .word SPI1_IRQHandler /* SPI1 */ + .word SPI2_IRQHandler /* SPI2 */ + .word USART1_IRQHandler /* USART1 */ + .word USART2_IRQHandler /* USART2 */ + .word USART3_IRQHandler /* USART3 */ + .word EXTI15_10_IRQHandler /* External Line[15:10]s */ + .word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */ + .word OTG_FS_WKUP_IRQHandler /* USB OTG FS Wakeup through EXTI line */ + .word TIM8_BRK_TIM12_IRQHandler /* TIM8 Break and TIM12 */ + .word TIM8_UP_TIM13_IRQHandler /* TIM8 Update and TIM13 */ + .word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */ + .word TIM8_CC_IRQHandler /* TIM8 Capture Compare */ + .word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */ + .word FMC_IRQHandler /* FMC */ + .word SDIO_IRQHandler /* SDIO */ + .word TIM5_IRQHandler /* TIM5 */ + .word SPI3_IRQHandler /* SPI3 */ + .word UART4_IRQHandler /* UART4 */ + .word UART5_IRQHandler /* UART5 */ + .word TIM6_DAC_IRQHandler /* TIM6 and DAC1&2 underrun errors */ + .word TIM7_IRQHandler /* TIM7 */ + .word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */ + .word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */ + .word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */ + .word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */ + .word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */ + .word ETH_IRQHandler /* Ethernet */ + .word ETH_WKUP_IRQHandler /* Ethernet Wakeup through EXTI line */ + .word CAN2_TX_IRQHandler /* CAN2 TX */ + .word CAN2_RX0_IRQHandler /* CAN2 RX0 */ + .word CAN2_RX1_IRQHandler /* CAN2 RX1 */ + .word CAN2_SCE_IRQHandler /* CAN2 SCE */ + .word OTG_FS_IRQHandler /* USB OTG FS */ + .word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */ + .word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */ + .word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */ + .word USART6_IRQHandler /* USART6 */ + .word I2C3_EV_IRQHandler /* I2C3 event */ + .word I2C3_ER_IRQHandler /* I2C3 error */ + .word OTG_HS_EP1_OUT_IRQHandler /* USB OTG HS End Point 1 Out */ + .word OTG_HS_EP1_IN_IRQHandler /* USB OTG HS End Point 1 In */ + .word OTG_HS_WKUP_IRQHandler /* USB OTG HS Wakeup through EXTI */ + .word OTG_HS_IRQHandler /* USB OTG HS */ + .word DCMI_IRQHandler /* DCMI */ + .word 0 /* Reserved */ + .word HASH_RNG_IRQHandler /* Hash and Rng */ + .word FPU_IRQHandler /* FPU */ + .word UART7_IRQHandler /* UART7 */ + .word UART8_IRQHandler /* UART8 */ + .word SPI4_IRQHandler /* SPI4 */ + .word SPI5_IRQHandler /* SPI5 */ + .word SPI6_IRQHandler /* SPI6 */ + .word SAI1_IRQHandler /* SAI1 */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word DMA2D_IRQHandler /* DMA2D */ +/******************************************************************************* +* +* Provide weak aliases for each Exception handler to the Default_Handler. +* As they are weak aliases, any function with the same name will override +* this definition. +* +*******************************************************************************/ + .weak NMI_Handler + .thumb_set NMI_Handler,Default_Handler + + .weak HardFault_Handler + .thumb_set HardFault_Handler,Default_Handler + + .weak MemManage_Handler + .thumb_set MemManage_Handler,Default_Handler + + .weak BusFault_Handler + .thumb_set BusFault_Handler,Default_Handler + + .weak UsageFault_Handler + .thumb_set UsageFault_Handler,Default_Handler + + .weak SVC_Handler + .thumb_set SVC_Handler,Default_Handler + + .weak DebugMon_Handler + .thumb_set DebugMon_Handler,Default_Handler + + .weak PendSV_Handler + .thumb_set PendSV_Handler,Default_Handler + + .weak SysTick_Handler + .thumb_set SysTick_Handler,Default_Handler + + .weak WWDG_IRQHandler + .thumb_set WWDG_IRQHandler,Default_Handler + + .weak PVD_IRQHandler + .thumb_set PVD_IRQHandler,Default_Handler + + .weak TAMP_STAMP_IRQHandler + .thumb_set TAMP_STAMP_IRQHandler,Default_Handler + + .weak RTC_WKUP_IRQHandler + .thumb_set RTC_WKUP_IRQHandler,Default_Handler + + .weak FLASH_IRQHandler + .thumb_set FLASH_IRQHandler,Default_Handler + + .weak RCC_IRQHandler + .thumb_set RCC_IRQHandler,Default_Handler + + .weak EXTI0_IRQHandler + .thumb_set EXTI0_IRQHandler,Default_Handler + + .weak EXTI1_IRQHandler + .thumb_set EXTI1_IRQHandler,Default_Handler + + .weak EXTI2_IRQHandler + .thumb_set EXTI2_IRQHandler,Default_Handler + + .weak EXTI3_IRQHandler + .thumb_set EXTI3_IRQHandler,Default_Handler + + .weak EXTI4_IRQHandler + .thumb_set EXTI4_IRQHandler,Default_Handler + + .weak DMA1_Stream0_IRQHandler + .thumb_set DMA1_Stream0_IRQHandler,Default_Handler + + .weak DMA1_Stream1_IRQHandler + .thumb_set DMA1_Stream1_IRQHandler,Default_Handler + + .weak DMA1_Stream2_IRQHandler + .thumb_set DMA1_Stream2_IRQHandler,Default_Handler + + .weak DMA1_Stream3_IRQHandler + .thumb_set DMA1_Stream3_IRQHandler,Default_Handler + + .weak DMA1_Stream4_IRQHandler + .thumb_set DMA1_Stream4_IRQHandler,Default_Handler + + .weak DMA1_Stream5_IRQHandler + .thumb_set DMA1_Stream5_IRQHandler,Default_Handler + + .weak DMA1_Stream6_IRQHandler + .thumb_set DMA1_Stream6_IRQHandler,Default_Handler + + .weak ADC_IRQHandler + .thumb_set ADC_IRQHandler,Default_Handler + + .weak CAN1_TX_IRQHandler + .thumb_set CAN1_TX_IRQHandler,Default_Handler + + .weak CAN1_RX0_IRQHandler + .thumb_set CAN1_RX0_IRQHandler,Default_Handler + + .weak CAN1_RX1_IRQHandler + .thumb_set CAN1_RX1_IRQHandler,Default_Handler + + .weak CAN1_SCE_IRQHandler + .thumb_set CAN1_SCE_IRQHandler,Default_Handler + + .weak EXTI9_5_IRQHandler + .thumb_set EXTI9_5_IRQHandler,Default_Handler + + .weak TIM1_BRK_TIM9_IRQHandler + .thumb_set TIM1_BRK_TIM9_IRQHandler,Default_Handler + + .weak TIM1_UP_TIM10_IRQHandler + .thumb_set TIM1_UP_TIM10_IRQHandler,Default_Handler + + .weak TIM1_TRG_COM_TIM11_IRQHandler + .thumb_set TIM1_TRG_COM_TIM11_IRQHandler,Default_Handler + + .weak TIM1_CC_IRQHandler + .thumb_set TIM1_CC_IRQHandler,Default_Handler + + .weak TIM2_IRQHandler + .thumb_set TIM2_IRQHandler,Default_Handler + + .weak TIM3_IRQHandler + .thumb_set TIM3_IRQHandler,Default_Handler + + .weak TIM4_IRQHandler + .thumb_set TIM4_IRQHandler,Default_Handler + + .weak I2C1_EV_IRQHandler + .thumb_set I2C1_EV_IRQHandler,Default_Handler + + .weak I2C1_ER_IRQHandler + .thumb_set I2C1_ER_IRQHandler,Default_Handler + + .weak I2C2_EV_IRQHandler + .thumb_set I2C2_EV_IRQHandler,Default_Handler + + .weak I2C2_ER_IRQHandler + .thumb_set I2C2_ER_IRQHandler,Default_Handler + + .weak SPI1_IRQHandler + .thumb_set SPI1_IRQHandler,Default_Handler + + .weak SPI2_IRQHandler + .thumb_set SPI2_IRQHandler,Default_Handler + + .weak USART1_IRQHandler + .thumb_set USART1_IRQHandler,Default_Handler + + .weak USART2_IRQHandler + .thumb_set USART2_IRQHandler,Default_Handler + + .weak USART3_IRQHandler + .thumb_set USART3_IRQHandler,Default_Handler + + .weak EXTI15_10_IRQHandler + .thumb_set EXTI15_10_IRQHandler,Default_Handler + + .weak RTC_Alarm_IRQHandler + .thumb_set RTC_Alarm_IRQHandler,Default_Handler + + .weak OTG_FS_WKUP_IRQHandler + .thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler + + .weak TIM8_BRK_TIM12_IRQHandler + .thumb_set TIM8_BRK_TIM12_IRQHandler,Default_Handler + + .weak TIM8_UP_TIM13_IRQHandler + .thumb_set TIM8_UP_TIM13_IRQHandler,Default_Handler + + .weak TIM8_TRG_COM_TIM14_IRQHandler + .thumb_set TIM8_TRG_COM_TIM14_IRQHandler,Default_Handler + + .weak TIM8_CC_IRQHandler + .thumb_set TIM8_CC_IRQHandler,Default_Handler + + .weak DMA1_Stream7_IRQHandler + .thumb_set DMA1_Stream7_IRQHandler,Default_Handler + + .weak FMC_IRQHandler + .thumb_set FMC_IRQHandler,Default_Handler + + .weak SDIO_IRQHandler + .thumb_set SDIO_IRQHandler,Default_Handler + + .weak TIM5_IRQHandler + .thumb_set TIM5_IRQHandler,Default_Handler + + .weak SPI3_IRQHandler + .thumb_set SPI3_IRQHandler,Default_Handler + + .weak UART4_IRQHandler + .thumb_set UART4_IRQHandler,Default_Handler + + .weak UART5_IRQHandler + .thumb_set UART5_IRQHandler,Default_Handler + + .weak TIM6_DAC_IRQHandler + .thumb_set TIM6_DAC_IRQHandler,Default_Handler + + .weak TIM7_IRQHandler + .thumb_set TIM7_IRQHandler,Default_Handler + + .weak DMA2_Stream0_IRQHandler + .thumb_set DMA2_Stream0_IRQHandler,Default_Handler + + .weak DMA2_Stream1_IRQHandler + .thumb_set DMA2_Stream1_IRQHandler,Default_Handler + + .weak DMA2_Stream2_IRQHandler + .thumb_set DMA2_Stream2_IRQHandler,Default_Handler + + .weak DMA2_Stream3_IRQHandler + .thumb_set DMA2_Stream3_IRQHandler,Default_Handler + + .weak DMA2_Stream4_IRQHandler + .thumb_set DMA2_Stream4_IRQHandler,Default_Handler + + .weak ETH_IRQHandler + .thumb_set ETH_IRQHandler,Default_Handler + + .weak ETH_WKUP_IRQHandler + .thumb_set ETH_WKUP_IRQHandler,Default_Handler + + .weak CAN2_TX_IRQHandler + .thumb_set CAN2_TX_IRQHandler,Default_Handler + + .weak CAN2_RX0_IRQHandler + .thumb_set CAN2_RX0_IRQHandler,Default_Handler + + .weak CAN2_RX1_IRQHandler + .thumb_set CAN2_RX1_IRQHandler,Default_Handler + + .weak CAN2_SCE_IRQHandler + .thumb_set CAN2_SCE_IRQHandler,Default_Handler + + .weak OTG_FS_IRQHandler + .thumb_set OTG_FS_IRQHandler,Default_Handler + + .weak DMA2_Stream5_IRQHandler + .thumb_set DMA2_Stream5_IRQHandler,Default_Handler + + .weak DMA2_Stream6_IRQHandler + .thumb_set DMA2_Stream6_IRQHandler,Default_Handler + + .weak DMA2_Stream7_IRQHandler + .thumb_set DMA2_Stream7_IRQHandler,Default_Handler + + .weak USART6_IRQHandler + .thumb_set USART6_IRQHandler,Default_Handler + + .weak I2C3_EV_IRQHandler + .thumb_set I2C3_EV_IRQHandler,Default_Handler + + .weak I2C3_ER_IRQHandler + .thumb_set I2C3_ER_IRQHandler,Default_Handler + + .weak OTG_HS_EP1_OUT_IRQHandler + .thumb_set OTG_HS_EP1_OUT_IRQHandler,Default_Handler + + .weak OTG_HS_EP1_IN_IRQHandler + .thumb_set OTG_HS_EP1_IN_IRQHandler,Default_Handler + + .weak OTG_HS_WKUP_IRQHandler + .thumb_set OTG_HS_WKUP_IRQHandler,Default_Handler + + .weak OTG_HS_IRQHandler + .thumb_set OTG_HS_IRQHandler,Default_Handler + + .weak DCMI_IRQHandler + .thumb_set DCMI_IRQHandler,Default_Handler + + .weak HASH_RNG_IRQHandler + .thumb_set HASH_RNG_IRQHandler,Default_Handler + + .weak FPU_IRQHandler + .thumb_set FPU_IRQHandler,Default_Handler + + .weak UART7_IRQHandler + .thumb_set UART7_IRQHandler,Default_Handler + + .weak UART8_IRQHandler + .thumb_set UART8_IRQHandler,Default_Handler + + .weak SPI4_IRQHandler + .thumb_set SPI4_IRQHandler,Default_Handler + + .weak SPI5_IRQHandler + .thumb_set SPI5_IRQHandler,Default_Handler + + .weak SPI6_IRQHandler + .thumb_set SPI6_IRQHandler,Default_Handler + + .weak SAI1_IRQHandler + .thumb_set SAI1_IRQHandler,Default_Handler + + .weak DMA2D_IRQHandler + .thumb_set DMA2D_IRQHandler,Default_Handler + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ + diff --git a/OwlPedalMkII/Src/stm32f4xx_hal_msp.c b/OwlPedalMkII/Src/stm32f4xx_hal_msp.c new file mode 100644 index 00000000..b40e6d1d --- /dev/null +++ b/OwlPedalMkII/Src/stm32f4xx_hal_msp.c @@ -0,0 +1,777 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * File Name : stm32f4xx_hal_msp.c + * Description : This file provides code for the MSP Initialization + * and de-Initialization codes. + ****************************************************************************** + * This notice applies to any and all portions of this file + * that are not between comment pairs USER CODE BEGIN and + * USER CODE END. Other portions of this file, whether + * inserted by the user or by software development tools + * are owned by their respective copyright owners. + * + * Copyright (c) 2019 STMicroelectronics International N.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ +extern DMA_HandleTypeDef hdma_adc3; + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN TD */ + +/* USER CODE END TD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN Define */ + +/* USER CODE END Define */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN Macro */ + +/* USER CODE END Macro */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* External functions --------------------------------------------------------*/ +/* USER CODE BEGIN ExternalFunctions */ + +/* USER CODE END ExternalFunctions */ + +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ +/** + * Initializes the Global MSP. + */ +void HAL_MspInit(void) +{ + /* USER CODE BEGIN MspInit 0 */ + + /* USER CODE END MspInit 0 */ + + __HAL_RCC_SYSCFG_CLK_ENABLE(); + __HAL_RCC_PWR_CLK_ENABLE(); + + /* System interrupt init*/ + /* PendSV_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0); + + /* USER CODE BEGIN MspInit 1 */ + + /* USER CODE END MspInit 1 */ +} + +/** +* @brief ADC MSP Initialization +* This function configures the hardware resources used in this example +* @param hadc: ADC handle pointer +* @retval None +*/ +void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(hadc->Instance==ADC1) + { + /* USER CODE BEGIN ADC1_MspInit 0 */ + + /* USER CODE END ADC1_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_ADC1_CLK_ENABLE(); + + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**ADC1 GPIO Configuration + PB1 ------> ADC1_IN9 + */ + GPIO_InitStruct.Pin = EXP_RING_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(EXP_RING_GPIO_Port, &GPIO_InitStruct); + + /* USER CODE BEGIN ADC1_MspInit 1 */ + + /* USER CODE END ADC1_MspInit 1 */ + } + else if(hadc->Instance==ADC3) + { + /* USER CODE BEGIN ADC3_MspInit 0 */ + + /* USER CODE END ADC3_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_ADC3_CLK_ENABLE(); + + __HAL_RCC_GPIOF_CLK_ENABLE(); + __HAL_RCC_GPIOC_CLK_ENABLE(); + /**ADC3 GPIO Configuration + PF10 ------> ADC3_IN8 + PC1 ------> ADC3_IN11 + PC2 ------> ADC3_IN12 + PC3 ------> ADC3_IN13 + */ + GPIO_InitStruct.Pin = ADC4_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(ADC4_GPIO_Port, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = ADC3_Pin|ADC2_Pin|ADC1_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /* ADC3 DMA Init */ + /* ADC3 Init */ + hdma_adc3.Instance = DMA2_Stream0; + hdma_adc3.Init.Channel = DMA_CHANNEL_2; + hdma_adc3.Init.Direction = DMA_PERIPH_TO_MEMORY; + hdma_adc3.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_adc3.Init.MemInc = DMA_MINC_ENABLE; + hdma_adc3.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; + hdma_adc3.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; + hdma_adc3.Init.Mode = DMA_CIRCULAR; + hdma_adc3.Init.Priority = DMA_PRIORITY_LOW; + hdma_adc3.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + if (HAL_DMA_Init(&hdma_adc3) != HAL_OK) + { + Error_Handler(); + } + + __HAL_LINKDMA(hadc,DMA_Handle,hdma_adc3); + + /* USER CODE BEGIN ADC3_MspInit 1 */ + + /* USER CODE END ADC3_MspInit 1 */ + } + +} + +/** +* @brief ADC MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hadc: ADC handle pointer +* @retval None +*/ +void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) +{ + if(hadc->Instance==ADC1) + { + /* USER CODE BEGIN ADC1_MspDeInit 0 */ + + /* USER CODE END ADC1_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_ADC1_CLK_DISABLE(); + + /**ADC1 GPIO Configuration + PB1 ------> ADC1_IN9 + */ + HAL_GPIO_DeInit(EXP_RING_GPIO_Port, EXP_RING_Pin); + + /* USER CODE BEGIN ADC1_MspDeInit 1 */ + + /* USER CODE END ADC1_MspDeInit 1 */ + } + else if(hadc->Instance==ADC3) + { + /* USER CODE BEGIN ADC3_MspDeInit 0 */ + + /* USER CODE END ADC3_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_ADC3_CLK_DISABLE(); + + /**ADC3 GPIO Configuration + PF10 ------> ADC3_IN8 + PC1 ------> ADC3_IN11 + PC2 ------> ADC3_IN12 + PC3 ------> ADC3_IN13 + */ + HAL_GPIO_DeInit(ADC4_GPIO_Port, ADC4_Pin); + + HAL_GPIO_DeInit(GPIOC, ADC3_Pin|ADC2_Pin|ADC1_Pin); + + /* ADC3 DMA DeInit */ + HAL_DMA_DeInit(hadc->DMA_Handle); + /* USER CODE BEGIN ADC3_MspDeInit 1 */ + + /* USER CODE END ADC3_MspDeInit 1 */ + } + +} + +/** +* @brief RTC MSP Initialization +* This function configures the hardware resources used in this example +* @param hrtc: RTC handle pointer +* @retval None +*/ +void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc) +{ + if(hrtc->Instance==RTC) + { + /* USER CODE BEGIN RTC_MspInit 0 */ + + /* USER CODE END RTC_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_RTC_ENABLE(); + /* USER CODE BEGIN RTC_MspInit 1 */ + + /* USER CODE END RTC_MspInit 1 */ + } + +} + +/** +* @brief RTC MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hrtc: RTC handle pointer +* @retval None +*/ +void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc) +{ + if(hrtc->Instance==RTC) + { + /* USER CODE BEGIN RTC_MspDeInit 0 */ + + /* USER CODE END RTC_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_RTC_DISABLE(); + /* USER CODE BEGIN RTC_MspDeInit 1 */ + + /* USER CODE END RTC_MspDeInit 1 */ + } + +} + +/** +* @brief SPI MSP Initialization +* This function configures the hardware resources used in this example +* @param hspi: SPI handle pointer +* @retval None +*/ +void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(hspi->Instance==SPI1) + { + /* USER CODE BEGIN SPI1_MspInit 0 */ + + /* USER CODE END SPI1_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_SPI1_CLK_ENABLE(); + + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**SPI1 GPIO Configuration + PA6 ------> SPI1_MISO + PA7 ------> SPI1_MOSI + PB3 ------> SPI1_SCK + */ + GPIO_InitStruct.Pin = FLASH_MISO_Pin|FLASH_MOSI_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = FLASH_SCK_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; + HAL_GPIO_Init(FLASH_SCK_GPIO_Port, &GPIO_InitStruct); + + /* USER CODE BEGIN SPI1_MspInit 1 */ + + /* USER CODE END SPI1_MspInit 1 */ + } + else if(hspi->Instance==SPI4) + { + /* USER CODE BEGIN SPI4_MspInit 0 */ + + /* USER CODE END SPI4_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_SPI4_CLK_ENABLE(); + + __HAL_RCC_GPIOE_CLK_ENABLE(); + /**SPI4 GPIO Configuration + PE2 ------> SPI4_SCK + PE6 ------> SPI4_MOSI + */ + GPIO_InitStruct.Pin = CS_SCK_Pin|CS_SDA_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF5_SPI4; + HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + + /* USER CODE BEGIN SPI4_MspInit 1 */ + + /* USER CODE END SPI4_MspInit 1 */ + } + +} + +/** +* @brief SPI MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hspi: SPI handle pointer +* @retval None +*/ +void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) +{ + if(hspi->Instance==SPI1) + { + /* USER CODE BEGIN SPI1_MspDeInit 0 */ + + /* USER CODE END SPI1_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_SPI1_CLK_DISABLE(); + + /**SPI1 GPIO Configuration + PA6 ------> SPI1_MISO + PA7 ------> SPI1_MOSI + PB3 ------> SPI1_SCK + */ + HAL_GPIO_DeInit(GPIOA, FLASH_MISO_Pin|FLASH_MOSI_Pin); + + HAL_GPIO_DeInit(FLASH_SCK_GPIO_Port, FLASH_SCK_Pin); + + /* USER CODE BEGIN SPI1_MspDeInit 1 */ + + /* USER CODE END SPI1_MspDeInit 1 */ + } + else if(hspi->Instance==SPI4) + { + /* USER CODE BEGIN SPI4_MspDeInit 0 */ + + /* USER CODE END SPI4_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_SPI4_CLK_DISABLE(); + + /**SPI4 GPIO Configuration + PE2 ------> SPI4_SCK + PE6 ------> SPI4_MOSI + */ + HAL_GPIO_DeInit(GPIOE, CS_SCK_Pin|CS_SDA_Pin); + + /* USER CODE BEGIN SPI4_MspDeInit 1 */ + + /* USER CODE END SPI4_MspDeInit 1 */ + } + +} + +static uint32_t FMC_Initialized = 0; + +static void HAL_FMC_MspInit(void){ + /* USER CODE BEGIN FMC_MspInit 0 */ + + /* USER CODE END FMC_MspInit 0 */ + GPIO_InitTypeDef GPIO_InitStruct ={0}; + if (FMC_Initialized) { + return; + } + FMC_Initialized = 1; + + /* Peripheral clock enable */ + __HAL_RCC_FMC_CLK_ENABLE(); + + /** FMC GPIO Configuration + PF0 ------> FMC_A0 + PF1 ------> FMC_A1 + PF2 ------> FMC_A2 + PF3 ------> FMC_A3 + PF4 ------> FMC_A4 + PF5 ------> FMC_A5 + PC0 ------> FMC_SDNWE + PF11 ------> FMC_SDNRAS + PF12 ------> FMC_A6 + PF13 ------> FMC_A7 + PF14 ------> FMC_A8 + PF15 ------> FMC_A9 + PG0 ------> FMC_A10 + PG1 ------> FMC_A11 + PE7 ------> FMC_D4 + PE8 ------> FMC_D5 + PE9 ------> FMC_D6 + PE10 ------> FMC_D7 + PE11 ------> FMC_D8 + PE12 ------> FMC_D9 + PE13 ------> FMC_D10 + PE14 ------> FMC_D11 + PE15 ------> FMC_D12 + PD8 ------> FMC_D13 + PD9 ------> FMC_D14 + PD10 ------> FMC_D15 + PD14 ------> FMC_D0 + PD15 ------> FMC_D1 + PG4 ------> FMC_BA0 + PG5 ------> FMC_BA1 + PG8 ------> FMC_SDCLK + PD0 ------> FMC_D2 + PD1 ------> FMC_D3 + PG15 ------> FMC_SDNCAS + PB5 ------> FMC_SDCKE1 + PB6 ------> FMC_SDNE1 + PE0 ------> FMC_NBL0 + PE1 ------> FMC_NBL1 + */ + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 + |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_11|GPIO_PIN_12 + |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_0; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5 + |GPIO_PIN_8|GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 + |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 + |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14 + |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* USER CODE BEGIN FMC_MspInit 1 */ + + /* USER CODE END FMC_MspInit 1 */ +} + +void HAL_SDRAM_MspInit(SDRAM_HandleTypeDef* hsdram){ + /* USER CODE BEGIN SDRAM_MspInit 0 */ + + /* USER CODE END SDRAM_MspInit 0 */ + HAL_FMC_MspInit(); + /* USER CODE BEGIN SDRAM_MspInit 1 */ + + /* USER CODE END SDRAM_MspInit 1 */ +} + +static uint32_t FMC_DeInitialized = 0; + +static void HAL_FMC_MspDeInit(void){ + /* USER CODE BEGIN FMC_MspDeInit 0 */ + + /* USER CODE END FMC_MspDeInit 0 */ + if (FMC_DeInitialized) { + return; + } + FMC_DeInitialized = 1; + /* Peripheral clock enable */ + __HAL_RCC_FMC_CLK_DISABLE(); + + /** FMC GPIO Configuration + PF0 ------> FMC_A0 + PF1 ------> FMC_A1 + PF2 ------> FMC_A2 + PF3 ------> FMC_A3 + PF4 ------> FMC_A4 + PF5 ------> FMC_A5 + PC0 ------> FMC_SDNWE + PF11 ------> FMC_SDNRAS + PF12 ------> FMC_A6 + PF13 ------> FMC_A7 + PF14 ------> FMC_A8 + PF15 ------> FMC_A9 + PG0 ------> FMC_A10 + PG1 ------> FMC_A11 + PE7 ------> FMC_D4 + PE8 ------> FMC_D5 + PE9 ------> FMC_D6 + PE10 ------> FMC_D7 + PE11 ------> FMC_D8 + PE12 ------> FMC_D9 + PE13 ------> FMC_D10 + PE14 ------> FMC_D11 + PE15 ------> FMC_D12 + PD8 ------> FMC_D13 + PD9 ------> FMC_D14 + PD10 ------> FMC_D15 + PD14 ------> FMC_D0 + PD15 ------> FMC_D1 + PG4 ------> FMC_BA0 + PG5 ------> FMC_BA1 + PG8 ------> FMC_SDCLK + PD0 ------> FMC_D2 + PD1 ------> FMC_D3 + PG15 ------> FMC_SDNCAS + PB5 ------> FMC_SDCKE1 + PB6 ------> FMC_SDNE1 + PE0 ------> FMC_NBL0 + PE1 ------> FMC_NBL1 + */ + HAL_GPIO_DeInit(GPIOF, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 + |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_11|GPIO_PIN_12 + |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15); + + HAL_GPIO_DeInit(GPIOC, GPIO_PIN_0); + + HAL_GPIO_DeInit(GPIOG, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5 + |GPIO_PIN_8|GPIO_PIN_15); + + HAL_GPIO_DeInit(GPIOE, GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 + |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 + |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1); + + HAL_GPIO_DeInit(GPIOD, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14 + |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1); + + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_5|GPIO_PIN_6); + + /* USER CODE BEGIN FMC_MspDeInit 1 */ + + /* USER CODE END FMC_MspDeInit 1 */ +} + +void HAL_SDRAM_MspDeInit(SDRAM_HandleTypeDef* hsdram){ + /* USER CODE BEGIN SDRAM_MspDeInit 0 */ + + /* USER CODE END SDRAM_MspDeInit 0 */ + HAL_FMC_MspDeInit(); + /* USER CODE BEGIN SDRAM_MspDeInit 1 */ + + /* USER CODE END SDRAM_MspDeInit 1 */ +} + +extern DMA_HandleTypeDef hdma_sai1_a; + +extern DMA_HandleTypeDef hdma_sai1_b; + +static uint32_t SAI1_client =0; + +void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) +{ + + GPIO_InitTypeDef GPIO_InitStruct; +/* SAI1 */ + if(hsai->Instance==SAI1_Block_A) + { + /* Peripheral clock enable */ + if (SAI1_client == 0) + { + __HAL_RCC_SAI1_CLK_ENABLE(); + + /* Peripheral interrupt init*/ + HAL_NVIC_SetPriority(SAI1_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(SAI1_IRQn); + } + SAI1_client ++; + + /**SAI1_A_Block_A GPIO Configuration + PE4 ------> SAI1_FS_A + PE5 ------> SAI1_SCK_A + PD6 ------> SAI1_SD_A + */ + GPIO_InitStruct.Pin = CS_LRCK_Pin|CS_SCKE5_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; + HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = CS_SDIN_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; + HAL_GPIO_Init(CS_SDIN_GPIO_Port, &GPIO_InitStruct); + + /* Peripheral DMA init*/ + + hdma_sai1_a.Instance = DMA2_Stream1; + hdma_sai1_a.Init.Channel = DMA_CHANNEL_0; + hdma_sai1_a.Init.Direction = DMA_MEMORY_TO_PERIPH; + hdma_sai1_a.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_sai1_a.Init.MemInc = DMA_MINC_ENABLE; + hdma_sai1_a.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; + hdma_sai1_a.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; + hdma_sai1_a.Init.Mode = DMA_CIRCULAR; + hdma_sai1_a.Init.Priority = DMA_PRIORITY_VERY_HIGH; + hdma_sai1_a.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + if (HAL_DMA_Init(&hdma_sai1_a) != HAL_OK) + { + Error_Handler(); + } + + /* Several peripheral DMA handle pointers point to the same DMA handle. + Be aware that there is only one stream to perform all the requested DMAs. */ + __HAL_LINKDMA(hsai,hdmarx,hdma_sai1_a); + + __HAL_LINKDMA(hsai,hdmatx,hdma_sai1_a); + + } + if(hsai->Instance==SAI1_Block_B) + { + /* Peripheral clock enable */ + if (SAI1_client == 0) + { + __HAL_RCC_SAI1_CLK_ENABLE(); + + /* Peripheral interrupt init*/ + HAL_NVIC_SetPriority(SAI1_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(SAI1_IRQn); + } + SAI1_client ++; + + /**SAI1_B_Block_B GPIO Configuration + PE3 ------> SAI1_SD_B + */ + GPIO_InitStruct.Pin = CS_SDOUT_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; + HAL_GPIO_Init(CS_SDOUT_GPIO_Port, &GPIO_InitStruct); + + /* Peripheral DMA init*/ + + hdma_sai1_b.Instance = DMA2_Stream4; + hdma_sai1_b.Init.Channel = DMA_CHANNEL_1; + hdma_sai1_b.Init.Direction = DMA_PERIPH_TO_MEMORY; + hdma_sai1_b.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_sai1_b.Init.MemInc = DMA_MINC_ENABLE; + hdma_sai1_b.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; + hdma_sai1_b.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; + hdma_sai1_b.Init.Mode = DMA_CIRCULAR; + hdma_sai1_b.Init.Priority = DMA_PRIORITY_VERY_HIGH; + hdma_sai1_b.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + if (HAL_DMA_Init(&hdma_sai1_b) != HAL_OK) + { + Error_Handler(); + } + + /* Several peripheral DMA handle pointers point to the same DMA handle. + Be aware that there is only one stream to perform all the requested DMAs. */ + __HAL_LINKDMA(hsai,hdmarx,hdma_sai1_b); + __HAL_LINKDMA(hsai,hdmatx,hdma_sai1_b); + } +} + +void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) +{ +/* SAI1 */ + if(hsai->Instance==SAI1_Block_A) + { + SAI1_client --; + if (SAI1_client == 0) + { + /* Peripheral clock disable */ + __HAL_RCC_SAI1_CLK_DISABLE(); + HAL_NVIC_DisableIRQ(SAI1_IRQn); + } + + /**SAI1_A_Block_A GPIO Configuration + PE4 ------> SAI1_FS_A + PE5 ------> SAI1_SCK_A + PD6 ------> SAI1_SD_A + */ + HAL_GPIO_DeInit(GPIOE, CS_LRCK_Pin|CS_SCKE5_Pin); + + HAL_GPIO_DeInit(CS_SDIN_GPIO_Port, CS_SDIN_Pin); + + HAL_DMA_DeInit(hsai->hdmarx); + HAL_DMA_DeInit(hsai->hdmatx); + } + if(hsai->Instance==SAI1_Block_B) + { + SAI1_client --; + if (SAI1_client == 0) + { + /* Peripheral clock disable */ + __HAL_RCC_SAI1_CLK_DISABLE(); + HAL_NVIC_DisableIRQ(SAI1_IRQn); + } + + /**SAI1_B_Block_B GPIO Configuration + PE3 ------> SAI1_SD_B + */ + HAL_GPIO_DeInit(CS_SDOUT_GPIO_Port, CS_SDOUT_Pin); + + HAL_DMA_DeInit(hsai->hdmarx); + HAL_DMA_DeInit(hsai->hdmatx); + } +} + +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedalMkII/Src/stm32f4xx_it.c b/OwlPedalMkII/Src/stm32f4xx_it.c new file mode 100644 index 00000000..e4046a8e --- /dev/null +++ b/OwlPedalMkII/Src/stm32f4xx_it.c @@ -0,0 +1,207 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32f4xx_it.c + * @brief Interrupt Service Routines. + ****************************************************************************** + * + * COPYRIGHT(c) 2019 STMicroelectronics + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "stm32f4xx_it.h" +#include "FreeRTOS.h" +#include "task.h" +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN TD */ + +/* USER CODE END TD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ + +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* Private user code ---------------------------------------------------------*/ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* External variables --------------------------------------------------------*/ +extern PCD_HandleTypeDef hpcd_USB_OTG_FS; +extern DMA_HandleTypeDef hdma_adc3; +extern DMA_HandleTypeDef hdma_sai1_a; +extern DMA_HandleTypeDef hdma_sai1_b; +extern SAI_HandleTypeDef hsai_BlockA1; +extern SAI_HandleTypeDef hsai_BlockB1; +/* USER CODE BEGIN EV */ + +/* USER CODE END EV */ + +/******************************************************************************/ +/* Cortex-M4 Processor Interruption and Exception Handlers */ +/******************************************************************************/ +/** + * @brief This function handles System tick timer. + */ +void SysTick_Handler(void) +{ + /* USER CODE BEGIN SysTick_IRQn 0 */ + + /* USER CODE END SysTick_IRQn 0 */ + HAL_IncTick(); +#if (INCLUDE_xTaskGetSchedulerState == 1 ) + if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) + { +#endif /* INCLUDE_xTaskGetSchedulerState */ + xPortSysTickHandler(); +#if (INCLUDE_xTaskGetSchedulerState == 1 ) + } +#endif /* INCLUDE_xTaskGetSchedulerState */ + /* USER CODE BEGIN SysTick_IRQn 1 */ + + /* USER CODE END SysTick_IRQn 1 */ +} + +/******************************************************************************/ +/* STM32F4xx Peripheral Interrupt Handlers */ +/* Add here the Interrupt Handlers for the used peripherals. */ +/* For the available peripheral interrupt handler names, */ +/* please refer to the startup file (startup_stm32f4xx.s). */ +/******************************************************************************/ + +/** + * @brief This function handles EXTI line[9:5] interrupts. + */ +void EXTI9_5_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI9_5_IRQn 0 */ + + /* USER CODE END EXTI9_5_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_5); + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8); + /* USER CODE BEGIN EXTI9_5_IRQn 1 */ + + /* USER CODE END EXTI9_5_IRQn 1 */ +} + +/** + * @brief This function handles DMA2 stream0 global interrupt. + */ +void DMA2_Stream0_IRQHandler(void) +{ + /* USER CODE BEGIN DMA2_Stream0_IRQn 0 */ + + /* USER CODE END DMA2_Stream0_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_adc3); + /* USER CODE BEGIN DMA2_Stream0_IRQn 1 */ + + /* USER CODE END DMA2_Stream0_IRQn 1 */ +} + +/** + * @brief This function handles DMA2 stream1 global interrupt. + */ +void DMA2_Stream1_IRQHandler(void) +{ + /* USER CODE BEGIN DMA2_Stream1_IRQn 0 */ + + /* USER CODE END DMA2_Stream1_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_sai1_a); + /* USER CODE BEGIN DMA2_Stream1_IRQn 1 */ + + /* USER CODE END DMA2_Stream1_IRQn 1 */ +} + +/** + * @brief This function handles DMA2 stream4 global interrupt. + */ +void DMA2_Stream4_IRQHandler(void) +{ + /* USER CODE BEGIN DMA2_Stream4_IRQn 0 */ + + /* USER CODE END DMA2_Stream4_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_sai1_b); + /* USER CODE BEGIN DMA2_Stream4_IRQn 1 */ + + /* USER CODE END DMA2_Stream4_IRQn 1 */ +} + +/** + * @brief This function handles USB On The Go FS global interrupt. + */ +void OTG_FS_IRQHandler(void) +{ + /* USER CODE BEGIN OTG_FS_IRQn 0 */ + + /* USER CODE END OTG_FS_IRQn 0 */ + HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS); + /* USER CODE BEGIN OTG_FS_IRQn 1 */ + + /* USER CODE END OTG_FS_IRQn 1 */ +} + +/** + * @brief This function handles SAI1 global interrupt. + */ +void SAI1_IRQHandler(void) +{ + /* USER CODE BEGIN SAI1_IRQn 0 */ + + /* USER CODE END SAI1_IRQn 0 */ + HAL_SAI_IRQHandler(&hsai_BlockA1); + HAL_SAI_IRQHandler(&hsai_BlockB1); + /* USER CODE BEGIN SAI1_IRQn 1 */ + + /* USER CODE END SAI1_IRQn 1 */ +} + +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedalMkII/Src/system_stm32f4xx.c b/OwlPedalMkII/Src/system_stm32f4xx.c new file mode 100644 index 00000000..adcddf9b --- /dev/null +++ b/OwlPedalMkII/Src/system_stm32f4xx.c @@ -0,0 +1,763 @@ +/** + ****************************************************************************** + * @file system_stm32f4xx.c + * @author MCD Application Team + * @version V2.6.1 + * @date 14-February-2017 + * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File. + * + * This file provides two functions and one global variable to be called from + * user application: + * - SystemInit(): This function is called at startup just after reset and + * before branch to main program. This call is made inside + * the "startup_stm32f4xx.s" file. + * + * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used + * by the user application to setup the SysTick + * timer or configure other parameters. + * + * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must + * be called whenever the core clock is changed + * during program execution. + * + * + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2017 STMicroelectronics

+ * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************** + */ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup stm32f4xx_system + * @{ + */ + +/** @addtogroup STM32F4xx_System_Private_Includes + * @{ + */ + + +#include "stm32f4xx.h" + +#if !defined (HSE_VALUE) + #define HSE_VALUE ((uint32_t)25000000) /*!< Default value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_Defines + * @{ + */ + +/************************* Miscellaneous Configuration ************************/ +/*!< Uncomment the following line if you need to use external SRAM or SDRAM as data memory */ +#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)\ + || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ + || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) +/* #define DATA_IN_ExtSRAM */ +#endif /* STM32F40xxx || STM32F41xxx || STM32F42xxx || STM32F43xxx || STM32F469xx || STM32F479xx ||\ + STM32F412Zx || STM32F412Vx */ + +#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ + || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) +/* #define DATA_IN_ExtSDRAM */ +#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx ||\ + STM32F479xx */ + +/*!< Uncomment the following line if you need to relocate your vector Table in + Internal SRAM. */ +/* #define VECT_TAB_SRAM */ +#define VECT_TAB_OFFSET 0x00010000 /*!< Vector Table base offset field. + This value must be a multiple of 0x200. */ +/******************************************************************************/ + +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_Variables + * @{ + */ + /* This variable is updated in three ways: + 1) by calling CMSIS function SystemCoreClockUpdate() + 2) by calling HAL API function HAL_RCC_GetHCLKFreq() + 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency + Note: If you use this function to configure the system clock; then there + is no need to call the 2 first functions listed above, since SystemCoreClock + variable is updated automatically. + */ +uint32_t SystemCoreClock = 16000000; +const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; +const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4}; +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_FunctionPrototypes + * @{ + */ + +#if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM) + static void SystemInit_ExtMemCtl(void); +#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */ + +/** + * @} + */ + +/** @addtogroup STM32F4xx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system + * Initialize the FPU setting, vector table location and External memory + * configuration. + * @param None + * @retval None + */ +void SystemInit(void) +{ + /* FPU settings ------------------------------------------------------------*/ + #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) + SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */ + #endif + /* Reset the RCC clock configuration to the default reset state ------------*/ + /* Set HSION bit */ + RCC->CR |= (uint32_t)0x00000001; + + /* Reset CFGR register */ + RCC->CFGR = 0x00000000; + + /* Reset HSEON, CSSON and PLLON bits */ + RCC->CR &= (uint32_t)0xFEF6FFFF; + + /* Reset PLLCFGR register */ + RCC->PLLCFGR = 0x24003010; + + /* Reset HSEBYP bit */ + RCC->CR &= (uint32_t)0xFFFBFFFF; + + /* Disable all interrupts */ + RCC->CIR = 0x00000000; + +#if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM) + SystemInit_ExtMemCtl(); +#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */ + + /* Configure the Vector Table location add offset address ------------------*/ +#ifdef VECT_TAB_SRAM + SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ +#else + SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ +#endif +} + +/** + * @brief Update SystemCoreClock variable according to Clock Register Values. + * The SystemCoreClock variable contains the core clock (HCLK), it can + * be used by the user application to setup the SysTick timer or configure + * other parameters. + * + * @note Each time the core clock (HCLK) changes, this function must be called + * to update SystemCoreClock variable value. Otherwise, any configuration + * based on this variable will be incorrect. + * + * @note - The system frequency computed by this function is not the real + * frequency in the chip. It is calculated based on the predefined + * constant and the selected clock source: + * + * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) + * + * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) + * + * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) + * or HSI_VALUE(*) multiplied/divided by the PLL factors. + * + * (*) HSI_VALUE is a constant defined in stm32f4xx_hal_conf.h file (default value + * 16 MHz) but the real value may vary depending on the variations + * in voltage and temperature. + * + * (**) HSE_VALUE is a constant defined in stm32f4xx_hal_conf.h file (its value + * depends on the application requirements), user has to ensure that HSE_VALUE + * is same as the real frequency of the crystal used. Otherwise, this function + * may have wrong result. + * + * - The result of this function could be not correct when using fractional + * value for HSE crystal. + * + * @param None + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2; + + /* Get SYSCLK source -------------------------------------------------------*/ + tmp = RCC->CFGR & RCC_CFGR_SWS; + + switch (tmp) + { + case 0x00: /* HSI used as system clock source */ + SystemCoreClock = HSI_VALUE; + break; + case 0x04: /* HSE used as system clock source */ + SystemCoreClock = HSE_VALUE; + break; + case 0x08: /* PLL used as system clock source */ + + /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N + SYSCLK = PLL_VCO / PLL_P + */ + pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22; + pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM; + + if (pllsource != 0) + { + /* HSE used as PLL clock source */ + pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6); + } + else + { + /* HSI used as PLL clock source */ + pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6); + } + + pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2; + SystemCoreClock = pllvco/pllp; + break; + default: + SystemCoreClock = HSI_VALUE; + break; + } + /* Compute HCLK frequency --------------------------------------------------*/ + /* Get HCLK prescaler */ + tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; + /* HCLK frequency */ + SystemCoreClock >>= tmp; +} + +#if defined (DATA_IN_ExtSRAM) && defined (DATA_IN_ExtSDRAM) +#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ + || defined(STM32F469xx) || defined(STM32F479xx) +/** + * @brief Setup the external memory controller. + * Called in startup_stm32f4xx.s before jump to main. + * This function configures the external memories (SRAM/SDRAM) + * This SRAM/SDRAM will be used as program data memory (including heap and stack). + * @param None + * @retval None + */ +void SystemInit_ExtMemCtl(void) +{ + __IO uint32_t tmp = 0x00; + + register uint32_t tmpreg = 0, timeout = 0xFFFF; + register __IO uint32_t index; + + /* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface clock */ + RCC->AHB1ENR |= 0x000001F8; + + /* Delay after an RCC peripheral clock enabling */ + tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN); + + /* Connect PDx pins to FMC Alternate function */ + GPIOD->AFR[0] = 0x00CCC0CC; + GPIOD->AFR[1] = 0xCCCCCCCC; + /* Configure PDx pins in Alternate function mode */ + GPIOD->MODER = 0xAAAA0A8A; + /* Configure PDx pins speed to 100 MHz */ + GPIOD->OSPEEDR = 0xFFFF0FCF; + /* Configure PDx pins Output type to push-pull */ + GPIOD->OTYPER = 0x00000000; + /* No pull-up, pull-down for PDx pins */ + GPIOD->PUPDR = 0x00000000; + + /* Connect PEx pins to FMC Alternate function */ + GPIOE->AFR[0] = 0xC00CC0CC; + GPIOE->AFR[1] = 0xCCCCCCCC; + /* Configure PEx pins in Alternate function mode */ + GPIOE->MODER = 0xAAAA828A; + /* Configure PEx pins speed to 100 MHz */ + GPIOE->OSPEEDR = 0xFFFFC3CF; + /* Configure PEx pins Output type to push-pull */ + GPIOE->OTYPER = 0x00000000; + /* No pull-up, pull-down for PEx pins */ + GPIOE->PUPDR = 0x00000000; + + /* Connect PFx pins to FMC Alternate function */ + GPIOF->AFR[0] = 0xCCCCCCCC; + GPIOF->AFR[1] = 0xCCCCCCCC; + /* Configure PFx pins in Alternate function mode */ + GPIOF->MODER = 0xAA800AAA; + /* Configure PFx pins speed to 50 MHz */ + GPIOF->OSPEEDR = 0xAA800AAA; + /* Configure PFx pins Output type to push-pull */ + GPIOF->OTYPER = 0x00000000; + /* No pull-up, pull-down for PFx pins */ + GPIOF->PUPDR = 0x00000000; + + /* Connect PGx pins to FMC Alternate function */ + GPIOG->AFR[0] = 0xCCCCCCCC; + GPIOG->AFR[1] = 0xCCCCCCCC; + /* Configure PGx pins in Alternate function mode */ + GPIOG->MODER = 0xAAAAAAAA; + /* Configure PGx pins speed to 50 MHz */ + GPIOG->OSPEEDR = 0xAAAAAAAA; + /* Configure PGx pins Output type to push-pull */ + GPIOG->OTYPER = 0x00000000; + /* No pull-up, pull-down for PGx pins */ + GPIOG->PUPDR = 0x00000000; + + /* Connect PHx pins to FMC Alternate function */ + GPIOH->AFR[0] = 0x00C0CC00; + GPIOH->AFR[1] = 0xCCCCCCCC; + /* Configure PHx pins in Alternate function mode */ + GPIOH->MODER = 0xAAAA08A0; + /* Configure PHx pins speed to 50 MHz */ + GPIOH->OSPEEDR = 0xAAAA08A0; + /* Configure PHx pins Output type to push-pull */ + GPIOH->OTYPER = 0x00000000; + /* No pull-up, pull-down for PHx pins */ + GPIOH->PUPDR = 0x00000000; + + /* Connect PIx pins to FMC Alternate function */ + GPIOI->AFR[0] = 0xCCCCCCCC; + GPIOI->AFR[1] = 0x00000CC0; + /* Configure PIx pins in Alternate function mode */ + GPIOI->MODER = 0x0028AAAA; + /* Configure PIx pins speed to 50 MHz */ + GPIOI->OSPEEDR = 0x0028AAAA; + /* Configure PIx pins Output type to push-pull */ + GPIOI->OTYPER = 0x00000000; + /* No pull-up, pull-down for PIx pins */ + GPIOI->PUPDR = 0x00000000; + +/*-- FMC Configuration -------------------------------------------------------*/ + /* Enable the FMC interface clock */ + RCC->AHB3ENR |= 0x00000001; + /* Delay after an RCC peripheral clock enabling */ + tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN); + + FMC_Bank5_6->SDCR[0] = 0x000019E4; + FMC_Bank5_6->SDTR[0] = 0x01115351; + + /* SDRAM initialization sequence */ + /* Clock enable command */ + FMC_Bank5_6->SDCMR = 0x00000011; + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + while((tmpreg != 0) && (timeout-- > 0)) + { + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + } + + /* Delay */ + for (index = 0; index<1000; index++); + + /* PALL command */ + FMC_Bank5_6->SDCMR = 0x00000012; + timeout = 0xFFFF; + while((tmpreg != 0) && (timeout-- > 0)) + { + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + } + + /* Auto refresh command */ + FMC_Bank5_6->SDCMR = 0x00000073; + timeout = 0xFFFF; + while((tmpreg != 0) && (timeout-- > 0)) + { + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + } + + /* MRD register program */ + FMC_Bank5_6->SDCMR = 0x00046014; + timeout = 0xFFFF; + while((tmpreg != 0) && (timeout-- > 0)) + { + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + } + + /* Set refresh count */ + tmpreg = FMC_Bank5_6->SDRTR; + FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C<<1)); + + /* Disable write protection */ + tmpreg = FMC_Bank5_6->SDCR[0]; + FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF); + +#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) + /* Configure and enable Bank1_SRAM2 */ + FMC_Bank1->BTCR[2] = 0x00001011; + FMC_Bank1->BTCR[3] = 0x00000201; + FMC_Bank1E->BWTR[2] = 0x0fffffff; +#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ +#if defined(STM32F469xx) || defined(STM32F479xx) + /* Configure and enable Bank1_SRAM2 */ + FMC_Bank1->BTCR[2] = 0x00001091; + FMC_Bank1->BTCR[3] = 0x00110212; + FMC_Bank1E->BWTR[2] = 0x0fffffff; +#endif /* STM32F469xx || STM32F479xx */ + + (void)(tmp); +} +#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */ +#elif defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM) +/** + * @brief Setup the external memory controller. + * Called in startup_stm32f4xx.s before jump to main. + * This function configures the external memories (SRAM/SDRAM) + * This SRAM/SDRAM will be used as program data memory (including heap and stack). + * @param None + * @retval None + */ +void SystemInit_ExtMemCtl(void) +{ + __IO uint32_t tmp = 0x00; +#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ + || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) +#if defined (DATA_IN_ExtSDRAM) + register uint32_t tmpreg = 0, timeout = 0xFFFF; + register __IO uint32_t index; + +#if defined(STM32F446xx) + /* Enable GPIOA, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG interface + clock */ + RCC->AHB1ENR |= 0x0000007D; +#else + /* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface + clock */ + RCC->AHB1ENR |= 0x000001F8; +#endif /* STM32F446xx */ + /* Delay after an RCC peripheral clock enabling */ + tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN); + +#if defined(STM32F446xx) + /* Connect PAx pins to FMC Alternate function */ + GPIOA->AFR[0] |= 0xC0000000; + GPIOA->AFR[1] |= 0x00000000; + /* Configure PDx pins in Alternate function mode */ + GPIOA->MODER |= 0x00008000; + /* Configure PDx pins speed to 50 MHz */ + GPIOA->OSPEEDR |= 0x00008000; + /* Configure PDx pins Output type to push-pull */ + GPIOA->OTYPER |= 0x00000000; + /* No pull-up, pull-down for PDx pins */ + GPIOA->PUPDR |= 0x00000000; + + /* Connect PCx pins to FMC Alternate function */ + GPIOC->AFR[0] |= 0x00CC0000; + GPIOC->AFR[1] |= 0x00000000; + /* Configure PDx pins in Alternate function mode */ + GPIOC->MODER |= 0x00000A00; + /* Configure PDx pins speed to 50 MHz */ + GPIOC->OSPEEDR |= 0x00000A00; + /* Configure PDx pins Output type to push-pull */ + GPIOC->OTYPER |= 0x00000000; + /* No pull-up, pull-down for PDx pins */ + GPIOC->PUPDR |= 0x00000000; +#endif /* STM32F446xx */ + + /* Connect PDx pins to FMC Alternate function */ + GPIOD->AFR[0] = 0x000000CC; + GPIOD->AFR[1] = 0xCC000CCC; + /* Configure PDx pins in Alternate function mode */ + GPIOD->MODER = 0xA02A000A; + /* Configure PDx pins speed to 50 MHz */ + GPIOD->OSPEEDR = 0xA02A000A; + /* Configure PDx pins Output type to push-pull */ + GPIOD->OTYPER = 0x00000000; + /* No pull-up, pull-down for PDx pins */ + GPIOD->PUPDR = 0x00000000; + + /* Connect PEx pins to FMC Alternate function */ + GPIOE->AFR[0] = 0xC00000CC; + GPIOE->AFR[1] = 0xCCCCCCCC; + /* Configure PEx pins in Alternate function mode */ + GPIOE->MODER = 0xAAAA800A; + /* Configure PEx pins speed to 50 MHz */ + GPIOE->OSPEEDR = 0xAAAA800A; + /* Configure PEx pins Output type to push-pull */ + GPIOE->OTYPER = 0x00000000; + /* No pull-up, pull-down for PEx pins */ + GPIOE->PUPDR = 0x00000000; + + /* Connect PFx pins to FMC Alternate function */ + GPIOF->AFR[0] = 0xCCCCCCCC; + GPIOF->AFR[1] = 0xCCCCCCCC; + /* Configure PFx pins in Alternate function mode */ + GPIOF->MODER = 0xAA800AAA; + /* Configure PFx pins speed to 50 MHz */ + GPIOF->OSPEEDR = 0xAA800AAA; + /* Configure PFx pins Output type to push-pull */ + GPIOF->OTYPER = 0x00000000; + /* No pull-up, pull-down for PFx pins */ + GPIOF->PUPDR = 0x00000000; + + /* Connect PGx pins to FMC Alternate function */ + GPIOG->AFR[0] = 0xCCCCCCCC; + GPIOG->AFR[1] = 0xCCCCCCCC; + /* Configure PGx pins in Alternate function mode */ + GPIOG->MODER = 0xAAAAAAAA; + /* Configure PGx pins speed to 50 MHz */ + GPIOG->OSPEEDR = 0xAAAAAAAA; + /* Configure PGx pins Output type to push-pull */ + GPIOG->OTYPER = 0x00000000; + /* No pull-up, pull-down for PGx pins */ + GPIOG->PUPDR = 0x00000000; + +#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ + || defined(STM32F469xx) || defined(STM32F479xx) + /* Connect PHx pins to FMC Alternate function */ + GPIOH->AFR[0] = 0x00C0CC00; + GPIOH->AFR[1] = 0xCCCCCCCC; + /* Configure PHx pins in Alternate function mode */ + GPIOH->MODER = 0xAAAA08A0; + /* Configure PHx pins speed to 50 MHz */ + GPIOH->OSPEEDR = 0xAAAA08A0; + /* Configure PHx pins Output type to push-pull */ + GPIOH->OTYPER = 0x00000000; + /* No pull-up, pull-down for PHx pins */ + GPIOH->PUPDR = 0x00000000; + + /* Connect PIx pins to FMC Alternate function */ + GPIOI->AFR[0] = 0xCCCCCCCC; + GPIOI->AFR[1] = 0x00000CC0; + /* Configure PIx pins in Alternate function mode */ + GPIOI->MODER = 0x0028AAAA; + /* Configure PIx pins speed to 50 MHz */ + GPIOI->OSPEEDR = 0x0028AAAA; + /* Configure PIx pins Output type to push-pull */ + GPIOI->OTYPER = 0x00000000; + /* No pull-up, pull-down for PIx pins */ + GPIOI->PUPDR = 0x00000000; +#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */ + +/*-- FMC Configuration -------------------------------------------------------*/ + /* Enable the FMC interface clock */ + RCC->AHB3ENR |= 0x00000001; + /* Delay after an RCC peripheral clock enabling */ + tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN); + + /* Configure and enable SDRAM bank1 */ +#if defined(STM32F446xx) + FMC_Bank5_6->SDCR[0] = 0x00001954; +#else + FMC_Bank5_6->SDCR[0] = 0x000019E4; +#endif /* STM32F446xx */ + FMC_Bank5_6->SDTR[0] = 0x01115351; + + /* SDRAM initialization sequence */ + /* Clock enable command */ + FMC_Bank5_6->SDCMR = 0x00000011; + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + while((tmpreg != 0) && (timeout-- > 0)) + { + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + } + + /* Delay */ + for (index = 0; index<1000; index++); + + /* PALL command */ + FMC_Bank5_6->SDCMR = 0x00000012; + timeout = 0xFFFF; + while((tmpreg != 0) && (timeout-- > 0)) + { + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + } + + /* Auto refresh command */ +#if defined(STM32F446xx) + FMC_Bank5_6->SDCMR = 0x000000F3; +#else + FMC_Bank5_6->SDCMR = 0x00000073; +#endif /* STM32F446xx */ + timeout = 0xFFFF; + while((tmpreg != 0) && (timeout-- > 0)) + { + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + } + + /* MRD register program */ +#if defined(STM32F446xx) + FMC_Bank5_6->SDCMR = 0x00044014; +#else + FMC_Bank5_6->SDCMR = 0x00046014; +#endif /* STM32F446xx */ + timeout = 0xFFFF; + while((tmpreg != 0) && (timeout-- > 0)) + { + tmpreg = FMC_Bank5_6->SDSR & 0x00000020; + } + + /* Set refresh count */ + tmpreg = FMC_Bank5_6->SDRTR; +#if defined(STM32F446xx) + FMC_Bank5_6->SDRTR = (tmpreg | (0x0000050C<<1)); +#else + FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C<<1)); +#endif /* STM32F446xx */ + + /* Disable write protection */ + tmpreg = FMC_Bank5_6->SDCR[0]; + FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF); +#endif /* DATA_IN_ExtSDRAM */ +#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */ + +#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)\ + || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ + || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) + +#if defined(DATA_IN_ExtSRAM) +/*-- GPIOs Configuration -----------------------------------------------------*/ + /* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */ + RCC->AHB1ENR |= 0x00000078; + /* Delay after an RCC peripheral clock enabling */ + tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIODEN); + + /* Connect PDx pins to FMC Alternate function */ + GPIOD->AFR[0] = 0x00CCC0CC; + GPIOD->AFR[1] = 0xCCCCCCCC; + /* Configure PDx pins in Alternate function mode */ + GPIOD->MODER = 0xAAAA0A8A; + /* Configure PDx pins speed to 100 MHz */ + GPIOD->OSPEEDR = 0xFFFF0FCF; + /* Configure PDx pins Output type to push-pull */ + GPIOD->OTYPER = 0x00000000; + /* No pull-up, pull-down for PDx pins */ + GPIOD->PUPDR = 0x00000000; + + /* Connect PEx pins to FMC Alternate function */ + GPIOE->AFR[0] = 0xC00CC0CC; + GPIOE->AFR[1] = 0xCCCCCCCC; + /* Configure PEx pins in Alternate function mode */ + GPIOE->MODER = 0xAAAA828A; + /* Configure PEx pins speed to 100 MHz */ + GPIOE->OSPEEDR = 0xFFFFC3CF; + /* Configure PEx pins Output type to push-pull */ + GPIOE->OTYPER = 0x00000000; + /* No pull-up, pull-down for PEx pins */ + GPIOE->PUPDR = 0x00000000; + + /* Connect PFx pins to FMC Alternate function */ + GPIOF->AFR[0] = 0x00CCCCCC; + GPIOF->AFR[1] = 0xCCCC0000; + /* Configure PFx pins in Alternate function mode */ + GPIOF->MODER = 0xAA000AAA; + /* Configure PFx pins speed to 100 MHz */ + GPIOF->OSPEEDR = 0xFF000FFF; + /* Configure PFx pins Output type to push-pull */ + GPIOF->OTYPER = 0x00000000; + /* No pull-up, pull-down for PFx pins */ + GPIOF->PUPDR = 0x00000000; + + /* Connect PGx pins to FMC Alternate function */ + GPIOG->AFR[0] = 0x00CCCCCC; + GPIOG->AFR[1] = 0x000000C0; + /* Configure PGx pins in Alternate function mode */ + GPIOG->MODER = 0x00085AAA; + /* Configure PGx pins speed to 100 MHz */ + GPIOG->OSPEEDR = 0x000CAFFF; + /* Configure PGx pins Output type to push-pull */ + GPIOG->OTYPER = 0x00000000; + /* No pull-up, pull-down for PGx pins */ + GPIOG->PUPDR = 0x00000000; + +/*-- FMC/FSMC Configuration --------------------------------------------------*/ + /* Enable the FMC/FSMC interface clock */ + RCC->AHB3ENR |= 0x00000001; + +#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) + /* Delay after an RCC peripheral clock enabling */ + tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN); + /* Configure and enable Bank1_SRAM2 */ + FMC_Bank1->BTCR[2] = 0x00001011; + FMC_Bank1->BTCR[3] = 0x00000201; + FMC_Bank1E->BWTR[2] = 0x0fffffff; +#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ +#if defined(STM32F469xx) || defined(STM32F479xx) + /* Delay after an RCC peripheral clock enabling */ + tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN); + /* Configure and enable Bank1_SRAM2 */ + FMC_Bank1->BTCR[2] = 0x00001091; + FMC_Bank1->BTCR[3] = 0x00110212; + FMC_Bank1E->BWTR[2] = 0x0fffffff; +#endif /* STM32F469xx || STM32F479xx */ +#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx)\ + || defined(STM32F412Zx) || defined(STM32F412Vx) + /* Delay after an RCC peripheral clock enabling */ + tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FSMCEN); + /* Configure and enable Bank1_SRAM2 */ + FSMC_Bank1->BTCR[2] = 0x00001011; + FSMC_Bank1->BTCR[3] = 0x00000201; + FSMC_Bank1E->BWTR[2] = 0x0FFFFFFF; +#endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx */ + +#endif /* DATA_IN_ExtSRAM */ +#endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx ||\ + STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx */ + (void)(tmp); +} +#endif /* DATA_IN_ExtSRAM && DATA_IN_ExtSDRAM */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedalMkII/Src/usb_device.c b/OwlPedalMkII/Src/usb_device.c new file mode 100644 index 00000000..95ded99c --- /dev/null +++ b/OwlPedalMkII/Src/usb_device.c @@ -0,0 +1,100 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usb_device.c + * @version : v1.0_Cube + * @brief : This file implements the USB Device + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ + +#include "usb_device.h" +#include "usbd_core.h" +#include "usbd_desc.h" +#include "usbd_audio.h" + +/* USER CODE BEGIN Includes */ +/* USER CODE END Includes */ + +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +/* USER CODE BEGIN PFP */ +/* Private function prototypes -----------------------------------------------*/ + +/* USER CODE END PFP */ + +/* USB Device Core handle declaration. */ +USBD_HandleTypeDef hUsbDeviceFS; + +/* + * -- Insert your variables declaration here -- + */ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* + * -- Insert your external function declaration here -- + */ +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ + +/** + * Init USB device Library, add supported class and start the library + * @retval None + */ +void MX_USB_DEVICE_Init(void) +{ + /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */ + + /* USER CODE END USB_DEVICE_Init_PreTreatment */ + + /* Init Device Library, add supported class and start the library. */ + if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK) + { + Error_Handler(); + } + if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_AUDIO) != USBD_OK) + { + Error_Handler(); + } + if (USBD_AUDIO_RegisterInterface(&hUsbDeviceFS, NULL) != USBD_OK) + { + Error_Handler(); + } + if (USBD_Start(&hUsbDeviceFS) != USBD_OK) + { + Error_Handler(); + } + + /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */ + + /* USER CODE END USB_DEVICE_Init_PostTreatment */ +} + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedalMkII/Src/usbd_conf.c b/OwlPedalMkII/Src/usbd_conf.c new file mode 100644 index 00000000..f8a8c35c --- /dev/null +++ b/OwlPedalMkII/Src/usbd_conf.c @@ -0,0 +1,656 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usbd_conf.c + * @version : v1.0_Cube + * @brief : This file implements the board support package for the USB device library + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32f4xx.h" +#include "stm32f4xx_hal.h" +#include "usbd_def.h" +#include "usbd_core.h" + +/* USER CODE BEGIN Includes */ +#include "device.h" +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ + +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +PCD_HandleTypeDef hpcd_USB_OTG_FS; +void Error_Handler(void); + +/* External functions --------------------------------------------------------*/ +void SystemClock_Config(void); + +/* USER CODE BEGIN 0 */ +/* USER CODE END 0 */ + +/* USER CODE BEGIN PFP */ +/* Private function prototypes -----------------------------------------------*/ + +USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status); + +/* USER CODE END PFP */ + +/* Private functions ---------------------------------------------------------*/ + +/* USER CODE BEGIN 1 */ +/* USER CODE END 1 */ + +/******************************************************************************* + LL Driver Callbacks (PCD -> USB Device Library) +*******************************************************************************/ +/* MSP Init */ + +void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(pcdHandle->Instance==USB_OTG_FS) + { + /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */ + + /* USER CODE END USB_OTG_FS_MspInit 0 */ + + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**USB_OTG_FS GPIO Configuration + PA9 ------> USB_OTG_FS_VBUS + PA11 ------> USB_OTG_FS_DM + PA12 ------> USB_OTG_FS_DP + */ + GPIO_InitStruct.Pin = GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* Peripheral clock enable */ + __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); + + /* Peripheral interrupt init */ + HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(OTG_FS_IRQn); + /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */ + + /* USER CODE END USB_OTG_FS_MspInit 1 */ + } +} + +void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) +{ + if(pcdHandle->Instance==USB_OTG_FS) + { + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */ + + /* USER CODE END USB_OTG_FS_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); + + /**USB_OTG_FS GPIO Configuration + PA9 ------> USB_OTG_FS_VBUS + PA11 ------> USB_OTG_FS_DM + PA12 ------> USB_OTG_FS_DP + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_12); + + /* Peripheral interrupt Deinit*/ + HAL_NVIC_DisableIRQ(OTG_FS_IRQn); + + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */ + + /* USER CODE END USB_OTG_FS_MspDeInit 1 */ + } +} + +/** + * @brief Setup stage callback + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_SetupStage((USBD_HandleTypeDef*)hpcd->pData, (uint8_t *)hpcd->Setup); +} + +/** + * @brief Data Out stage callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#else +void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_DataOutStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff); +} + +/** + * @brief Data In stage callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#else +void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_DataInStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff); +} + +/** + * @brief SOF callback. + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_SOFCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_SOF((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief Reset callback. + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ResetCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_SpeedTypeDef speed = USBD_SPEED_FULL; + + if ( hpcd->Init.speed == PCD_SPEED_HIGH) + { + speed = USBD_SPEED_HIGH; + } + else if ( hpcd->Init.speed == PCD_SPEED_FULL) + { + speed = USBD_SPEED_FULL; + } + else + { + Error_Handler(); + } + /* Set Speed. */ + USBD_LL_SetSpeed((USBD_HandleTypeDef*)hpcd->pData, speed); + + /* Reset Device. */ + USBD_LL_Reset((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief Suspend callback. + * When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it) + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + /* Inform USB library that core enters in suspend Mode. */ + USBD_LL_Suspend((USBD_HandleTypeDef*)hpcd->pData); + __HAL_PCD_GATE_PHYCLOCK(hpcd); + /* Enter in STOP mode. */ + /* USER CODE BEGIN 2 */ + if (hpcd->Init.low_power_enable) + { + /* Set SLEEPDEEP bit and SleepOnExit of Cortex System Control Register */ + SCB->SCR |= (uint32_t)((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk)); + } + /* USER CODE END 2 */ +} + +/** + * @brief Resume callback. + * When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it) + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + /* USER CODE BEGIN 3 */ + /* USER CODE END 3 */ + USBD_LL_Resume((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief ISOOUTIncomplete callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#else +void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_IsoOUTIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); +} + +/** + * @brief ISOINIncomplete callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#else +void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_IsoINIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); +} + +/** + * @brief Connect callback. + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_DevConnected((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief Disconnect callback. + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_DevDisconnected((USBD_HandleTypeDef*)hpcd->pData); +} + +/******************************************************************************* + LL Driver Interface (USB Device Library --> PCD) +*******************************************************************************/ + +/** + * @brief Initializes the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) +{ + /* Init USB Ip. */ + if (pdev->id == DEVICE_FS) { + /* Link the driver to the stack. */ + hpcd_USB_OTG_FS.pData = pdev; + pdev->pData = &hpcd_USB_OTG_FS; + + hpcd_USB_OTG_FS.Instance = USB_OTG_FS; + hpcd_USB_OTG_FS.Init.dev_endpoints = 4; + hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; + hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; + hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; + hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; + hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; + hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; + hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE; + hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE; + if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) + { + Error_Handler( ); + } + +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) + /* Register USB PCD CallBacks */ + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SOF_CB_ID, PCD_SOFCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SETUPSTAGE_CB_ID, PCD_SetupStageCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESET_CB_ID, PCD_ResetCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SUSPEND_CB_ID, PCD_SuspendCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESUME_CB_ID, PCD_ResumeCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_CONNECT_CB_ID, PCD_ConnectCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_DISCONNECT_CB_ID, PCD_DisconnectCallback); + + HAL_PCD_RegisterDataOutStageCallback(&hpcd_USB_OTG_FS, PCD_DataOutStageCallback); + HAL_PCD_RegisterDataInStageCallback(&hpcd_USB_OTG_FS, PCD_DataInStageCallback); + HAL_PCD_RegisterIsoOutIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOOUTIncompleteCallback); + HAL_PCD_RegisterIsoInIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOINIncompleteCallback); +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +#ifdef USE_USBD_AUDIO_TX + HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_FS, 0x80); + HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x20); + HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x60); + HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 2, 0x40); +#else + HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_FS, 0xa0); + HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x40); + HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x60); +#endif + /* total 0x140 words available for rx and tx fifos */ + } + return USBD_OK; +} + +/** + * @brief De-Initializes the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_DeInit(pdev->pData); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Starts the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_Start(pdev->pData); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Stops the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_Stop(pdev->pData); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Opens an endpoint of the low level driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @param ep_type: Endpoint type + * @param ep_mps: Endpoint max packet size + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Open(pdev->pData, ep_addr, ep_mps, ep_type); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Closes an endpoint of the low level driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Close(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Flushes an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Flush(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Sets a Stall condition on an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_SetStall(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Clears a Stall condition on an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_ClrStall(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Returns Stall condition. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval Stall (1: Yes, 0: No) + */ +uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef*) pdev->pData; + + if((ep_addr & 0x80) == 0x80) + { + return hpcd->IN_ep[ep_addr & 0x7F].is_stall; + } + else + { + return hpcd->OUT_ep[ep_addr & 0x7F].is_stall; + } +} + +/** + * @brief Assigns a USB address to the device. + * @param pdev: Device handle + * @param dev_addr: Device address + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_SetAddress(pdev->pData, dev_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Transmits data over an endpoint. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @param pbuf: Pointer to data to be sent + * @param size: Data size + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Transmit(pdev->pData, ep_addr, pbuf, size); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Prepares an endpoint for reception. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @param pbuf: Pointer to data to be received + * @param size: Data size + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Receive(pdev->pData, ep_addr, pbuf, size); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Returns the last transfered packet size. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval Recived Data Size + */ +uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef*) pdev->pData, ep_addr); +} + +/** + * @brief Delays routine for the USB Device Library. + * @param Delay: Delay in ms + * @retval None + */ +void USBD_LL_Delay(uint32_t Delay) +{ + HAL_Delay(Delay); +} + +/** + * @brief Retuns the USB status depending on the HAL status: + * @param hal_status: HAL status + * @retval USB status + */ +USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status) +{ + USBD_StatusTypeDef usb_status = USBD_OK; + + switch (hal_status) + { + case HAL_OK : + usb_status = USBD_OK; + break; + case HAL_ERROR : + usb_status = USBD_FAIL; + break; + case HAL_BUSY : + usb_status = USBD_BUSY; + break; + case HAL_TIMEOUT : + usb_status = USBD_FAIL; + break; + default : + usb_status = USBD_FAIL; + break; + } + return usb_status; +} + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedalMkII/Src/usbd_desc.c b/OwlPedalMkII/Src/usbd_desc.c new file mode 100644 index 00000000..6a4b7740 --- /dev/null +++ b/OwlPedalMkII/Src/usbd_desc.c @@ -0,0 +1,445 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usbd_desc.c + * @version : v1.0_Cube + * @brief : This file implements the USB device descriptors. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "usbd_core.h" +#include "usbd_desc.h" +#include "usbd_conf.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ + +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY + * @{ + */ + +/** @addtogroup USBD_DESC + * @{ + */ + +/** @defgroup USBD_DESC_Private_TypesDefinitions USBD_DESC_Private_TypesDefinitions + * @brief Private types. + * @{ + */ + +/* USER CODE BEGIN PRIVATE_TYPES */ + +/* USER CODE END PRIVATE_TYPES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Defines USBD_DESC_Private_Defines + * @brief Private defines. + * @{ + */ + +#define USBD_VID 0x1209 +#define USBD_LANGID_STRING 1033 +#define USBD_MANUFACTURER_STRING "Rebel Technology" +#define USBD_PID_FS 0xdada +#define USBD_PRODUCT_STRING_FS "OWL-PEDAL" +#define USBD_CONFIGURATION_STRING_FS "AUDIO Config" +#define USBD_INTERFACE_STRING_FS "AUDIO Interface" + +#define USB_SIZ_BOS_DESC 0x0C + +/* USER CODE BEGIN PRIVATE_DEFINES */ + +/* USER CODE END PRIVATE_DEFINES */ + +/** + * @} + */ + +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/** @defgroup USBD_DESC_Private_Macros USBD_DESC_Private_Macros + * @brief Private macros. + * @{ + */ + +/* USER CODE BEGIN PRIVATE_MACRO */ + +/* USER CODE END PRIVATE_MACRO */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes + * @brief Private functions declaration. + * @{ + */ + +static void Get_SerialNum(void); +static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len); + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes + * @brief Private functions declaration for FS. + * @{ + */ + +uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +#if (USBD_LPM_ENABLED == 1) +uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +#endif /* (USBD_LPM_ENABLED == 1) */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables + * @brief Private variables. + * @{ + */ + +USBD_DescriptorsTypeDef FS_Desc = +{ + USBD_FS_DeviceDescriptor +, USBD_FS_LangIDStrDescriptor +, USBD_FS_ManufacturerStrDescriptor +, USBD_FS_ProductStrDescriptor +, USBD_FS_SerialStrDescriptor +, USBD_FS_ConfigStrDescriptor +, USBD_FS_InterfaceStrDescriptor +#if (USBD_LPM_ENABLED == 1) +, USBD_FS_USR_BOSDescriptor +#endif /* (USBD_LPM_ENABLED == 1) */ +}; + +#if defined ( __ICCARM__ ) /* IAR Compiler */ + #pragma data_alignment=4 +#endif /* defined ( __ICCARM__ ) */ +/** USB standard device descriptor. */ +__ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = +{ + 0x12, /*bLength */ + USB_DESC_TYPE_DEVICE, /*bDescriptorType*/ +#if (USBD_LPM_ENABLED == 1) + 0x01, /*bcdUSB */ /* changed to USB version 2.01 + in order to support LPM L1 suspend + resume test of USBCV3.0*/ +#else + 0x00, /*bcdUSB */ +#endif /* (USBD_LPM_ENABLED == 1) */ + 0x02, + 0x00, /*bDeviceClass*/ + 0x00, /*bDeviceSubClass*/ + 0x00, /*bDeviceProtocol*/ + USB_MAX_EP0_SIZE, /*bMaxPacketSize*/ + LOBYTE(USBD_VID), /*idVendor*/ + HIBYTE(USBD_VID), /*idVendor*/ + LOBYTE(USBD_PID_FS), /*idProduct*/ + HIBYTE(USBD_PID_FS), /*idProduct*/ + 0x00, /*bcdDevice rel. 2.00*/ + 0x02, + USBD_IDX_MFC_STR, /*Index of manufacturer string*/ + USBD_IDX_PRODUCT_STR, /*Index of product string*/ + USBD_IDX_SERIAL_STR, /*Index of serial number string*/ + USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/ +}; + +/* USB_DeviceDescriptor */ +/** BOS descriptor. */ +#if (USBD_LPM_ENABLED == 1) +#if defined ( __ICCARM__ ) /* IAR Compiler */ + #pragma data_alignment=4 +#endif /* defined ( __ICCARM__ ) */ +__ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = +{ + 0x5, + USB_DESC_TYPE_BOS, + 0xC, + 0x0, + 0x1, /* 1 device capability*/ + /* device capability*/ + 0x7, + USB_DEVICE_CAPABITY_TYPE, + 0x2, + 0x2, /* LPM capability bit set*/ + 0x0, + 0x0, + 0x0 +}; +#endif /* (USBD_LPM_ENABLED == 1) */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables + * @brief Private variables. + * @{ + */ + +#if defined ( __ICCARM__ ) /* IAR Compiler */ + #pragma data_alignment=4 +#endif /* defined ( __ICCARM__ ) */ + +/** USB lang indentifier descriptor. */ +__ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = +{ + USB_LEN_LANGID_STR_DESC, + USB_DESC_TYPE_STRING, + LOBYTE(USBD_LANGID_STRING), + HIBYTE(USBD_LANGID_STRING) +}; + +#if defined ( __ICCARM__ ) /* IAR Compiler */ + #pragma data_alignment=4 +#endif /* defined ( __ICCARM__ ) */ +/* Internal string descriptor. */ +__ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END; + +#if defined ( __ICCARM__ ) /*!< IAR Compiler */ + #pragma data_alignment=4 +#endif +__ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { + USB_SIZ_STRING_SERIAL, + USB_DESC_TYPE_STRING, +}; + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Functions USBD_DESC_Private_Functions + * @brief Private functions. + * @{ + */ + +/** + * @brief Return the device descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = sizeof(USBD_FS_DeviceDesc); + return USBD_FS_DeviceDesc; +} + +/** + * @brief Return the LangID string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = sizeof(USBD_LangIDDesc); + return USBD_LangIDDesc; +} + +/** + * @brief Return the product string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == 0) + { + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +/** + * @brief Return the manufacturer string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length); + return USBD_StrDesc; +} + +/** + * @brief Return the serial number string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = USB_SIZ_STRING_SERIAL; + + /* Update the serial number string descriptor with the data from the unique + * ID */ + Get_SerialNum(); + /* USER CODE BEGIN USBD_FS_SerialStrDescriptor */ + + /* USER CODE END USBD_FS_SerialStrDescriptor */ + return (uint8_t *) USBD_StringSerial; +} + +/** + * @brief Return the configuration string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == USBD_SPEED_HIGH) + { + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +/** + * @brief Return the interface string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == 0) + { + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +#if (USBD_LPM_ENABLED == 1) +/** + * @brief Return the BOS descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = sizeof(USBD_FS_BOSDesc); + return (uint8_t*)USBD_FS_BOSDesc; +} +#endif /* (USBD_LPM_ENABLED == 1) */ + +/** + * @brief Create the serial number string descriptor + * @param None + * @retval None + */ +static void Get_SerialNum(void) +{ + uint32_t deviceserial0, deviceserial1, deviceserial2; + + deviceserial0 = *(uint32_t *) DEVICE_ID1; + deviceserial1 = *(uint32_t *) DEVICE_ID2; + deviceserial2 = *(uint32_t *) DEVICE_ID3; + + deviceserial0 += deviceserial2; + + if (deviceserial0 != 0) + { + IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8); + IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4); + } +} + +/** + * @brief Convert Hex 32Bits value into char + * @param value: value to convert + * @param pbuf: pointer to the buffer + * @param len: buffer length + * @retval None + */ +static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len) +{ + uint8_t idx = 0; + + for (idx = 0; idx < len; idx++) + { + if (((value >> 28)) < 0xA) + { + pbuf[2 * idx] = (value >> 28) + '0'; + } + else + { + pbuf[2 * idx] = (value >> 28) + 'A' - 10; + } + + value = value << 4; + + pbuf[2 * idx + 1] = 0; + } +} +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ From ca7781eb8de4a821a2da1ca005e5c461de1deb68 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 13 Oct 2020 14:27:31 +0200 Subject: [PATCH 012/286] renamed subproject --- OwlPedal2/Inc/FreeRTOSConfig.h | 181 ------- OwlPedal2/Inc/hardware.h | 48 -- OwlPedal2/Inc/main.h | 157 ------ OwlPedal2/Inc/stm32f4xx_hal_conf.h | 443 ---------------- OwlPedal2/Inc/stm32f4xx_it.h | 83 --- OwlPedal2/Inc/usb_device.h | 105 ---- OwlPedal2/Inc/usbd_conf.h | 180 ------- OwlPedal2/Inc/usbd_desc.h | 145 ----- OwlPedal2/Makefile | 27 - OwlPedal2/OwlPedal2.ioc | 598 --------------------- OwlPedal2/Src/freertos.c | 136 ----- OwlPedal2/Src/main.c | 793 ---------------------------- OwlPedal2/Src/startup_stm32f427xx.s | 553 ------------------- OwlPedal2/Src/stm32f4xx_hal_msp.c | 739 -------------------------- OwlPedal2/Src/stm32f4xx_it.c | 221 -------- OwlPedal2/Src/system_stm32f4xx.c | 763 -------------------------- OwlPedal2/Src/usb_device.c | 100 ---- OwlPedal2/Src/usbd_conf.c | 656 ----------------------- OwlPedal2/Src/usbd_desc.c | 446 ---------------- 19 files changed, 6374 deletions(-) delete mode 100644 OwlPedal2/Inc/FreeRTOSConfig.h delete mode 100644 OwlPedal2/Inc/hardware.h delete mode 100644 OwlPedal2/Inc/main.h delete mode 100644 OwlPedal2/Inc/stm32f4xx_hal_conf.h delete mode 100644 OwlPedal2/Inc/stm32f4xx_it.h delete mode 100644 OwlPedal2/Inc/usb_device.h delete mode 100644 OwlPedal2/Inc/usbd_conf.h delete mode 100644 OwlPedal2/Inc/usbd_desc.h delete mode 100644 OwlPedal2/Makefile delete mode 100644 OwlPedal2/OwlPedal2.ioc delete mode 100644 OwlPedal2/Src/freertos.c delete mode 100644 OwlPedal2/Src/main.c delete mode 100644 OwlPedal2/Src/startup_stm32f427xx.s delete mode 100644 OwlPedal2/Src/stm32f4xx_hal_msp.c delete mode 100644 OwlPedal2/Src/stm32f4xx_it.c delete mode 100644 OwlPedal2/Src/system_stm32f4xx.c delete mode 100644 OwlPedal2/Src/usb_device.c delete mode 100644 OwlPedal2/Src/usbd_conf.c delete mode 100644 OwlPedal2/Src/usbd_desc.c diff --git a/OwlPedal2/Inc/FreeRTOSConfig.h b/OwlPedal2/Inc/FreeRTOSConfig.h deleted file mode 100644 index 79a1b42a..00000000 --- a/OwlPedal2/Inc/FreeRTOSConfig.h +++ /dev/null @@ -1,181 +0,0 @@ -/* USER CODE BEGIN Header */ -/* - FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS 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. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ -/* USER CODE END Header */ - -#ifndef FREERTOS_CONFIG_H -#define FREERTOS_CONFIG_H - -/*----------------------------------------------------------- - * Application specific definitions. - * - * These definitions should be adjusted for your particular hardware and - * application requirements. - * - * These parameters and more are described within the 'configuration' section of the - * FreeRTOS API documentation available on the FreeRTOS.org web site. - * - * See http://www.freertos.org/a00110.html - *----------------------------------------------------------*/ - -/* USER CODE BEGIN Includes */ - -#include "device.h" -#ifdef DEBUG_STACK -#define configUSE_TRACE_FACILITY 1 -#define INCLUDE_uxTaskGetStackHighWaterMark 1 -#endif /* DEBUG_STACK */ - -/* USER CODE END Includes */ - -/* Ensure definitions are only used by the compiler, and not by the assembler. */ -#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) - #include - extern uint32_t SystemCoreClock; - void xPortSysTickHandler(void); -#endif -#define configUSE_PREEMPTION 0 -#define configSUPPORT_STATIC_ALLOCATION 1 -#define configSUPPORT_DYNAMIC_ALLOCATION 1 -#define configUSE_IDLE_HOOK 0 -#define configUSE_TICK_HOOK 0 -#define configCPU_CLOCK_HZ ( SystemCoreClock ) -#define configTICK_RATE_HZ ((TickType_t)1000) -#define configMAX_PRIORITIES ( 7 ) -#define configMINIMAL_STACK_SIZE ((uint16_t)128) -#define configTOTAL_HEAP_SIZE ((size_t)8192) -#define configMAX_TASK_NAME_LEN ( 16 ) -#define configUSE_16_BIT_TICKS 0 -#define configQUEUE_REGISTRY_SIZE 8 -#define configCHECK_FOR_STACK_OVERFLOW 2 -#define configUSE_MALLOC_FAILED_HOOK 1 -#define configENABLE_BACKWARD_COMPATIBILITY 0 -#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 - -/* Co-routine definitions. */ -#define configUSE_CO_ROUTINES 0 -#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) - -/* Set the following definitions to 1 to include the API function, or zero -to exclude the API function. */ -#define INCLUDE_vTaskPrioritySet 1 -#define INCLUDE_uxTaskPriorityGet 1 -#define INCLUDE_vTaskDelete 1 -#define INCLUDE_vTaskCleanUpResources 0 -#define INCLUDE_vTaskSuspend 1 -#define INCLUDE_vTaskDelayUntil 1 -#define INCLUDE_vTaskDelay 1 -#define INCLUDE_xTaskGetSchedulerState 1 - -/* Cortex-M specific definitions. */ -#ifdef __NVIC_PRIO_BITS - /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */ - #define configPRIO_BITS __NVIC_PRIO_BITS -#else - #define configPRIO_BITS 4 -#endif - -/* The lowest interrupt priority that can be used in a call to a "set priority" -function. */ -#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15 - -/* The highest interrupt priority that can be used by any interrupt service -routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL -INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER -PRIORITY THAN THIS! (higher priorities are lower numeric values. */ -#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5 - -/* Interrupt priorities used by the kernel port layer itself. These are generic -to all Cortex-M ports, and do not rely on any particular library functions. */ -#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) -/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!! -See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ -#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) - -/* Normal assert() semantics without relying on the provision of an assert.h -header file. */ -/* USER CODE BEGIN 1 */ -#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );} -/* USER CODE END 1 */ - -/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS -standard names. */ -#define vPortSVCHandler SVC_Handler -#define xPortPendSVHandler PendSV_Handler - -/* IMPORTANT: This define is commented when used with STM32Cube firmware, when the timebase source is SysTick, - to prevent overwriting SysTick_Handler defined within STM32Cube HAL */ - -/* #define xPortSysTickHandler SysTick_Handler */ - -/* USER CODE BEGIN Defines */ -/* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */ -/* USER CODE END Defines */ - -#endif /* FREERTOS_CONFIG_H */ diff --git a/OwlPedal2/Inc/hardware.h b/OwlPedal2/Inc/hardware.h deleted file mode 100644 index 22bb8627..00000000 --- a/OwlPedal2/Inc/hardware.h +++ /dev/null @@ -1,48 +0,0 @@ -#include "main.h" -#include "stm32f4xx_hal.h" - -#define DEBUG_STACK - -#define OWL_PEDAL_MKII -#define HARDWARE_ID OWL_PEDAL_HARDWARE -#define HARDWARE_VERSION "OWL Pedal mkII" - -#define USE_USBD_AUDIO -#define USE_USBD_AUDIO_TX // microphone -#define USE_USBD_AUDIO_RX // speaker -#define USE_USBD_MIDI -#define USE_USBD_FS -#define USBD_HANDLE hUsbDeviceFS - -/* USB audio settings */ -#define AUDIO_BITS_PER_SAMPLE 16 -#define AUDIO_BYTES_PER_SAMPLE (AUDIO_BITS_PER_SAMPLE/8) -#define AUDIO_CHANNELS 2 -#define USB_AUDIO_CHANNELS 2 -/* #define AUDIO_INT32_TO_SAMPLE(x) (__REV16((x)>>8)) */ -/* #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(__REV16(x))<<8) */ -#define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) -#define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) - -#define USE_BKPSRAM - -/* #define USE_MODE_BUTTON */ -/* #define MODE_BUTTON_PIN SW3_Pin */ -/* #define MODE_BUTTON_PORT SW3_GPIO_Port */ -/* #define MODE_BUTTON_GAIN ADC_C */ -/* #define MODE_BUTTON_PATCH ADC_D */ - -#define USE_ADC -#define ADC_PERIPH hadc3 -#define ADC_A 0 -#define ADC_B 1 -#define ADC_C 2 -#define ADC_D 3 -#define USE_CODEC -#define USE_CS4271 -#define CODEC_HP_FILTER -#define CODEC_SPI hspi4 - -#define NOF_ADC_VALUES 4 -#define NOF_PARAMETERS 40 -#define NOF_BUTTONS (2+4) diff --git a/OwlPedal2/Inc/main.h b/OwlPedal2/Inc/main.h deleted file mode 100644 index 0a912e90..00000000 --- a/OwlPedal2/Inc/main.h +++ /dev/null @@ -1,157 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : main.h - * @brief : Header for main.c file. - * This file contains the common defines of the application. - ****************************************************************************** - * This notice applies to any and all portions of this file - * that are not between comment pairs USER CODE BEGIN and - * USER CODE END. Other portions of this file, whether - * inserted by the user or by software development tools - * are owned by their respective copyright owners. - * - * Copyright (c) 2019 STMicroelectronics International N.V. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted, provided that the following conditions are met: - * - * 1. Redistribution of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of other - * contributors to this software may be used to endorse or promote products - * derived from this software without specific written permission. - * 4. This software, including modifications and/or derivative works of this - * software, must execute solely and exclusively on microcontroller or - * microprocessor devices manufactured by or for STMicroelectronics. - * 5. Redistribution and use of this software other than as permitted under - * this license is void and will automatically terminate your rights under - * this license. - * - * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY - * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT - * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __MAIN_H -#define __MAIN_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Exported types ------------------------------------------------------------*/ -/* USER CODE BEGIN ET */ - -/* USER CODE END ET */ - -/* Exported constants --------------------------------------------------------*/ -/* USER CODE BEGIN EC */ - -/* USER CODE END EC */ - -/* Exported macro ------------------------------------------------------------*/ -/* USER CODE BEGIN EM */ - -/* USER CODE END EM */ - -/* Exported functions prototypes ---------------------------------------------*/ -void Error_Handler(void); - -/* USER CODE BEGIN EFP */ - -/* USER CODE END EFP */ - -/* Private defines -----------------------------------------------------------*/ -#define CS_SCK_Pin GPIO_PIN_2 -#define CS_SCK_GPIO_Port GPIOE -#define CS_SDOUT_Pin GPIO_PIN_3 -#define CS_SDOUT_GPIO_Port GPIOE -#define CS_LRCK_Pin GPIO_PIN_4 -#define CS_LRCK_GPIO_Port GPIOE -#define CS_SCKE5_Pin GPIO_PIN_5 -#define CS_SCKE5_GPIO_Port GPIOE -#define CS_SDA_Pin GPIO_PIN_6 -#define CS_SDA_GPIO_Port GPIOE -#define EXTSPI_nCS_Pin GPIO_PIN_15 -#define EXTSPI_nCS_GPIO_Port GPIOC -#define ADC4_Pin GPIO_PIN_10 -#define ADC4_GPIO_Port GPIOF -#define ADC3_Pin GPIO_PIN_1 -#define ADC3_GPIO_Port GPIOC -#define ADC2_Pin GPIO_PIN_2 -#define ADC2_GPIO_Port GPIOC -#define ADC1_Pin GPIO_PIN_3 -#define ADC1_GPIO_Port GPIOC -#define FLASH_MISO_Pin GPIO_PIN_6 -#define FLASH_MISO_GPIO_Port GPIOA -#define FLASH_MOSI_Pin GPIO_PIN_7 -#define FLASH_MOSI_GPIO_Port GPIOA -#define FLASH_HOLD_Pin GPIO_PIN_4 -#define FLASH_HOLD_GPIO_Port GPIOC -#define FLASH_nCS_Pin GPIO_PIN_5 -#define FLASH_nCS_GPIO_Port GPIOC -#define SW2_Pin GPIO_PIN_2 -#define SW2_GPIO_Port GPIOB -#define SW2_EXTI_IRQn EXTI2_IRQn -#define CS_nCS_Pin GPIO_PIN_10 -#define CS_nCS_GPIO_Port GPIOB -#define CS_nRST_Pin GPIO_PIN_11 -#define CS_nRST_GPIO_Port GPIOB -#define USBD_VBUS_Pin GPIO_PIN_9 -#define USBD_VBUS_GPIO_Port GPIOA -#define USBD_DM_Pin GPIO_PIN_11 -#define USBD_DM_GPIO_Port GPIOA -#define USBD_DP_Pin GPIO_PIN_12 -#define USBD_DP_GPIO_Port GPIOA -#define CS_SDIN_Pin GPIO_PIN_6 -#define CS_SDIN_GPIO_Port GPIOD -#define FLASH_SCK_Pin GPIO_PIN_3 -#define FLASH_SCK_GPIO_Port GPIOB -#define SW3_Pin GPIO_PIN_8 -#define SW3_GPIO_Port GPIOB -#define SW3_EXTI_IRQn EXTI9_5_IRQn -#define SW1_Pin GPIO_PIN_9 -#define SW1_GPIO_Port GPIOB -#define SW1_EXTI_IRQn EXTI9_5_IRQn -/* USER CODE BEGIN Private defines */ - -#define CS_CS_Pin GPIO_PIN_10 -#define CS_CS_GPIO_Port GPIOB -#define CS_RST_Pin GPIO_PIN_11 -#define CS_RST_GPIO_Port GPIOB - -/* USER CODE END Private defines */ - -#ifdef __cplusplus -} -#endif - -#endif /* __MAIN_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Inc/stm32f4xx_hal_conf.h b/OwlPedal2/Inc/stm32f4xx_hal_conf.h deleted file mode 100644 index e1a6d820..00000000 --- a/OwlPedal2/Inc/stm32f4xx_hal_conf.h +++ /dev/null @@ -1,443 +0,0 @@ -/** - ****************************************************************************** - * @file stm32f4xx_hal_conf_template.h - * @author MCD Application Team - * @brief HAL configuration template file. - * This file should be copied to the application folder and renamed - * to stm32f4xx_hal_conf.h. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2017 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F4xx_HAL_CONF_H -#define __STM32F4xx_HAL_CONF_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ - -/* ########################## Module Selection ############################## */ -/** - * @brief This is the list of modules to be used in the HAL driver - */ -#define HAL_MODULE_ENABLED - - #define HAL_ADC_MODULE_ENABLED -/* #define HAL_CRYP_MODULE_ENABLED */ -/* #define HAL_CAN_MODULE_ENABLED */ -/* #define HAL_CRC_MODULE_ENABLED */ -/* #define HAL_CRYP_MODULE_ENABLED */ -/* #define HAL_DAC_MODULE_ENABLED */ -/* #define HAL_DCMI_MODULE_ENABLED */ -/* #define HAL_DMA2D_MODULE_ENABLED */ -/* #define HAL_ETH_MODULE_ENABLED */ -/* #define HAL_NAND_MODULE_ENABLED */ -/* #define HAL_NOR_MODULE_ENABLED */ -/* #define HAL_PCCARD_MODULE_ENABLED */ -/* #define HAL_SRAM_MODULE_ENABLED */ -#define HAL_SDRAM_MODULE_ENABLED -/* #define HAL_HASH_MODULE_ENABLED */ -/* #define HAL_I2C_MODULE_ENABLED */ -/* #define HAL_I2S_MODULE_ENABLED */ -/* #define HAL_IWDG_MODULE_ENABLED */ -/* #define HAL_LTDC_MODULE_ENABLED */ -/* #define HAL_RNG_MODULE_ENABLED */ -#define HAL_RTC_MODULE_ENABLED -#define HAL_SAI_MODULE_ENABLED -/* #define HAL_SD_MODULE_ENABLED */ -/* #define HAL_MMC_MODULE_ENABLED */ -#define HAL_SPI_MODULE_ENABLED -/* #define HAL_TIM_MODULE_ENABLED */ -/* #define HAL_UART_MODULE_ENABLED */ -/* #define HAL_USART_MODULE_ENABLED */ -/* #define HAL_IRDA_MODULE_ENABLED */ -/* #define HAL_SMARTCARD_MODULE_ENABLED */ -/* #define HAL_SMBUS_MODULE_ENABLED */ -/* #define HAL_WWDG_MODULE_ENABLED */ -#define HAL_PCD_MODULE_ENABLED -/* #define HAL_HCD_MODULE_ENABLED */ -/* #define HAL_DSI_MODULE_ENABLED */ -/* #define HAL_QSPI_MODULE_ENABLED */ -/* #define HAL_QSPI_MODULE_ENABLED */ -/* #define HAL_CEC_MODULE_ENABLED */ -/* #define HAL_FMPI2C_MODULE_ENABLED */ -/* #define HAL_SPDIFRX_MODULE_ENABLED */ -/* #define HAL_DFSDM_MODULE_ENABLED */ -/* #define HAL_LPTIM_MODULE_ENABLED */ -#define HAL_GPIO_MODULE_ENABLED -#define HAL_EXTI_MODULE_ENABLED -#define HAL_DMA_MODULE_ENABLED -#define HAL_RCC_MODULE_ENABLED -#define HAL_FLASH_MODULE_ENABLED -#define HAL_PWR_MODULE_ENABLED -#define HAL_CORTEX_MODULE_ENABLED - -/* ########################## HSE/HSI Values adaptation ##################### */ -/** - * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. - * This value is used by the RCC HAL module to compute the system frequency - * (when HSE is used as system clock source, directly or through the PLL). - */ -#if !defined (HSE_VALUE) - #define HSE_VALUE ((uint32_t)25000000U) /*!< Value of the External oscillator in Hz */ -#endif /* HSE_VALUE */ - -#if !defined (HSE_STARTUP_TIMEOUT) - #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ -#endif /* HSE_STARTUP_TIMEOUT */ - -/** - * @brief Internal High Speed oscillator (HSI) value. - * This value is used by the RCC HAL module to compute the system frequency - * (when HSI is used as system clock source, directly or through the PLL). - */ -#if !defined (HSI_VALUE) - #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ -#endif /* HSI_VALUE */ - -/** - * @brief Internal Low Speed oscillator (LSI) value. - */ -#if !defined (LSI_VALUE) - #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/ -#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz - The real value may vary depending on the variations - in voltage and temperature.*/ -/** - * @brief External Low Speed oscillator (LSE) value. - */ -#if !defined (LSE_VALUE) - #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */ -#endif /* LSE_VALUE */ - -#if !defined (LSE_STARTUP_TIMEOUT) - #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ -#endif /* LSE_STARTUP_TIMEOUT */ - -/** - * @brief External clock source for I2S peripheral - * This value is used by the I2S HAL module to compute the I2S clock source - * frequency, this source is inserted directly through I2S_CKIN pad. - */ -#if !defined (EXTERNAL_CLOCK_VALUE) - #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/ -#endif /* EXTERNAL_CLOCK_VALUE */ - -/* Tip: To avoid modifying this file each time you need to use different HSE, - === you can define the HSE value in your toolchain compiler preprocessor. */ - -/* ########################### System Configuration ######################### */ -/** - * @brief This is the HAL system configuration section - */ -#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ -#define TICK_INT_PRIORITY ((uint32_t)15U) /*!< tick interrupt priority */ -#define USE_RTOS 0U -#define PREFETCH_ENABLE 1U -#define INSTRUCTION_CACHE_ENABLE 1U -#define DATA_CACHE_ENABLE 1U - -/* ########################## Assert Selection ############################## */ -/** - * @brief Uncomment the line below to expanse the "assert_param" macro in the - * HAL drivers code - */ - #define USE_FULL_ASSERT 1U - -/* ################## Ethernet peripheral configuration ##################### */ - -/* Section 1 : Ethernet peripheral configuration */ - -/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ -#define MAC_ADDR0 2U -#define MAC_ADDR1 0U -#define MAC_ADDR2 0U -#define MAC_ADDR3 0U -#define MAC_ADDR4 0U -#define MAC_ADDR5 0U - -/* Definition of the Ethernet driver buffers size and count */ -#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ -#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ -#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ -#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ - -/* Section 2: PHY configuration section */ - -/* DP83848_PHY_ADDRESS Address*/ -#define DP83848_PHY_ADDRESS 0x01U -/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ -#define PHY_RESET_DELAY ((uint32_t)0x000000FFU) -/* PHY Configuration delay */ -#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU) - -#define PHY_READ_TO ((uint32_t)0x0000FFFFU) -#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU) - -/* Section 3: Common PHY Registers */ - -#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */ -#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */ - -#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ -#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ -#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ -#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */ -#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */ -#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */ -#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */ -#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */ -#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */ -#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */ - -#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ -#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ -#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */ - -/* Section 4: Extended PHY Registers */ -#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ - -#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */ -#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */ - -/* ################## SPI peripheral configuration ########################## */ - -/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver -* Activated: CRC code is present inside driver -* Deactivated: CRC code cleaned from driver -*/ - -#define USE_SPI_CRC 0U - -/* Includes ------------------------------------------------------------------*/ -/** - * @brief Include module's header file - */ - -#ifdef HAL_RCC_MODULE_ENABLED - #include "stm32f4xx_hal_rcc.h" -#endif /* HAL_RCC_MODULE_ENABLED */ - -#ifdef HAL_EXTI_MODULE_ENABLED - #include "stm32f4xx_hal_exti.h" -#endif /* HAL_EXTI_MODULE_ENABLED */ - -#ifdef HAL_GPIO_MODULE_ENABLED - #include "stm32f4xx_hal_gpio.h" -#endif /* HAL_GPIO_MODULE_ENABLED */ - -#ifdef HAL_DMA_MODULE_ENABLED - #include "stm32f4xx_hal_dma.h" -#endif /* HAL_DMA_MODULE_ENABLED */ - -#ifdef HAL_CORTEX_MODULE_ENABLED - #include "stm32f4xx_hal_cortex.h" -#endif /* HAL_CORTEX_MODULE_ENABLED */ - -#ifdef HAL_ADC_MODULE_ENABLED - #include "stm32f4xx_hal_adc.h" -#endif /* HAL_ADC_MODULE_ENABLED */ - -#ifdef HAL_CAN_MODULE_ENABLED - #include "stm32f4xx_hal_can.h" -#endif /* HAL_CAN_MODULE_ENABLED */ - -#ifdef HAL_CRC_MODULE_ENABLED - #include "stm32f4xx_hal_crc.h" -#endif /* HAL_CRC_MODULE_ENABLED */ - -#ifdef HAL_CRYP_MODULE_ENABLED - #include "stm32f4xx_hal_cryp.h" -#endif /* HAL_CRYP_MODULE_ENABLED */ - -#ifdef HAL_SMBUS_MODULE_ENABLED -#include "stm32f4xx_hal_smbus.h" -#endif /* HAL_SMBUS_MODULE_ENABLED */ - -#ifdef HAL_DMA2D_MODULE_ENABLED - #include "stm32f4xx_hal_dma2d.h" -#endif /* HAL_DMA2D_MODULE_ENABLED */ - -#ifdef HAL_DAC_MODULE_ENABLED - #include "stm32f4xx_hal_dac.h" -#endif /* HAL_DAC_MODULE_ENABLED */ - -#ifdef HAL_DCMI_MODULE_ENABLED - #include "stm32f4xx_hal_dcmi.h" -#endif /* HAL_DCMI_MODULE_ENABLED */ - -#ifdef HAL_ETH_MODULE_ENABLED - #include "stm32f4xx_hal_eth.h" -#endif /* HAL_ETH_MODULE_ENABLED */ - -#ifdef HAL_FLASH_MODULE_ENABLED - #include "stm32f4xx_hal_flash.h" -#endif /* HAL_FLASH_MODULE_ENABLED */ - -#ifdef HAL_SRAM_MODULE_ENABLED - #include "stm32f4xx_hal_sram.h" -#endif /* HAL_SRAM_MODULE_ENABLED */ - -#ifdef HAL_NOR_MODULE_ENABLED - #include "stm32f4xx_hal_nor.h" -#endif /* HAL_NOR_MODULE_ENABLED */ - -#ifdef HAL_NAND_MODULE_ENABLED - #include "stm32f4xx_hal_nand.h" -#endif /* HAL_NAND_MODULE_ENABLED */ - -#ifdef HAL_PCCARD_MODULE_ENABLED - #include "stm32f4xx_hal_pccard.h" -#endif /* HAL_PCCARD_MODULE_ENABLED */ - -#ifdef HAL_SDRAM_MODULE_ENABLED - #include "stm32f4xx_hal_sdram.h" -#endif /* HAL_SDRAM_MODULE_ENABLED */ - -#ifdef HAL_HASH_MODULE_ENABLED - #include "stm32f4xx_hal_hash.h" -#endif /* HAL_HASH_MODULE_ENABLED */ - -#ifdef HAL_I2C_MODULE_ENABLED - #include "stm32f4xx_hal_i2c.h" -#endif /* HAL_I2C_MODULE_ENABLED */ - -#ifdef HAL_I2S_MODULE_ENABLED - #include "stm32f4xx_hal_i2s.h" -#endif /* HAL_I2S_MODULE_ENABLED */ - -#ifdef HAL_IWDG_MODULE_ENABLED - #include "stm32f4xx_hal_iwdg.h" -#endif /* HAL_IWDG_MODULE_ENABLED */ - -#ifdef HAL_LTDC_MODULE_ENABLED - #include "stm32f4xx_hal_ltdc.h" -#endif /* HAL_LTDC_MODULE_ENABLED */ - -#ifdef HAL_PWR_MODULE_ENABLED - #include "stm32f4xx_hal_pwr.h" -#endif /* HAL_PWR_MODULE_ENABLED */ - -#ifdef HAL_RNG_MODULE_ENABLED - #include "stm32f4xx_hal_rng.h" -#endif /* HAL_RNG_MODULE_ENABLED */ - -#ifdef HAL_RTC_MODULE_ENABLED - #include "stm32f4xx_hal_rtc.h" -#endif /* HAL_RTC_MODULE_ENABLED */ - -#ifdef HAL_SAI_MODULE_ENABLED - #include "stm32f4xx_hal_sai.h" -#endif /* HAL_SAI_MODULE_ENABLED */ - -#ifdef HAL_SD_MODULE_ENABLED - #include "stm32f4xx_hal_sd.h" -#endif /* HAL_SD_MODULE_ENABLED */ - -#ifdef HAL_MMC_MODULE_ENABLED - #include "stm32f4xx_hal_mmc.h" -#endif /* HAL_MMC_MODULE_ENABLED */ - -#ifdef HAL_SPI_MODULE_ENABLED - #include "stm32f4xx_hal_spi.h" -#endif /* HAL_SPI_MODULE_ENABLED */ - -#ifdef HAL_TIM_MODULE_ENABLED - #include "stm32f4xx_hal_tim.h" -#endif /* HAL_TIM_MODULE_ENABLED */ - -#ifdef HAL_UART_MODULE_ENABLED - #include "stm32f4xx_hal_uart.h" -#endif /* HAL_UART_MODULE_ENABLED */ - -#ifdef HAL_USART_MODULE_ENABLED - #include "stm32f4xx_hal_usart.h" -#endif /* HAL_USART_MODULE_ENABLED */ - -#ifdef HAL_IRDA_MODULE_ENABLED - #include "stm32f4xx_hal_irda.h" -#endif /* HAL_IRDA_MODULE_ENABLED */ - -#ifdef HAL_SMARTCARD_MODULE_ENABLED - #include "stm32f4xx_hal_smartcard.h" -#endif /* HAL_SMARTCARD_MODULE_ENABLED */ - -#ifdef HAL_WWDG_MODULE_ENABLED - #include "stm32f4xx_hal_wwdg.h" -#endif /* HAL_WWDG_MODULE_ENABLED */ - -#ifdef HAL_PCD_MODULE_ENABLED - #include "stm32f4xx_hal_pcd.h" -#endif /* HAL_PCD_MODULE_ENABLED */ - -#ifdef HAL_HCD_MODULE_ENABLED - #include "stm32f4xx_hal_hcd.h" -#endif /* HAL_HCD_MODULE_ENABLED */ - -#ifdef HAL_DSI_MODULE_ENABLED - #include "stm32f4xx_hal_dsi.h" -#endif /* HAL_DSI_MODULE_ENABLED */ - -#ifdef HAL_QSPI_MODULE_ENABLED - #include "stm32f4xx_hal_qspi.h" -#endif /* HAL_QSPI_MODULE_ENABLED */ - -#ifdef HAL_CEC_MODULE_ENABLED - #include "stm32f4xx_hal_cec.h" -#endif /* HAL_CEC_MODULE_ENABLED */ - -#ifdef HAL_FMPI2C_MODULE_ENABLED - #include "stm32f4xx_hal_fmpi2c.h" -#endif /* HAL_FMPI2C_MODULE_ENABLED */ - -#ifdef HAL_SPDIFRX_MODULE_ENABLED - #include "stm32f4xx_hal_spdifrx.h" -#endif /* HAL_SPDIFRX_MODULE_ENABLED */ - -#ifdef HAL_DFSDM_MODULE_ENABLED - #include "stm32f4xx_hal_dfsdm.h" -#endif /* HAL_DFSDM_MODULE_ENABLED */ - -#ifdef HAL_LPTIM_MODULE_ENABLED - #include "stm32f4xx_hal_lptim.h" -#endif /* HAL_LPTIM_MODULE_ENABLED */ - -/* Exported macro ------------------------------------------------------------*/ -#ifdef USE_FULL_ASSERT -/** - * @brief The assert_param macro is used for function's parameters check. - * @param expr: If expr is false, it calls assert_failed function - * which reports the name of the source file and the source - * line number of the call that failed. - * If expr is true, it returns no value. - * @retval None - */ - #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) -/* Exported functions ------------------------------------------------------- */ - void assert_failed(uint8_t* file, uint32_t line); -#else - #define assert_param(expr) ((void)0U) -#endif /* USE_FULL_ASSERT */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32F4xx_HAL_CONF_H */ - - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Inc/stm32f4xx_it.h b/OwlPedal2/Inc/stm32f4xx_it.h deleted file mode 100644 index a9bbcc2a..00000000 --- a/OwlPedal2/Inc/stm32f4xx_it.h +++ /dev/null @@ -1,83 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32f4xx_it.h - * @brief This file contains the headers of the interrupt handlers. - ****************************************************************************** - * - * COPYRIGHT(c) 2019 STMicroelectronics - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32F4xx_IT_H -#define __STM32F4xx_IT_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Exported types ------------------------------------------------------------*/ -/* USER CODE BEGIN ET */ - -/* USER CODE END ET */ - -/* Exported constants --------------------------------------------------------*/ -/* USER CODE BEGIN EC */ - -/* USER CODE END EC */ - -/* Exported macro ------------------------------------------------------------*/ -/* USER CODE BEGIN EM */ - -/* USER CODE END EM */ - -/* Exported functions prototypes ---------------------------------------------*/ -void SysTick_Handler(void); -void EXTI2_IRQHandler(void); -void EXTI9_5_IRQHandler(void); -void DMA2_Stream0_IRQHandler(void); -void DMA2_Stream1_IRQHandler(void); -void DMA2_Stream4_IRQHandler(void); -void OTG_FS_IRQHandler(void); -void SAI1_IRQHandler(void); -/* USER CODE BEGIN EFP */ - -/* USER CODE END EFP */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32F4xx_IT_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Inc/usb_device.h b/OwlPedal2/Inc/usb_device.h deleted file mode 100644 index 98cf5857..00000000 --- a/OwlPedal2/Inc/usb_device.h +++ /dev/null @@ -1,105 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : usb_device.h - * @version : v1.0_Cube - * @brief : Header for usb_device.c file. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2019 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under Ultimate Liberty license - * SLA0044, the "License"; You may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * www.st.com/SLA0044 - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __USB_DEVICE__H__ -#define __USB_DEVICE__H__ - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx.h" -#include "stm32f4xx_hal.h" -#include "usbd_def.h" - -/* USER CODE BEGIN INCLUDE */ - -/* USER CODE END INCLUDE */ - -/** @addtogroup USBD_OTG_DRIVER - * @{ - */ - -/** @defgroup USBD_DEVICE USBD_DEVICE - * @brief Device file for Usb otg low level driver. - * @{ - */ - -/** @defgroup USBD_DEVICE_Exported_Variables USBD_DEVICE_Exported_Variables - * @brief Public variables. - * @{ - */ - -/* Private variables ---------------------------------------------------------*/ -/* USER CODE BEGIN PV */ - -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* - * -- Insert your variables declaration here -- - */ -/* USER CODE BEGIN VARIABLES */ - -/* USER CODE END VARIABLES */ -/** - * @} - */ - -/** @defgroup USBD_DEVICE_Exported_FunctionsPrototype USBD_DEVICE_Exported_FunctionsPrototype - * @brief Declaration of public functions for Usb device. - * @{ - */ - -/** USB Device initialization function. */ -void MX_USB_DEVICE_Init(void); - -/* - * -- Insert functions declaration here -- - */ -/* USER CODE BEGIN FD */ - -/* USER CODE END FD */ -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __USB_DEVICE__H__ */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Inc/usbd_conf.h b/OwlPedal2/Inc/usbd_conf.h deleted file mode 100644 index 85bae835..00000000 --- a/OwlPedal2/Inc/usbd_conf.h +++ /dev/null @@ -1,180 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : usbd_conf.h - * @version : v1.0_Cube - * @brief : Header for usbd_conf.c file. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2019 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under Ultimate Liberty license - * SLA0044, the "License"; You may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * www.st.com/SLA0044 - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __USBD_CONF__H__ -#define __USBD_CONF__H__ - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include -#include -#include -#include "main.h" -#include "stm32f4xx.h" -#include "stm32f4xx_hal.h" - -/* USER CODE BEGIN INCLUDE */ -#ifdef DEBUG -#define DEBUG_LEVEL 3 -#else -#define DEBUG_LEVEL 0 -#endif -/* USER CODE END INCLUDE */ - -/** @addtogroup USBD_OTG_DRIVER - * @brief Driver for Usb device. - * @{ - */ - -/** @defgroup USBD_CONF USBD_CONF - * @brief Configuration file for Usb otg low level driver. - * @{ - */ - -/** @defgroup USBD_CONF_Exported_Variables USBD_CONF_Exported_Variables - * @brief Public variables. - * @{ - */ - -/** - * @} - */ - -/** @defgroup USBD_CONF_Exported_Defines USBD_CONF_Exported_Defines - * @brief Defines for configuration of the Usb device. - * @{ - */ - -/*---------- -----------*/ -#define USBD_MAX_NUM_INTERFACES 5U -/*---------- -----------*/ -#define USBD_MAX_NUM_CONFIGURATION 5U -/*---------- -----------*/ -#define USBD_MAX_STR_DESC_SIZ 512U -/*---------- -----------*/ -#define USBD_DEBUG_LEVEL DEBUG_LEVEL -/*---------- -----------*/ -#define USBD_LPM_ENABLED 0U -/*---------- -----------*/ -#define USBD_SELF_POWERED 1U -/*---------- -----------*/ -#define USBD_AUDIO_FREQ AUDIO_SAMPLINGRATE - -/****************************************/ -/* #define for FS and HS identification */ -#define DEVICE_FS 0 -#define DEVICE_HS 1 - -/** - * @} - */ - -/** @defgroup USBD_CONF_Exported_Macros USBD_CONF_Exported_Macros - * @brief Aliases. - * @{ - */ - -/* Memory management macros */ - -/** Alias for memory allocation. */ -#define USBD_malloc malloc - -/** Alias for memory release. */ -#define USBD_free free - -/** Alias for memory set. */ -#define USBD_memset memset - -/** Alias for memory copy. */ -#define USBD_memcpy memcpy - -/** Alias for delay. */ -#define USBD_Delay HAL_Delay - -/* DEBUG macros */ - -#if (USBD_DEBUG_LEVEL > 0) -#define USBD_UsrLog(...) do { printf(__VA_ARGS__); \ - printf("\n"); } while(0) -#else -#define USBD_UsrLog(...) -#endif - -#if (USBD_DEBUG_LEVEL > 1) - -#define USBD_ErrLog(...) do { printf("ERROR: ") ;\ - printf(__VA_ARGS__);\ - printf("\n"); } while(0) -#else -#define USBD_ErrLog(...) -#endif - -#if (USBD_DEBUG_LEVEL > 2) -#define USBD_DbgLog(...) do { printf("DEBUG : ") ; \ - printf(__VA_ARGS__);\ - printf("\n"); } while(0) -#else -#define USBD_DbgLog(...) -#endif - -/** - * @} - */ - -/** @defgroup USBD_CONF_Exported_Types USBD_CONF_Exported_Types - * @brief Types. - * @{ - */ - -/** - * @} - */ - -/** @defgroup USBD_CONF_Exported_FunctionsPrototype USBD_CONF_Exported_FunctionsPrototype - * @brief Declaration of public functions for Usb device. - * @{ - */ - -/* Exported functions -------------------------------------------------------*/ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __USBD_CONF__H__ */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Inc/usbd_desc.h b/OwlPedal2/Inc/usbd_desc.h deleted file mode 100644 index 122f582b..00000000 --- a/OwlPedal2/Inc/usbd_desc.h +++ /dev/null @@ -1,145 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : usbd_desc.c - * @version : v1.0_Cube - * @brief : Header for usbd_conf.c file. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2019 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under Ultimate Liberty license - * SLA0044, the "License"; You may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * www.st.com/SLA0044 - * - ****************************************************************************** - */ -/* USER CODE END Header */ -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __USBD_DESC__C__ -#define __USBD_DESC__C__ - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "usbd_def.h" - -/* USER CODE BEGIN INCLUDE */ - -/* USER CODE END INCLUDE */ - -/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY - * @{ - */ - -/** @defgroup USBD_DESC USBD_DESC - * @brief Usb device descriptors module. - * @{ - */ - -/** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants - * @brief Constants. - * @{ - */ -#define DEVICE_ID1 (UID_BASE) -#define DEVICE_ID2 (UID_BASE + 0x4) -#define DEVICE_ID3 (UID_BASE + 0x8) - -#define USB_SIZ_STRING_SERIAL 0x1A - -/* USER CODE BEGIN EXPORTED_CONSTANTS */ - -/* USER CODE END EXPORTED_CONSTANTS */ - -/** - * @} - */ - -/** @defgroup USBD_DESC_Exported_Defines USBD_DESC_Exported_Defines - * @brief Defines. - * @{ - */ - -/* USER CODE BEGIN EXPORTED_DEFINES */ - -/* USER CODE END EXPORTED_DEFINES */ - -/** - * @} - */ - -/** @defgroup USBD_DESC_Exported_TypesDefinitions USBD_DESC_Exported_TypesDefinitions - * @brief Types. - * @{ - */ - -/* USER CODE BEGIN EXPORTED_TYPES */ - -/* USER CODE END EXPORTED_TYPES */ - -/** - * @} - */ - -/** @defgroup USBD_DESC_Exported_Macros USBD_DESC_Exported_Macros - * @brief Aliases. - * @{ - */ - -/* USER CODE BEGIN EXPORTED_MACRO */ - -/* USER CODE END EXPORTED_MACRO */ - -/** - * @} - */ - -/** @defgroup USBD_DESC_Exported_Variables USBD_DESC_Exported_Variables - * @brief Public variables. - * @{ - */ - -/** Descriptor for the Usb device. */ -extern USBD_DescriptorsTypeDef FS_Desc; - -/* USER CODE BEGIN EXPORTED_VARIABLES */ - -/* USER CODE END EXPORTED_VARIABLES */ - -/** - * @} - */ - -/** @defgroup USBD_DESC_Exported_FunctionsPrototype USBD_DESC_Exported_FunctionsPrototype - * @brief Public functions declaration. - * @{ - */ - -/* USER CODE BEGIN EXPORTED_FUNCTIONS */ - -/* USER CODE END EXPORTED_FUNCTIONS */ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __USBD_DESC__C__ */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Makefile b/OwlPedal2/Makefile deleted file mode 100644 index edc877f1..00000000 --- a/OwlPedal2/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -PROJECT = OwlPedal2 -BUILDROOT = . -OPENWARE ?= $(BUILDROOT)/.. - -include $(OPENWARE)/Hardware/owl2.mk - -C_SRC = $(notdir $(wildcard Src/*.c)) -CPP_SRC = $(notdir $(wildcard Src/*.cpp)) -C_SRC += sdram.c -C_SRC += cs4272.c -C_SRC += usbd_audio.c - -include $(OPENWARE)/Hardware/sources.mk - -OBJS = $(C_SRC:%.c=Build/%.o) -OBJS += $(CPP_SRC:%.cpp=Build/%.o) -OBJS += $(S_SRC:%.s=Build/%.o) - -OBJS += $(OBJS_SAI) -OBJS += $(OBJS_SDRAM) -OBJS += $(OBJS_USBD) -OBJS += $(OBJS_DSP) -OBJS += $(OBJS_OS) -OBJS += $(OBJS_UART) -OBJS += $(OBJS_RTC) - -include $(OPENWARE)/Hardware/f4.mk diff --git a/OwlPedal2/OwlPedal2.ioc b/OwlPedal2/OwlPedal2.ioc deleted file mode 100644 index efa1d973..00000000 --- a/OwlPedal2/OwlPedal2.ioc +++ /dev/null @@ -1,598 +0,0 @@ -#MicroXplorer Configuration settings - do not modify -ADC3.Channel-31\#ChannelRegularConversion=ADC_CHANNEL_13 -ADC3.Channel-32\#ChannelRegularConversion=ADC_CHANNEL_12 -ADC3.Channel-33\#ChannelRegularConversion=ADC_CHANNEL_11 -ADC3.Channel-34\#ChannelRegularConversion=ADC_CHANNEL_8 -ADC3.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV8 -ADC3.ContinuousConvMode=ENABLE -ADC3.DMAContinuousRequests=ENABLE -ADC3.DataAlign=ADC_DATAALIGN_RIGHT -ADC3.DiscontinuousConvMode=DISABLE -ADC3.EOCSelection=ADC_EOC_SEQ_CONV -ADC3.EnableAnalogWatchDog=false -ADC3.ExternalTrigConv=ADC_SOFTWARE_START -ADC3.ExternalTrigConvEdge=ADC_EXTERNALTRIGCONVEDGE_NONE -ADC3.IPParameters=Rank-31\#ChannelRegularConversion,Channel-31\#ChannelRegularConversion,SamplingTime-31\#ChannelRegularConversion,NbrOfConversionFlag,ScanConvMode,ContinuousConvMode,DMAContinuousRequests,EOCSelection,InjNumberOfConversion,EnableAnalogWatchDog,ExternalTrigConv,Rank-32\#ChannelRegularConversion,Channel-32\#ChannelRegularConversion,SamplingTime-32\#ChannelRegularConversion,Rank-33\#ChannelRegularConversion,Channel-33\#ChannelRegularConversion,SamplingTime-33\#ChannelRegularConversion,Rank-34\#ChannelRegularConversion,Channel-34\#ChannelRegularConversion,SamplingTime-34\#ChannelRegularConversion,NbrOfConversion,ClockPrescaler,Resolution,DataAlign,DiscontinuousConvMode,ExternalTrigConvEdge -ADC3.InjNumberOfConversion=0 -ADC3.NbrOfConversion=4 -ADC3.NbrOfConversionFlag=1 -ADC3.Rank-31\#ChannelRegularConversion=1 -ADC3.Rank-32\#ChannelRegularConversion=2 -ADC3.Rank-33\#ChannelRegularConversion=3 -ADC3.Rank-34\#ChannelRegularConversion=4 -ADC3.Resolution=ADC_RESOLUTION_12B -ADC3.SamplingTime-31\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -ADC3.SamplingTime-32\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -ADC3.SamplingTime-33\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -ADC3.SamplingTime-34\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -ADC3.ScanConvMode=ENABLE -Dma.ADC3.0.Direction=DMA_PERIPH_TO_MEMORY -Dma.ADC3.0.FIFOMode=DMA_FIFOMODE_DISABLE -Dma.ADC3.0.Instance=DMA2_Stream0 -Dma.ADC3.0.MemDataAlignment=DMA_MDATAALIGN_HALFWORD -Dma.ADC3.0.MemInc=DMA_MINC_ENABLE -Dma.ADC3.0.Mode=DMA_CIRCULAR -Dma.ADC3.0.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD -Dma.ADC3.0.PeriphInc=DMA_PINC_DISABLE -Dma.ADC3.0.Priority=DMA_PRIORITY_LOW -Dma.ADC3.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -Dma.Request0=ADC3 -Dma.Request1=SAI1_A -Dma.Request2=SAI1_B -Dma.RequestsNb=3 -Dma.SAI1_A.1.Direction=DMA_MEMORY_TO_PERIPH -Dma.SAI1_A.1.FIFOMode=DMA_FIFOMODE_DISABLE -Dma.SAI1_A.1.Instance=DMA2_Stream1 -Dma.SAI1_A.1.MemDataAlignment=DMA_MDATAALIGN_WORD -Dma.SAI1_A.1.MemInc=DMA_MINC_ENABLE -Dma.SAI1_A.1.Mode=DMA_CIRCULAR -Dma.SAI1_A.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD -Dma.SAI1_A.1.PeriphInc=DMA_PINC_DISABLE -Dma.SAI1_A.1.Priority=DMA_PRIORITY_VERY_HIGH -Dma.SAI1_A.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -Dma.SAI1_B.2.Direction=DMA_PERIPH_TO_MEMORY -Dma.SAI1_B.2.FIFOMode=DMA_FIFOMODE_DISABLE -Dma.SAI1_B.2.Instance=DMA2_Stream4 -Dma.SAI1_B.2.MemDataAlignment=DMA_MDATAALIGN_WORD -Dma.SAI1_B.2.MemInc=DMA_MINC_ENABLE -Dma.SAI1_B.2.Mode=DMA_CIRCULAR -Dma.SAI1_B.2.PeriphDataAlignment=DMA_PDATAALIGN_WORD -Dma.SAI1_B.2.PeriphInc=DMA_PINC_DISABLE -Dma.SAI1_B.2.Priority=DMA_PRIORITY_VERY_HIGH -Dma.SAI1_B.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_3 -FMC.ExitSelfRefreshDelay1=6 -FMC.IPParameters=ReadPipeDelay1,ReadBurst1,ReadBurst2,SDClockPeriod1,SDClockPeriod2,CASLatency1,LoadToActiveDelay1,ExitSelfRefreshDelay1,SelfRefreshTime1,RowCycleDelay1,RowCycleDelay2,WriteRecoveryTime1,RPDelay1,RPDelay2,RCDDelay1 -FMC.LoadToActiveDelay1=2 -FMC.RCDDelay1=2 -FMC.RPDelay1=2 -FMC.RPDelay2=2 -FMC.ReadBurst1=FMC_SDRAM_RBURST_ENABLE -FMC.ReadBurst2=FMC_SDRAM_RBURST_ENABLE -FMC.ReadPipeDelay1=FMC_SDRAM_RPIPE_DELAY_0 -FMC.RowCycleDelay1=6 -FMC.RowCycleDelay2=6 -FMC.SDClockPeriod1=FMC_SDRAM_CLOCK_PERIOD_2 -FMC.SDClockPeriod2=FMC_SDRAM_CLOCK_PERIOD_2 -FMC.SelfRefreshTime1=4 -FMC.WriteRecoveryTime1=2 -FREERTOS.FootprintOK=true -FREERTOS.INCLUDE_vTaskDelayUntil=1 -FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configENABLE_BACKWARD_COMPATIBILITY,configUSE_MUTEXES,FootprintOK,MEMORY_ALLOCATION,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,INCLUDE_vTaskDelayUntil,configTOTAL_HEAP_SIZE -FREERTOS.MEMORY_ALLOCATION=2 -FREERTOS.Tasks01=defaultTask,0,128,StartDefaultTask,Default,NULL -FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 -FREERTOS.configENABLE_BACKWARD_COMPATIBILITY=0 -FREERTOS.configTOTAL_HEAP_SIZE=8192 -FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 -FREERTOS.configUSE_MUTEXES=0 -FREERTOS.configUSE_PREEMPTION=0 -File.Version=6 -KeepUserPlacement=false -Mcu.Family=STM32F4 -Mcu.IP0=ADC3 -Mcu.IP1=DMA -Mcu.IP10=SYS -Mcu.IP11=USB_DEVICE -Mcu.IP12=USB_OTG_FS -Mcu.IP2=FMC -Mcu.IP3=FREERTOS -Mcu.IP4=NVIC -Mcu.IP5=RCC -Mcu.IP6=RTC -Mcu.IP7=SAI1 -Mcu.IP8=SPI1 -Mcu.IP9=SPI4 -Mcu.IPNb=13 -Mcu.Name=STM32F427Z(G-I)Tx -Mcu.Package=LQFP144 -Mcu.Pin0=PE2 -Mcu.Pin1=PE3 -Mcu.Pin10=PF4 -Mcu.Pin11=PF5 -Mcu.Pin12=PF10 -Mcu.Pin13=PH0/OSC_IN -Mcu.Pin14=PH1/OSC_OUT -Mcu.Pin15=PC0 -Mcu.Pin16=PC1 -Mcu.Pin17=PC2 -Mcu.Pin18=PC3 -Mcu.Pin19=PA2 -Mcu.Pin2=PE4 -Mcu.Pin20=PA6 -Mcu.Pin21=PA7 -Mcu.Pin22=PC4 -Mcu.Pin23=PC5 -Mcu.Pin24=PB2/BOOT1 -Mcu.Pin25=PF11 -Mcu.Pin26=PF12 -Mcu.Pin27=PF13 -Mcu.Pin28=PF14 -Mcu.Pin29=PF15 -Mcu.Pin3=PE5 -Mcu.Pin30=PG0 -Mcu.Pin31=PG1 -Mcu.Pin32=PE7 -Mcu.Pin33=PE8 -Mcu.Pin34=PE9 -Mcu.Pin35=PE10 -Mcu.Pin36=PE11 -Mcu.Pin37=PE12 -Mcu.Pin38=PE13 -Mcu.Pin39=PE14 -Mcu.Pin4=PE6 -Mcu.Pin40=PE15 -Mcu.Pin41=PB10 -Mcu.Pin42=PB11 -Mcu.Pin43=PD8 -Mcu.Pin44=PD9 -Mcu.Pin45=PD10 -Mcu.Pin46=PD14 -Mcu.Pin47=PD15 -Mcu.Pin48=PG4 -Mcu.Pin49=PG5 -Mcu.Pin5=PC15/OSC32_OUT -Mcu.Pin50=PG8 -Mcu.Pin51=PA9 -Mcu.Pin52=PA11 -Mcu.Pin53=PA12 -Mcu.Pin54=PA13 -Mcu.Pin55=PA14 -Mcu.Pin56=PD0 -Mcu.Pin57=PD1 -Mcu.Pin58=PD6 -Mcu.Pin59=PG15 -Mcu.Pin6=PF0 -Mcu.Pin60=PB3 -Mcu.Pin61=PB5 -Mcu.Pin62=PB6 -Mcu.Pin63=PB8 -Mcu.Pin64=PB9 -Mcu.Pin65=PE0 -Mcu.Pin66=PE1 -Mcu.Pin67=VP_FREERTOS_VS_CMSIS_V1 -Mcu.Pin68=VP_RTC_VS_RTC_Activate -Mcu.Pin69=VP_SYS_VS_Systick -Mcu.Pin7=PF1 -Mcu.Pin70=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS -Mcu.Pin8=PF2 -Mcu.Pin9=PF3 -Mcu.PinsNb=71 -Mcu.ThirdPartyNb=0 -Mcu.UserConstants= -Mcu.UserName=STM32F427ZITx -MxCube.Version=5.5.0 -MxDb.Version=DB.5.0.50 -NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -NVIC.DMA2_Stream0_IRQn=true\:10\:0\:true\:false\:true\:true\:true\:true -NVIC.DMA2_Stream1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -NVIC.DMA2_Stream4_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -NVIC.EXTI2_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true -NVIC.EXTI9_5_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true -NVIC.ForceEnableDMAVector=true -NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -NVIC.OTG_FS_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true -NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false -NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 -NVIC.SAI1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:true\:true -NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -PA11.GPIOParameters=GPIO_Label -PA11.GPIO_Label=USBD_DM -PA11.Mode=Device_Only -PA11.Signal=USB_OTG_FS_DM -PA12.GPIOParameters=GPIO_Label -PA12.GPIO_Label=USBD_DP -PA12.Mode=Device_Only -PA12.Signal=USB_OTG_FS_DP -PA13.Mode=Serial_Wire -PA13.Signal=SYS_JTMS-SWDIO -PA14.Mode=Serial_Wire -PA14.Signal=SYS_JTCK-SWCLK -PA2.Locked=true -PA2.Signal=USART2_TX -PA6.GPIOParameters=GPIO_Label -PA6.GPIO_Label=FLASH_MISO -PA6.Mode=Full_Duplex_Master -PA6.Signal=SPI1_MISO -PA7.GPIOParameters=GPIO_Label -PA7.GPIO_Label=FLASH_MOSI -PA7.Mode=Full_Duplex_Master -PA7.Signal=SPI1_MOSI -PA9.GPIOParameters=GPIO_Label -PA9.GPIO_Label=USBD_VBUS -PA9.Mode=Activate_VBUS -PA9.Signal=USB_OTG_FS_VBUS -PB10.GPIOParameters=GPIO_Label -PB10.GPIO_Label=CS_nCS -PB10.Locked=true -PB10.Signal=GPIO_Output -PB11.GPIOParameters=GPIO_Label -PB11.GPIO_Label=CS_nRST -PB11.Locked=true -PB11.Signal=GPIO_Output -PB2/BOOT1.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -PB2/BOOT1.GPIO_Label=SW2 -PB2/BOOT1.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -PB2/BOOT1.GPIO_PuPd=GPIO_PULLUP -PB2/BOOT1.Locked=true -PB2/BOOT1.Signal=GPXTI2 -PB3.GPIOParameters=GPIO_Label -PB3.GPIO_Label=FLASH_SCK -PB3.Locked=true -PB3.Mode=Full_Duplex_Master -PB3.Signal=SPI1_SCK -PB5.Mode=SdramChipSelect2_1 -PB5.Signal=FMC_SDCKE1 -PB6.Mode=SdramChipSelect2_1 -PB6.Signal=FMC_SDNE1 -PB8.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -PB8.GPIO_Label=SW3 -PB8.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -PB8.GPIO_PuPd=GPIO_PULLUP -PB8.Locked=true -PB8.Signal=GPXTI8 -PB9.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -PB9.GPIO_Label=SW1 -PB9.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -PB9.GPIO_PuPd=GPIO_PULLUP -PB9.Locked=true -PB9.Signal=GPXTI9 -PC0.Signal=FMC_SDNWE -PC1.GPIOParameters=GPIO_Label -PC1.GPIO_Label=ADC3 -PC1.Locked=true -PC1.Signal=ADCx_IN11 -PC15/OSC32_OUT.GPIOParameters=GPIO_Label -PC15/OSC32_OUT.GPIO_Label=EXTSPI_nCS -PC15/OSC32_OUT.Locked=true -PC15/OSC32_OUT.Signal=GPIO_Output -PC2.GPIOParameters=GPIO_Label -PC2.GPIO_Label=ADC2 -PC2.Locked=true -PC2.Signal=ADCx_IN12 -PC3.GPIOParameters=GPIO_Label -PC3.GPIO_Label=ADC1 -PC3.Locked=true -PC3.Signal=ADCx_IN13 -PC4.GPIOParameters=GPIO_Label -PC4.GPIO_Label=FLASH_HOLD -PC4.Locked=true -PC4.Signal=GPIO_Output -PC5.GPIOParameters=GPIO_Label -PC5.GPIO_Label=FLASH_nCS -PC5.Locked=true -PC5.Signal=GPIO_Output -PCC.Checker=false -PCC.Line=STM32F427/437 -PCC.MCU=STM32F427Z(G-I)Tx -PCC.PartNumber=STM32F427ZITx -PCC.Seq0=0 -PCC.Series=STM32F4 -PCC.Temperature=25 -PCC.Vdd=3.3 -PD0.Signal=FMC_D2_DA2 -PD1.Signal=FMC_D3_DA3 -PD10.Signal=FMC_D15_DA15 -PD14.Signal=FMC_D0_DA0 -PD15.Signal=FMC_D1_DA1 -PD6.GPIOParameters=GPIO_Label -PD6.GPIO_Label=CS_SDIN -PD6.Mode=SAI_A_AsyncSlave -PD6.Signal=SAI1_SD_A -PD8.Signal=FMC_D13_DA13 -PD9.Signal=FMC_D14_DA14 -PE0.Signal=FMC_NBL0 -PE1.Signal=FMC_NBL1 -PE10.Signal=FMC_D7_DA7 -PE11.Signal=FMC_D8_DA8 -PE12.Signal=FMC_D9_DA9 -PE13.Signal=FMC_D10_DA10 -PE14.Signal=FMC_D11_DA11 -PE15.Signal=FMC_D12_DA12 -PE2.GPIOParameters=GPIO_Label -PE2.GPIO_Label=CS_SCK -PE2.Mode=TX_Only_Simplex_Unidirect_Master -PE2.Signal=SPI4_SCK -PE3.GPIOParameters=GPIO_Label -PE3.GPIO_Label=CS_SDOUT -PE3.Mode=SAI_B_SyncSlave -PE3.Signal=SAI1_SD_B -PE4.GPIOParameters=GPIO_Label -PE4.GPIO_Label=CS_LRCK -PE4.Mode=SAI_A_AsyncSlave -PE4.Signal=SAI1_FS_A -PE5.GPIOParameters=GPIO_Label -PE5.GPIO_Label=CS_SCK -PE5.Mode=SAI_A_AsyncSlave -PE5.Signal=SAI1_SCK_A -PE6.GPIOParameters=GPIO_Label -PE6.GPIO_Label=CS_SDA -PE6.Mode=TX_Only_Simplex_Unidirect_Master -PE6.Signal=SPI4_MOSI -PE7.Signal=FMC_D4_DA4 -PE8.Signal=FMC_D5_DA5 -PE9.Signal=FMC_D6_DA6 -PF0.Signal=FMC_A0 -PF1.Signal=FMC_A1 -PF10.GPIOParameters=GPIO_Label -PF10.GPIO_Label=ADC4 -PF10.Locked=true -PF10.Mode=IN8 -PF10.Signal=ADC3_IN8 -PF11.Signal=FMC_SDNRAS -PF12.Signal=FMC_A6 -PF13.Signal=FMC_A7 -PF14.Signal=FMC_A8 -PF15.Signal=FMC_A9 -PF2.Signal=FMC_A2 -PF3.Signal=FMC_A3 -PF4.Signal=FMC_A4 -PF5.Signal=FMC_A5 -PG0.Signal=FMC_A10 -PG1.Signal=FMC_A11 -PG15.Signal=FMC_SDNCAS -PG4.Signal=FMC_A14_BA0 -PG5.Signal=FMC_A15_BA1 -PG8.Signal=FMC_SDCLK -PH0/OSC_IN.Mode=HSE-External-Oscillator -PH0/OSC_IN.Signal=RCC_OSC_IN -PH1/OSC_OUT.Mode=HSE-External-Oscillator -PH1/OSC_OUT.Signal=RCC_OSC_OUT -PinOutPanel.RotationAngle=0 -ProjectManager.AskForMigrate=true -ProjectManager.BackupPrevious=false -ProjectManager.CompilerOptimize=6 -ProjectManager.ComputerToolchain=false -ProjectManager.CoupleFile=false -ProjectManager.CustomerFirmwarePackage= -ProjectManager.DefaultFWLocation=true -ProjectManager.DeletePrevious=true -ProjectManager.DeviceId=STM32F427ZITx -ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.24.2 -ProjectManager.FreePins=true -ProjectManager.HalAssertFull=true -ProjectManager.HeapSize=0x200 -ProjectManager.KeepUserCode=true -ProjectManager.LastFirmware=true -ProjectManager.LibraryCopy=0 -ProjectManager.MainLocation=Src -ProjectManager.NoMain=false -ProjectManager.PreviousToolchain= -ProjectManager.ProjectBuild=false -ProjectManager.ProjectFileName=OwlPedal2.ioc -ProjectManager.ProjectName=OwlPedal2 -ProjectManager.StackSize=0x400 -ProjectManager.TargetToolchain=Makefile -ProjectManager.ToolChainLocation= -ProjectManager.UnderRoot=false -ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-MX_SPI5_Init-SPI5-false-HAL-true,9-MX_TIM2_Init-TIM2-false-HAL-true,10-MX_USART2_UART_Init-USART2-false-HAL-true,11-SystemClock_Config-RCC-false-HAL-true,12-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,13-MX_TIM3_Init-TIM3-false-HAL-true,14-MX_RTC_Init-RTC-false-HAL-true -RCC.48MHZClocksFreq_Value=48000000 -RCC.AHBFreq_Value=168000000 -RCC.APB1CLKDivider=RCC_HCLK_DIV4 -RCC.APB1Freq_Value=42000000 -RCC.APB1TimFreq_Value=84000000 -RCC.APB2CLKDivider=RCC_HCLK_DIV2 -RCC.APB2Freq_Value=84000000 -RCC.APB2TimFreq_Value=168000000 -RCC.CECFreq_Value=32786.88524590164 -RCC.CortexFreq_Value=168000000 -RCC.EthernetFreq_Value=168000000 -RCC.FCLKCortexFreq_Value=168000000 -RCC.FamilyName=M -RCC.HCLKFreq_Value=168000000 -RCC.HSE_VALUE=25000000 -RCC.HSI_VALUE=16000000 -RCC.I2C1Freq_Value=54000000 -RCC.I2C2Freq_Value=54000000 -RCC.I2C3Freq_Value=54000000 -RCC.I2C4Freq_Value=54000000 -RCC.I2SClocksFreq_Value=96000000 -RCC.I2SFreq_Value=96000000 -RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CECFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SClocksFreq_Value,I2SFreq_Value,LCDTFToutputFreq_Value,LPTIM1Freq_Value,LSE_VALUE,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLI2SPCLKFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLI2SRoutputFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLQoutputFreq_Value,PLLSAIN,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIRCLKFreq_Value,PLLSAIoutputFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SAI1Freq_Value,SAI2Freq_Value,SAI_AClocksFreq_Value,SAI_BClocksFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,UART4Freq_Value,UART5Freq_Value,UART7Freq_Value,UART8Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USART6Freq_Value,USBFreq_Value,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value,VCOSAIOutputFreq_ValueQ,VcooutputI2S,VcooutputI2SQ -RCC.LCDTFToutputFreq_Value=25000000 -RCC.LPTIM1Freq_Value=54000000 -RCC.LSE_VALUE=32768 -RCC.LSI_VALUE=32000 -RCC.MCO2PinFreq_Value=168000000 -RCC.PLLCLKFreq_Value=168000000 -RCC.PLLI2SPCLKFreq_Value=96000000 -RCC.PLLI2SQCLKFreq_Value=96000000 -RCC.PLLI2SRCLKFreq_Value=96000000 -RCC.PLLI2SRoutputFreq_Value=96000000 -RCC.PLLM=25 -RCC.PLLN=336 -RCC.PLLQ=7 -RCC.PLLQCLKFreq_Value=48000000 -RCC.PLLQoutputFreq_Value=48000000 -RCC.PLLSAIN=100 -RCC.PLLSAIPCLKFreq_Value=50000000 -RCC.PLLSAIQCLKFreq_Value=50000000 -RCC.PLLSAIRCLKFreq_Value=50000000 -RCC.PLLSAIoutputFreq_Value=50000000 -RCC.RTCFreq_Value=32000 -RCC.RTCHSEDivFreq_Value=12500000 -RCC.SAI1Freq_Value=50000000 -RCC.SAI2Freq_Value=50000000 -RCC.SAI_AClocksFreq_Value=25000000 -RCC.SAI_BClocksFreq_Value=25000000 -RCC.SDMMCFreq_Value=216000000 -RCC.SPDIFRXFreq_Value=96000000 -RCC.SYSCLKFreq_VALUE=168000000 -RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK -RCC.UART4Freq_Value=54000000 -RCC.UART5Freq_Value=54000000 -RCC.UART7Freq_Value=54000000 -RCC.UART8Freq_Value=54000000 -RCC.USART1Freq_Value=108000000 -RCC.USART2Freq_Value=54000000 -RCC.USART3Freq_Value=54000000 -RCC.USART6Freq_Value=108000000 -RCC.USBFreq_Value=48000000 -RCC.VCOI2SOutputFreq_Value=192000000 -RCC.VCOInputFreq_Value=1000000 -RCC.VCOOutputFreq_Value=336000000 -RCC.VCOSAIOutputFreq_Value=100000000 -RCC.VCOSAIOutputFreq_ValueQ=25000000 -RCC.VcooutputI2S=96000000 -RCC.VcooutputI2SQ=96000000 -SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX -SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_RX -SAI1.DataSize-SAI_A_AsyncSlave=SAI_DATASIZE_24 -SAI1.FSDefinition-SAI_A_AsyncSlave=SAI_FS_CHANNEL_IDENTIFICATION -SAI1.FSDefinition-SAI_B_SyncSlave=SAI_FS_CHANNEL_IDENTIFICATION -SAI1.FrameLength-SAI_A_AsyncSlave=64 -SAI1.FrameLength-SAI_B_SyncSlave=64 -SAI1.IPParameters=Instance-SAI_A_AsyncSlave,VirtualMode-SAI_A_AsyncSlave,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,Synchro-SAI_B_SyncSlave,FrameLength-SAI_B_SyncSlave,SlotSize-SAI_B_SyncSlave,AudioMode-SAI_B_SyncSlave,AudioMode-SAI_A_AsyncSlave,DataSize-SAI_A_AsyncSlave,FrameLength-SAI_A_AsyncSlave,SlotSize-SAI_A_AsyncSlave,SlotNumber-SAI_A_AsyncSlave,FSDefinition-SAI_A_AsyncSlave,FSDefinition-SAI_B_SyncSlave,Synchro-SAI_A_AsyncSlave,Synchro_A,Synchro_B -SAI1.Instance-SAI_A_AsyncSlave=SAI$Index_Block_A -SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B -SAI1.SlotNumber-SAI_A_AsyncSlave=2 -SAI1.SlotSize-SAI_A_AsyncSlave=SAI_SLOTSIZE_32B -SAI1.SlotSize-SAI_B_SyncSlave=SAI_SLOTSIZE_32B -SAI1.Synchro-SAI_A_AsyncSlave=SAI_ASYNCHRONOUS -SAI1.Synchro-SAI_B_SyncSlave=SAI_SYNCHRONOUS -SAI1.Synchro_A=SAI_ASYNCHRONOUS -SAI1.Synchro_B=SAI_SYNCHRONOUS -SAI1.VirtualMode-SAI_A_AsyncSlave=VM_SLAVE -SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE -SH.ADCx_IN11.0=ADC3_IN11,IN11 -SH.ADCx_IN11.ConfNb=1 -SH.ADCx_IN12.0=ADC3_IN12,IN12 -SH.ADCx_IN12.ConfNb=1 -SH.ADCx_IN13.0=ADC3_IN13,IN13 -SH.ADCx_IN13.ConfNb=1 -SH.FMC_A0.0=FMC_A0,12b-sda1 -SH.FMC_A0.ConfNb=1 -SH.FMC_A1.0=FMC_A1,12b-sda1 -SH.FMC_A1.ConfNb=1 -SH.FMC_A10.0=FMC_A10,12b-sda1 -SH.FMC_A10.ConfNb=1 -SH.FMC_A11.0=FMC_A11,12b-sda1 -SH.FMC_A11.ConfNb=1 -SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 -SH.FMC_A14_BA0.ConfNb=1 -SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 -SH.FMC_A15_BA1.ConfNb=1 -SH.FMC_A2.0=FMC_A2,12b-sda1 -SH.FMC_A2.ConfNb=1 -SH.FMC_A3.0=FMC_A3,12b-sda1 -SH.FMC_A3.ConfNb=1 -SH.FMC_A4.0=FMC_A4,12b-sda1 -SH.FMC_A4.ConfNb=1 -SH.FMC_A5.0=FMC_A5,12b-sda1 -SH.FMC_A5.ConfNb=1 -SH.FMC_A6.0=FMC_A6,12b-sda1 -SH.FMC_A6.ConfNb=1 -SH.FMC_A7.0=FMC_A7,12b-sda1 -SH.FMC_A7.ConfNb=1 -SH.FMC_A8.0=FMC_A8,12b-sda1 -SH.FMC_A8.ConfNb=1 -SH.FMC_A9.0=FMC_A9,12b-sda1 -SH.FMC_A9.ConfNb=1 -SH.FMC_D0_DA0.0=FMC_D0,sd-16b-d1 -SH.FMC_D0_DA0.ConfNb=1 -SH.FMC_D10_DA10.0=FMC_D10,sd-16b-d1 -SH.FMC_D10_DA10.ConfNb=1 -SH.FMC_D11_DA11.0=FMC_D11,sd-16b-d1 -SH.FMC_D11_DA11.ConfNb=1 -SH.FMC_D12_DA12.0=FMC_D12,sd-16b-d1 -SH.FMC_D12_DA12.ConfNb=1 -SH.FMC_D13_DA13.0=FMC_D13,sd-16b-d1 -SH.FMC_D13_DA13.ConfNb=1 -SH.FMC_D14_DA14.0=FMC_D14,sd-16b-d1 -SH.FMC_D14_DA14.ConfNb=1 -SH.FMC_D15_DA15.0=FMC_D15,sd-16b-d1 -SH.FMC_D15_DA15.ConfNb=1 -SH.FMC_D1_DA1.0=FMC_D1,sd-16b-d1 -SH.FMC_D1_DA1.ConfNb=1 -SH.FMC_D2_DA2.0=FMC_D2,sd-16b-d1 -SH.FMC_D2_DA2.ConfNb=1 -SH.FMC_D3_DA3.0=FMC_D3,sd-16b-d1 -SH.FMC_D3_DA3.ConfNb=1 -SH.FMC_D4_DA4.0=FMC_D4,sd-16b-d1 -SH.FMC_D4_DA4.ConfNb=1 -SH.FMC_D5_DA5.0=FMC_D5,sd-16b-d1 -SH.FMC_D5_DA5.ConfNb=1 -SH.FMC_D6_DA6.0=FMC_D6,sd-16b-d1 -SH.FMC_D6_DA6.ConfNb=1 -SH.FMC_D7_DA7.0=FMC_D7,sd-16b-d1 -SH.FMC_D7_DA7.ConfNb=1 -SH.FMC_D8_DA8.0=FMC_D8,sd-16b-d1 -SH.FMC_D8_DA8.ConfNb=1 -SH.FMC_D9_DA9.0=FMC_D9,sd-16b-d1 -SH.FMC_D9_DA9.ConfNb=1 -SH.FMC_NBL0.0=FMC_NBL0,Sd2ByteEnable1 -SH.FMC_NBL0.ConfNb=1 -SH.FMC_NBL1.0=FMC_NBL1,Sd2ByteEnable1 -SH.FMC_NBL1.ConfNb=1 -SH.FMC_SDCLK.0=FMC_SDCLK,12b-sda1 -SH.FMC_SDCLK.ConfNb=1 -SH.FMC_SDNCAS.0=FMC_SDNCAS,12b-sda1 -SH.FMC_SDNCAS.ConfNb=1 -SH.FMC_SDNRAS.0=FMC_SDNRAS,12b-sda1 -SH.FMC_SDNRAS.ConfNb=1 -SH.FMC_SDNWE.0=FMC_SDNWE,12b-sda1 -SH.FMC_SDNWE.ConfNb=1 -SH.GPXTI2.0=GPIO_EXTI2 -SH.GPXTI2.ConfNb=1 -SH.GPXTI8.0=GPIO_EXTI8 -SH.GPXTI8.ConfNb=1 -SH.GPXTI9.0=GPIO_EXTI9 -SH.GPXTI9.ConfNb=1 -SPI1.CalculateBaudRate=42.0 MBits/s -SPI1.Direction=SPI_DIRECTION_2LINES -SPI1.IPParameters=Mode,CalculateBaudRate,VirtualType,Direction -SPI1.Mode=SPI_MODE_MASTER -SPI1.VirtualType=VM_MASTER -SPI4.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128 -SPI4.CalculateBaudRate=656.25 KBits/s -SPI4.Direction=SPI_DIRECTION_2LINES -SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,VirtualType,Direction -SPI4.Mode=SPI_MODE_MASTER -SPI4.VirtualType=VM_MASTER -USB_DEVICE.CLASS_NAME_FS=AUDIO -USB_DEVICE.IPParameters=VirtualMode-AUDIO_FS,VirtualModeFS,CLASS_NAME_FS,PID_AUDIO_FS,MANUFACTURER_STRING-AUDIO_FS,VID-AUDIO_FS,PRODUCT_STRING_AUDIO_FS,USBD_MAX_NUM_INTERFACES-AUDIO_FS,USBD_MAX_NUM_CONFIGURATION-AUDIO_FS,USBD_AUDIO_FREQ-AUDIO_FS -USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology -USB_DEVICE.PID_AUDIO_FS=0xdada -USB_DEVICE.PRODUCT_STRING_AUDIO_FS=OWL-PEDAL -USB_DEVICE.USBD_AUDIO_FREQ-AUDIO_FS=48000 -USB_DEVICE.USBD_MAX_NUM_CONFIGURATION-AUDIO_FS=2 -USB_DEVICE.USBD_MAX_NUM_INTERFACES-AUDIO_FS=5 -USB_DEVICE.VID-AUDIO_FS=0x1209 -USB_DEVICE.VirtualMode-AUDIO_FS=Audio -USB_DEVICE.VirtualModeFS=Audio_FS -USB_OTG_FS.IPParameters=VirtualMode -USB_OTG_FS.VirtualMode=Device_Only -VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 -VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 -VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled -VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate -VP_SYS_VS_Systick.Mode=SysTick -VP_SYS_VS_Systick.Signal=SYS_VS_Systick -VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Mode=AUDIO_FS -VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_FS -board=Alchemist diff --git a/OwlPedal2/Src/freertos.c b/OwlPedal2/Src/freertos.c deleted file mode 100644 index ad5906e2..00000000 --- a/OwlPedal2/Src/freertos.c +++ /dev/null @@ -1,136 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * File Name : freertos.c - * Description : Code for freertos applications - ****************************************************************************** - * This notice applies to any and all portions of this file - * that are not between comment pairs USER CODE BEGIN and - * USER CODE END. Other portions of this file, whether - * inserted by the user or by software development tools - * are owned by their respective copyright owners. - * - * Copyright (c) 2019 STMicroelectronics International N.V. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted, provided that the following conditions are met: - * - * 1. Redistribution of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of other - * contributors to this software may be used to endorse or promote products - * derived from this software without specific written permission. - * 4. This software, including modifications and/or derivative works of this - * software, must execute solely and exclusively on microcontroller or - * microprocessor devices manufactured by or for STMicroelectronics. - * 5. Redistribution and use of this software other than as permitted under - * this license is void and will automatically terminate your rights under - * this license. - * - * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY - * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT - * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Includes ------------------------------------------------------------------*/ -#include "FreeRTOS.h" -#include "task.h" -#include "main.h" - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN PTD */ - -/* USER CODE END PTD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ - -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ -/* USER CODE BEGIN Variables */ - -/* USER CODE END Variables */ - -/* Private function prototypes -----------------------------------------------*/ -/* USER CODE BEGIN FunctionPrototypes */ - -/* USER CODE END FunctionPrototypes */ - -/* GetIdleTaskMemory prototype (linked to static allocation support) */ -void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ); - -/* Hook prototypes */ -void vApplicationStackOverflowHook(TaskHandle_t xTask, signed char *pcTaskName); -void vApplicationMallocFailedHook(void); - -/* USER CODE BEGIN 4 */ -__weak void vApplicationStackOverflowHook(TaskHandle_t xTask, signed char *pcTaskName) -{ - /* Run time stack overflow checking is performed if - configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is - called if a stack overflow is detected. */ -} -/* USER CODE END 4 */ - -/* USER CODE BEGIN 5 */ -__weak void vApplicationMallocFailedHook(void) -{ - /* vApplicationMallocFailedHook() will only be called if - configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook - function that will get called if a call to pvPortMalloc() fails. - pvPortMalloc() is called internally by the kernel whenever a task, queue, - timer or semaphore is created. It is also called by various parts of the - demo application. If heap_1.c or heap_2.c are used, then the size of the - heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in - FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used - to query the size of free heap space that remains (although it does not - provide information on how the remaining heap might be fragmented). */ -} -/* USER CODE END 5 */ - -/* USER CODE BEGIN GET_IDLE_TASK_MEMORY */ -static StaticTask_t xIdleTaskTCBBuffer; -static StackType_t xIdleStack[configMINIMAL_STACK_SIZE]; - -void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ) -{ - *ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer; - *ppxIdleTaskStackBuffer = &xIdleStack[0]; - *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; - /* place for user code */ -} -/* USER CODE END GET_IDLE_TASK_MEMORY */ - -/* Private application code --------------------------------------------------*/ -/* USER CODE BEGIN Application */ - -/* USER CODE END Application */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Src/main.c b/OwlPedal2/Src/main.c deleted file mode 100644 index f3457f34..00000000 --- a/OwlPedal2/Src/main.c +++ /dev/null @@ -1,793 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : main.c - * @brief : Main program body - ****************************************************************************** - * This notice applies to any and all portions of this file - * that are not between comment pairs USER CODE BEGIN and - * USER CODE END. Other portions of this file, whether - * inserted by the user or by software development tools - * are owned by their respective copyright owners. - * - * Copyright (c) 2019 STMicroelectronics International N.V. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted, provided that the following conditions are met: - * - * 1. Redistribution of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of other - * contributors to this software may be used to endorse or promote products - * derived from this software without specific written permission. - * 4. This software, including modifications and/or derivative works of this - * software, must execute solely and exclusively on microcontroller or - * microprocessor devices manufactured by or for STMicroelectronics. - * 5. Redistribution and use of this software other than as permitted under - * this license is void and will automatically terminate your rights under - * this license. - * - * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY - * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT - * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" -#include "cmsis_os.h" -#include "usb_device.h" - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN PTD */ - -/* USER CODE END PTD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ - -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ -ADC_HandleTypeDef hadc3; -DMA_HandleTypeDef hdma_adc3; - -RTC_HandleTypeDef hrtc; - -SAI_HandleTypeDef hsai_BlockA1; -SAI_HandleTypeDef hsai_BlockB1; -DMA_HandleTypeDef hdma_sai1_a; -DMA_HandleTypeDef hdma_sai1_b; - -SPI_HandleTypeDef hspi1; -SPI_HandleTypeDef hspi4; - -SDRAM_HandleTypeDef hsdram1; - -osThreadId defaultTaskHandle; -/* USER CODE BEGIN PV */ -/* Private variables ---------------------------------------------------------*/ - -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -void SystemClock_Config(void); -static void MX_GPIO_Init(void); -static void MX_DMA_Init(void); -static void MX_ADC3_Init(void); -static void MX_FMC_Init(void); -static void MX_SAI1_Init(void); -static void MX_SPI1_Init(void); -static void MX_SPI4_Init(void); -static void MX_RTC_Init(void); -void StartDefaultTask(void const * argument); - -/* USER CODE BEGIN PFP */ -/* Private function prototypes -----------------------------------------------*/ - -void setup(); -void loop(void); -void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram); -void initialise_monitor_handles(void); - -/* USER CODE END PFP */ - -/* Private user code ---------------------------------------------------------*/ -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/** - * @brief The application entry point. - * @retval int - */ -int main(void) -{ - /* USER CODE BEGIN 1 */ -#ifdef DEBUG -#warning "DEBUG uses printf and semihosting!" - if(CoreDebug->DHCSR & 0x01) - initialise_monitor_handles(); // remove when not semi-hosting - printf("showtime\n"); -#endif - /* USER CODE END 1 */ - - - /* MCU Configuration--------------------------------------------------------*/ - - /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ - HAL_Init(); - - /* USER CODE BEGIN Init */ - - /* USER CODE END Init */ - - /* Configure the system clock */ - SystemClock_Config(); - - /* USER CODE BEGIN SysInit */ - - /* USER CODE END SysInit */ - - /* Initialize all configured peripherals */ - MX_GPIO_Init(); - MX_DMA_Init(); - MX_ADC3_Init(); - MX_FMC_Init(); - MX_SAI1_Init(); - MX_SPI1_Init(); - MX_SPI4_Init(); - MX_RTC_Init(); - /* USER CODE BEGIN 2 */ - - HAL_SAI_DeInit(&hsai_BlockA1); - HAL_SAI_DeInit(&hsai_BlockB1); - hsai_BlockA1.Instance = SAI1_Block_A; - hsai_BlockA1.Init.AudioMode = SAI_MODESLAVE_TX; - hsai_BlockA1.Init.Synchro = SAI_ASYNCHRONOUS; - hsai_BlockA1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; - hsai_BlockA1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; - hsai_BlockA1.Init.SynchroExt = SAI_SYNCEXT_DISABLE; - hsai_BlockA1.Init.MonoStereoMode = SAI_STEREOMODE; - hsai_BlockA1.Init.CompandingMode = SAI_NOCOMPANDING; - hsai_BlockA1.Init.TriState = SAI_OUTPUT_NOTRELEASED; - if (HAL_SAI_InitProtocol(&hsai_BlockA1, SAI_I2S_STANDARD, SAI_PROTOCOL_DATASIZE_24BIT, 2) != HAL_OK) - Error_Handler(); - hsai_BlockB1.Instance = SAI1_Block_B; - hsai_BlockB1.Init.AudioMode = SAI_MODESLAVE_RX; - hsai_BlockB1.Init.Synchro = SAI_SYNCHRONOUS; - hsai_BlockB1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; - hsai_BlockB1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; - hsai_BlockB1.Init.SynchroExt = SAI_SYNCEXT_DISABLE; - hsai_BlockB1.Init.MonoStereoMode = SAI_STEREOMODE; - hsai_BlockB1.Init.CompandingMode = SAI_NOCOMPANDING; - hsai_BlockB1.Init.TriState = SAI_OUTPUT_NOTRELEASED; - if (HAL_SAI_InitProtocol(&hsai_BlockB1, SAI_I2S_STANDARD, SAI_PROTOCOL_DATASIZE_24BIT, 2) != HAL_OK) - Error_Handler(); - - SDRAM_Initialization_Sequence(&hsdram1); - - /* USER CODE END 2 */ - - /* USER CODE BEGIN RTOS_MUTEX */ - /* add mutexes, ... */ - /* USER CODE END RTOS_MUTEX */ - - /* USER CODE BEGIN RTOS_SEMAPHORES */ - /* add semaphores, ... */ - /* USER CODE END RTOS_SEMAPHORES */ - - /* USER CODE BEGIN RTOS_TIMERS */ - /* start timers, add new ones, ... */ - /* USER CODE END RTOS_TIMERS */ - - /* USER CODE BEGIN RTOS_QUEUES */ - /* add queues, ... */ - /* USER CODE END RTOS_QUEUES */ - - /* Create the thread(s) */ - /* definition and creation of defaultTask */ - osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128); - defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL); - - /* USER CODE BEGIN RTOS_THREADS */ - /* add threads, ... */ - /* USER CODE END RTOS_THREADS */ - - /* Start scheduler */ - osKernelStart(); - - /* We should never get here as control is now taken by the scheduler */ - - /* Infinite loop */ - /* USER CODE BEGIN WHILE */ - while (1) - { - /* USER CODE END WHILE */ - - /* USER CODE BEGIN 3 */ - - } - /* USER CODE END 3 */ -} - -/** - * @brief System Clock Configuration - * @retval None - */ -void SystemClock_Config(void) -{ - RCC_OscInitTypeDef RCC_OscInitStruct = {0}; - RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; - RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; - - /** Macro to configure SAI1BlockB clock source selection - */ - __HAL_RCC_SAI_BLOCKBCLKSOURCE_CONFIG(SAI_CLKSOURCE_PLLSAI); - /** Macro to configure SAI1BlockA clock source selection - */ - __HAL_RCC_SAI_BLOCKACLKSOURCE_CONFIG(SAI_CLKSOURCE_PLLSAI); - /** Configure the main internal regulator output voltage - */ - __HAL_RCC_PWR_CLK_ENABLE(); - __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); - /** Initializes the CPU, AHB and APB busses clocks - */ - RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE; - RCC_OscInitStruct.HSEState = RCC_HSE_ON; - RCC_OscInitStruct.LSIState = RCC_LSI_ON; - RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; - RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; - RCC_OscInitStruct.PLL.PLLM = 25; - RCC_OscInitStruct.PLL.PLLN = 336; - RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; - RCC_OscInitStruct.PLL.PLLQ = 7; - if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) - { - Error_Handler(); - } - /** Initializes the CPU, AHB and APB busses clocks - */ - RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK - |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; - RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; - RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; - RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; - RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; - - if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) - { - Error_Handler(); - } - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SAI_PLLSAI|RCC_PERIPHCLK_RTC; - PeriphClkInitStruct.PLLSAI.PLLSAIN = 100; - PeriphClkInitStruct.PLLSAI.PLLSAIQ = 4; - PeriphClkInitStruct.PLLSAIDivQ = 1; - PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI; - if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) - { - Error_Handler(); - } -} - -/** - * @brief ADC3 Initialization Function - * @param None - * @retval None - */ -static void MX_ADC3_Init(void) -{ - - /* USER CODE BEGIN ADC3_Init 0 */ - - /* USER CODE END ADC3_Init 0 */ - - ADC_ChannelConfTypeDef sConfig = {0}; - - /* USER CODE BEGIN ADC3_Init 1 */ - - /* USER CODE END ADC3_Init 1 */ - /** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion) - */ - hadc3.Instance = ADC3; - hadc3.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV8; - hadc3.Init.Resolution = ADC_RESOLUTION_12B; - hadc3.Init.ScanConvMode = ENABLE; - hadc3.Init.ContinuousConvMode = ENABLE; - hadc3.Init.DiscontinuousConvMode = DISABLE; - hadc3.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; - hadc3.Init.ExternalTrigConv = ADC_SOFTWARE_START; - hadc3.Init.DataAlign = ADC_DATAALIGN_RIGHT; - hadc3.Init.NbrOfConversion = 4; - hadc3.Init.DMAContinuousRequests = ENABLE; - hadc3.Init.EOCSelection = ADC_EOC_SEQ_CONV; - if (HAL_ADC_Init(&hadc3) != HAL_OK) - { - Error_Handler(); - } - /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. - */ - sConfig.Channel = ADC_CHANNEL_13; - sConfig.Rank = 1; - sConfig.SamplingTime = ADC_SAMPLETIME_144CYCLES; - if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK) - { - Error_Handler(); - } - /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. - */ - sConfig.Channel = ADC_CHANNEL_12; - sConfig.Rank = 2; - if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK) - { - Error_Handler(); - } - /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. - */ - sConfig.Channel = ADC_CHANNEL_11; - sConfig.Rank = 3; - if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK) - { - Error_Handler(); - } - /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. - */ - sConfig.Channel = ADC_CHANNEL_8; - sConfig.Rank = 4; - if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN ADC3_Init 2 */ - - /* USER CODE END ADC3_Init 2 */ - -} - -/** - * @brief RTC Initialization Function - * @param None - * @retval None - */ -static void MX_RTC_Init(void) -{ - - /* USER CODE BEGIN RTC_Init 0 */ - - /* USER CODE END RTC_Init 0 */ - - /* USER CODE BEGIN RTC_Init 1 */ - - /* USER CODE END RTC_Init 1 */ - /** Initialize RTC Only - */ - hrtc.Instance = RTC; - hrtc.Init.HourFormat = RTC_HOURFORMAT_24; - hrtc.Init.AsynchPrediv = 127; - hrtc.Init.SynchPrediv = 255; - hrtc.Init.OutPut = RTC_OUTPUT_DISABLE; - hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH; - hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN; - if (HAL_RTC_Init(&hrtc) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN RTC_Init 2 */ - - /* USER CODE END RTC_Init 2 */ - -} - -/** - * @brief SAI1 Initialization Function - * @param None - * @retval None - */ -static void MX_SAI1_Init(void) -{ - - /* USER CODE BEGIN SAI1_Init 0 */ - - /* USER CODE END SAI1_Init 0 */ - - /* USER CODE BEGIN SAI1_Init 1 */ - - /* USER CODE END SAI1_Init 1 */ - hsai_BlockA1.Instance = SAI1_Block_A; - hsai_BlockA1.Init.Protocol = SAI_FREE_PROTOCOL; - hsai_BlockA1.Init.AudioMode = SAI_MODESLAVE_TX; - hsai_BlockA1.Init.DataSize = SAI_DATASIZE_24; - hsai_BlockA1.Init.FirstBit = SAI_FIRSTBIT_MSB; - hsai_BlockA1.Init.ClockStrobing = SAI_CLOCKSTROBING_FALLINGEDGE; - hsai_BlockA1.Init.Synchro = SAI_ASYNCHRONOUS; - hsai_BlockA1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; - hsai_BlockA1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; - hsai_BlockA1.FrameInit.FrameLength = 64; - hsai_BlockA1.FrameInit.ActiveFrameLength = 1; - hsai_BlockA1.FrameInit.FSDefinition = SAI_FS_CHANNEL_IDENTIFICATION; - hsai_BlockA1.FrameInit.FSPolarity = SAI_FS_ACTIVE_LOW; - hsai_BlockA1.FrameInit.FSOffset = SAI_FS_FIRSTBIT; - hsai_BlockA1.SlotInit.FirstBitOffset = 0; - hsai_BlockA1.SlotInit.SlotSize = SAI_SLOTSIZE_32B; - hsai_BlockA1.SlotInit.SlotNumber = 2; - hsai_BlockA1.SlotInit.SlotActive = 0x00000000; - if (HAL_SAI_Init(&hsai_BlockA1) != HAL_OK) - { - Error_Handler(); - } - hsai_BlockB1.Instance = SAI1_Block_B; - hsai_BlockB1.Init.Protocol = SAI_FREE_PROTOCOL; - hsai_BlockB1.Init.AudioMode = SAI_MODESLAVE_RX; - hsai_BlockB1.Init.DataSize = SAI_DATASIZE_24; - hsai_BlockB1.Init.FirstBit = SAI_FIRSTBIT_MSB; - hsai_BlockB1.Init.ClockStrobing = SAI_CLOCKSTROBING_FALLINGEDGE; - hsai_BlockB1.Init.Synchro = SAI_SYNCHRONOUS; - hsai_BlockB1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; - hsai_BlockB1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; - hsai_BlockB1.FrameInit.FrameLength = 64; - hsai_BlockB1.FrameInit.ActiveFrameLength = 1; - hsai_BlockB1.FrameInit.FSDefinition = SAI_FS_CHANNEL_IDENTIFICATION; - hsai_BlockB1.FrameInit.FSPolarity = SAI_FS_ACTIVE_LOW; - hsai_BlockB1.FrameInit.FSOffset = SAI_FS_FIRSTBIT; - hsai_BlockB1.SlotInit.FirstBitOffset = 0; - hsai_BlockB1.SlotInit.SlotSize = SAI_SLOTSIZE_32B; - hsai_BlockB1.SlotInit.SlotNumber = 2; - hsai_BlockB1.SlotInit.SlotActive = 0x00000000; - if (HAL_SAI_Init(&hsai_BlockB1) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN SAI1_Init 2 */ - - /* USER CODE END SAI1_Init 2 */ - -} - -/** - * @brief SPI1 Initialization Function - * @param None - * @retval None - */ -static void MX_SPI1_Init(void) -{ - - /* USER CODE BEGIN SPI1_Init 0 */ - - /* USER CODE END SPI1_Init 0 */ - - /* USER CODE BEGIN SPI1_Init 1 */ - - /* USER CODE END SPI1_Init 1 */ - /* SPI1 parameter configuration*/ - hspi1.Instance = SPI1; - hspi1.Init.Mode = SPI_MODE_MASTER; - hspi1.Init.Direction = SPI_DIRECTION_2LINES; - hspi1.Init.DataSize = SPI_DATASIZE_8BIT; - hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; - hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; - hspi1.Init.NSS = SPI_NSS_SOFT; - hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2; - hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; - hspi1.Init.TIMode = SPI_TIMODE_DISABLE; - hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; - hspi1.Init.CRCPolynomial = 10; - if (HAL_SPI_Init(&hspi1) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN SPI1_Init 2 */ - - /* USER CODE END SPI1_Init 2 */ - -} - -/** - * @brief SPI4 Initialization Function - * @param None - * @retval None - */ -static void MX_SPI4_Init(void) -{ - - /* USER CODE BEGIN SPI4_Init 0 */ - - /* USER CODE END SPI4_Init 0 */ - - /* USER CODE BEGIN SPI4_Init 1 */ - - /* USER CODE END SPI4_Init 1 */ - /* SPI4 parameter configuration*/ - hspi4.Instance = SPI4; - hspi4.Init.Mode = SPI_MODE_MASTER; - hspi4.Init.Direction = SPI_DIRECTION_2LINES; - hspi4.Init.DataSize = SPI_DATASIZE_8BIT; - hspi4.Init.CLKPolarity = SPI_POLARITY_LOW; - hspi4.Init.CLKPhase = SPI_PHASE_1EDGE; - hspi4.Init.NSS = SPI_NSS_SOFT; - hspi4.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_128; - hspi4.Init.FirstBit = SPI_FIRSTBIT_MSB; - hspi4.Init.TIMode = SPI_TIMODE_DISABLE; - hspi4.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; - hspi4.Init.CRCPolynomial = 10; - if (HAL_SPI_Init(&hspi4) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN SPI4_Init 2 */ - - /* USER CODE END SPI4_Init 2 */ - -} - -/** - * Enable DMA controller clock - */ -static void MX_DMA_Init(void) -{ - - /* DMA controller clock enable */ - __HAL_RCC_DMA2_CLK_ENABLE(); - - /* DMA interrupt init */ - /* DMA2_Stream0_IRQn interrupt configuration */ - HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 10, 0); - HAL_NVIC_EnableIRQ(DMA2_Stream0_IRQn); - /* DMA2_Stream1_IRQn interrupt configuration */ - HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(DMA2_Stream1_IRQn); - /* DMA2_Stream4_IRQn interrupt configuration */ - HAL_NVIC_SetPriority(DMA2_Stream4_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(DMA2_Stream4_IRQn); - -} - -/* FMC initialization function */ -static void MX_FMC_Init(void) -{ - - /* USER CODE BEGIN FMC_Init 0 */ - - /* USER CODE END FMC_Init 0 */ - - FMC_SDRAM_TimingTypeDef SdramTiming = {0}; - - /* USER CODE BEGIN FMC_Init 1 */ - - /* USER CODE END FMC_Init 1 */ - - /** Perform the SDRAM1 memory initialization sequence - */ - hsdram1.Instance = FMC_SDRAM_DEVICE; - /* hsdram1.Init */ - hsdram1.Init.SDBank = FMC_SDRAM_BANK2; - hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8; - hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_12; - hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_16; - hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4; - hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3; - hsdram1.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE; - hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2; - hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE; - hsdram1.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0; - /* SdramTiming */ - SdramTiming.LoadToActiveDelay = 2; - SdramTiming.ExitSelfRefreshDelay = 6; - SdramTiming.SelfRefreshTime = 4; - SdramTiming.RowCycleDelay = 6; - SdramTiming.WriteRecoveryTime = 2; - SdramTiming.RPDelay = 2; - SdramTiming.RCDDelay = 2; - - if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK) - { - Error_Handler( ); - } - - /* USER CODE BEGIN FMC_Init 2 */ - - /* USER CODE END FMC_Init 2 */ -} - -/** - * @brief GPIO Initialization Function - * @param None - * @retval None - */ -static void MX_GPIO_Init(void) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - - /* GPIO Ports Clock Enable */ - __HAL_RCC_GPIOE_CLK_ENABLE(); - __HAL_RCC_GPIOC_CLK_ENABLE(); - __HAL_RCC_GPIOF_CLK_ENABLE(); - __HAL_RCC_GPIOH_CLK_ENABLE(); - __HAL_RCC_GPIOA_CLK_ENABLE(); - __HAL_RCC_GPIOB_CLK_ENABLE(); - __HAL_RCC_GPIOG_CLK_ENABLE(); - __HAL_RCC_GPIOD_CLK_ENABLE(); - - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOC, EXTSPI_nCS_Pin|FLASH_HOLD_Pin|FLASH_nCS_Pin, GPIO_PIN_RESET); - - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOB, CS_nCS_Pin|CS_nRST_Pin, GPIO_PIN_RESET); - - /*Configure GPIO pins : PC13 PC14 PC6 PC7 - PC8 PC9 PC10 PC11 - PC12 */ - GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_6|GPIO_PIN_7 - |GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11 - |GPIO_PIN_12; - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /*Configure GPIO pins : EXTSPI_nCS_Pin FLASH_HOLD_Pin FLASH_nCS_Pin */ - GPIO_InitStruct.Pin = EXTSPI_nCS_Pin|FLASH_HOLD_Pin|FLASH_nCS_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /*Configure GPIO pins : PF6 PF7 PF8 PF9 */ - GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9; - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); - - /*Configure GPIO pins : PA0 PA1 PA3 PA4 - PA5 PA8 PA10 PA15 */ - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_3|GPIO_PIN_4 - |GPIO_PIN_5|GPIO_PIN_8|GPIO_PIN_10|GPIO_PIN_15; - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /*Configure GPIO pin : PA2 */ - GPIO_InitStruct.Pin = GPIO_PIN_2; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF7_USART2; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /*Configure GPIO pins : PB0 PB1 PB12 PB13 - PB14 PB15 PB4 PB7 */ - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_12|GPIO_PIN_13 - |GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_4|GPIO_PIN_7; - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /*Configure GPIO pins : SW2_Pin SW3_Pin SW1_Pin */ - GPIO_InitStruct.Pin = SW2_Pin|SW3_Pin|SW1_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; - GPIO_InitStruct.Pull = GPIO_PULLUP; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /*Configure GPIO pins : CS_nCS_Pin CS_nRST_Pin */ - GPIO_InitStruct.Pin = CS_nCS_Pin|CS_nRST_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /*Configure GPIO pins : PD11 PD12 PD13 PD2 - PD3 PD4 PD5 PD7 */ - GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_2 - |GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_7; - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); - - /*Configure GPIO pins : PG2 PG3 PG6 PG7 - PG9 PG10 PG11 PG12 - PG13 PG14 */ - GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_6|GPIO_PIN_7 - |GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12 - |GPIO_PIN_13|GPIO_PIN_14; - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); - - /* EXTI interrupt init*/ - HAL_NVIC_SetPriority(EXTI2_IRQn, 15, 0); - HAL_NVIC_EnableIRQ(EXTI2_IRQn); - - HAL_NVIC_SetPriority(EXTI9_5_IRQn, 15, 0); - HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); - -} - -/* USER CODE BEGIN 4 */ - -/* USER CODE END 4 */ - -/* USER CODE BEGIN Header_StartDefaultTask */ -/** - * @brief Function implementing the defaultTask thread. - * @param argument: Not used - * @retval None - */ -/* USER CODE END Header_StartDefaultTask */ -void StartDefaultTask(void const * argument) -{ - /* init code for USB_DEVICE */ - MX_USB_DEVICE_Init(); - /* USER CODE BEGIN 5 */ - setup(); - - /* Infinite loop */ - for(;;) - { - loop(); - /* osDelay(1); */ - } - /* USER CODE END 5 */ -} - -/** - * @brief This function is executed in case of error occurrence. - * @retval None - */ -void Error_Handler(void) -{ - /* USER CODE BEGIN Error_Handler_Debug */ - /* User can add his own implementation to report the HAL error return state */ -#ifdef DEBUG - __asm__("BKPT"); -#else - NVIC_SystemReset(); -#endif - /* USER CODE END Error_Handler_Debug */ -} - -#ifdef USE_FULL_ASSERT -/** - * @brief Reports the name of the source file and the source line number - * where the assert_param error has occurred. - * @param file: pointer to the source file name - * @param line: assert_param error line source number - * @retval None - */ -void assert_failed(uint8_t *file, uint32_t line) -{ - /* USER CODE BEGIN 6 */ - /* User can add his own implementation to report the file name and line number, - ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ -#ifdef DEBUG - __asm__("BKPT"); -#else - NVIC_SystemReset(); -#endif - /* USER CODE END 6 */ -} -#endif /* USE_FULL_ASSERT */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Src/startup_stm32f427xx.s b/OwlPedal2/Src/startup_stm32f427xx.s deleted file mode 100644 index 7ddee113..00000000 --- a/OwlPedal2/Src/startup_stm32f427xx.s +++ /dev/null @@ -1,553 +0,0 @@ -/** - ****************************************************************************** - * @file startup_stm32f427xx.s - * @author MCD Application Team - * @version V2.6.1 - * @date 14-February-2017 - * @brief STM32F427xx Devices vector table for GCC based toolchains. - * This module performs: - * - Set the initial SP - * - Set the initial PC == Reset_Handler, - * - Set the vector table entries with the exceptions ISR address - * - Branches to main in the C library (which eventually - * calls main()). - * After Reset the Cortex-M4 processor is in Thread mode, - * priority is Privileged, and the Stack is set to Main. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT 2017 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - - .syntax unified - .cpu cortex-m4 - .fpu softvfp - .thumb - -.global g_pfnVectors -.global Default_Handler - -/* start address for the initialization values of the .data section. -defined in linker script */ -.word _sidata -/* start address for the .data section. defined in linker script */ -.word _sdata -/* end address for the .data section. defined in linker script */ -.word _edata -/* start address for the .bss section. defined in linker script */ -.word _sbss -/* end address for the .bss section. defined in linker script */ -.word _ebss -/* stack used for SystemInit_ExtMemCtl; always internal RAM used */ - -/** - * @brief This is the code that gets called when the processor first - * starts execution following a reset event. Only the absolutely - * necessary set is performed, after which the application - * supplied main() routine is called. - * @param None - * @retval : None -*/ - - .section .text.Reset_Handler - .weak Reset_Handler - .type Reset_Handler, %function -Reset_Handler: - ldr sp, =_estack /* set stack pointer */ - -/* Copy the data segment initializers from flash to SRAM */ - movs r1, #0 - b LoopCopyDataInit - -CopyDataInit: - ldr r3, =_sidata - ldr r3, [r3, r1] - str r3, [r0, r1] - adds r1, r1, #4 - -LoopCopyDataInit: - ldr r0, =_sdata - ldr r3, =_edata - adds r2, r0, r1 - cmp r2, r3 - bcc CopyDataInit - ldr r2, =_sbss - b LoopFillZerobss -/* Zero fill the bss segment. */ -FillZerobss: - movs r3, #0 - str r3, [r2], #4 - -LoopFillZerobss: - ldr r3, = _ebss - cmp r2, r3 - bcc FillZerobss - -/* Call the clock system intitialization function.*/ - bl SystemInit -/* Call static constructors */ - bl __libc_init_array -/* Call the application's entry point.*/ - bl main - bx lr -.size Reset_Handler, .-Reset_Handler - -/** - * @brief This is the code that gets called when the processor receives an - * unexpected interrupt. This simply enters an infinite loop, preserving - * the system state for examination by a debugger. - * @param None - * @retval None -*/ - .section .text.Default_Handler,"ax",%progbits -Default_Handler: -Infinite_Loop: - b Infinite_Loop - .size Default_Handler, .-Default_Handler -/****************************************************************************** -* -* The minimal vector table for a Cortex M3. Note that the proper constructs -* must be placed on this to ensure that it ends up at physical address -* 0x0000.0000. -* -*******************************************************************************/ - .section .isr_vector,"a",%progbits - .type g_pfnVectors, %object - .size g_pfnVectors, .-g_pfnVectors - - -g_pfnVectors: - .word _estack - .word Reset_Handler - - .word NMI_Handler - .word HardFault_Handler - .word MemManage_Handler - .word BusFault_Handler - .word UsageFault_Handler - .word 0 - .word 0 - .word 0 - .word 0 - .word SVC_Handler - .word DebugMon_Handler - .word 0 - .word PendSV_Handler - .word SysTick_Handler - - /* External Interrupts */ - .word WWDG_IRQHandler /* Window WatchDog */ - .word PVD_IRQHandler /* PVD through EXTI Line detection */ - .word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */ - .word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */ - .word FLASH_IRQHandler /* FLASH */ - .word RCC_IRQHandler /* RCC */ - .word EXTI0_IRQHandler /* EXTI Line0 */ - .word EXTI1_IRQHandler /* EXTI Line1 */ - .word EXTI2_IRQHandler /* EXTI Line2 */ - .word EXTI3_IRQHandler /* EXTI Line3 */ - .word EXTI4_IRQHandler /* EXTI Line4 */ - .word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */ - .word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */ - .word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */ - .word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */ - .word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */ - .word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */ - .word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */ - .word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */ - .word CAN1_TX_IRQHandler /* CAN1 TX */ - .word CAN1_RX0_IRQHandler /* CAN1 RX0 */ - .word CAN1_RX1_IRQHandler /* CAN1 RX1 */ - .word CAN1_SCE_IRQHandler /* CAN1 SCE */ - .word EXTI9_5_IRQHandler /* External Line[9:5]s */ - .word TIM1_BRK_TIM9_IRQHandler /* TIM1 Break and TIM9 */ - .word TIM1_UP_TIM10_IRQHandler /* TIM1 Update and TIM10 */ - .word TIM1_TRG_COM_TIM11_IRQHandler /* TIM1 Trigger and Commutation and TIM11 */ - .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */ - .word TIM2_IRQHandler /* TIM2 */ - .word TIM3_IRQHandler /* TIM3 */ - .word TIM4_IRQHandler /* TIM4 */ - .word I2C1_EV_IRQHandler /* I2C1 Event */ - .word I2C1_ER_IRQHandler /* I2C1 Error */ - .word I2C2_EV_IRQHandler /* I2C2 Event */ - .word I2C2_ER_IRQHandler /* I2C2 Error */ - .word SPI1_IRQHandler /* SPI1 */ - .word SPI2_IRQHandler /* SPI2 */ - .word USART1_IRQHandler /* USART1 */ - .word USART2_IRQHandler /* USART2 */ - .word USART3_IRQHandler /* USART3 */ - .word EXTI15_10_IRQHandler /* External Line[15:10]s */ - .word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */ - .word OTG_FS_WKUP_IRQHandler /* USB OTG FS Wakeup through EXTI line */ - .word TIM8_BRK_TIM12_IRQHandler /* TIM8 Break and TIM12 */ - .word TIM8_UP_TIM13_IRQHandler /* TIM8 Update and TIM13 */ - .word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */ - .word TIM8_CC_IRQHandler /* TIM8 Capture Compare */ - .word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */ - .word FMC_IRQHandler /* FMC */ - .word SDIO_IRQHandler /* SDIO */ - .word TIM5_IRQHandler /* TIM5 */ - .word SPI3_IRQHandler /* SPI3 */ - .word UART4_IRQHandler /* UART4 */ - .word UART5_IRQHandler /* UART5 */ - .word TIM6_DAC_IRQHandler /* TIM6 and DAC1&2 underrun errors */ - .word TIM7_IRQHandler /* TIM7 */ - .word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */ - .word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */ - .word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */ - .word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */ - .word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */ - .word ETH_IRQHandler /* Ethernet */ - .word ETH_WKUP_IRQHandler /* Ethernet Wakeup through EXTI line */ - .word CAN2_TX_IRQHandler /* CAN2 TX */ - .word CAN2_RX0_IRQHandler /* CAN2 RX0 */ - .word CAN2_RX1_IRQHandler /* CAN2 RX1 */ - .word CAN2_SCE_IRQHandler /* CAN2 SCE */ - .word OTG_FS_IRQHandler /* USB OTG FS */ - .word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */ - .word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */ - .word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */ - .word USART6_IRQHandler /* USART6 */ - .word I2C3_EV_IRQHandler /* I2C3 event */ - .word I2C3_ER_IRQHandler /* I2C3 error */ - .word OTG_HS_EP1_OUT_IRQHandler /* USB OTG HS End Point 1 Out */ - .word OTG_HS_EP1_IN_IRQHandler /* USB OTG HS End Point 1 In */ - .word OTG_HS_WKUP_IRQHandler /* USB OTG HS Wakeup through EXTI */ - .word OTG_HS_IRQHandler /* USB OTG HS */ - .word DCMI_IRQHandler /* DCMI */ - .word 0 /* Reserved */ - .word HASH_RNG_IRQHandler /* Hash and Rng */ - .word FPU_IRQHandler /* FPU */ - .word UART7_IRQHandler /* UART7 */ - .word UART8_IRQHandler /* UART8 */ - .word SPI4_IRQHandler /* SPI4 */ - .word SPI5_IRQHandler /* SPI5 */ - .word SPI6_IRQHandler /* SPI6 */ - .word SAI1_IRQHandler /* SAI1 */ - .word 0 /* Reserved */ - .word 0 /* Reserved */ - .word DMA2D_IRQHandler /* DMA2D */ -/******************************************************************************* -* -* Provide weak aliases for each Exception handler to the Default_Handler. -* As they are weak aliases, any function with the same name will override -* this definition. -* -*******************************************************************************/ - .weak NMI_Handler - .thumb_set NMI_Handler,Default_Handler - - .weak HardFault_Handler - .thumb_set HardFault_Handler,Default_Handler - - .weak MemManage_Handler - .thumb_set MemManage_Handler,Default_Handler - - .weak BusFault_Handler - .thumb_set BusFault_Handler,Default_Handler - - .weak UsageFault_Handler - .thumb_set UsageFault_Handler,Default_Handler - - .weak SVC_Handler - .thumb_set SVC_Handler,Default_Handler - - .weak DebugMon_Handler - .thumb_set DebugMon_Handler,Default_Handler - - .weak PendSV_Handler - .thumb_set PendSV_Handler,Default_Handler - - .weak SysTick_Handler - .thumb_set SysTick_Handler,Default_Handler - - .weak WWDG_IRQHandler - .thumb_set WWDG_IRQHandler,Default_Handler - - .weak PVD_IRQHandler - .thumb_set PVD_IRQHandler,Default_Handler - - .weak TAMP_STAMP_IRQHandler - .thumb_set TAMP_STAMP_IRQHandler,Default_Handler - - .weak RTC_WKUP_IRQHandler - .thumb_set RTC_WKUP_IRQHandler,Default_Handler - - .weak FLASH_IRQHandler - .thumb_set FLASH_IRQHandler,Default_Handler - - .weak RCC_IRQHandler - .thumb_set RCC_IRQHandler,Default_Handler - - .weak EXTI0_IRQHandler - .thumb_set EXTI0_IRQHandler,Default_Handler - - .weak EXTI1_IRQHandler - .thumb_set EXTI1_IRQHandler,Default_Handler - - .weak EXTI2_IRQHandler - .thumb_set EXTI2_IRQHandler,Default_Handler - - .weak EXTI3_IRQHandler - .thumb_set EXTI3_IRQHandler,Default_Handler - - .weak EXTI4_IRQHandler - .thumb_set EXTI4_IRQHandler,Default_Handler - - .weak DMA1_Stream0_IRQHandler - .thumb_set DMA1_Stream0_IRQHandler,Default_Handler - - .weak DMA1_Stream1_IRQHandler - .thumb_set DMA1_Stream1_IRQHandler,Default_Handler - - .weak DMA1_Stream2_IRQHandler - .thumb_set DMA1_Stream2_IRQHandler,Default_Handler - - .weak DMA1_Stream3_IRQHandler - .thumb_set DMA1_Stream3_IRQHandler,Default_Handler - - .weak DMA1_Stream4_IRQHandler - .thumb_set DMA1_Stream4_IRQHandler,Default_Handler - - .weak DMA1_Stream5_IRQHandler - .thumb_set DMA1_Stream5_IRQHandler,Default_Handler - - .weak DMA1_Stream6_IRQHandler - .thumb_set DMA1_Stream6_IRQHandler,Default_Handler - - .weak ADC_IRQHandler - .thumb_set ADC_IRQHandler,Default_Handler - - .weak CAN1_TX_IRQHandler - .thumb_set CAN1_TX_IRQHandler,Default_Handler - - .weak CAN1_RX0_IRQHandler - .thumb_set CAN1_RX0_IRQHandler,Default_Handler - - .weak CAN1_RX1_IRQHandler - .thumb_set CAN1_RX1_IRQHandler,Default_Handler - - .weak CAN1_SCE_IRQHandler - .thumb_set CAN1_SCE_IRQHandler,Default_Handler - - .weak EXTI9_5_IRQHandler - .thumb_set EXTI9_5_IRQHandler,Default_Handler - - .weak TIM1_BRK_TIM9_IRQHandler - .thumb_set TIM1_BRK_TIM9_IRQHandler,Default_Handler - - .weak TIM1_UP_TIM10_IRQHandler - .thumb_set TIM1_UP_TIM10_IRQHandler,Default_Handler - - .weak TIM1_TRG_COM_TIM11_IRQHandler - .thumb_set TIM1_TRG_COM_TIM11_IRQHandler,Default_Handler - - .weak TIM1_CC_IRQHandler - .thumb_set TIM1_CC_IRQHandler,Default_Handler - - .weak TIM2_IRQHandler - .thumb_set TIM2_IRQHandler,Default_Handler - - .weak TIM3_IRQHandler - .thumb_set TIM3_IRQHandler,Default_Handler - - .weak TIM4_IRQHandler - .thumb_set TIM4_IRQHandler,Default_Handler - - .weak I2C1_EV_IRQHandler - .thumb_set I2C1_EV_IRQHandler,Default_Handler - - .weak I2C1_ER_IRQHandler - .thumb_set I2C1_ER_IRQHandler,Default_Handler - - .weak I2C2_EV_IRQHandler - .thumb_set I2C2_EV_IRQHandler,Default_Handler - - .weak I2C2_ER_IRQHandler - .thumb_set I2C2_ER_IRQHandler,Default_Handler - - .weak SPI1_IRQHandler - .thumb_set SPI1_IRQHandler,Default_Handler - - .weak SPI2_IRQHandler - .thumb_set SPI2_IRQHandler,Default_Handler - - .weak USART1_IRQHandler - .thumb_set USART1_IRQHandler,Default_Handler - - .weak USART2_IRQHandler - .thumb_set USART2_IRQHandler,Default_Handler - - .weak USART3_IRQHandler - .thumb_set USART3_IRQHandler,Default_Handler - - .weak EXTI15_10_IRQHandler - .thumb_set EXTI15_10_IRQHandler,Default_Handler - - .weak RTC_Alarm_IRQHandler - .thumb_set RTC_Alarm_IRQHandler,Default_Handler - - .weak OTG_FS_WKUP_IRQHandler - .thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler - - .weak TIM8_BRK_TIM12_IRQHandler - .thumb_set TIM8_BRK_TIM12_IRQHandler,Default_Handler - - .weak TIM8_UP_TIM13_IRQHandler - .thumb_set TIM8_UP_TIM13_IRQHandler,Default_Handler - - .weak TIM8_TRG_COM_TIM14_IRQHandler - .thumb_set TIM8_TRG_COM_TIM14_IRQHandler,Default_Handler - - .weak TIM8_CC_IRQHandler - .thumb_set TIM8_CC_IRQHandler,Default_Handler - - .weak DMA1_Stream7_IRQHandler - .thumb_set DMA1_Stream7_IRQHandler,Default_Handler - - .weak FMC_IRQHandler - .thumb_set FMC_IRQHandler,Default_Handler - - .weak SDIO_IRQHandler - .thumb_set SDIO_IRQHandler,Default_Handler - - .weak TIM5_IRQHandler - .thumb_set TIM5_IRQHandler,Default_Handler - - .weak SPI3_IRQHandler - .thumb_set SPI3_IRQHandler,Default_Handler - - .weak UART4_IRQHandler - .thumb_set UART4_IRQHandler,Default_Handler - - .weak UART5_IRQHandler - .thumb_set UART5_IRQHandler,Default_Handler - - .weak TIM6_DAC_IRQHandler - .thumb_set TIM6_DAC_IRQHandler,Default_Handler - - .weak TIM7_IRQHandler - .thumb_set TIM7_IRQHandler,Default_Handler - - .weak DMA2_Stream0_IRQHandler - .thumb_set DMA2_Stream0_IRQHandler,Default_Handler - - .weak DMA2_Stream1_IRQHandler - .thumb_set DMA2_Stream1_IRQHandler,Default_Handler - - .weak DMA2_Stream2_IRQHandler - .thumb_set DMA2_Stream2_IRQHandler,Default_Handler - - .weak DMA2_Stream3_IRQHandler - .thumb_set DMA2_Stream3_IRQHandler,Default_Handler - - .weak DMA2_Stream4_IRQHandler - .thumb_set DMA2_Stream4_IRQHandler,Default_Handler - - .weak ETH_IRQHandler - .thumb_set ETH_IRQHandler,Default_Handler - - .weak ETH_WKUP_IRQHandler - .thumb_set ETH_WKUP_IRQHandler,Default_Handler - - .weak CAN2_TX_IRQHandler - .thumb_set CAN2_TX_IRQHandler,Default_Handler - - .weak CAN2_RX0_IRQHandler - .thumb_set CAN2_RX0_IRQHandler,Default_Handler - - .weak CAN2_RX1_IRQHandler - .thumb_set CAN2_RX1_IRQHandler,Default_Handler - - .weak CAN2_SCE_IRQHandler - .thumb_set CAN2_SCE_IRQHandler,Default_Handler - - .weak OTG_FS_IRQHandler - .thumb_set OTG_FS_IRQHandler,Default_Handler - - .weak DMA2_Stream5_IRQHandler - .thumb_set DMA2_Stream5_IRQHandler,Default_Handler - - .weak DMA2_Stream6_IRQHandler - .thumb_set DMA2_Stream6_IRQHandler,Default_Handler - - .weak DMA2_Stream7_IRQHandler - .thumb_set DMA2_Stream7_IRQHandler,Default_Handler - - .weak USART6_IRQHandler - .thumb_set USART6_IRQHandler,Default_Handler - - .weak I2C3_EV_IRQHandler - .thumb_set I2C3_EV_IRQHandler,Default_Handler - - .weak I2C3_ER_IRQHandler - .thumb_set I2C3_ER_IRQHandler,Default_Handler - - .weak OTG_HS_EP1_OUT_IRQHandler - .thumb_set OTG_HS_EP1_OUT_IRQHandler,Default_Handler - - .weak OTG_HS_EP1_IN_IRQHandler - .thumb_set OTG_HS_EP1_IN_IRQHandler,Default_Handler - - .weak OTG_HS_WKUP_IRQHandler - .thumb_set OTG_HS_WKUP_IRQHandler,Default_Handler - - .weak OTG_HS_IRQHandler - .thumb_set OTG_HS_IRQHandler,Default_Handler - - .weak DCMI_IRQHandler - .thumb_set DCMI_IRQHandler,Default_Handler - - .weak HASH_RNG_IRQHandler - .thumb_set HASH_RNG_IRQHandler,Default_Handler - - .weak FPU_IRQHandler - .thumb_set FPU_IRQHandler,Default_Handler - - .weak UART7_IRQHandler - .thumb_set UART7_IRQHandler,Default_Handler - - .weak UART8_IRQHandler - .thumb_set UART8_IRQHandler,Default_Handler - - .weak SPI4_IRQHandler - .thumb_set SPI4_IRQHandler,Default_Handler - - .weak SPI5_IRQHandler - .thumb_set SPI5_IRQHandler,Default_Handler - - .weak SPI6_IRQHandler - .thumb_set SPI6_IRQHandler,Default_Handler - - .weak SAI1_IRQHandler - .thumb_set SAI1_IRQHandler,Default_Handler - - .weak DMA2D_IRQHandler - .thumb_set DMA2D_IRQHandler,Default_Handler - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ - diff --git a/OwlPedal2/Src/stm32f4xx_hal_msp.c b/OwlPedal2/Src/stm32f4xx_hal_msp.c deleted file mode 100644 index 604e802b..00000000 --- a/OwlPedal2/Src/stm32f4xx_hal_msp.c +++ /dev/null @@ -1,739 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * File Name : stm32f4xx_hal_msp.c - * Description : This file provides code for the MSP Initialization - * and de-Initialization codes. - ****************************************************************************** - * This notice applies to any and all portions of this file - * that are not between comment pairs USER CODE BEGIN and - * USER CODE END. Other portions of this file, whether - * inserted by the user or by software development tools - * are owned by their respective copyright owners. - * - * Copyright (c) 2019 STMicroelectronics International N.V. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted, provided that the following conditions are met: - * - * 1. Redistribution of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of other - * contributors to this software may be used to endorse or promote products - * derived from this software without specific written permission. - * 4. This software, including modifications and/or derivative works of this - * software, must execute solely and exclusively on microcontroller or - * microprocessor devices manufactured by or for STMicroelectronics. - * 5. Redistribution and use of this software other than as permitted under - * this license is void and will automatically terminate your rights under - * this license. - * - * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY - * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT - * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ -extern DMA_HandleTypeDef hdma_adc3; - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN TD */ - -/* USER CODE END TD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN Define */ - -/* USER CODE END Define */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN Macro */ - -/* USER CODE END Macro */ - -/* Private variables ---------------------------------------------------------*/ -/* USER CODE BEGIN PV */ - -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* External functions --------------------------------------------------------*/ -/* USER CODE BEGIN ExternalFunctions */ - -/* USER CODE END ExternalFunctions */ - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ -/** - * Initializes the Global MSP. - */ -void HAL_MspInit(void) -{ - /* USER CODE BEGIN MspInit 0 */ - - /* USER CODE END MspInit 0 */ - - __HAL_RCC_SYSCFG_CLK_ENABLE(); - __HAL_RCC_PWR_CLK_ENABLE(); - - /* System interrupt init*/ - /* PendSV_IRQn interrupt configuration */ - HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0); - - /* USER CODE BEGIN MspInit 1 */ - - /* USER CODE END MspInit 1 */ -} - -/** -* @brief ADC MSP Initialization -* This function configures the hardware resources used in this example -* @param hadc: ADC handle pointer -* @retval None -*/ -void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - if(hadc->Instance==ADC3) - { - /* USER CODE BEGIN ADC3_MspInit 0 */ - - /* USER CODE END ADC3_MspInit 0 */ - /* Peripheral clock enable */ - __HAL_RCC_ADC3_CLK_ENABLE(); - - __HAL_RCC_GPIOF_CLK_ENABLE(); - __HAL_RCC_GPIOC_CLK_ENABLE(); - /**ADC3 GPIO Configuration - PF10 ------> ADC3_IN8 - PC1 ------> ADC3_IN11 - PC2 ------> ADC3_IN12 - PC3 ------> ADC3_IN13 - */ - GPIO_InitStruct.Pin = ADC4_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(ADC4_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = ADC3_Pin|ADC2_Pin|ADC1_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /* ADC3 DMA Init */ - /* ADC3 Init */ - hdma_adc3.Instance = DMA2_Stream0; - hdma_adc3.Init.Channel = DMA_CHANNEL_2; - hdma_adc3.Init.Direction = DMA_PERIPH_TO_MEMORY; - hdma_adc3.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_adc3.Init.MemInc = DMA_MINC_ENABLE; - hdma_adc3.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; - hdma_adc3.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; - hdma_adc3.Init.Mode = DMA_CIRCULAR; - hdma_adc3.Init.Priority = DMA_PRIORITY_LOW; - hdma_adc3.Init.FIFOMode = DMA_FIFOMODE_DISABLE; - if (HAL_DMA_Init(&hdma_adc3) != HAL_OK) - { - Error_Handler(); - } - - __HAL_LINKDMA(hadc,DMA_Handle,hdma_adc3); - - /* USER CODE BEGIN ADC3_MspInit 1 */ - - /* USER CODE END ADC3_MspInit 1 */ - } - -} - -/** -* @brief ADC MSP De-Initialization -* This function freeze the hardware resources used in this example -* @param hadc: ADC handle pointer -* @retval None -*/ -void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) -{ - if(hadc->Instance==ADC3) - { - /* USER CODE BEGIN ADC3_MspDeInit 0 */ - - /* USER CODE END ADC3_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_ADC3_CLK_DISABLE(); - - /**ADC3 GPIO Configuration - PF10 ------> ADC3_IN8 - PC1 ------> ADC3_IN11 - PC2 ------> ADC3_IN12 - PC3 ------> ADC3_IN13 - */ - HAL_GPIO_DeInit(ADC4_GPIO_Port, ADC4_Pin); - - HAL_GPIO_DeInit(GPIOC, ADC3_Pin|ADC2_Pin|ADC1_Pin); - - /* ADC3 DMA DeInit */ - HAL_DMA_DeInit(hadc->DMA_Handle); - /* USER CODE BEGIN ADC3_MspDeInit 1 */ - - /* USER CODE END ADC3_MspDeInit 1 */ - } - -} - -/** -* @brief RTC MSP Initialization -* This function configures the hardware resources used in this example -* @param hrtc: RTC handle pointer -* @retval None -*/ -void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc) -{ - if(hrtc->Instance==RTC) - { - /* USER CODE BEGIN RTC_MspInit 0 */ - - /* USER CODE END RTC_MspInit 0 */ - /* Peripheral clock enable */ - __HAL_RCC_RTC_ENABLE(); - /* USER CODE BEGIN RTC_MspInit 1 */ - - /* USER CODE END RTC_MspInit 1 */ - } - -} - -/** -* @brief RTC MSP De-Initialization -* This function freeze the hardware resources used in this example -* @param hrtc: RTC handle pointer -* @retval None -*/ -void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc) -{ - if(hrtc->Instance==RTC) - { - /* USER CODE BEGIN RTC_MspDeInit 0 */ - - /* USER CODE END RTC_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_RTC_DISABLE(); - /* USER CODE BEGIN RTC_MspDeInit 1 */ - - /* USER CODE END RTC_MspDeInit 1 */ - } - -} - -/** -* @brief SPI MSP Initialization -* This function configures the hardware resources used in this example -* @param hspi: SPI handle pointer -* @retval None -*/ -void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - if(hspi->Instance==SPI1) - { - /* USER CODE BEGIN SPI1_MspInit 0 */ - - /* USER CODE END SPI1_MspInit 0 */ - /* Peripheral clock enable */ - __HAL_RCC_SPI1_CLK_ENABLE(); - - __HAL_RCC_GPIOA_CLK_ENABLE(); - __HAL_RCC_GPIOB_CLK_ENABLE(); - /**SPI1 GPIO Configuration - PA6 ------> SPI1_MISO - PA7 ------> SPI1_MOSI - PB3 ------> SPI1_SCK - */ - GPIO_InitStruct.Pin = FLASH_MISO_Pin|FLASH_MOSI_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = FLASH_SCK_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; - HAL_GPIO_Init(FLASH_SCK_GPIO_Port, &GPIO_InitStruct); - - /* USER CODE BEGIN SPI1_MspInit 1 */ - - /* USER CODE END SPI1_MspInit 1 */ - } - else if(hspi->Instance==SPI4) - { - /* USER CODE BEGIN SPI4_MspInit 0 */ - - /* USER CODE END SPI4_MspInit 0 */ - /* Peripheral clock enable */ - __HAL_RCC_SPI4_CLK_ENABLE(); - - __HAL_RCC_GPIOE_CLK_ENABLE(); - /**SPI4 GPIO Configuration - PE2 ------> SPI4_SCK - PE6 ------> SPI4_MOSI - */ - GPIO_InitStruct.Pin = CS_SCK_Pin|CS_SDA_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF5_SPI4; - HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); - - /* USER CODE BEGIN SPI4_MspInit 1 */ - - /* USER CODE END SPI4_MspInit 1 */ - } - -} - -/** -* @brief SPI MSP De-Initialization -* This function freeze the hardware resources used in this example -* @param hspi: SPI handle pointer -* @retval None -*/ -void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) -{ - if(hspi->Instance==SPI1) - { - /* USER CODE BEGIN SPI1_MspDeInit 0 */ - - /* USER CODE END SPI1_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_SPI1_CLK_DISABLE(); - - /**SPI1 GPIO Configuration - PA6 ------> SPI1_MISO - PA7 ------> SPI1_MOSI - PB3 ------> SPI1_SCK - */ - HAL_GPIO_DeInit(GPIOA, FLASH_MISO_Pin|FLASH_MOSI_Pin); - - HAL_GPIO_DeInit(FLASH_SCK_GPIO_Port, FLASH_SCK_Pin); - - /* USER CODE BEGIN SPI1_MspDeInit 1 */ - - /* USER CODE END SPI1_MspDeInit 1 */ - } - else if(hspi->Instance==SPI4) - { - /* USER CODE BEGIN SPI4_MspDeInit 0 */ - - /* USER CODE END SPI4_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_SPI4_CLK_DISABLE(); - - /**SPI4 GPIO Configuration - PE2 ------> SPI4_SCK - PE6 ------> SPI4_MOSI - */ - HAL_GPIO_DeInit(GPIOE, CS_SCK_Pin|CS_SDA_Pin); - - /* USER CODE BEGIN SPI4_MspDeInit 1 */ - - /* USER CODE END SPI4_MspDeInit 1 */ - } - -} - -static uint32_t FMC_Initialized = 0; - -static void HAL_FMC_MspInit(void){ - /* USER CODE BEGIN FMC_MspInit 0 */ - - /* USER CODE END FMC_MspInit 0 */ - GPIO_InitTypeDef GPIO_InitStruct ={0}; - if (FMC_Initialized) { - return; - } - FMC_Initialized = 1; - - /* Peripheral clock enable */ - __HAL_RCC_FMC_CLK_ENABLE(); - - /** FMC GPIO Configuration - PF0 ------> FMC_A0 - PF1 ------> FMC_A1 - PF2 ------> FMC_A2 - PF3 ------> FMC_A3 - PF4 ------> FMC_A4 - PF5 ------> FMC_A5 - PC0 ------> FMC_SDNWE - PF11 ------> FMC_SDNRAS - PF12 ------> FMC_A6 - PF13 ------> FMC_A7 - PF14 ------> FMC_A8 - PF15 ------> FMC_A9 - PG0 ------> FMC_A10 - PG1 ------> FMC_A11 - PE7 ------> FMC_D4 - PE8 ------> FMC_D5 - PE9 ------> FMC_D6 - PE10 ------> FMC_D7 - PE11 ------> FMC_D8 - PE12 ------> FMC_D9 - PE13 ------> FMC_D10 - PE14 ------> FMC_D11 - PE15 ------> FMC_D12 - PD8 ------> FMC_D13 - PD9 ------> FMC_D14 - PD10 ------> FMC_D15 - PD14 ------> FMC_D0 - PD15 ------> FMC_D1 - PG4 ------> FMC_BA0 - PG5 ------> FMC_BA1 - PG8 ------> FMC_SDCLK - PD0 ------> FMC_D2 - PD1 ------> FMC_D3 - PG15 ------> FMC_SDNCAS - PB5 ------> FMC_SDCKE1 - PB6 ------> FMC_SDNE1 - PE0 ------> FMC_NBL0 - PE1 ------> FMC_NBL1 - */ - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 - |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_11|GPIO_PIN_12 - |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF12_FMC; - HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = GPIO_PIN_0; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF12_FMC; - HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5 - |GPIO_PIN_8|GPIO_PIN_15; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF12_FMC; - HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 - |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 - |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF12_FMC; - HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14 - |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF12_FMC; - HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF12_FMC; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /* USER CODE BEGIN FMC_MspInit 1 */ - - /* USER CODE END FMC_MspInit 1 */ -} - -void HAL_SDRAM_MspInit(SDRAM_HandleTypeDef* hsdram){ - /* USER CODE BEGIN SDRAM_MspInit 0 */ - - /* USER CODE END SDRAM_MspInit 0 */ - HAL_FMC_MspInit(); - /* USER CODE BEGIN SDRAM_MspInit 1 */ - - /* USER CODE END SDRAM_MspInit 1 */ -} - -static uint32_t FMC_DeInitialized = 0; - -static void HAL_FMC_MspDeInit(void){ - /* USER CODE BEGIN FMC_MspDeInit 0 */ - - /* USER CODE END FMC_MspDeInit 0 */ - if (FMC_DeInitialized) { - return; - } - FMC_DeInitialized = 1; - /* Peripheral clock enable */ - __HAL_RCC_FMC_CLK_DISABLE(); - - /** FMC GPIO Configuration - PF0 ------> FMC_A0 - PF1 ------> FMC_A1 - PF2 ------> FMC_A2 - PF3 ------> FMC_A3 - PF4 ------> FMC_A4 - PF5 ------> FMC_A5 - PC0 ------> FMC_SDNWE - PF11 ------> FMC_SDNRAS - PF12 ------> FMC_A6 - PF13 ------> FMC_A7 - PF14 ------> FMC_A8 - PF15 ------> FMC_A9 - PG0 ------> FMC_A10 - PG1 ------> FMC_A11 - PE7 ------> FMC_D4 - PE8 ------> FMC_D5 - PE9 ------> FMC_D6 - PE10 ------> FMC_D7 - PE11 ------> FMC_D8 - PE12 ------> FMC_D9 - PE13 ------> FMC_D10 - PE14 ------> FMC_D11 - PE15 ------> FMC_D12 - PD8 ------> FMC_D13 - PD9 ------> FMC_D14 - PD10 ------> FMC_D15 - PD14 ------> FMC_D0 - PD15 ------> FMC_D1 - PG4 ------> FMC_BA0 - PG5 ------> FMC_BA1 - PG8 ------> FMC_SDCLK - PD0 ------> FMC_D2 - PD1 ------> FMC_D3 - PG15 ------> FMC_SDNCAS - PB5 ------> FMC_SDCKE1 - PB6 ------> FMC_SDNE1 - PE0 ------> FMC_NBL0 - PE1 ------> FMC_NBL1 - */ - HAL_GPIO_DeInit(GPIOF, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 - |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_11|GPIO_PIN_12 - |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15); - - HAL_GPIO_DeInit(GPIOC, GPIO_PIN_0); - - HAL_GPIO_DeInit(GPIOG, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5 - |GPIO_PIN_8|GPIO_PIN_15); - - HAL_GPIO_DeInit(GPIOE, GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 - |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 - |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1); - - HAL_GPIO_DeInit(GPIOD, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14 - |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1); - - HAL_GPIO_DeInit(GPIOB, GPIO_PIN_5|GPIO_PIN_6); - - /* USER CODE BEGIN FMC_MspDeInit 1 */ - - /* USER CODE END FMC_MspDeInit 1 */ -} - -void HAL_SDRAM_MspDeInit(SDRAM_HandleTypeDef* hsdram){ - /* USER CODE BEGIN SDRAM_MspDeInit 0 */ - - /* USER CODE END SDRAM_MspDeInit 0 */ - HAL_FMC_MspDeInit(); - /* USER CODE BEGIN SDRAM_MspDeInit 1 */ - - /* USER CODE END SDRAM_MspDeInit 1 */ -} - -extern DMA_HandleTypeDef hdma_sai1_a; - -extern DMA_HandleTypeDef hdma_sai1_b; - -static uint32_t SAI1_client =0; - -void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) -{ - - GPIO_InitTypeDef GPIO_InitStruct; -/* SAI1 */ - if(hsai->Instance==SAI1_Block_A) - { - /* Peripheral clock enable */ - if (SAI1_client == 0) - { - __HAL_RCC_SAI1_CLK_ENABLE(); - - /* Peripheral interrupt init*/ - HAL_NVIC_SetPriority(SAI1_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(SAI1_IRQn); - } - SAI1_client ++; - - /**SAI1_A_Block_A GPIO Configuration - PE4 ------> SAI1_FS_A - PE5 ------> SAI1_SCK_A - PD6 ------> SAI1_SD_A - */ - GPIO_InitStruct.Pin = CS_LRCK_Pin|CS_SCKE5_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; - HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = CS_SDIN_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; - HAL_GPIO_Init(CS_SDIN_GPIO_Port, &GPIO_InitStruct); - - /* Peripheral DMA init*/ - - hdma_sai1_a.Instance = DMA2_Stream1; - hdma_sai1_a.Init.Channel = DMA_CHANNEL_0; - hdma_sai1_a.Init.Direction = DMA_MEMORY_TO_PERIPH; - hdma_sai1_a.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_sai1_a.Init.MemInc = DMA_MINC_ENABLE; - hdma_sai1_a.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; - hdma_sai1_a.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - hdma_sai1_a.Init.Mode = DMA_CIRCULAR; - hdma_sai1_a.Init.Priority = DMA_PRIORITY_VERY_HIGH; - hdma_sai1_a.Init.FIFOMode = DMA_FIFOMODE_DISABLE; - if (HAL_DMA_Init(&hdma_sai1_a) != HAL_OK) - { - Error_Handler(); - } - - /* Several peripheral DMA handle pointers point to the same DMA handle. - Be aware that there is only one stream to perform all the requested DMAs. */ - __HAL_LINKDMA(hsai,hdmarx,hdma_sai1_a); - - __HAL_LINKDMA(hsai,hdmatx,hdma_sai1_a); - - } - if(hsai->Instance==SAI1_Block_B) - { - /* Peripheral clock enable */ - if (SAI1_client == 0) - { - __HAL_RCC_SAI1_CLK_ENABLE(); - - /* Peripheral interrupt init*/ - HAL_NVIC_SetPriority(SAI1_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(SAI1_IRQn); - } - SAI1_client ++; - - /**SAI1_B_Block_B GPIO Configuration - PE3 ------> SAI1_SD_B - */ - GPIO_InitStruct.Pin = CS_SDOUT_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; - HAL_GPIO_Init(CS_SDOUT_GPIO_Port, &GPIO_InitStruct); - - /* Peripheral DMA init*/ - - hdma_sai1_b.Instance = DMA2_Stream4; - hdma_sai1_b.Init.Channel = DMA_CHANNEL_1; - hdma_sai1_b.Init.Direction = DMA_PERIPH_TO_MEMORY; - hdma_sai1_b.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_sai1_b.Init.MemInc = DMA_MINC_ENABLE; - hdma_sai1_b.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; - hdma_sai1_b.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - hdma_sai1_b.Init.Mode = DMA_CIRCULAR; - hdma_sai1_b.Init.Priority = DMA_PRIORITY_VERY_HIGH; - hdma_sai1_b.Init.FIFOMode = DMA_FIFOMODE_DISABLE; - if (HAL_DMA_Init(&hdma_sai1_b) != HAL_OK) - { - Error_Handler(); - } - - /* Several peripheral DMA handle pointers point to the same DMA handle. - Be aware that there is only one stream to perform all the requested DMAs. */ - __HAL_LINKDMA(hsai,hdmarx,hdma_sai1_b); - __HAL_LINKDMA(hsai,hdmatx,hdma_sai1_b); - } -} - -void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) -{ -/* SAI1 */ - if(hsai->Instance==SAI1_Block_A) - { - SAI1_client --; - if (SAI1_client == 0) - { - /* Peripheral clock disable */ - __HAL_RCC_SAI1_CLK_DISABLE(); - HAL_NVIC_DisableIRQ(SAI1_IRQn); - } - - /**SAI1_A_Block_A GPIO Configuration - PE4 ------> SAI1_FS_A - PE5 ------> SAI1_SCK_A - PD6 ------> SAI1_SD_A - */ - HAL_GPIO_DeInit(GPIOE, CS_LRCK_Pin|CS_SCKE5_Pin); - - HAL_GPIO_DeInit(CS_SDIN_GPIO_Port, CS_SDIN_Pin); - - HAL_DMA_DeInit(hsai->hdmarx); - HAL_DMA_DeInit(hsai->hdmatx); - } - if(hsai->Instance==SAI1_Block_B) - { - SAI1_client --; - if (SAI1_client == 0) - { - /* Peripheral clock disable */ - __HAL_RCC_SAI1_CLK_DISABLE(); - HAL_NVIC_DisableIRQ(SAI1_IRQn); - } - - /**SAI1_B_Block_B GPIO Configuration - PE3 ------> SAI1_SD_B - */ - HAL_GPIO_DeInit(CS_SDOUT_GPIO_Port, CS_SDOUT_Pin); - - HAL_DMA_DeInit(hsai->hdmarx); - HAL_DMA_DeInit(hsai->hdmatx); - } -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Src/stm32f4xx_it.c b/OwlPedal2/Src/stm32f4xx_it.c deleted file mode 100644 index afca18e1..00000000 --- a/OwlPedal2/Src/stm32f4xx_it.c +++ /dev/null @@ -1,221 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32f4xx_it.c - * @brief Interrupt Service Routines. - ****************************************************************************** - * - * COPYRIGHT(c) 2019 STMicroelectronics - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" -#include "stm32f4xx_it.h" -#include "FreeRTOS.h" -#include "task.h" -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN TD */ - -/* USER CODE END TD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ - -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ -/* USER CODE BEGIN PV */ - -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* Private user code ---------------------------------------------------------*/ -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* External variables --------------------------------------------------------*/ -extern PCD_HandleTypeDef hpcd_USB_OTG_FS; -extern DMA_HandleTypeDef hdma_adc3; -extern DMA_HandleTypeDef hdma_sai1_a; -extern DMA_HandleTypeDef hdma_sai1_b; -extern SAI_HandleTypeDef hsai_BlockA1; -extern SAI_HandleTypeDef hsai_BlockB1; -/* USER CODE BEGIN EV */ - -/* USER CODE END EV */ - -/******************************************************************************/ -/* Cortex-M4 Processor Interruption and Exception Handlers */ -/******************************************************************************/ -/** - * @brief This function handles System tick timer. - */ -void SysTick_Handler(void) -{ - /* USER CODE BEGIN SysTick_IRQn 0 */ - - /* USER CODE END SysTick_IRQn 0 */ - HAL_IncTick(); -#if (INCLUDE_xTaskGetSchedulerState == 1 ) - if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) - { -#endif /* INCLUDE_xTaskGetSchedulerState */ - xPortSysTickHandler(); -#if (INCLUDE_xTaskGetSchedulerState == 1 ) - } -#endif /* INCLUDE_xTaskGetSchedulerState */ - /* USER CODE BEGIN SysTick_IRQn 1 */ - - /* USER CODE END SysTick_IRQn 1 */ -} - -/******************************************************************************/ -/* STM32F4xx Peripheral Interrupt Handlers */ -/* Add here the Interrupt Handlers for the used peripherals. */ -/* For the available peripheral interrupt handler names, */ -/* please refer to the startup file (startup_stm32f4xx.s). */ -/******************************************************************************/ - -/** - * @brief This function handles EXTI line2 interrupt. - */ -void EXTI2_IRQHandler(void) -{ - /* USER CODE BEGIN EXTI2_IRQn 0 */ - - /* USER CODE END EXTI2_IRQn 0 */ - HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2); - /* USER CODE BEGIN EXTI2_IRQn 1 */ - - /* USER CODE END EXTI2_IRQn 1 */ -} - -/** - * @brief This function handles EXTI line[9:5] interrupts. - */ -void EXTI9_5_IRQHandler(void) -{ - /* USER CODE BEGIN EXTI9_5_IRQn 0 */ - - /* USER CODE END EXTI9_5_IRQn 0 */ - HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8); - HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_9); - /* USER CODE BEGIN EXTI9_5_IRQn 1 */ - - /* USER CODE END EXTI9_5_IRQn 1 */ -} - -/** - * @brief This function handles DMA2 stream0 global interrupt. - */ -void DMA2_Stream0_IRQHandler(void) -{ - /* USER CODE BEGIN DMA2_Stream0_IRQn 0 */ - - /* USER CODE END DMA2_Stream0_IRQn 0 */ - HAL_DMA_IRQHandler(&hdma_adc3); - /* USER CODE BEGIN DMA2_Stream0_IRQn 1 */ - - /* USER CODE END DMA2_Stream0_IRQn 1 */ -} - -/** - * @brief This function handles DMA2 stream1 global interrupt. - */ -void DMA2_Stream1_IRQHandler(void) -{ - /* USER CODE BEGIN DMA2_Stream1_IRQn 0 */ - - /* USER CODE END DMA2_Stream1_IRQn 0 */ - HAL_DMA_IRQHandler(&hdma_sai1_a); - /* USER CODE BEGIN DMA2_Stream1_IRQn 1 */ - - /* USER CODE END DMA2_Stream1_IRQn 1 */ -} - -/** - * @brief This function handles DMA2 stream4 global interrupt. - */ -void DMA2_Stream4_IRQHandler(void) -{ - /* USER CODE BEGIN DMA2_Stream4_IRQn 0 */ - - /* USER CODE END DMA2_Stream4_IRQn 0 */ - HAL_DMA_IRQHandler(&hdma_sai1_b); - /* USER CODE BEGIN DMA2_Stream4_IRQn 1 */ - - /* USER CODE END DMA2_Stream4_IRQn 1 */ -} - -/** - * @brief This function handles USB On The Go FS global interrupt. - */ -void OTG_FS_IRQHandler(void) -{ - /* USER CODE BEGIN OTG_FS_IRQn 0 */ - - /* USER CODE END OTG_FS_IRQn 0 */ - HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS); - /* USER CODE BEGIN OTG_FS_IRQn 1 */ - - /* USER CODE END OTG_FS_IRQn 1 */ -} - -/** - * @brief This function handles SAI1 global interrupt. - */ -void SAI1_IRQHandler(void) -{ - /* USER CODE BEGIN SAI1_IRQn 0 */ - - /* USER CODE END SAI1_IRQn 0 */ - HAL_SAI_IRQHandler(&hsai_BlockA1); - HAL_SAI_IRQHandler(&hsai_BlockB1); - /* USER CODE BEGIN SAI1_IRQn 1 */ - - /* USER CODE END SAI1_IRQn 1 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Src/system_stm32f4xx.c b/OwlPedal2/Src/system_stm32f4xx.c deleted file mode 100644 index adcddf9b..00000000 --- a/OwlPedal2/Src/system_stm32f4xx.c +++ /dev/null @@ -1,763 +0,0 @@ -/** - ****************************************************************************** - * @file system_stm32f4xx.c - * @author MCD Application Team - * @version V2.6.1 - * @date 14-February-2017 - * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File. - * - * This file provides two functions and one global variable to be called from - * user application: - * - SystemInit(): This function is called at startup just after reset and - * before branch to main program. This call is made inside - * the "startup_stm32f4xx.s" file. - * - * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used - * by the user application to setup the SysTick - * timer or configure other parameters. - * - * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must - * be called whenever the core clock is changed - * during program execution. - * - * - ****************************************************************************** - * @attention - * - *

© COPYRIGHT 2017 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ - -/** @addtogroup CMSIS - * @{ - */ - -/** @addtogroup stm32f4xx_system - * @{ - */ - -/** @addtogroup STM32F4xx_System_Private_Includes - * @{ - */ - - -#include "stm32f4xx.h" - -#if !defined (HSE_VALUE) - #define HSE_VALUE ((uint32_t)25000000) /*!< Default value of the External oscillator in Hz */ -#endif /* HSE_VALUE */ - -#if !defined (HSI_VALUE) - #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/ -#endif /* HSI_VALUE */ - -/** - * @} - */ - -/** @addtogroup STM32F4xx_System_Private_TypesDefinitions - * @{ - */ - -/** - * @} - */ - -/** @addtogroup STM32F4xx_System_Private_Defines - * @{ - */ - -/************************* Miscellaneous Configuration ************************/ -/*!< Uncomment the following line if you need to use external SRAM or SDRAM as data memory */ -#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)\ - || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ - || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) -/* #define DATA_IN_ExtSRAM */ -#endif /* STM32F40xxx || STM32F41xxx || STM32F42xxx || STM32F43xxx || STM32F469xx || STM32F479xx ||\ - STM32F412Zx || STM32F412Vx */ - -#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ - || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) -/* #define DATA_IN_ExtSDRAM */ -#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx ||\ - STM32F479xx */ - -/*!< Uncomment the following line if you need to relocate your vector Table in - Internal SRAM. */ -/* #define VECT_TAB_SRAM */ -#define VECT_TAB_OFFSET 0x00010000 /*!< Vector Table base offset field. - This value must be a multiple of 0x200. */ -/******************************************************************************/ - -/** - * @} - */ - -/** @addtogroup STM32F4xx_System_Private_Macros - * @{ - */ - -/** - * @} - */ - -/** @addtogroup STM32F4xx_System_Private_Variables - * @{ - */ - /* This variable is updated in three ways: - 1) by calling CMSIS function SystemCoreClockUpdate() - 2) by calling HAL API function HAL_RCC_GetHCLKFreq() - 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency - Note: If you use this function to configure the system clock; then there - is no need to call the 2 first functions listed above, since SystemCoreClock - variable is updated automatically. - */ -uint32_t SystemCoreClock = 16000000; -const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; -const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4}; -/** - * @} - */ - -/** @addtogroup STM32F4xx_System_Private_FunctionPrototypes - * @{ - */ - -#if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM) - static void SystemInit_ExtMemCtl(void); -#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */ - -/** - * @} - */ - -/** @addtogroup STM32F4xx_System_Private_Functions - * @{ - */ - -/** - * @brief Setup the microcontroller system - * Initialize the FPU setting, vector table location and External memory - * configuration. - * @param None - * @retval None - */ -void SystemInit(void) -{ - /* FPU settings ------------------------------------------------------------*/ - #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) - SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */ - #endif - /* Reset the RCC clock configuration to the default reset state ------------*/ - /* Set HSION bit */ - RCC->CR |= (uint32_t)0x00000001; - - /* Reset CFGR register */ - RCC->CFGR = 0x00000000; - - /* Reset HSEON, CSSON and PLLON bits */ - RCC->CR &= (uint32_t)0xFEF6FFFF; - - /* Reset PLLCFGR register */ - RCC->PLLCFGR = 0x24003010; - - /* Reset HSEBYP bit */ - RCC->CR &= (uint32_t)0xFFFBFFFF; - - /* Disable all interrupts */ - RCC->CIR = 0x00000000; - -#if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM) - SystemInit_ExtMemCtl(); -#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */ - - /* Configure the Vector Table location add offset address ------------------*/ -#ifdef VECT_TAB_SRAM - SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ -#else - SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ -#endif -} - -/** - * @brief Update SystemCoreClock variable according to Clock Register Values. - * The SystemCoreClock variable contains the core clock (HCLK), it can - * be used by the user application to setup the SysTick timer or configure - * other parameters. - * - * @note Each time the core clock (HCLK) changes, this function must be called - * to update SystemCoreClock variable value. Otherwise, any configuration - * based on this variable will be incorrect. - * - * @note - The system frequency computed by this function is not the real - * frequency in the chip. It is calculated based on the predefined - * constant and the selected clock source: - * - * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) - * - * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) - * - * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) - * or HSI_VALUE(*) multiplied/divided by the PLL factors. - * - * (*) HSI_VALUE is a constant defined in stm32f4xx_hal_conf.h file (default value - * 16 MHz) but the real value may vary depending on the variations - * in voltage and temperature. - * - * (**) HSE_VALUE is a constant defined in stm32f4xx_hal_conf.h file (its value - * depends on the application requirements), user has to ensure that HSE_VALUE - * is same as the real frequency of the crystal used. Otherwise, this function - * may have wrong result. - * - * - The result of this function could be not correct when using fractional - * value for HSE crystal. - * - * @param None - * @retval None - */ -void SystemCoreClockUpdate(void) -{ - uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2; - - /* Get SYSCLK source -------------------------------------------------------*/ - tmp = RCC->CFGR & RCC_CFGR_SWS; - - switch (tmp) - { - case 0x00: /* HSI used as system clock source */ - SystemCoreClock = HSI_VALUE; - break; - case 0x04: /* HSE used as system clock source */ - SystemCoreClock = HSE_VALUE; - break; - case 0x08: /* PLL used as system clock source */ - - /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N - SYSCLK = PLL_VCO / PLL_P - */ - pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22; - pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM; - - if (pllsource != 0) - { - /* HSE used as PLL clock source */ - pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6); - } - else - { - /* HSI used as PLL clock source */ - pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6); - } - - pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2; - SystemCoreClock = pllvco/pllp; - break; - default: - SystemCoreClock = HSI_VALUE; - break; - } - /* Compute HCLK frequency --------------------------------------------------*/ - /* Get HCLK prescaler */ - tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; - /* HCLK frequency */ - SystemCoreClock >>= tmp; -} - -#if defined (DATA_IN_ExtSRAM) && defined (DATA_IN_ExtSDRAM) -#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ - || defined(STM32F469xx) || defined(STM32F479xx) -/** - * @brief Setup the external memory controller. - * Called in startup_stm32f4xx.s before jump to main. - * This function configures the external memories (SRAM/SDRAM) - * This SRAM/SDRAM will be used as program data memory (including heap and stack). - * @param None - * @retval None - */ -void SystemInit_ExtMemCtl(void) -{ - __IO uint32_t tmp = 0x00; - - register uint32_t tmpreg = 0, timeout = 0xFFFF; - register __IO uint32_t index; - - /* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface clock */ - RCC->AHB1ENR |= 0x000001F8; - - /* Delay after an RCC peripheral clock enabling */ - tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN); - - /* Connect PDx pins to FMC Alternate function */ - GPIOD->AFR[0] = 0x00CCC0CC; - GPIOD->AFR[1] = 0xCCCCCCCC; - /* Configure PDx pins in Alternate function mode */ - GPIOD->MODER = 0xAAAA0A8A; - /* Configure PDx pins speed to 100 MHz */ - GPIOD->OSPEEDR = 0xFFFF0FCF; - /* Configure PDx pins Output type to push-pull */ - GPIOD->OTYPER = 0x00000000; - /* No pull-up, pull-down for PDx pins */ - GPIOD->PUPDR = 0x00000000; - - /* Connect PEx pins to FMC Alternate function */ - GPIOE->AFR[0] = 0xC00CC0CC; - GPIOE->AFR[1] = 0xCCCCCCCC; - /* Configure PEx pins in Alternate function mode */ - GPIOE->MODER = 0xAAAA828A; - /* Configure PEx pins speed to 100 MHz */ - GPIOE->OSPEEDR = 0xFFFFC3CF; - /* Configure PEx pins Output type to push-pull */ - GPIOE->OTYPER = 0x00000000; - /* No pull-up, pull-down for PEx pins */ - GPIOE->PUPDR = 0x00000000; - - /* Connect PFx pins to FMC Alternate function */ - GPIOF->AFR[0] = 0xCCCCCCCC; - GPIOF->AFR[1] = 0xCCCCCCCC; - /* Configure PFx pins in Alternate function mode */ - GPIOF->MODER = 0xAA800AAA; - /* Configure PFx pins speed to 50 MHz */ - GPIOF->OSPEEDR = 0xAA800AAA; - /* Configure PFx pins Output type to push-pull */ - GPIOF->OTYPER = 0x00000000; - /* No pull-up, pull-down for PFx pins */ - GPIOF->PUPDR = 0x00000000; - - /* Connect PGx pins to FMC Alternate function */ - GPIOG->AFR[0] = 0xCCCCCCCC; - GPIOG->AFR[1] = 0xCCCCCCCC; - /* Configure PGx pins in Alternate function mode */ - GPIOG->MODER = 0xAAAAAAAA; - /* Configure PGx pins speed to 50 MHz */ - GPIOG->OSPEEDR = 0xAAAAAAAA; - /* Configure PGx pins Output type to push-pull */ - GPIOG->OTYPER = 0x00000000; - /* No pull-up, pull-down for PGx pins */ - GPIOG->PUPDR = 0x00000000; - - /* Connect PHx pins to FMC Alternate function */ - GPIOH->AFR[0] = 0x00C0CC00; - GPIOH->AFR[1] = 0xCCCCCCCC; - /* Configure PHx pins in Alternate function mode */ - GPIOH->MODER = 0xAAAA08A0; - /* Configure PHx pins speed to 50 MHz */ - GPIOH->OSPEEDR = 0xAAAA08A0; - /* Configure PHx pins Output type to push-pull */ - GPIOH->OTYPER = 0x00000000; - /* No pull-up, pull-down for PHx pins */ - GPIOH->PUPDR = 0x00000000; - - /* Connect PIx pins to FMC Alternate function */ - GPIOI->AFR[0] = 0xCCCCCCCC; - GPIOI->AFR[1] = 0x00000CC0; - /* Configure PIx pins in Alternate function mode */ - GPIOI->MODER = 0x0028AAAA; - /* Configure PIx pins speed to 50 MHz */ - GPIOI->OSPEEDR = 0x0028AAAA; - /* Configure PIx pins Output type to push-pull */ - GPIOI->OTYPER = 0x00000000; - /* No pull-up, pull-down for PIx pins */ - GPIOI->PUPDR = 0x00000000; - -/*-- FMC Configuration -------------------------------------------------------*/ - /* Enable the FMC interface clock */ - RCC->AHB3ENR |= 0x00000001; - /* Delay after an RCC peripheral clock enabling */ - tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN); - - FMC_Bank5_6->SDCR[0] = 0x000019E4; - FMC_Bank5_6->SDTR[0] = 0x01115351; - - /* SDRAM initialization sequence */ - /* Clock enable command */ - FMC_Bank5_6->SDCMR = 0x00000011; - tmpreg = FMC_Bank5_6->SDSR & 0x00000020; - while((tmpreg != 0) && (timeout-- > 0)) - { - tmpreg = FMC_Bank5_6->SDSR & 0x00000020; - } - - /* Delay */ - for (index = 0; index<1000; index++); - - /* PALL command */ - FMC_Bank5_6->SDCMR = 0x00000012; - timeout = 0xFFFF; - while((tmpreg != 0) && (timeout-- > 0)) - { - tmpreg = FMC_Bank5_6->SDSR & 0x00000020; - } - - /* Auto refresh command */ - FMC_Bank5_6->SDCMR = 0x00000073; - timeout = 0xFFFF; - while((tmpreg != 0) && (timeout-- > 0)) - { - tmpreg = FMC_Bank5_6->SDSR & 0x00000020; - } - - /* MRD register program */ - FMC_Bank5_6->SDCMR = 0x00046014; - timeout = 0xFFFF; - while((tmpreg != 0) && (timeout-- > 0)) - { - tmpreg = FMC_Bank5_6->SDSR & 0x00000020; - } - - /* Set refresh count */ - tmpreg = FMC_Bank5_6->SDRTR; - FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C<<1)); - - /* Disable write protection */ - tmpreg = FMC_Bank5_6->SDCR[0]; - FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF); - -#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) - /* Configure and enable Bank1_SRAM2 */ - FMC_Bank1->BTCR[2] = 0x00001011; - FMC_Bank1->BTCR[3] = 0x00000201; - FMC_Bank1E->BWTR[2] = 0x0fffffff; -#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ -#if defined(STM32F469xx) || defined(STM32F479xx) - /* Configure and enable Bank1_SRAM2 */ - FMC_Bank1->BTCR[2] = 0x00001091; - FMC_Bank1->BTCR[3] = 0x00110212; - FMC_Bank1E->BWTR[2] = 0x0fffffff; -#endif /* STM32F469xx || STM32F479xx */ - - (void)(tmp); -} -#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */ -#elif defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM) -/** - * @brief Setup the external memory controller. - * Called in startup_stm32f4xx.s before jump to main. - * This function configures the external memories (SRAM/SDRAM) - * This SRAM/SDRAM will be used as program data memory (including heap and stack). - * @param None - * @retval None - */ -void SystemInit_ExtMemCtl(void) -{ - __IO uint32_t tmp = 0x00; -#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ - || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) -#if defined (DATA_IN_ExtSDRAM) - register uint32_t tmpreg = 0, timeout = 0xFFFF; - register __IO uint32_t index; - -#if defined(STM32F446xx) - /* Enable GPIOA, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG interface - clock */ - RCC->AHB1ENR |= 0x0000007D; -#else - /* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface - clock */ - RCC->AHB1ENR |= 0x000001F8; -#endif /* STM32F446xx */ - /* Delay after an RCC peripheral clock enabling */ - tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN); - -#if defined(STM32F446xx) - /* Connect PAx pins to FMC Alternate function */ - GPIOA->AFR[0] |= 0xC0000000; - GPIOA->AFR[1] |= 0x00000000; - /* Configure PDx pins in Alternate function mode */ - GPIOA->MODER |= 0x00008000; - /* Configure PDx pins speed to 50 MHz */ - GPIOA->OSPEEDR |= 0x00008000; - /* Configure PDx pins Output type to push-pull */ - GPIOA->OTYPER |= 0x00000000; - /* No pull-up, pull-down for PDx pins */ - GPIOA->PUPDR |= 0x00000000; - - /* Connect PCx pins to FMC Alternate function */ - GPIOC->AFR[0] |= 0x00CC0000; - GPIOC->AFR[1] |= 0x00000000; - /* Configure PDx pins in Alternate function mode */ - GPIOC->MODER |= 0x00000A00; - /* Configure PDx pins speed to 50 MHz */ - GPIOC->OSPEEDR |= 0x00000A00; - /* Configure PDx pins Output type to push-pull */ - GPIOC->OTYPER |= 0x00000000; - /* No pull-up, pull-down for PDx pins */ - GPIOC->PUPDR |= 0x00000000; -#endif /* STM32F446xx */ - - /* Connect PDx pins to FMC Alternate function */ - GPIOD->AFR[0] = 0x000000CC; - GPIOD->AFR[1] = 0xCC000CCC; - /* Configure PDx pins in Alternate function mode */ - GPIOD->MODER = 0xA02A000A; - /* Configure PDx pins speed to 50 MHz */ - GPIOD->OSPEEDR = 0xA02A000A; - /* Configure PDx pins Output type to push-pull */ - GPIOD->OTYPER = 0x00000000; - /* No pull-up, pull-down for PDx pins */ - GPIOD->PUPDR = 0x00000000; - - /* Connect PEx pins to FMC Alternate function */ - GPIOE->AFR[0] = 0xC00000CC; - GPIOE->AFR[1] = 0xCCCCCCCC; - /* Configure PEx pins in Alternate function mode */ - GPIOE->MODER = 0xAAAA800A; - /* Configure PEx pins speed to 50 MHz */ - GPIOE->OSPEEDR = 0xAAAA800A; - /* Configure PEx pins Output type to push-pull */ - GPIOE->OTYPER = 0x00000000; - /* No pull-up, pull-down for PEx pins */ - GPIOE->PUPDR = 0x00000000; - - /* Connect PFx pins to FMC Alternate function */ - GPIOF->AFR[0] = 0xCCCCCCCC; - GPIOF->AFR[1] = 0xCCCCCCCC; - /* Configure PFx pins in Alternate function mode */ - GPIOF->MODER = 0xAA800AAA; - /* Configure PFx pins speed to 50 MHz */ - GPIOF->OSPEEDR = 0xAA800AAA; - /* Configure PFx pins Output type to push-pull */ - GPIOF->OTYPER = 0x00000000; - /* No pull-up, pull-down for PFx pins */ - GPIOF->PUPDR = 0x00000000; - - /* Connect PGx pins to FMC Alternate function */ - GPIOG->AFR[0] = 0xCCCCCCCC; - GPIOG->AFR[1] = 0xCCCCCCCC; - /* Configure PGx pins in Alternate function mode */ - GPIOG->MODER = 0xAAAAAAAA; - /* Configure PGx pins speed to 50 MHz */ - GPIOG->OSPEEDR = 0xAAAAAAAA; - /* Configure PGx pins Output type to push-pull */ - GPIOG->OTYPER = 0x00000000; - /* No pull-up, pull-down for PGx pins */ - GPIOG->PUPDR = 0x00000000; - -#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ - || defined(STM32F469xx) || defined(STM32F479xx) - /* Connect PHx pins to FMC Alternate function */ - GPIOH->AFR[0] = 0x00C0CC00; - GPIOH->AFR[1] = 0xCCCCCCCC; - /* Configure PHx pins in Alternate function mode */ - GPIOH->MODER = 0xAAAA08A0; - /* Configure PHx pins speed to 50 MHz */ - GPIOH->OSPEEDR = 0xAAAA08A0; - /* Configure PHx pins Output type to push-pull */ - GPIOH->OTYPER = 0x00000000; - /* No pull-up, pull-down for PHx pins */ - GPIOH->PUPDR = 0x00000000; - - /* Connect PIx pins to FMC Alternate function */ - GPIOI->AFR[0] = 0xCCCCCCCC; - GPIOI->AFR[1] = 0x00000CC0; - /* Configure PIx pins in Alternate function mode */ - GPIOI->MODER = 0x0028AAAA; - /* Configure PIx pins speed to 50 MHz */ - GPIOI->OSPEEDR = 0x0028AAAA; - /* Configure PIx pins Output type to push-pull */ - GPIOI->OTYPER = 0x00000000; - /* No pull-up, pull-down for PIx pins */ - GPIOI->PUPDR = 0x00000000; -#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */ - -/*-- FMC Configuration -------------------------------------------------------*/ - /* Enable the FMC interface clock */ - RCC->AHB3ENR |= 0x00000001; - /* Delay after an RCC peripheral clock enabling */ - tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN); - - /* Configure and enable SDRAM bank1 */ -#if defined(STM32F446xx) - FMC_Bank5_6->SDCR[0] = 0x00001954; -#else - FMC_Bank5_6->SDCR[0] = 0x000019E4; -#endif /* STM32F446xx */ - FMC_Bank5_6->SDTR[0] = 0x01115351; - - /* SDRAM initialization sequence */ - /* Clock enable command */ - FMC_Bank5_6->SDCMR = 0x00000011; - tmpreg = FMC_Bank5_6->SDSR & 0x00000020; - while((tmpreg != 0) && (timeout-- > 0)) - { - tmpreg = FMC_Bank5_6->SDSR & 0x00000020; - } - - /* Delay */ - for (index = 0; index<1000; index++); - - /* PALL command */ - FMC_Bank5_6->SDCMR = 0x00000012; - timeout = 0xFFFF; - while((tmpreg != 0) && (timeout-- > 0)) - { - tmpreg = FMC_Bank5_6->SDSR & 0x00000020; - } - - /* Auto refresh command */ -#if defined(STM32F446xx) - FMC_Bank5_6->SDCMR = 0x000000F3; -#else - FMC_Bank5_6->SDCMR = 0x00000073; -#endif /* STM32F446xx */ - timeout = 0xFFFF; - while((tmpreg != 0) && (timeout-- > 0)) - { - tmpreg = FMC_Bank5_6->SDSR & 0x00000020; - } - - /* MRD register program */ -#if defined(STM32F446xx) - FMC_Bank5_6->SDCMR = 0x00044014; -#else - FMC_Bank5_6->SDCMR = 0x00046014; -#endif /* STM32F446xx */ - timeout = 0xFFFF; - while((tmpreg != 0) && (timeout-- > 0)) - { - tmpreg = FMC_Bank5_6->SDSR & 0x00000020; - } - - /* Set refresh count */ - tmpreg = FMC_Bank5_6->SDRTR; -#if defined(STM32F446xx) - FMC_Bank5_6->SDRTR = (tmpreg | (0x0000050C<<1)); -#else - FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C<<1)); -#endif /* STM32F446xx */ - - /* Disable write protection */ - tmpreg = FMC_Bank5_6->SDCR[0]; - FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF); -#endif /* DATA_IN_ExtSDRAM */ -#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */ - -#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)\ - || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\ - || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) - -#if defined(DATA_IN_ExtSRAM) -/*-- GPIOs Configuration -----------------------------------------------------*/ - /* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */ - RCC->AHB1ENR |= 0x00000078; - /* Delay after an RCC peripheral clock enabling */ - tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIODEN); - - /* Connect PDx pins to FMC Alternate function */ - GPIOD->AFR[0] = 0x00CCC0CC; - GPIOD->AFR[1] = 0xCCCCCCCC; - /* Configure PDx pins in Alternate function mode */ - GPIOD->MODER = 0xAAAA0A8A; - /* Configure PDx pins speed to 100 MHz */ - GPIOD->OSPEEDR = 0xFFFF0FCF; - /* Configure PDx pins Output type to push-pull */ - GPIOD->OTYPER = 0x00000000; - /* No pull-up, pull-down for PDx pins */ - GPIOD->PUPDR = 0x00000000; - - /* Connect PEx pins to FMC Alternate function */ - GPIOE->AFR[0] = 0xC00CC0CC; - GPIOE->AFR[1] = 0xCCCCCCCC; - /* Configure PEx pins in Alternate function mode */ - GPIOE->MODER = 0xAAAA828A; - /* Configure PEx pins speed to 100 MHz */ - GPIOE->OSPEEDR = 0xFFFFC3CF; - /* Configure PEx pins Output type to push-pull */ - GPIOE->OTYPER = 0x00000000; - /* No pull-up, pull-down for PEx pins */ - GPIOE->PUPDR = 0x00000000; - - /* Connect PFx pins to FMC Alternate function */ - GPIOF->AFR[0] = 0x00CCCCCC; - GPIOF->AFR[1] = 0xCCCC0000; - /* Configure PFx pins in Alternate function mode */ - GPIOF->MODER = 0xAA000AAA; - /* Configure PFx pins speed to 100 MHz */ - GPIOF->OSPEEDR = 0xFF000FFF; - /* Configure PFx pins Output type to push-pull */ - GPIOF->OTYPER = 0x00000000; - /* No pull-up, pull-down for PFx pins */ - GPIOF->PUPDR = 0x00000000; - - /* Connect PGx pins to FMC Alternate function */ - GPIOG->AFR[0] = 0x00CCCCCC; - GPIOG->AFR[1] = 0x000000C0; - /* Configure PGx pins in Alternate function mode */ - GPIOG->MODER = 0x00085AAA; - /* Configure PGx pins speed to 100 MHz */ - GPIOG->OSPEEDR = 0x000CAFFF; - /* Configure PGx pins Output type to push-pull */ - GPIOG->OTYPER = 0x00000000; - /* No pull-up, pull-down for PGx pins */ - GPIOG->PUPDR = 0x00000000; - -/*-- FMC/FSMC Configuration --------------------------------------------------*/ - /* Enable the FMC/FSMC interface clock */ - RCC->AHB3ENR |= 0x00000001; - -#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) - /* Delay after an RCC peripheral clock enabling */ - tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN); - /* Configure and enable Bank1_SRAM2 */ - FMC_Bank1->BTCR[2] = 0x00001011; - FMC_Bank1->BTCR[3] = 0x00000201; - FMC_Bank1E->BWTR[2] = 0x0fffffff; -#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ -#if defined(STM32F469xx) || defined(STM32F479xx) - /* Delay after an RCC peripheral clock enabling */ - tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN); - /* Configure and enable Bank1_SRAM2 */ - FMC_Bank1->BTCR[2] = 0x00001091; - FMC_Bank1->BTCR[3] = 0x00110212; - FMC_Bank1E->BWTR[2] = 0x0fffffff; -#endif /* STM32F469xx || STM32F479xx */ -#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx)\ - || defined(STM32F412Zx) || defined(STM32F412Vx) - /* Delay after an RCC peripheral clock enabling */ - tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FSMCEN); - /* Configure and enable Bank1_SRAM2 */ - FSMC_Bank1->BTCR[2] = 0x00001011; - FSMC_Bank1->BTCR[3] = 0x00000201; - FSMC_Bank1E->BWTR[2] = 0x0FFFFFFF; -#endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx */ - -#endif /* DATA_IN_ExtSRAM */ -#endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx ||\ - STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx */ - (void)(tmp); -} -#endif /* DATA_IN_ExtSRAM && DATA_IN_ExtSDRAM */ -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Src/usb_device.c b/OwlPedal2/Src/usb_device.c deleted file mode 100644 index 95ded99c..00000000 --- a/OwlPedal2/Src/usb_device.c +++ /dev/null @@ -1,100 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : usb_device.c - * @version : v1.0_Cube - * @brief : This file implements the USB Device - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2020 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under Ultimate Liberty license - * SLA0044, the "License"; You may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * www.st.com/SLA0044 - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Includes ------------------------------------------------------------------*/ - -#include "usb_device.h" -#include "usbd_core.h" -#include "usbd_desc.h" -#include "usbd_audio.h" - -/* USER CODE BEGIN Includes */ -/* USER CODE END Includes */ - -/* USER CODE BEGIN PV */ -/* Private variables ---------------------------------------------------------*/ - -/* USER CODE END PV */ - -/* USER CODE BEGIN PFP */ -/* Private function prototypes -----------------------------------------------*/ - -/* USER CODE END PFP */ - -/* USB Device Core handle declaration. */ -USBD_HandleTypeDef hUsbDeviceFS; - -/* - * -- Insert your variables declaration here -- - */ -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* - * -- Insert your external function declaration here -- - */ -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ - -/** - * Init USB device Library, add supported class and start the library - * @retval None - */ -void MX_USB_DEVICE_Init(void) -{ - /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */ - - /* USER CODE END USB_DEVICE_Init_PreTreatment */ - - /* Init Device Library, add supported class and start the library. */ - if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK) - { - Error_Handler(); - } - if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_AUDIO) != USBD_OK) - { - Error_Handler(); - } - if (USBD_AUDIO_RegisterInterface(&hUsbDeviceFS, NULL) != USBD_OK) - { - Error_Handler(); - } - if (USBD_Start(&hUsbDeviceFS) != USBD_OK) - { - Error_Handler(); - } - - /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */ - - /* USER CODE END USB_DEVICE_Init_PostTreatment */ -} - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Src/usbd_conf.c b/OwlPedal2/Src/usbd_conf.c deleted file mode 100644 index a541d41e..00000000 --- a/OwlPedal2/Src/usbd_conf.c +++ /dev/null @@ -1,656 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : usbd_conf.c - * @version : v1.0_Cube - * @brief : This file implements the board support package for the USB device library - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2019 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under Ultimate Liberty license - * SLA0044, the "License"; You may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * www.st.com/SLA0044 - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx.h" -#include "stm32f4xx_hal.h" -#include "usbd_def.h" -#include "usbd_core.h" - -/* USER CODE BEGIN Includes */ -#include "device.h" -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* Private define ------------------------------------------------------------*/ -/* Private macro -------------------------------------------------------------*/ - -/* USER CODE BEGIN PV */ -/* Private variables ---------------------------------------------------------*/ - -/* USER CODE END PV */ - -PCD_HandleTypeDef hpcd_USB_OTG_FS; -void Error_Handler(void); - -/* External functions --------------------------------------------------------*/ -void SystemClock_Config(void); - -/* USER CODE BEGIN 0 */ -/* USER CODE END 0 */ - -/* USER CODE BEGIN PFP */ -/* Private function prototypes -----------------------------------------------*/ - -USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status); - -/* USER CODE END PFP */ - -/* Private functions ---------------------------------------------------------*/ - -/* USER CODE BEGIN 1 */ -/* USER CODE END 1 */ - -/******************************************************************************* - LL Driver Callbacks (PCD -> USB Device Library) -*******************************************************************************/ -/* MSP Init */ - -void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - if(pcdHandle->Instance==USB_OTG_FS) - { - /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */ - - /* USER CODE END USB_OTG_FS_MspInit 0 */ - - __HAL_RCC_GPIOA_CLK_ENABLE(); - /**USB_OTG_FS GPIO Configuration - PA9 ------> USB_OTG_FS_VBUS - PA11 ------> USB_OTG_FS_DM - PA12 ------> USB_OTG_FS_DP - */ - GPIO_InitStruct.Pin = GPIO_PIN_9; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* Peripheral clock enable */ - __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); - - /* Peripheral interrupt init */ - HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(OTG_FS_IRQn); - /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */ - - /* USER CODE END USB_OTG_FS_MspInit 1 */ - } -} - -void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) -{ - if(pcdHandle->Instance==USB_OTG_FS) - { - /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */ - - /* USER CODE END USB_OTG_FS_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); - - /**USB_OTG_FS GPIO Configuration - PA9 ------> USB_OTG_FS_VBUS - PA11 ------> USB_OTG_FS_DM - PA12 ------> USB_OTG_FS_DP - */ - HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_12); - - /* Peripheral interrupt Deinit*/ - HAL_NVIC_DisableIRQ(OTG_FS_IRQn); - - /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */ - - /* USER CODE END USB_OTG_FS_MspDeInit 1 */ - } -} - -/** - * @brief Setup stage callback - * @param hpcd: PCD handle - * @retval None - */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) -#else -void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ -{ - USBD_LL_SetupStage((USBD_HandleTypeDef*)hpcd->pData, (uint8_t *)hpcd->Setup); -} - -/** - * @brief Data Out stage callback. - * @param hpcd: PCD handle - * @param epnum: Endpoint number - * @retval None - */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#else -void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ -{ - USBD_LL_DataOutStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff); -} - -/** - * @brief Data In stage callback. - * @param hpcd: PCD handle - * @param epnum: Endpoint number - * @retval None - */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#else -void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ -{ - USBD_LL_DataInStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff); -} - -/** - * @brief SOF callback. - * @param hpcd: PCD handle - * @retval None - */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_SOFCallback(PCD_HandleTypeDef *hpcd) -#else -void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ -{ - USBD_LL_SOF((USBD_HandleTypeDef*)hpcd->pData); -} - -/** - * @brief Reset callback. - * @param hpcd: PCD handle - * @retval None - */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ResetCallback(PCD_HandleTypeDef *hpcd) -#else -void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ -{ - USBD_SpeedTypeDef speed = USBD_SPEED_FULL; - - if ( hpcd->Init.speed == PCD_SPEED_HIGH) - { - speed = USBD_SPEED_HIGH; - } - else if ( hpcd->Init.speed == PCD_SPEED_FULL) - { - speed = USBD_SPEED_FULL; - } - else - { - Error_Handler(); - } - /* Set Speed. */ - USBD_LL_SetSpeed((USBD_HandleTypeDef*)hpcd->pData, speed); - - /* Reset Device. */ - USBD_LL_Reset((USBD_HandleTypeDef*)hpcd->pData); -} - -/** - * @brief Suspend callback. - * When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it) - * @param hpcd: PCD handle - * @retval None - */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) -#else -void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ -{ - /* Inform USB library that core enters in suspend Mode. */ - USBD_LL_Suspend((USBD_HandleTypeDef*)hpcd->pData); - __HAL_PCD_GATE_PHYCLOCK(hpcd); - /* Enter in STOP mode. */ - /* USER CODE BEGIN 2 */ - if (hpcd->Init.low_power_enable) - { - /* Set SLEEPDEEP bit and SleepOnExit of Cortex System Control Register */ - SCB->SCR |= (uint32_t)((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk)); - } - /* USER CODE END 2 */ -} - -/** - * @brief Resume callback. - * When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it) - * @param hpcd: PCD handle - * @retval None - */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) -#else -void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ -{ - /* USER CODE BEGIN 3 */ - /* USER CODE END 3 */ - USBD_LL_Resume((USBD_HandleTypeDef*)hpcd->pData); -} - -/** - * @brief ISOOUTIncomplete callback. - * @param hpcd: PCD handle - * @param epnum: Endpoint number - * @retval None - */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#else -void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ -{ - USBD_LL_IsoOUTIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); -} - -/** - * @brief ISOINIncomplete callback. - * @param hpcd: PCD handle - * @param epnum: Endpoint number - * @retval None - */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#else -void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ -{ - USBD_LL_IsoINIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); -} - -/** - * @brief Connect callback. - * @param hpcd: PCD handle - * @retval None - */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) -#else -void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ -{ - USBD_LL_DevConnected((USBD_HandleTypeDef*)hpcd->pData); -} - -/** - * @brief Disconnect callback. - * @param hpcd: PCD handle - * @retval None - */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) -#else -void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ -{ - USBD_LL_DevDisconnected((USBD_HandleTypeDef*)hpcd->pData); -} - -/******************************************************************************* - LL Driver Interface (USB Device Library --> PCD) -*******************************************************************************/ - -/** - * @brief Initializes the low level portion of the device driver. - * @param pdev: Device handle - * @retval USBD status - */ -USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) -{ - /* Init USB Ip. */ - if (pdev->id == DEVICE_FS) { - /* Link the driver to the stack. */ - hpcd_USB_OTG_FS.pData = pdev; - pdev->pData = &hpcd_USB_OTG_FS; - - hpcd_USB_OTG_FS.Instance = USB_OTG_FS; - hpcd_USB_OTG_FS.Init.dev_endpoints = 4; - hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; - hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; - hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; - hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; - hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; - hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; - hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE; - hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE; - if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) - { - Error_Handler( ); - } - -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) - /* Register USB PCD CallBacks */ - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SOF_CB_ID, PCD_SOFCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SETUPSTAGE_CB_ID, PCD_SetupStageCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESET_CB_ID, PCD_ResetCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SUSPEND_CB_ID, PCD_SuspendCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESUME_CB_ID, PCD_ResumeCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_CONNECT_CB_ID, PCD_ConnectCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_DISCONNECT_CB_ID, PCD_DisconnectCallback); - - HAL_PCD_RegisterDataOutStageCallback(&hpcd_USB_OTG_FS, PCD_DataOutStageCallback); - HAL_PCD_RegisterDataInStageCallback(&hpcd_USB_OTG_FS, PCD_DataInStageCallback); - HAL_PCD_RegisterIsoOutIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOOUTIncompleteCallback); - HAL_PCD_RegisterIsoInIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOINIncompleteCallback); -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ -#ifdef USE_USBD_AUDIO_TX - HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_FS, 0x80); - HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x20); - HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x60); - HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 2, 0x40); -#else - HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_FS, 0xa0); - HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x40); - HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x60); -#endif - /* total 0x140 words available for rx and tx fifos */ - } - return USBD_OK; -} - -/** - * @brief De-Initializes the low level portion of the device driver. - * @param pdev: Device handle - * @retval USBD status - */ -USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev) -{ - HAL_StatusTypeDef hal_status = HAL_OK; - USBD_StatusTypeDef usb_status = USBD_OK; - - hal_status = HAL_PCD_DeInit(pdev->pData); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; -} - -/** - * @brief Starts the low level portion of the device driver. - * @param pdev: Device handle - * @retval USBD status - */ -USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev) -{ - HAL_StatusTypeDef hal_status = HAL_OK; - USBD_StatusTypeDef usb_status = USBD_OK; - - hal_status = HAL_PCD_Start(pdev->pData); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; -} - -/** - * @brief Stops the low level portion of the device driver. - * @param pdev: Device handle - * @retval USBD status - */ -USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev) -{ - HAL_StatusTypeDef hal_status = HAL_OK; - USBD_StatusTypeDef usb_status = USBD_OK; - - hal_status = HAL_PCD_Stop(pdev->pData); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; -} - -/** - * @brief Opens an endpoint of the low level driver. - * @param pdev: Device handle - * @param ep_addr: Endpoint number - * @param ep_type: Endpoint type - * @param ep_mps: Endpoint max packet size - * @retval USBD status - */ -USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps) -{ - HAL_StatusTypeDef hal_status = HAL_OK; - USBD_StatusTypeDef usb_status = USBD_OK; - - hal_status = HAL_PCD_EP_Open(pdev->pData, ep_addr, ep_mps, ep_type); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; -} - -/** - * @brief Closes an endpoint of the low level driver. - * @param pdev: Device handle - * @param ep_addr: Endpoint number - * @retval USBD status - */ -USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) -{ - HAL_StatusTypeDef hal_status = HAL_OK; - USBD_StatusTypeDef usb_status = USBD_OK; - - hal_status = HAL_PCD_EP_Close(pdev->pData, ep_addr); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; -} - -/** - * @brief Flushes an endpoint of the Low Level Driver. - * @param pdev: Device handle - * @param ep_addr: Endpoint number - * @retval USBD status - */ -USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) -{ - HAL_StatusTypeDef hal_status = HAL_OK; - USBD_StatusTypeDef usb_status = USBD_OK; - - hal_status = HAL_PCD_EP_Flush(pdev->pData, ep_addr); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; -} - -/** - * @brief Sets a Stall condition on an endpoint of the Low Level Driver. - * @param pdev: Device handle - * @param ep_addr: Endpoint number - * @retval USBD status - */ -USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) -{ - HAL_StatusTypeDef hal_status = HAL_OK; - USBD_StatusTypeDef usb_status = USBD_OK; - - hal_status = HAL_PCD_EP_SetStall(pdev->pData, ep_addr); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; -} - -/** - * @brief Clears a Stall condition on an endpoint of the Low Level Driver. - * @param pdev: Device handle - * @param ep_addr: Endpoint number - * @retval USBD status - */ -USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) -{ - HAL_StatusTypeDef hal_status = HAL_OK; - USBD_StatusTypeDef usb_status = USBD_OK; - - hal_status = HAL_PCD_EP_ClrStall(pdev->pData, ep_addr); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; -} - -/** - * @brief Returns Stall condition. - * @param pdev: Device handle - * @param ep_addr: Endpoint number - * @retval Stall (1: Yes, 0: No) - */ -uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) -{ - PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef*) pdev->pData; - - if((ep_addr & 0x80) == 0x80) - { - return hpcd->IN_ep[ep_addr & 0x7F].is_stall; - } - else - { - return hpcd->OUT_ep[ep_addr & 0x7F].is_stall; - } -} - -/** - * @brief Assigns a USB address to the device. - * @param pdev: Device handle - * @param dev_addr: Device address - * @retval USBD status - */ -USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr) -{ - HAL_StatusTypeDef hal_status = HAL_OK; - USBD_StatusTypeDef usb_status = USBD_OK; - - hal_status = HAL_PCD_SetAddress(pdev->pData, dev_addr); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; -} - -/** - * @brief Transmits data over an endpoint. - * @param pdev: Device handle - * @param ep_addr: Endpoint number - * @param pbuf: Pointer to data to be sent - * @param size: Data size - * @retval USBD status - */ -USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint16_t size) -{ - HAL_StatusTypeDef hal_status = HAL_OK; - USBD_StatusTypeDef usb_status = USBD_OK; - - hal_status = HAL_PCD_EP_Transmit(pdev->pData, ep_addr, pbuf, size); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; -} - -/** - * @brief Prepares an endpoint for reception. - * @param pdev: Device handle - * @param ep_addr: Endpoint number - * @param pbuf: Pointer to data to be received - * @param size: Data size - * @retval USBD status - */ -USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint16_t size) -{ - HAL_StatusTypeDef hal_status = HAL_OK; - USBD_StatusTypeDef usb_status = USBD_OK; - - hal_status = HAL_PCD_EP_Receive(pdev->pData, ep_addr, pbuf, size); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; -} - -/** - * @brief Returns the last transfered packet size. - * @param pdev: Device handle - * @param ep_addr: Endpoint number - * @retval Recived Data Size - */ -uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr) -{ - return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef*) pdev->pData, ep_addr); -} - -/** - * @brief Delays routine for the USB Device Library. - * @param Delay: Delay in ms - * @retval None - */ -void USBD_LL_Delay(uint32_t Delay) -{ - HAL_Delay(Delay); -} - -/** - * @brief Retuns the USB status depending on the HAL status: - * @param hal_status: HAL status - * @retval USB status - */ -USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status) -{ - USBD_StatusTypeDef usb_status = USBD_OK; - - switch (hal_status) - { - case HAL_OK : - usb_status = USBD_OK; - break; - case HAL_ERROR : - usb_status = USBD_FAIL; - break; - case HAL_BUSY : - usb_status = USBD_BUSY; - break; - case HAL_TIMEOUT : - usb_status = USBD_FAIL; - break; - default : - usb_status = USBD_FAIL; - break; - } - return usb_status; -} - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal2/Src/usbd_desc.c b/OwlPedal2/Src/usbd_desc.c deleted file mode 100644 index 016cba0a..00000000 --- a/OwlPedal2/Src/usbd_desc.c +++ /dev/null @@ -1,446 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : usbd_desc.c - * @version : v1.0_Cube - * @brief : This file implements the USB device descriptors. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2019 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under Ultimate Liberty license - * SLA0044, the "License"; You may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * www.st.com/SLA0044 - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Includes ------------------------------------------------------------------*/ -#include "usbd_core.h" -#include "usbd_desc.h" -#include "usbd_conf.h" - -/* USER CODE BEGIN INCLUDE */ - -/* USER CODE END INCLUDE */ - -/* Private typedef -----------------------------------------------------------*/ -/* Private define ------------------------------------------------------------*/ -/* Private macro -------------------------------------------------------------*/ - -/* USER CODE BEGIN PV */ -/* Private variables ---------------------------------------------------------*/ - -/* USER CODE END PV */ - -/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY - * @{ - */ - -/** @addtogroup USBD_DESC - * @{ - */ - -/** @defgroup USBD_DESC_Private_TypesDefinitions USBD_DESC_Private_TypesDefinitions - * @brief Private types. - * @{ - */ - -/* USER CODE BEGIN PRIVATE_TYPES */ - -/* USER CODE END PRIVATE_TYPES */ - -/** - * @} - */ - -/** @defgroup USBD_DESC_Private_Defines USBD_DESC_Private_Defines - * @brief Private defines. - * @{ - */ - -#define USBD_VID 0x1209 -#define USBD_LANGID_STRING 1033 -#define USBD_MANUFACTURER_STRING "Rebel Technology" -#define USBD_PID_FS 0xdada -#define USBD_PRODUCT_STRING_FS "OWL-PEDAL" -#define USBD_CONFIGURATION_STRING_FS "AUDIO Config" -#define USBD_INTERFACE_STRING_FS "AUDIO Interface" - -#define USB_SIZ_BOS_DESC 0x0C - -/* USER CODE BEGIN PRIVATE_DEFINES */ - -/* USER CODE END PRIVATE_DEFINES */ - -/** - * @} - */ - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/** @defgroup USBD_DESC_Private_Macros USBD_DESC_Private_Macros - * @brief Private macros. - * @{ - */ - -/* USER CODE BEGIN PRIVATE_MACRO */ - -/* USER CODE END PRIVATE_MACRO */ - -/** - * @} - */ - -/** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes - * @brief Private functions declaration. - * @{ - */ - -static void Get_SerialNum(void); -static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len); - -/** - * @} - */ - - -/** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes - * @brief Private functions declaration for FS. - * @{ - */ - -uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -#if (USBD_LPM_ENABLED == 1) -uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -#endif /* (USBD_LPM_ENABLED == 1) */ - -/** - * @} - */ - -/** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables - * @brief Private variables. - * @{ - */ - -USBD_DescriptorsTypeDef FS_Desc = -{ - USBD_FS_DeviceDescriptor -, USBD_FS_LangIDStrDescriptor -, USBD_FS_ManufacturerStrDescriptor -, USBD_FS_ProductStrDescriptor -, USBD_FS_SerialStrDescriptor -, USBD_FS_ConfigStrDescriptor -, USBD_FS_InterfaceStrDescriptor -#if (USBD_LPM_ENABLED == 1) -, USBD_FS_USR_BOSDescriptor -#endif /* (USBD_LPM_ENABLED == 1) */ -}; - -#if defined ( __ICCARM__ ) /* IAR Compiler */ - #pragma data_alignment=4 -#endif /* defined ( __ICCARM__ ) */ -/** USB standard device descriptor. */ -__ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = -{ - 0x12, /*bLength */ - USB_DESC_TYPE_DEVICE, /*bDescriptorType*/ -#if (USBD_LPM_ENABLED == 1) - 0x01, /*bcdUSB */ /* changed to USB version 2.01 - in order to support LPM L1 suspend - resume test of USBCV3.0*/ -#else - 0x00, /*bcdUSB */ -#endif /* (USBD_LPM_ENABLED == 1) */ - 0x02, - 0x00, /*bDeviceClass*/ - 0x00, /*bDeviceSubClass*/ - 0x00, /*bDeviceProtocol*/ - USB_MAX_EP0_SIZE, /*bMaxPacketSize*/ - LOBYTE(USBD_VID), /*idVendor*/ - HIBYTE(USBD_VID), /*idVendor*/ - LOBYTE(USBD_PID_FS), /*idProduct*/ - HIBYTE(USBD_PID_FS), /*idProduct*/ - 0x00, /*bcdDevice rel. 2.00*/ - 0x02, - USBD_IDX_MFC_STR, /*Index of manufacturer string*/ - USBD_IDX_PRODUCT_STR, /*Index of product string*/ - USBD_IDX_SERIAL_STR, /*Index of serial number string*/ - USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/ -}; - -/* USB_DeviceDescriptor */ -/** BOS descriptor. */ -#if (USBD_LPM_ENABLED == 1) -#if defined ( __ICCARM__ ) /* IAR Compiler */ - #pragma data_alignment=4 -#endif /* defined ( __ICCARM__ ) */ -__ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = -{ - 0x5, - USB_DESC_TYPE_BOS, - 0xC, - 0x0, - 0x1, /* 1 device capability*/ - /* device capability*/ - 0x7, - USB_DEVICE_CAPABITY_TYPE, - 0x2, - 0x2, /* LPM capability bit set*/ - 0x0, - 0x0, - 0x0 -}; -#endif /* (USBD_LPM_ENABLED == 1) */ - -/** - * @} - */ - -/** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables - * @brief Private variables. - * @{ - */ - -#if defined ( __ICCARM__ ) /* IAR Compiler */ - #pragma data_alignment=4 -#endif /* defined ( __ICCARM__ ) */ - -/** USB lang indentifier descriptor. */ -__ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = -{ - USB_LEN_LANGID_STR_DESC, - USB_DESC_TYPE_STRING, - LOBYTE(USBD_LANGID_STRING), - HIBYTE(USBD_LANGID_STRING) -}; - -#if defined ( __ICCARM__ ) /* IAR Compiler */ - #pragma data_alignment=4 -#endif /* defined ( __ICCARM__ ) */ -/* Internal string descriptor. */ -__ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END; - -#if defined ( __ICCARM__ ) /*!< IAR Compiler */ - #pragma data_alignment=4 -#endif -__ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { - USB_SIZ_STRING_SERIAL, - USB_DESC_TYPE_STRING, -}; - -/** - * @} - */ - -/** @defgroup USBD_DESC_Private_Functions USBD_DESC_Private_Functions - * @brief Private functions. - * @{ - */ - -/** - * @brief Return the device descriptor - * @param speed : Current device speed - * @param length : Pointer to data length variable - * @retval Pointer to descriptor buffer - */ -uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) -{ - UNUSED(speed); - *length = sizeof(USBD_FS_DeviceDesc); - return USBD_FS_DeviceDesc; -} - -/** - * @brief Return the LangID string descriptor - * @param speed : Current device speed - * @param length : Pointer to data length variable - * @retval Pointer to descriptor buffer - */ -uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) -{ - UNUSED(speed); - *length = sizeof(USBD_LangIDDesc); - return USBD_LangIDDesc; -} - -/** - * @brief Return the product string descriptor - * @param speed : Current device speed - * @param length : Pointer to data length variable - * @retval Pointer to descriptor buffer - */ -uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) -{ - if(speed == 0) - { - USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); - } - else - { - USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); - } - return USBD_StrDesc; -} - -/** - * @brief Return the manufacturer string descriptor - * @param speed : Current device speed - * @param length : Pointer to data length variable - * @retval Pointer to descriptor buffer - */ -uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) -{ - UNUSED(speed); - USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length); - return USBD_StrDesc; -} - -/** - * @brief Return the serial number string descriptor - * @param speed : Current device speed - * @param length : Pointer to data length variable - * @retval Pointer to descriptor buffer - */ -uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) -{ - UNUSED(speed); - *length = USB_SIZ_STRING_SERIAL; - - /* Update the serial number string descriptor with the data from the unique - * ID */ - Get_SerialNum(); - /* USER CODE BEGIN USBD_FS_SerialStrDescriptor */ - - /* USER CODE END USBD_FS_SerialStrDescriptor */ - return (uint8_t *) USBD_StringSerial; -} - -/** - * @brief Return the configuration string descriptor - * @param speed : Current device speed - * @param length : Pointer to data length variable - * @retval Pointer to descriptor buffer - */ -uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) -{ - if(speed == USBD_SPEED_HIGH) - { - USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); - } - else - { - USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); - } - return USBD_StrDesc; -} - -/** - * @brief Return the interface string descriptor - * @param speed : Current device speed - * @param length : Pointer to data length variable - * @retval Pointer to descriptor buffer - */ -uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) -{ - if(speed == 0) - { - USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); - } - else - { - USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); - } - return USBD_StrDesc; -} - -#if (USBD_LPM_ENABLED == 1) -/** - * @brief Return the BOS descriptor - * @param speed : Current device speed - * @param length : Pointer to data length variable - * @retval Pointer to descriptor buffer - */ -uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) -{ - UNUSED(speed); - *length = sizeof(USBD_FS_BOSDesc); - return (uint8_t*)USBD_FS_BOSDesc; -} -#endif /* (USBD_LPM_ENABLED == 1) */ - -/** - * @brief Create the serial number string descriptor - * @param None - * @retval None - */ -static void Get_SerialNum(void) -{ - uint32_t deviceserial0, deviceserial1, deviceserial2; - - deviceserial0 = *(uint32_t *) DEVICE_ID1; - deviceserial1 = *(uint32_t *) DEVICE_ID2; - deviceserial2 = *(uint32_t *) DEVICE_ID3; - - deviceserial0 += deviceserial2; - - if (deviceserial0 != 0) - { - IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8); - IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4); - } -} - -/** - * @brief Convert Hex 32Bits value into char - * @param value: value to convert - * @param pbuf: pointer to the buffer - * @param len: buffer length - * @retval None - */ -static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len) -{ - uint8_t idx = 0; - - for (idx = 0; idx < len; idx++) - { - if (((value >> 28)) < 0xA) - { - pbuf[2 * idx] = (value >> 28) + '0'; - } - else - { - pbuf[2 * idx] = (value >> 28) + 'A' - 10; - } - - value = value << 4; - - pbuf[2 * idx + 1] = 0; - } -} -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ From ce72289a600cf0d01528c26c0058deb53f5e596f Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 13 Oct 2020 14:33:30 +0200 Subject: [PATCH 013/286] added LED R and G pins --- OwlPedalMkII/Inc/main.h | 4 + OwlPedalMkII/OwlPedal2.ioc | 138 ++++++++++++++++++---------------- OwlPedalMkII/Src/OwlPedal.cpp | 2 + OwlPedalMkII/Src/main.c | 14 +++- 4 files changed, 92 insertions(+), 66 deletions(-) diff --git a/OwlPedalMkII/Inc/main.h b/OwlPedalMkII/Inc/main.h index 15723bbd..36e93fe0 100644 --- a/OwlPedalMkII/Inc/main.h +++ b/OwlPedalMkII/Inc/main.h @@ -100,6 +100,10 @@ void Error_Handler(void); #define CS_SDA_GPIO_Port GPIOE #define EXTSPI_nCS_Pin GPIO_PIN_15 #define EXTSPI_nCS_GPIO_Port GPIOC +#define LED_R_Pin GPIO_PIN_7 +#define LED_R_GPIO_Port GPIOF +#define LED_G_Pin GPIO_PIN_9 +#define LED_G_GPIO_Port GPIOF #define ADC4_Pin GPIO_PIN_10 #define ADC4_GPIO_Port GPIOF #define ADC3_Pin GPIO_PIN_1 diff --git a/OwlPedalMkII/OwlPedal2.ioc b/OwlPedalMkII/OwlPedal2.ioc index 6b160fe4..c415d275 100644 --- a/OwlPedalMkII/OwlPedal2.ioc +++ b/OwlPedalMkII/OwlPedal2.ioc @@ -1,4 +1,5 @@ #MicroXplorer Configuration settings - do not modify +PF7.GPIOParameters=GPIO_Label SH.FMC_D7_DA7.0=FMC_D7,sd-16b-d1 Dma.ADC3.0.FIFOMode=DMA_FIFOMODE_DISABLE SH.FMC_D0_DA0.ConfNb=1 @@ -45,6 +46,7 @@ USB_DEVICE.PID_AUDIO_FS=0xdada NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false SAI1.FSDefinition-SAI_B_SyncSlave=SAI_FS_CHANNEL_IDENTIFICATION SH.GPXTI3.ConfNb=1 +PF7.Signal=GPIO_Output SH.FMC_SDNWE.0=FMC_SDNWE,12b-sda1 SPI1.Direction=SPI_DIRECTION_2LINES SH.FMC_D11_DA11.0=FMC_D11,sd-16b-d1 @@ -117,14 +119,15 @@ SH.GPXTI8.ConfNb=1 FREERTOS.FootprintOK=true PA5.GPIOParameters=GPIO_Label FMC.WriteRecoveryTime1=2 +PF7.Locked=true SH.ADCx_IN9.0=ADC1_IN9,IN9 SH.FMC_A1.0=FMC_A1,12b-sda1 ADC3.DMAContinuousRequests=ENABLE RCC.APB2CLKDivider=RCC_HCLK_DIV2 SH.FMC_SDCLK.0=FMC_SDCLK,12b-sda1 RCC.CECFreq_Value=32786.88524590164 -ADC3.ExternalTrigConvEdge=ADC_EXTERNALTRIGCONVEDGE_NONE PF14.Signal=FMC_A8 +ADC3.ExternalTrigConvEdge=ADC_EXTERNALTRIGCONVEDGE_NONE RCC.APB1TimFreq_Value=84000000 Dma.ADC3.0.Instance=DMA2_Stream0 NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false @@ -156,17 +159,19 @@ SH.FMC_A1.ConfNb=1 FREERTOS.Tasks01=defaultTask,0,128,StartDefaultTask,Default,NULL ADC1.Rank-0\#ChannelRegularConversion=1 USB_DEVICE.VirtualMode-AUDIO_FS=Audio -Mcu.PinsNb=73 +Mcu.PinsNb=75 Dma.SAI1_B.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -Mcu.Pin71=VP_SYS_VS_Systick -Mcu.Pin72=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS +Mcu.Pin73=VP_SYS_VS_Systick +Mcu.Pin74=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS +Mcu.Pin71=VP_FREERTOS_VS_CMSIS_V1 +Mcu.Pin72=VP_RTC_VS_RTC_Activate ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,NbrOfConversionFlag,master,ClockPrescaler PG5.Signal=FMC_A15_BA1 SH.FMC_D10_DA10.0=FMC_D10,sd-16b-d1 PA9.GPIO_Label=USBD_VBUS FREERTOS.INCLUDE_vTaskDelayUntil=1 FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 -Mcu.Pin70=VP_RTC_VS_RTC_Activate +Mcu.Pin70=PE1 PB8.GPIO_PuPd=GPIO_PULLUP PC2.Signal=ADCx_IN12 PB11.GPIO_Label=CS_nRST @@ -174,58 +179,58 @@ PD1.Signal=FMC_D3_DA3 PA11.GPIO_Label=USBD_DM RCC.VCOSAIOutputFreq_ValueQ=25000000 NVIC.DMA2_Stream1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -Mcu.Pin68=PE1 -Mcu.Pin69=VP_FREERTOS_VS_CMSIS_V1 +Mcu.Pin68=PB8 +Mcu.Pin69=PE0 RCC.UART8Freq_Value=54000000 PC0.Signal=FMC_SDNWE RCC.APB1CLKDivider=RCC_HCLK_DIV4 ADC3.Channel-31\#ChannelRegularConversion=ADC_CHANNEL_13 PD6.Mode=SAI_A_AsyncSlave -Mcu.Pin62=PG15 -Mcu.Pin63=PB3 -Mcu.Pin60=PD1 -Mcu.Pin61=PD6 -Mcu.Pin66=PB8 -Mcu.Pin67=PE0 -Mcu.Pin64=PB5 +Mcu.Pin62=PD1 +Mcu.Pin63=PD6 +Mcu.Pin60=PA14 +Mcu.Pin61=PD0 +Mcu.Pin66=PB5 +Mcu.Pin67=PB6 +Mcu.Pin64=PG15 ADC3.Resolution=ADC_RESOLUTION_12B -Mcu.Pin65=PB6 +Mcu.Pin65=PB3 Dma.SAI1_B.2.PeriphInc=DMA_PINC_DISABLE PC3.GPIOParameters=GPIO_Label PD10.Signal=FMC_D15_DA15 SH.FMC_A3.0=FMC_A3,12b-sda1 PB8.GPIO_Label=SW2 -Mcu.Pin59=PD0 +Mcu.Pin59=PA13 FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_3 SH.GPXTI2.ConfNb=1 -Mcu.Pin57=PA13 -Mcu.Pin58=PA14 -Mcu.Pin51=PG4 +Mcu.Pin57=PA11 +Mcu.Pin58=PA12 +Mcu.Pin51=PD14 RCC.USART6Freq_Value=108000000 SH.FMC_D15_DA15.0=FMC_D15,sd-16b-d1 -Mcu.Pin52=PG5 +Mcu.Pin52=PD15 Dma.SAI1_B.2.PeriphDataAlignment=DMA_PDATAALIGN_WORD -Mcu.Pin50=PD15 -Mcu.Pin55=PA11 -Mcu.Pin56=PA12 -Mcu.Pin53=PG8 -Mcu.Pin54=PA9 +Mcu.Pin50=PD10 +Mcu.Pin55=PG8 +Mcu.Pin56=PA9 +Mcu.Pin53=PG4 +Mcu.Pin54=PG5 PA9.Signal=USB_OTG_FS_VBUS PB11.GPIOParameters=GPIO_Label ADC3.NbrOfConversion=4 -Mcu.Pin48=PD10 -Mcu.Pin49=PD14 -Mcu.Pin46=PD8 -Mcu.Pin47=PD9 +Mcu.Pin48=PD8 +Mcu.Pin49=PD9 +Mcu.Pin46=PB10 +Mcu.Pin47=PB11 PB10.Signal=GPIO_Output PA5.Signal=GPXTI5 -Mcu.Pin40=PE12 -Mcu.Pin41=PE13 +Mcu.Pin40=PE10 +Mcu.Pin41=PE11 FREERTOS.MEMORY_ALLOCATION=2 -Mcu.Pin44=PB10 -Mcu.Pin45=PB11 -Mcu.Pin42=PE14 -Mcu.Pin43=PE15 +Mcu.Pin44=PE14 +Mcu.Pin45=PE15 +Mcu.Pin42=PE12 +Mcu.Pin43=PE13 ProjectManager.LastFirmware=true FMC.ReadBurst1=FMC_SDRAM_RBURST_ENABLE SH.FMC_A6.0=FMC_A6,12b-sda1 @@ -233,25 +238,25 @@ FMC.ReadBurst2=FMC_SDRAM_RBURST_ENABLE PE14.Signal=FMC_D11_DA11 PE6.Mode=TX_Only_Simplex_Unidirect_Master PE15.Signal=FMC_D12_DA12 -Mcu.Pin37=PE9 -Mcu.Pin38=PE10 -Mcu.Pin35=PE7 +Mcu.Pin37=PE7 +Mcu.Pin38=PE8 +Mcu.Pin35=PG0 RCC.I2C1Freq_Value=54000000 -Mcu.Pin36=PE8 +Mcu.Pin36=PG1 PE8.Signal=FMC_D5_DA5 RCC.PLLI2SPCLKFreq_Value=96000000 SPI1.Mode=SPI_MODE_MASTER SH.FMC_D14_DA14.ConfNb=1 -Mcu.Pin39=PE11 +Mcu.Pin39=PE9 PC2.GPIOParameters=GPIO_Label -Mcu.Pin30=PF13 +Mcu.Pin30=PF11 RCC.EthernetFreq_Value=168000000 SH.ADCx_IN12.ConfNb=1 -Mcu.Pin33=PG0 -Mcu.Pin34=PG1 +Mcu.Pin33=PF14 +Mcu.Pin34=PF15 ADC3.SamplingTime-33\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -Mcu.Pin31=PF14 -Mcu.Pin32=PF15 +Mcu.Pin31=PF12 +Mcu.Pin32=PF13 NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false FREERTOS.configUSE_MUTEXES=0 PF13.Signal=FMC_A7 @@ -259,25 +264,26 @@ PA13.Mode=Serial_Wire SH.FMC_SDNCAS.0=FMC_SDNCAS,12b-sda1 ProjectManager.FreePins=true Dma.ADC3.0.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD +PF9.GPIOParameters=GPIO_Label SH.FMC_NBL1.ConfNb=1 RCC.PLLI2SQCLKFreq_Value=96000000 -Mcu.Pin26=PB1 -Mcu.Pin27=PB2/BOOT1 +Mcu.Pin26=PC4 +Mcu.Pin27=PC5 NVIC.DMA2_Stream4_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true RCC.RTCHSEDivFreq_Value=12500000 -Mcu.Pin24=PC4 +Mcu.Pin24=PA6 ProjectManager.UnderRoot=false -Mcu.Pin25=PC5 -Mcu.Pin28=PF11 -Mcu.Pin29=PF12 +Mcu.Pin25=PA7 +Mcu.Pin28=PB1 +Mcu.Pin29=PB2/BOOT1 SH.FMC_D7_DA7.ConfNb=1 -Mcu.Pin22=PA6 +Mcu.Pin22=PA3 PB5.Signal=FMC_SDCKE1 -Mcu.Pin23=PA7 -Mcu.Pin20=PA3 +Mcu.Pin23=PA5 +Mcu.Pin20=PC3 ADC1.master=1 PA3.Locked=true -Mcu.Pin21=PA5 +Mcu.Pin21=PA2 PA5.GPIO_Label=SW1 NVIC.ForceEnableDMAVector=true SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX @@ -289,22 +295,23 @@ SH.FMC_A5.0=FMC_A5,12b-sda1 PA11.Signal=USB_OTG_FS_DM SH.FMC_SDNRAS.ConfNb=1 ProjectManager.HeapSize=0x200 -Mcu.Pin15=PC0 +Mcu.Pin15=PH0/OSC_IN NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -Mcu.Pin16=PC1 +Mcu.Pin16=PH1/OSC_OUT ADC3.EOCSelection=ADC_EOC_SEQ_CONV -Mcu.Pin13=PH0/OSC_IN +Mcu.Pin13=PF9 Dma.ADC3.0.Mode=DMA_CIRCULAR -Mcu.Pin14=PH1/OSC_OUT -Mcu.Pin19=PA2 +Mcu.Pin14=PF10 +Mcu.Pin19=PC2 PF10.GPIOParameters=GPIO_Label ProjectManager.ComputerToolchain=false -Mcu.Pin17=PC2 -Mcu.Pin18=PC3 +PF9.Signal=GPIO_Output +Mcu.Pin17=PC0 +Mcu.Pin18=PC1 Dma.SAI1_B.2.Instance=DMA2_Stream4 NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 Mcu.Pin11=PF5 -Mcu.Pin12=PF10 +Mcu.Pin12=PF7 Mcu.Pin10=PF4 Dma.SAI1_A.1.Priority=DMA_PRIORITY_VERY_HIGH PE3.Signal=SAI1_SD_B @@ -374,6 +381,7 @@ Mcu.IP1=ADC3 PA12.Signal=USB_OTG_FS_DP PE4.GPIOParameters=GPIO_Label PB8.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PF9.Locked=true Mcu.UserConstants= SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE SPI4.Mode=SPI_MODE_MASTER @@ -427,6 +435,7 @@ PC15/OSC32_OUT.GPIOParameters=GPIO_Label SH.FMC_D2_DA2.0=FMC_D2,sd-16b-d1 Mcu.IP13=USB_OTG_FS PE13.Signal=FMC_D10_DA10 +PF7.GPIO_Label=LED_R RCC.VCOInputFreq_Value=1000000 PA14.Mode=Serial_Wire PF11.Signal=FMC_SDNRAS @@ -532,6 +541,7 @@ PE2.GPIOParameters=GPIO_Label PC2.Locked=true ProjectManager.RegisterCallBack= RCC.USBFreq_Value=48000000 +PF9.GPIO_Label=LED_G RCC.PLLSAIoutputFreq_Value=50000000 PE11.Signal=FMC_D8_DA8 RCC.LSE_VALUE=32768 @@ -568,8 +578,8 @@ RCC.UART5Freq_Value=54000000 ADC3.Channel-34\#ChannelRegularConversion=ADC_CHANNEL_8 RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CECFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SClocksFreq_Value,I2SFreq_Value,LCDTFToutputFreq_Value,LPTIM1Freq_Value,LSE_VALUE,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLI2SPCLKFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLI2SRoutputFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLQoutputFreq_Value,PLLSAIN,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIRCLKFreq_Value,PLLSAIoutputFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SAI1Freq_Value,SAI2Freq_Value,SAI_AClocksFreq_Value,SAI_BClocksFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,UART4Freq_Value,UART5Freq_Value,UART7Freq_Value,UART8Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USART6Freq_Value,USBFreq_Value,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value,VCOSAIOutputFreq_ValueQ,VcooutputI2S,VcooutputI2SQ ProjectManager.AskForMigrate=true -PE0.Signal=FMC_NBL0 Mcu.Name=STM32F427Z(G-I)Tx +PE0.Signal=FMC_NBL0 Dma.SAI1_B.2.Direction=DMA_PERIPH_TO_MEMORY PE12.Signal=FMC_D9_DA9 NVIC.SavedPendsvIrqHandlerGenerated=true diff --git a/OwlPedalMkII/Src/OwlPedal.cpp b/OwlPedalMkII/Src/OwlPedal.cpp index d77afd23..15c3a570 100644 --- a/OwlPedalMkII/Src/OwlPedal.cpp +++ b/OwlPedalMkII/Src/OwlPedal.cpp @@ -16,6 +16,8 @@ void setGateValue(uint8_t ch, int16_t value){ void setup(){ HAL_GPIO_WritePin(EXP_TIP_GPIO_Port, EXP_TIP_Pin, GPIO_PIN_SET); + HAL_GPIO_WritePin(LED_R_GPIO_Port, LED_R_Pin, GPIO_PIN_SET); + HAL_GPIO_WritePin(LED_G_GPIO_Port, LED_G_Pin, GPIO_PIN_SET); owl_setup(); } diff --git a/OwlPedalMkII/Src/main.c b/OwlPedalMkII/Src/main.c index 80043356..07a44f4f 100644 --- a/OwlPedalMkII/Src/main.c +++ b/OwlPedalMkII/Src/main.c @@ -686,6 +686,9 @@ static void MX_GPIO_Init(void) /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOC, EXTSPI_nCS_Pin|FLASH_HOLD_Pin|FLASH_nCS_Pin, GPIO_PIN_RESET); + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(GPIOF, LED_R_Pin|LED_G_Pin, GPIO_PIN_RESET); + /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOB, EXP_TIP_Pin|CS_nCS_Pin|CS_nRST_Pin, GPIO_PIN_RESET); @@ -706,12 +709,19 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - /*Configure GPIO pins : PF6 PF7 PF8 PF9 */ - GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9; + /*Configure GPIO pins : PF6 PF8 */ + GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_8; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + /*Configure GPIO pins : LED_R_Pin LED_G_Pin */ + GPIO_InitStruct.Pin = LED_R_Pin|LED_G_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + /*Configure GPIO pins : PA0 PA1 PA4 PA8 PA10 PA15 */ GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_8 From b69683b8e0cf033ee9b02356cc9188b87280d4fa Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 13 Oct 2020 16:28:47 +0200 Subject: [PATCH 014/286] renamed LED pins --- OwlPedalMkII/Inc/hardware.h | 4 +--- OwlPedalMkII/Inc/main.h | 8 ++++---- OwlPedalMkII/OwlPedal2.ioc | 14 ++++++++++---- OwlPedalMkII/Src/OwlPedal.cpp | 36 +++++++++++++++++++++++++++++++---- OwlPedalMkII/Src/main.c | 6 +++--- 5 files changed, 50 insertions(+), 18 deletions(-) diff --git a/OwlPedalMkII/Inc/hardware.h b/OwlPedalMkII/Inc/hardware.h index 22bb8627..7b028534 100644 --- a/OwlPedalMkII/Inc/hardware.h +++ b/OwlPedalMkII/Inc/hardware.h @@ -18,9 +18,7 @@ #define AUDIO_BITS_PER_SAMPLE 16 #define AUDIO_BYTES_PER_SAMPLE (AUDIO_BITS_PER_SAMPLE/8) #define AUDIO_CHANNELS 2 -#define USB_AUDIO_CHANNELS 2 -/* #define AUDIO_INT32_TO_SAMPLE(x) (__REV16((x)>>8)) */ -/* #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(__REV16(x))<<8) */ +#define USB_AUDIO_CHANNELS 0 #define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) diff --git a/OwlPedalMkII/Inc/main.h b/OwlPedalMkII/Inc/main.h index 36e93fe0..680d3c62 100644 --- a/OwlPedalMkII/Inc/main.h +++ b/OwlPedalMkII/Inc/main.h @@ -100,10 +100,10 @@ void Error_Handler(void); #define CS_SDA_GPIO_Port GPIOE #define EXTSPI_nCS_Pin GPIO_PIN_15 #define EXTSPI_nCS_GPIO_Port GPIOC -#define LED_R_Pin GPIO_PIN_7 -#define LED_R_GPIO_Port GPIOF -#define LED_G_Pin GPIO_PIN_9 -#define LED_G_GPIO_Port GPIOF +#define LED_RED_Pin GPIO_PIN_7 +#define LED_RED_GPIO_Port GPIOF +#define LED_GREEN_Pin GPIO_PIN_9 +#define LED_GREEN_GPIO_Port GPIOF #define ADC4_Pin GPIO_PIN_10 #define ADC4_GPIO_Port GPIOF #define ADC3_Pin GPIO_PIN_1 diff --git a/OwlPedalMkII/OwlPedal2.ioc b/OwlPedalMkII/OwlPedal2.ioc index c415d275..1509a3ac 100644 --- a/OwlPedalMkII/OwlPedal2.ioc +++ b/OwlPedalMkII/OwlPedal2.ioc @@ -23,18 +23,19 @@ PG8.Signal=FMC_SDCLK RCC.PLLCLKFreq_Value=168000000 RCC.PLLQCLKFreq_Value=48000000 PG0.Signal=FMC_A10 +PA3.GPIO_PuPd=GPIO_PULLUP FMC.LoadToActiveDelay1=2 VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled PC3.Locked=true RCC.RTCFreq_Value=32000 -PA3.GPIOParameters=GPIO_Label +PA3.GPIOParameters=GPIO_PuPd,GPIO_Label PA6.GPIO_Label=FLASH_MISO Dma.SAI1_A.1.Mode=DMA_CIRCULAR SH.FMC_SDNWE.ConfNb=1 SH.FMC_D5_DA5.0=FMC_D5,sd-16b-d1 Dma.SAI1_A.1.MemDataAlignment=DMA_MDATAALIGN_WORD PD6.GPIO_Label=CS_SDIN -PA2.GPIOParameters=GPIO_Label +PA2.GPIOParameters=GPIO_PuPd,GPIO_Label Dma.SAI1_B.2.Mode=DMA_CIRCULAR PinOutPanel.RotationAngle=0 PE6.GPIO_Label=CS_SDA @@ -89,6 +90,7 @@ PC4.GPIO_Label=FLASH_HOLD PE9.Signal=FMC_D6_DA6 SH.FMC_A2.0=FMC_A2,12b-sda1 PB1.GPIO_Label=EXP_RING +PA5.GPIO_PuPd=GPIO_PULLUP SH.FMC_D15_DA15.ConfNb=1 ADC3.ContinuousConvMode=ENABLE PE4.GPIO_Label=CS_LRCK @@ -117,13 +119,14 @@ VP_SYS_VS_Systick.Signal=SYS_VS_Systick SH.FMC_A11.ConfNb=1 SH.GPXTI8.ConfNb=1 FREERTOS.FootprintOK=true -PA5.GPIOParameters=GPIO_Label +PA5.GPIOParameters=GPIO_PuPd,GPIO_Label FMC.WriteRecoveryTime1=2 PF7.Locked=true SH.ADCx_IN9.0=ADC1_IN9,IN9 SH.FMC_A1.0=FMC_A1,12b-sda1 ADC3.DMAContinuousRequests=ENABLE RCC.APB2CLKDivider=RCC_HCLK_DIV2 +NVIC.EXTI2_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true SH.FMC_SDCLK.0=FMC_SDCLK,12b-sda1 RCC.CECFreq_Value=32786.88524590164 PF14.Signal=FMC_A8 @@ -288,8 +291,8 @@ PA5.GPIO_Label=SW1 NVIC.ForceEnableDMAVector=true SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -SH.FMC_A10.ConfNb=1 PE5.GPIO_Label=CS_SCK +SH.FMC_A10.ConfNb=1 ProjectManager.CompilerOptimize=6 SH.FMC_A5.0=FMC_A5,12b-sda1 PA11.Signal=USB_OTG_FS_DM @@ -330,6 +333,7 @@ ADC3.EnableAnalogWatchDog=false Mcu.Family=STM32F4 FMC.IPParameters=ReadPipeDelay1,ReadBurst1,ReadBurst2,SDClockPeriod1,SDClockPeriod2,CASLatency1,LoadToActiveDelay1,ExitSelfRefreshDelay1,SelfRefreshTime1,RowCycleDelay1,RowCycleDelay2,WriteRecoveryTime1,RPDelay1,RPDelay2,RCDDelay1 ProjectManager.MainLocation=Src +PA2.GPIO_PuPd=GPIO_PULLUP SH.FMC_A6.ConfNb=1 PA6.Mode=Full_Duplex_Master USB_DEVICE.CLASS_NAME_FS=AUDIO @@ -352,6 +356,7 @@ PA12.GPIOParameters=GPIO_Label ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-SystemClock_Config-RCC-false-HAL-true,9-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,10-MX_RTC_Init-RTC-false-HAL-true,11-MX_ADC1_Init-ADC1-false-HAL-true PA9.GPIOParameters=GPIO_Label PA11.GPIOParameters=GPIO_Label +NVIC.EXTI3_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true SH.FMC_D6_DA6.0=FMC_D6,sd-16b-d1 PA11.Mode=Device_Only PB2/BOOT1.GPIOParameters=GPIO_Label @@ -412,6 +417,7 @@ SH.FMC_A10.0=FMC_A10,12b-sda1 RCC.AHBFreq_Value=168000000 Mcu.Pin0=PE2 Mcu.Pin1=PE3 +GPIO.groupedBy=Group By Peripherals Mcu.Pin2=PE4 FREERTOS.configUSE_PREEMPTION=0 Mcu.Pin3=PE5 diff --git a/OwlPedalMkII/Src/OwlPedal.cpp b/OwlPedalMkII/Src/OwlPedal.cpp index 15c3a570..c964f8aa 100644 --- a/OwlPedalMkII/Src/OwlPedal.cpp +++ b/OwlPedalMkII/Src/OwlPedal.cpp @@ -9,16 +9,44 @@ #include "OpenWareMidiControl.h" +void setLed(uint8_t led, uint32_t rgb){ + switch(rgb){ + case RED_COLOUR: + HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_SET); + HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_RESET); + break; + case GREEN_COLOUR: + HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_RESET); + HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_SET); + break; + // case YELLOW_COLOUR: + // // not working + // HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_SET); + // HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_SET); + // break; + case NO_COLOUR: + HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_RESET); + HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_RESET); + break; + } +} + void setGateValue(uint8_t ch, int16_t value){ - // if(ch == PUSHBUTTON) - // HAL_GPIO_WritePin(GATE_OUT_GPIO_Port, GATE_OUT_Pin, value ? GPIO_PIN_RESET : GPIO_PIN_SET); + if(ch == PUSHBUTTON){ + HAL_GPIO_TogglePin(LED_RED_GPIO_Port, LED_RED_Pin); + HAL_GPIO_TogglePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin); + }else if(ch == GREEN_BUTTON){ + setLed(0, GREEN_COLOUR); + }else if(ch == RED_BUTTON){ + setLed(0, RED_COLOUR); + } } void setup(){ + setLed(0, RED_COLOUR); HAL_GPIO_WritePin(EXP_TIP_GPIO_Port, EXP_TIP_Pin, GPIO_PIN_SET); - HAL_GPIO_WritePin(LED_R_GPIO_Port, LED_R_Pin, GPIO_PIN_SET); - HAL_GPIO_WritePin(LED_G_GPIO_Port, LED_G_Pin, GPIO_PIN_SET); owl_setup(); + setLed(0, GREEN_COLOUR); } void loop(void){ diff --git a/OwlPedalMkII/Src/main.c b/OwlPedalMkII/Src/main.c index 07a44f4f..3d51bf81 100644 --- a/OwlPedalMkII/Src/main.c +++ b/OwlPedalMkII/Src/main.c @@ -687,7 +687,7 @@ static void MX_GPIO_Init(void) HAL_GPIO_WritePin(GPIOC, EXTSPI_nCS_Pin|FLASH_HOLD_Pin|FLASH_nCS_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOF, LED_R_Pin|LED_G_Pin, GPIO_PIN_RESET); + HAL_GPIO_WritePin(GPIOF, LED_RED_Pin|LED_GREEN_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOB, EXP_TIP_Pin|CS_nCS_Pin|CS_nRST_Pin, GPIO_PIN_RESET); @@ -715,8 +715,8 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); - /*Configure GPIO pins : LED_R_Pin LED_G_Pin */ - GPIO_InitStruct.Pin = LED_R_Pin|LED_G_Pin; + /*Configure GPIO pins : LED_RED_Pin LED_GREEN_Pin */ + GPIO_InitStruct.Pin = LED_RED_Pin|LED_GREEN_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; From 3e4bc8c1f2683df9b365903db05f84f00d3612ce Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 13 Oct 2020 17:21:47 +0200 Subject: [PATCH 015/286] enabled EXTI --- OwlPedalMkII/Inc/main.h | 2 ++ OwlPedalMkII/Inc/stm32f4xx_it.h | 2 ++ OwlPedalMkII/OwlPedal2.ioc | 13 ++++++++----- OwlPedalMkII/Src/main.c | 8 +++++++- OwlPedalMkII/Src/stm32f4xx_it.c | 28 ++++++++++++++++++++++++++++ OwlPedalMkII/cube-update.sh | 4 ++++ 6 files changed, 51 insertions(+), 6 deletions(-) create mode 100755 OwlPedalMkII/cube-update.sh diff --git a/OwlPedalMkII/Inc/main.h b/OwlPedalMkII/Inc/main.h index 680d3c62..2741fb8f 100644 --- a/OwlPedalMkII/Inc/main.h +++ b/OwlPedalMkII/Inc/main.h @@ -114,8 +114,10 @@ void Error_Handler(void); #define ADC1_GPIO_Port GPIOC #define SW4_Pin GPIO_PIN_2 #define SW4_GPIO_Port GPIOA +#define SW4_EXTI_IRQn EXTI2_IRQn #define SW3_Pin GPIO_PIN_3 #define SW3_GPIO_Port GPIOA +#define SW3_EXTI_IRQn EXTI3_IRQn #define SW1_Pin GPIO_PIN_5 #define SW1_GPIO_Port GPIOA #define SW1_EXTI_IRQn EXTI9_5_IRQn diff --git a/OwlPedalMkII/Inc/stm32f4xx_it.h b/OwlPedalMkII/Inc/stm32f4xx_it.h index daf83bd9..b3238d74 100644 --- a/OwlPedalMkII/Inc/stm32f4xx_it.h +++ b/OwlPedalMkII/Inc/stm32f4xx_it.h @@ -63,6 +63,8 @@ /* Exported functions prototypes ---------------------------------------------*/ void SysTick_Handler(void); +void EXTI2_IRQHandler(void); +void EXTI3_IRQHandler(void); void EXTI9_5_IRQHandler(void); void DMA2_Stream0_IRQHandler(void); void DMA2_Stream1_IRQHandler(void); diff --git a/OwlPedalMkII/OwlPedal2.ioc b/OwlPedalMkII/OwlPedal2.ioc index 1509a3ac..a7e79823 100644 --- a/OwlPedalMkII/OwlPedal2.ioc +++ b/OwlPedalMkII/OwlPedal2.ioc @@ -28,14 +28,14 @@ FMC.LoadToActiveDelay1=2 VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled PC3.Locked=true RCC.RTCFreq_Value=32000 -PA3.GPIOParameters=GPIO_PuPd,GPIO_Label +PA3.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI PA6.GPIO_Label=FLASH_MISO Dma.SAI1_A.1.Mode=DMA_CIRCULAR SH.FMC_SDNWE.ConfNb=1 SH.FMC_D5_DA5.0=FMC_D5,sd-16b-d1 Dma.SAI1_A.1.MemDataAlignment=DMA_MDATAALIGN_WORD PD6.GPIO_Label=CS_SDIN -PA2.GPIOParameters=GPIO_PuPd,GPIO_Label +PA2.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI Dma.SAI1_B.2.Mode=DMA_CIRCULAR PinOutPanel.RotationAngle=0 PE6.GPIO_Label=CS_SDA @@ -119,7 +119,7 @@ VP_SYS_VS_Systick.Signal=SYS_VS_Systick SH.FMC_A11.ConfNb=1 SH.GPXTI8.ConfNb=1 FREERTOS.FootprintOK=true -PA5.GPIOParameters=GPIO_PuPd,GPIO_Label +PA5.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI FMC.WriteRecoveryTime1=2 PF7.Locked=true SH.ADCx_IN9.0=ADC1_IN9,IN9 @@ -199,6 +199,7 @@ Mcu.Pin64=PG15 ADC3.Resolution=ADC_RESOLUTION_12B Mcu.Pin65=PB3 Dma.SAI1_B.2.PeriphInc=DMA_PINC_DISABLE +PA3.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING PC3.GPIOParameters=GPIO_Label PD10.Signal=FMC_D15_DA15 SH.FMC_A3.0=FMC_A3,12b-sda1 @@ -441,7 +442,7 @@ PC15/OSC32_OUT.GPIOParameters=GPIO_Label SH.FMC_D2_DA2.0=FMC_D2,sd-16b-d1 Mcu.IP13=USB_OTG_FS PE13.Signal=FMC_D10_DA10 -PF7.GPIO_Label=LED_R +PF7.GPIO_Label=LED_RED RCC.VCOInputFreq_Value=1000000 PA14.Mode=Serial_Wire PF11.Signal=FMC_SDNRAS @@ -507,6 +508,7 @@ RCC.I2SFreq_Value=96000000 SH.GPXTI5.0=GPIO_EXTI5 ADC3.DiscontinuousConvMode=DISABLE SH.ADCx_IN13.0=ADC3_IN13,IN13 +PA5.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING SAI1.Synchro_A=SAI_ASYNCHRONOUS SH.FMC_A9.ConfNb=1 SAI1.Synchro_B=SAI_SYNCHRONOUS @@ -547,7 +549,7 @@ PE2.GPIOParameters=GPIO_Label PC2.Locked=true ProjectManager.RegisterCallBack= RCC.USBFreq_Value=48000000 -PF9.GPIO_Label=LED_G +PF9.GPIO_Label=LED_GREEN RCC.PLLSAIoutputFreq_Value=50000000 PE11.Signal=FMC_D8_DA8 RCC.LSE_VALUE=32768 @@ -607,6 +609,7 @@ SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B NVIC.EXTI9_5_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true PA14.Signal=SYS_JTCK-SWCLK RCC.HSI_VALUE=16000000 +PA2.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING Dma.ADC3.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode RCC.PLLQ=7 ADC1.NbrOfConversionFlag=1 diff --git a/OwlPedalMkII/Src/main.c b/OwlPedalMkII/Src/main.c index 3d51bf81..e545128f 100644 --- a/OwlPedalMkII/Src/main.c +++ b/OwlPedalMkII/Src/main.c @@ -733,7 +733,7 @@ static void MX_GPIO_Init(void) /*Configure GPIO pins : SW4_Pin SW3_Pin SW1_Pin */ GPIO_InitStruct.Pin = SW4_Pin|SW3_Pin|SW1_Pin; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; - GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /*Configure GPIO pins : PB0 PB12 PB13 PB14 @@ -776,6 +776,12 @@ static void MX_GPIO_Init(void) HAL_GPIO_Init(SW2_GPIO_Port, &GPIO_InitStruct); /* EXTI interrupt init*/ + HAL_NVIC_SetPriority(EXTI2_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(EXTI2_IRQn); + + HAL_NVIC_SetPriority(EXTI3_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(EXTI3_IRQn); + HAL_NVIC_SetPriority(EXTI9_5_IRQn, 15, 0); HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); diff --git a/OwlPedalMkII/Src/stm32f4xx_it.c b/OwlPedalMkII/Src/stm32f4xx_it.c index e4046a8e..6a5b84c3 100644 --- a/OwlPedalMkII/Src/stm32f4xx_it.c +++ b/OwlPedalMkII/Src/stm32f4xx_it.c @@ -115,6 +115,34 @@ void SysTick_Handler(void) /* please refer to the startup file (startup_stm32f4xx.s). */ /******************************************************************************/ +/** + * @brief This function handles EXTI line2 interrupt. + */ +void EXTI2_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI2_IRQn 0 */ + + /* USER CODE END EXTI2_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2); + /* USER CODE BEGIN EXTI2_IRQn 1 */ + + /* USER CODE END EXTI2_IRQn 1 */ +} + +/** + * @brief This function handles EXTI line3 interrupt. + */ +void EXTI3_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI3_IRQn 0 */ + + /* USER CODE END EXTI3_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_3); + /* USER CODE BEGIN EXTI3_IRQn 1 */ + + /* USER CODE END EXTI3_IRQn 1 */ +} + /** * @brief This function handles EXTI line[9:5] interrupts. */ diff --git a/OwlPedalMkII/cube-update.sh b/OwlPedalMkII/cube-update.sh new file mode 100755 index 00000000..20094fec --- /dev/null +++ b/OwlPedalMkII/cube-update.sh @@ -0,0 +1,4 @@ +#!/bin/bash +git checkout Src/usb_device.c +git checkout Src/usbd_conf.c Inc/usbd_conf.h +rm -f Src/usbd_audio_if.c Inc/usbd_audio_if.h From 62b709a4d692173b1785b3183801b62aac5b1d00 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 13 Oct 2020 17:23:07 +0200 Subject: [PATCH 016/286] configure rising/falling interrupt --- OwlPedalMkII/Src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OwlPedalMkII/Src/main.c b/OwlPedalMkII/Src/main.c index e545128f..60cae68e 100644 --- a/OwlPedalMkII/Src/main.c +++ b/OwlPedalMkII/Src/main.c @@ -732,7 +732,7 @@ static void MX_GPIO_Init(void) /*Configure GPIO pins : SW4_Pin SW3_Pin SW1_Pin */ GPIO_InitStruct.Pin = SW4_Pin|SW3_Pin|SW1_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); From 4bf799b997fe6eebbb81f32263f898182f361c00 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Sun, 1 Nov 2020 01:09:00 +0100 Subject: [PATCH 017/286] usb config changes --- OwlPedalMkII/Inc/hardware.h | 8 ++++---- OwlPedalMkII/Inc/usbd_conf.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/OwlPedalMkII/Inc/hardware.h b/OwlPedalMkII/Inc/hardware.h index 7b028534..44ff43e4 100644 --- a/OwlPedalMkII/Inc/hardware.h +++ b/OwlPedalMkII/Inc/hardware.h @@ -7,9 +7,9 @@ #define HARDWARE_ID OWL_PEDAL_HARDWARE #define HARDWARE_VERSION "OWL Pedal mkII" -#define USE_USBD_AUDIO -#define USE_USBD_AUDIO_TX // microphone -#define USE_USBD_AUDIO_RX // speaker +/* #define USE_USBD_AUDIO */ +/* #define USE_USBD_AUDIO_TX // microphone */ +/* #define USE_USBD_AUDIO_RX // speaker */ #define USE_USBD_MIDI #define USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS @@ -18,7 +18,7 @@ #define AUDIO_BITS_PER_SAMPLE 16 #define AUDIO_BYTES_PER_SAMPLE (AUDIO_BITS_PER_SAMPLE/8) #define AUDIO_CHANNELS 2 -#define USB_AUDIO_CHANNELS 0 +#define USB_AUDIO_CHANNELS 2 #define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) diff --git a/OwlPedalMkII/Inc/usbd_conf.h b/OwlPedalMkII/Inc/usbd_conf.h index 85bae835..a4ae0135 100644 --- a/OwlPedalMkII/Inc/usbd_conf.h +++ b/OwlPedalMkII/Inc/usbd_conf.h @@ -70,7 +70,7 @@ /*---------- -----------*/ #define USBD_MAX_NUM_INTERFACES 5U /*---------- -----------*/ -#define USBD_MAX_NUM_CONFIGURATION 5U +#define USBD_MAX_NUM_CONFIGURATION 1U /*---------- -----------*/ #define USBD_MAX_STR_DESC_SIZ 512U /*---------- -----------*/ @@ -78,7 +78,7 @@ /*---------- -----------*/ #define USBD_LPM_ENABLED 0U /*---------- -----------*/ -#define USBD_SELF_POWERED 1U +#define USBD_SELF_POWERED 0U /*---------- -----------*/ #define USBD_AUDIO_FREQ AUDIO_SAMPLINGRATE From 569243bb6f7d1994bf3807139249fe5d602f23e0 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 11 Mar 2021 23:13:02 +0100 Subject: [PATCH 018/286] renamed OwlPedal2 --- {OwlPedalMkII => OwlPedal2}/Inc/FreeRTOSConfig.h | 0 {OwlPedalMkII => OwlPedal2}/Inc/hardware.h | 0 {OwlPedalMkII => OwlPedal2}/Inc/main.h | 0 {OwlPedalMkII => OwlPedal2}/Inc/stm32f4xx_hal_conf.h | 0 {OwlPedalMkII => OwlPedal2}/Inc/stm32f4xx_it.h | 0 {OwlPedalMkII => OwlPedal2}/Inc/usb_device.h | 0 {OwlPedalMkII => OwlPedal2}/Inc/usbd_conf.h | 0 {OwlPedalMkII => OwlPedal2}/Inc/usbd_desc.h | 0 {OwlPedalMkII => OwlPedal2}/Makefile | 0 {OwlPedalMkII => OwlPedal2}/OwlPedal2.ioc | 0 {OwlPedalMkII => OwlPedal2}/Src/OwlPedal.cpp | 0 {OwlPedalMkII => OwlPedal2}/Src/freertos.c | 0 {OwlPedalMkII => OwlPedal2}/Src/main.c | 0 {OwlPedalMkII => OwlPedal2}/Src/startup_stm32f427xx.s | 0 {OwlPedalMkII => OwlPedal2}/Src/stm32f4xx_hal_msp.c | 0 {OwlPedalMkII => OwlPedal2}/Src/stm32f4xx_it.c | 0 {OwlPedalMkII => OwlPedal2}/Src/system_stm32f4xx.c | 0 {OwlPedalMkII => OwlPedal2}/Src/usb_device.c | 0 {OwlPedalMkII => OwlPedal2}/Src/usbd_conf.c | 0 {OwlPedalMkII => OwlPedal2}/Src/usbd_desc.c | 0 {OwlPedalMkII => OwlPedal2}/cube-update.sh | 0 21 files changed, 0 insertions(+), 0 deletions(-) rename {OwlPedalMkII => OwlPedal2}/Inc/FreeRTOSConfig.h (100%) rename {OwlPedalMkII => OwlPedal2}/Inc/hardware.h (100%) rename {OwlPedalMkII => OwlPedal2}/Inc/main.h (100%) rename {OwlPedalMkII => OwlPedal2}/Inc/stm32f4xx_hal_conf.h (100%) rename {OwlPedalMkII => OwlPedal2}/Inc/stm32f4xx_it.h (100%) rename {OwlPedalMkII => OwlPedal2}/Inc/usb_device.h (100%) rename {OwlPedalMkII => OwlPedal2}/Inc/usbd_conf.h (100%) rename {OwlPedalMkII => OwlPedal2}/Inc/usbd_desc.h (100%) rename {OwlPedalMkII => OwlPedal2}/Makefile (100%) rename {OwlPedalMkII => OwlPedal2}/OwlPedal2.ioc (100%) rename {OwlPedalMkII => OwlPedal2}/Src/OwlPedal.cpp (100%) rename {OwlPedalMkII => OwlPedal2}/Src/freertos.c (100%) rename {OwlPedalMkII => OwlPedal2}/Src/main.c (100%) rename {OwlPedalMkII => OwlPedal2}/Src/startup_stm32f427xx.s (100%) rename {OwlPedalMkII => OwlPedal2}/Src/stm32f4xx_hal_msp.c (100%) rename {OwlPedalMkII => OwlPedal2}/Src/stm32f4xx_it.c (100%) rename {OwlPedalMkII => OwlPedal2}/Src/system_stm32f4xx.c (100%) rename {OwlPedalMkII => OwlPedal2}/Src/usb_device.c (100%) rename {OwlPedalMkII => OwlPedal2}/Src/usbd_conf.c (100%) rename {OwlPedalMkII => OwlPedal2}/Src/usbd_desc.c (100%) rename {OwlPedalMkII => OwlPedal2}/cube-update.sh (100%) diff --git a/OwlPedalMkII/Inc/FreeRTOSConfig.h b/OwlPedal2/Inc/FreeRTOSConfig.h similarity index 100% rename from OwlPedalMkII/Inc/FreeRTOSConfig.h rename to OwlPedal2/Inc/FreeRTOSConfig.h diff --git a/OwlPedalMkII/Inc/hardware.h b/OwlPedal2/Inc/hardware.h similarity index 100% rename from OwlPedalMkII/Inc/hardware.h rename to OwlPedal2/Inc/hardware.h diff --git a/OwlPedalMkII/Inc/main.h b/OwlPedal2/Inc/main.h similarity index 100% rename from OwlPedalMkII/Inc/main.h rename to OwlPedal2/Inc/main.h diff --git a/OwlPedalMkII/Inc/stm32f4xx_hal_conf.h b/OwlPedal2/Inc/stm32f4xx_hal_conf.h similarity index 100% rename from OwlPedalMkII/Inc/stm32f4xx_hal_conf.h rename to OwlPedal2/Inc/stm32f4xx_hal_conf.h diff --git a/OwlPedalMkII/Inc/stm32f4xx_it.h b/OwlPedal2/Inc/stm32f4xx_it.h similarity index 100% rename from OwlPedalMkII/Inc/stm32f4xx_it.h rename to OwlPedal2/Inc/stm32f4xx_it.h diff --git a/OwlPedalMkII/Inc/usb_device.h b/OwlPedal2/Inc/usb_device.h similarity index 100% rename from OwlPedalMkII/Inc/usb_device.h rename to OwlPedal2/Inc/usb_device.h diff --git a/OwlPedalMkII/Inc/usbd_conf.h b/OwlPedal2/Inc/usbd_conf.h similarity index 100% rename from OwlPedalMkII/Inc/usbd_conf.h rename to OwlPedal2/Inc/usbd_conf.h diff --git a/OwlPedalMkII/Inc/usbd_desc.h b/OwlPedal2/Inc/usbd_desc.h similarity index 100% rename from OwlPedalMkII/Inc/usbd_desc.h rename to OwlPedal2/Inc/usbd_desc.h diff --git a/OwlPedalMkII/Makefile b/OwlPedal2/Makefile similarity index 100% rename from OwlPedalMkII/Makefile rename to OwlPedal2/Makefile diff --git a/OwlPedalMkII/OwlPedal2.ioc b/OwlPedal2/OwlPedal2.ioc similarity index 100% rename from OwlPedalMkII/OwlPedal2.ioc rename to OwlPedal2/OwlPedal2.ioc diff --git a/OwlPedalMkII/Src/OwlPedal.cpp b/OwlPedal2/Src/OwlPedal.cpp similarity index 100% rename from OwlPedalMkII/Src/OwlPedal.cpp rename to OwlPedal2/Src/OwlPedal.cpp diff --git a/OwlPedalMkII/Src/freertos.c b/OwlPedal2/Src/freertos.c similarity index 100% rename from OwlPedalMkII/Src/freertos.c rename to OwlPedal2/Src/freertos.c diff --git a/OwlPedalMkII/Src/main.c b/OwlPedal2/Src/main.c similarity index 100% rename from OwlPedalMkII/Src/main.c rename to OwlPedal2/Src/main.c diff --git a/OwlPedalMkII/Src/startup_stm32f427xx.s b/OwlPedal2/Src/startup_stm32f427xx.s similarity index 100% rename from OwlPedalMkII/Src/startup_stm32f427xx.s rename to OwlPedal2/Src/startup_stm32f427xx.s diff --git a/OwlPedalMkII/Src/stm32f4xx_hal_msp.c b/OwlPedal2/Src/stm32f4xx_hal_msp.c similarity index 100% rename from OwlPedalMkII/Src/stm32f4xx_hal_msp.c rename to OwlPedal2/Src/stm32f4xx_hal_msp.c diff --git a/OwlPedalMkII/Src/stm32f4xx_it.c b/OwlPedal2/Src/stm32f4xx_it.c similarity index 100% rename from OwlPedalMkII/Src/stm32f4xx_it.c rename to OwlPedal2/Src/stm32f4xx_it.c diff --git a/OwlPedalMkII/Src/system_stm32f4xx.c b/OwlPedal2/Src/system_stm32f4xx.c similarity index 100% rename from OwlPedalMkII/Src/system_stm32f4xx.c rename to OwlPedal2/Src/system_stm32f4xx.c diff --git a/OwlPedalMkII/Src/usb_device.c b/OwlPedal2/Src/usb_device.c similarity index 100% rename from OwlPedalMkII/Src/usb_device.c rename to OwlPedal2/Src/usb_device.c diff --git a/OwlPedalMkII/Src/usbd_conf.c b/OwlPedal2/Src/usbd_conf.c similarity index 100% rename from OwlPedalMkII/Src/usbd_conf.c rename to OwlPedal2/Src/usbd_conf.c diff --git a/OwlPedalMkII/Src/usbd_desc.c b/OwlPedal2/Src/usbd_desc.c similarity index 100% rename from OwlPedalMkII/Src/usbd_desc.c rename to OwlPedal2/Src/usbd_desc.c diff --git a/OwlPedalMkII/cube-update.sh b/OwlPedal2/cube-update.sh similarity index 100% rename from OwlPedalMkII/cube-update.sh rename to OwlPedal2/cube-update.sh From 3018a8b1c2eaccd4a25430e8fc51c2c744523168 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 12 Mar 2021 00:42:53 +0100 Subject: [PATCH 019/286] updated OWL2 pedal --- OwlPedal2/Inc/hardware.h | 7 +- OwlPedal2/Inc/main.h | 9 ++ OwlPedal2/OwlPedal2.ioc | 164 ++++++++++++++++++++----------------- OwlPedal2/Src/OwlPedal.cpp | 80 ++++++++++++++---- OwlPedal2/Src/usbd_conf.c | 26 +++--- 5 files changed, 178 insertions(+), 108 deletions(-) diff --git a/OwlPedal2/Inc/hardware.h b/OwlPedal2/Inc/hardware.h index 44ff43e4..54e6a4c0 100644 --- a/OwlPedal2/Inc/hardware.h +++ b/OwlPedal2/Inc/hardware.h @@ -7,9 +7,9 @@ #define HARDWARE_ID OWL_PEDAL_HARDWARE #define HARDWARE_VERSION "OWL Pedal mkII" -/* #define USE_USBD_AUDIO */ -/* #define USE_USBD_AUDIO_TX // microphone */ -/* #define USE_USBD_AUDIO_RX // speaker */ +#define USE_USBD_AUDIO +#define USE_USBD_AUDIO_TX // microphone +#define USE_USBD_AUDIO_RX // speaker #define USE_USBD_MIDI #define USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS @@ -36,6 +36,7 @@ #define ADC_B 1 #define ADC_C 2 #define ADC_D 3 +/* #define ADC_E 4 */ #define USE_CODEC #define USE_CS4271 #define CODEC_HP_FILTER diff --git a/OwlPedal2/Inc/main.h b/OwlPedal2/Inc/main.h index 2741fb8f..4f563c0e 100644 --- a/OwlPedal2/Inc/main.h +++ b/OwlPedal2/Inc/main.h @@ -157,6 +157,15 @@ void Error_Handler(void); #define CS_RST_Pin GPIO_PIN_11 #define CS_RST_GPIO_Port GPIOB +#define USBD_VBUS_Pin GPIO_PIN_9 +#define USBD_VBUS_GPIO_Port GPIOA +#define USBD_ID_Pin GPIO_PIN_10 +#define USBD_ID_GPIO_Port GPIOA +#define USBD_DM_Pin GPIO_PIN_11 +#define USBD_DM_GPIO_Port GPIOA +#define USBD_DP_Pin GPIO_PIN_12 +#define USBD_DP_GPIO_Port GPIOA + /* USER CODE END Private defines */ #ifdef __cplusplus diff --git a/OwlPedal2/OwlPedal2.ioc b/OwlPedal2/OwlPedal2.ioc index a7e79823..62ac4e5d 100644 --- a/OwlPedal2/OwlPedal2.ioc +++ b/OwlPedal2/OwlPedal2.ioc @@ -51,7 +51,7 @@ PF7.Signal=GPIO_Output SH.FMC_SDNWE.0=FMC_SDNWE,12b-sda1 SPI1.Direction=SPI_DIRECTION_2LINES SH.FMC_D11_DA11.0=FMC_D11,sd-16b-d1 -Dma.SAI1_A.1.Instance=DMA2_Stream1 +Dma.SAI1_A.1.Instance=DMA2_Stream3 RCC.I2C4Freq_Value=54000000 PE2.Mode=TX_Only_Simplex_Unidirect_Master RCC.APB2TimFreq_Value=168000000 @@ -77,11 +77,13 @@ RCC.PLLSAIRCLKFreq_Value=50000000 ProjectManager.ProjectBuild=false NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false PB3.Mode=Full_Duplex_Master +ADC1.ScanConvMode=ENABLE +PA4.Locked=true Dma.ADC3.0.PeriphInc=DMA_PINC_DISABLE ADC3.ExternalTrigConv=ADC_SOFTWARE_START FMC.SelfRefreshTime1=4 -ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.25.1 -MxDb.Version=DB.6.0.0 +ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.25.2 +MxDb.Version=DB.6.0.10 USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology USB_DEVICE.USBD_MAX_NUM_CONFIGURATION-AUDIO_FS=2 ProjectManager.BackupPrevious=false @@ -96,7 +98,7 @@ ADC3.ContinuousConvMode=ENABLE PE4.GPIO_Label=CS_LRCK PF10.Locked=true ADC3.IPParameters=Rank-31\#ChannelRegularConversion,Channel-31\#ChannelRegularConversion,SamplingTime-31\#ChannelRegularConversion,NbrOfConversionFlag,ScanConvMode,ContinuousConvMode,DMAContinuousRequests,EOCSelection,InjNumberOfConversion,EnableAnalogWatchDog,ExternalTrigConv,Rank-32\#ChannelRegularConversion,Channel-32\#ChannelRegularConversion,SamplingTime-32\#ChannelRegularConversion,Rank-33\#ChannelRegularConversion,Channel-33\#ChannelRegularConversion,SamplingTime-33\#ChannelRegularConversion,Rank-34\#ChannelRegularConversion,Channel-34\#ChannelRegularConversion,SamplingTime-34\#ChannelRegularConversion,NbrOfConversion,ClockPrescaler,Resolution,DataAlign,DiscontinuousConvMode,ExternalTrigConvEdge -SH.ADCx_IN11.ConfNb=1 +SH.ADCx_IN11.ConfNb=2 PE2.Signal=SPI4_SCK ADC3.Channel-33\#ChannelRegularConversion=ADC_CHANNEL_11 SH.FMC_D1_DA1.0=FMC_D1,sd-16b-d1 @@ -104,10 +106,10 @@ NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false PC15/OSC32_OUT.Locked=true PF3.Signal=FMC_A3 VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 -NVIC.SAI1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true +NVIC.SAI1_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true PE10.Signal=FMC_D7_DA7 ProjectManager.HalAssertFull=true -ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_3CYCLES +ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES RCC.MCO2PinFreq_Value=168000000 Mcu.Package=LQFP144 PB1.Signal=ADCx_IN9 @@ -126,13 +128,13 @@ SH.ADCx_IN9.0=ADC1_IN9,IN9 SH.FMC_A1.0=FMC_A1,12b-sda1 ADC3.DMAContinuousRequests=ENABLE RCC.APB2CLKDivider=RCC_HCLK_DIV2 -NVIC.EXTI2_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true +NVIC.EXTI2_IRQn=true\:5\:0\:false\:false\:true\:false\:true\:true SH.FMC_SDCLK.0=FMC_SDCLK,12b-sda1 RCC.CECFreq_Value=32786.88524590164 PF14.Signal=FMC_A8 ADC3.ExternalTrigConvEdge=ADC_EXTERNALTRIGCONVEDGE_NONE RCC.APB1TimFreq_Value=84000000 -Dma.ADC3.0.Instance=DMA2_Stream0 +Dma.ADC3.0.Instance=DMA2_Stream1 NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false FMC.RowCycleDelay2=6 PF10.Mode=IN8 @@ -142,6 +144,8 @@ USB_OTG_FS.IPParameters=VirtualMode PB10.GPIOParameters=GPIO_Label ADC3.Rank-34\#ChannelRegularConversion=4 SAI1.SlotSize-SAI_A_AsyncSlave=SAI_SLOTSIZE_32B +PA4.GPIO_Label=BYPASS +ADC1.EOCSelection=ADC_EOC_SEQ_CONV PD15.Signal=FMC_D1_DA1 SH.FMC_D3_DA3.0=FMC_D3,sd-16b-d1 ProjectManager.CustomerFirmwarePackage= @@ -162,79 +166,81 @@ SH.FMC_A1.ConfNb=1 FREERTOS.Tasks01=defaultTask,0,128,StartDefaultTask,Default,NULL ADC1.Rank-0\#ChannelRegularConversion=1 USB_DEVICE.VirtualMode-AUDIO_FS=Audio -Mcu.PinsNb=75 +Mcu.PinsNb=76 Dma.SAI1_B.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -Mcu.Pin73=VP_SYS_VS_Systick -Mcu.Pin74=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS -Mcu.Pin71=VP_FREERTOS_VS_CMSIS_V1 -Mcu.Pin72=VP_RTC_VS_RTC_Activate -ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,NbrOfConversionFlag,master,ClockPrescaler +Mcu.Pin73=VP_RTC_VS_RTC_Activate +Mcu.Pin74=VP_SYS_VS_Systick +Mcu.Pin71=PE1 +Mcu.Pin72=VP_FREERTOS_VS_CMSIS_V1 +ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,NbrOfConversionFlag,master,ClockPrescaler,ScanConvMode,ContinuousConvMode,DMAContinuousRequests,EOCSelection,NbrOfConversion PG5.Signal=FMC_A15_BA1 +Mcu.Pin75=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS SH.FMC_D10_DA10.0=FMC_D10,sd-16b-d1 PA9.GPIO_Label=USBD_VBUS FREERTOS.INCLUDE_vTaskDelayUntil=1 FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 -Mcu.Pin70=PE1 +Mcu.Pin70=PE0 PB8.GPIO_PuPd=GPIO_PULLUP PC2.Signal=ADCx_IN12 PB11.GPIO_Label=CS_nRST PD1.Signal=FMC_D3_DA3 PA11.GPIO_Label=USBD_DM RCC.VCOSAIOutputFreq_ValueQ=25000000 -NVIC.DMA2_Stream1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -Mcu.Pin68=PB8 -Mcu.Pin69=PE0 +NVIC.DMA2_Stream1_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true +Mcu.Pin68=PB6 +Mcu.Pin69=PB8 RCC.UART8Freq_Value=54000000 PC0.Signal=FMC_SDNWE RCC.APB1CLKDivider=RCC_HCLK_DIV4 ADC3.Channel-31\#ChannelRegularConversion=ADC_CHANNEL_13 PD6.Mode=SAI_A_AsyncSlave -Mcu.Pin62=PD1 -Mcu.Pin63=PD6 -Mcu.Pin60=PA14 -Mcu.Pin61=PD0 -Mcu.Pin66=PB5 -Mcu.Pin67=PB6 -Mcu.Pin64=PG15 +Mcu.Pin62=PD0 +Mcu.Pin63=PD1 +Mcu.Pin60=PA13 +Mcu.Pin61=PA14 +Mcu.Pin66=PB3 +Mcu.Pin67=PB5 +Mcu.Pin64=PD6 ADC3.Resolution=ADC_RESOLUTION_12B -Mcu.Pin65=PB3 +Mcu.Pin65=PG15 Dma.SAI1_B.2.PeriphInc=DMA_PINC_DISABLE PA3.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING PC3.GPIOParameters=GPIO_Label PD10.Signal=FMC_D15_DA15 SH.FMC_A3.0=FMC_A3,12b-sda1 PB8.GPIO_Label=SW2 -Mcu.Pin59=PA13 +Mcu.Pin59=PA12 FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_3 SH.GPXTI2.ConfNb=1 -Mcu.Pin57=PA11 -Mcu.Pin58=PA12 -Mcu.Pin51=PD14 +Mcu.Pin57=PA9 +Mcu.Pin58=PA11 +Mcu.Pin51=PD10 RCC.USART6Freq_Value=108000000 SH.FMC_D15_DA15.0=FMC_D15,sd-16b-d1 -Mcu.Pin52=PD15 +Mcu.Pin52=PD14 Dma.SAI1_B.2.PeriphDataAlignment=DMA_PDATAALIGN_WORD -Mcu.Pin50=PD10 -Mcu.Pin55=PG8 -Mcu.Pin56=PA9 -Mcu.Pin53=PG4 -Mcu.Pin54=PG5 +Mcu.Pin50=PD9 +Mcu.Pin55=PG5 +Mcu.Pin56=PG8 +Mcu.Pin53=PD15 +Mcu.Pin54=PG4 PA9.Signal=USB_OTG_FS_VBUS PB11.GPIOParameters=GPIO_Label +PA4.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING ADC3.NbrOfConversion=4 -Mcu.Pin48=PD8 -Mcu.Pin49=PD9 -Mcu.Pin46=PB10 -Mcu.Pin47=PB11 +Mcu.Pin48=PB11 +Mcu.Pin49=PD8 +Mcu.Pin46=PE15 +Mcu.Pin47=PB10 PB10.Signal=GPIO_Output PA5.Signal=GPXTI5 -Mcu.Pin40=PE10 -Mcu.Pin41=PE11 +Mcu.Pin40=PE9 +Mcu.Pin41=PE10 FREERTOS.MEMORY_ALLOCATION=2 -Mcu.Pin44=PE14 -Mcu.Pin45=PE15 -Mcu.Pin42=PE12 -Mcu.Pin43=PE13 +Mcu.Pin44=PE13 +Mcu.Pin45=PE14 +Mcu.Pin42=PE11 +Mcu.Pin43=PE12 ProjectManager.LastFirmware=true FMC.ReadBurst1=FMC_SDRAM_RBURST_ENABLE SH.FMC_A6.0=FMC_A6,12b-sda1 @@ -242,28 +248,29 @@ FMC.ReadBurst2=FMC_SDRAM_RBURST_ENABLE PE14.Signal=FMC_D11_DA11 PE6.Mode=TX_Only_Simplex_Unidirect_Master PE15.Signal=FMC_D12_DA12 -Mcu.Pin37=PE7 -Mcu.Pin38=PE8 -Mcu.Pin35=PG0 +Mcu.Pin37=PG1 +Mcu.Pin38=PE7 +Mcu.Pin35=PF15 RCC.I2C1Freq_Value=54000000 -Mcu.Pin36=PG1 +Mcu.Pin36=PG0 PE8.Signal=FMC_D5_DA5 RCC.PLLI2SPCLKFreq_Value=96000000 SPI1.Mode=SPI_MODE_MASTER SH.FMC_D14_DA14.ConfNb=1 -Mcu.Pin39=PE9 +Mcu.Pin39=PE8 PC2.GPIOParameters=GPIO_Label -Mcu.Pin30=PF11 +Mcu.Pin30=PB2/BOOT1 RCC.EthernetFreq_Value=168000000 -SH.ADCx_IN12.ConfNb=1 -Mcu.Pin33=PF14 -Mcu.Pin34=PF15 +SH.ADCx_IN12.ConfNb=2 +Mcu.Pin33=PF13 +Mcu.Pin34=PF14 ADC3.SamplingTime-33\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -Mcu.Pin31=PF12 -Mcu.Pin32=PF13 +Mcu.Pin31=PF11 +Mcu.Pin32=PF12 NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false FREERTOS.configUSE_MUTEXES=0 PF13.Signal=FMC_A7 +ADC1.DMAContinuousRequests=DISABLE PA13.Mode=Serial_Wire SH.FMC_SDNCAS.0=FMC_SDNCAS,12b-sda1 ProjectManager.FreePins=true @@ -271,19 +278,20 @@ Dma.ADC3.0.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD PF9.GPIOParameters=GPIO_Label SH.FMC_NBL1.ConfNb=1 RCC.PLLI2SQCLKFreq_Value=96000000 -Mcu.Pin26=PC4 -Mcu.Pin27=PC5 -NVIC.DMA2_Stream4_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true +Mcu.Pin26=PA7 +Mcu.Pin27=PC4 +NVIC.DMA2_Stream4_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true RCC.RTCHSEDivFreq_Value=12500000 -Mcu.Pin24=PA6 +Mcu.Pin24=PA5 ProjectManager.UnderRoot=false -Mcu.Pin25=PA7 -Mcu.Pin28=PB1 -Mcu.Pin29=PB2/BOOT1 +Mcu.Pin25=PA6 +Mcu.Pin28=PC5 +Mcu.Pin29=PB1 SH.FMC_D7_DA7.ConfNb=1 +PA4.Signal=GPXTI4 Mcu.Pin22=PA3 PB5.Signal=FMC_SDCKE1 -Mcu.Pin23=PA5 +Mcu.Pin23=PA4 Mcu.Pin20=PC3 ADC1.master=1 PA3.Locked=true @@ -345,6 +353,7 @@ SH.FMC_A2.ConfNb=1 PC15/OSC32_OUT.GPIO_Label=EXTSPI_nCS ProjectManager.KeepUserCode=true Mcu.UserName=STM32F427ZITx +ADC1.ContinuousConvMode=ENABLE SH.FMC_D14_DA14.0=FMC_D14,sd-16b-d1 Dma.SAI1_A.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode Dma.SAI1_B.2.MemInc=DMA_MINC_ENABLE @@ -357,7 +366,7 @@ PA12.GPIOParameters=GPIO_Label ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-SystemClock_Config-RCC-false-HAL-true,9-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,10-MX_RTC_Init-RTC-false-HAL-true,11-MX_ADC1_Init-ADC1-false-HAL-true PA9.GPIOParameters=GPIO_Label PA11.GPIOParameters=GPIO_Label -NVIC.EXTI3_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true +NVIC.EXTI3_IRQn=true\:5\:0\:false\:false\:true\:false\:true\:true SH.FMC_D6_DA6.0=FMC_D6,sd-16b-d1 PA11.Mode=Device_Only PB2/BOOT1.GPIOParameters=GPIO_Label @@ -380,6 +389,7 @@ Mcu.IP4=FREERTOS Mcu.IP5=NVIC RCC.FCLKCortexFreq_Value=168000000 Mcu.IP2=DMA +NVIC.ADC_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true Mcu.IP3=FMC Mcu.IP0=ADC1 SH.FMC_A7.0=FMC_A7,12b-sda1 @@ -407,7 +417,6 @@ PF12.Signal=FMC_A6 FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 Mcu.Pin6=PF0 Mcu.Pin7=PF1 -NVIC.DMA2_Stream0_IRQn=true\:10\:0\:true\:false\:true\:true\:true\:true Mcu.Pin8=PF2 Mcu.Pin9=PF3 RCC.VCOSAIOutputFreq_Value=100000000 @@ -428,6 +437,7 @@ ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_9 RCC.HSE_VALUE=25000000 NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false SH.FMC_A14_BA0.ConfNb=1 +PA4.GPIO_PuPd=GPIO_PULLUP ADC3.InjNumberOfConversion=0 SH.FMC_D8_DA8.0=FMC_D8,sd-16b-d1 FMC.ExitSelfRefreshDelay1=6 @@ -450,7 +460,7 @@ PB5.Mode=SdramChipSelect2_1 File.Version=6 PE3.GPIOParameters=GPIO_Label ADC3.DataAlign=ADC_DATAALIGN_RIGHT -SH.ADCx_IN13.ConfNb=1 +SH.ADCx_IN13.ConfNb=2 SH.FMC_D5_DA5.ConfNb=1 PB3.GPIOParameters=GPIO_Label Dma.ADC3.0.MemInc=DMA_MINC_ENABLE @@ -494,9 +504,9 @@ SH.FMC_NBL0.ConfNb=1 PD6.Signal=SAI1_SD_A SAI1.Synchro-SAI_A_AsyncSlave=SAI_ASYNCHRONOUS Dma.Request0=ADC3 -PE3.Mode=SAI_B_SyncSlave -PE2.GPIO_Label=CS_SCK PC2.GPIO_Label=ADC2 +PE2.GPIO_Label=CS_SCK +PE3.Mode=SAI_B_SyncSlave PB3.Locked=true PA3.Signal=GPXTI3 PA2.Locked=true @@ -504,6 +514,7 @@ PB3.GPIO_Label=FLASH_SCK SH.FMC_A3.ConfNb=1 VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate ADC3.SamplingTime-31\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +SH.ADCx_IN13.1=ADC1_IN13 RCC.I2SFreq_Value=96000000 SH.GPXTI5.0=GPIO_EXTI5 ADC3.DiscontinuousConvMode=DISABLE @@ -533,6 +544,7 @@ PA12.GPIO_Label=USBD_DP RCC.FamilyName=M PA13.Signal=SYS_JTMS-SWDIO VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 +SH.ADCx_IN12.1=ADC1_IN12 SH.ADCx_IN12.0=ADC3_IN12,IN12 PA9.Mode=Activate_VBUS SH.FMC_A15_BA1.ConfNb=1 @@ -550,6 +562,7 @@ PC2.Locked=true ProjectManager.RegisterCallBack= RCC.USBFreq_Value=48000000 PF9.GPIO_Label=LED_GREEN +NVIC.DMA2_Stream3_IRQn=true\:5\:0\:false\:false\:true\:false\:false\:true RCC.PLLSAIoutputFreq_Value=50000000 PE11.Signal=FMC_D8_DA8 RCC.LSE_VALUE=32768 @@ -566,8 +579,9 @@ PH0/OSC_IN.Signal=RCC_OSC_IN NVIC.SavedSystickIrqHandlerGenerated=true RCC.APB2Freq_Value=84000000 RCC.UART4Freq_Value=54000000 +SH.ADCx_IN11.1=ADC1_IN11 SH.ADCx_IN11.0=ADC3_IN11,IN11 -MxCube.Version=6.0.1 +MxCube.Version=6.1.1 SH.FMC_D13_DA13.ConfNb=1 PF10.Signal=ADC3_IN8 PE5.Mode=SAI_A_AsyncSlave @@ -576,6 +590,7 @@ VP_SYS_VS_Systick.Mode=SysTick SH.FMC_D12_DA12.0=FMC_D12,sd-16b-d1 PF15.Signal=FMC_A9 SPI4.CalculateBaudRate=656.25 KBits/s +PA4.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI Dma.SAI1_B.2.Priority=DMA_PRIORITY_VERY_HIGH PF1.Signal=FMC_A1 VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_FS @@ -583,9 +598,10 @@ VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Mode=AUDIO_FS PE6.Signal=SPI4_MOSI SH.FMC_D11_DA11.ConfNb=1 RCC.UART5Freq_Value=54000000 +ADC1.NbrOfConversion=1 ADC3.Channel-34\#ChannelRegularConversion=ADC_CHANNEL_8 RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CECFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SClocksFreq_Value,I2SFreq_Value,LCDTFToutputFreq_Value,LPTIM1Freq_Value,LSE_VALUE,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLI2SPCLKFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLI2SRoutputFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLQoutputFreq_Value,PLLSAIN,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIRCLKFreq_Value,PLLSAIoutputFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SAI1Freq_Value,SAI2Freq_Value,SAI_AClocksFreq_Value,SAI_BClocksFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,UART4Freq_Value,UART5Freq_Value,UART7Freq_Value,UART8Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USART6Freq_Value,USBFreq_Value,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value,VCOSAIOutputFreq_ValueQ,VcooutputI2S,VcooutputI2SQ -ProjectManager.AskForMigrate=true +ProjectManager.AskForMigrate=false Mcu.Name=STM32F427Z(G-I)Tx PE0.Signal=FMC_NBL0 Dma.SAI1_B.2.Direction=DMA_PERIPH_TO_MEMORY @@ -602,12 +618,14 @@ RCC.48MHZClocksFreq_Value=48000000 PB3.Signal=SPI1_SCK RCC.SYSCLKFreq_VALUE=168000000 PA7.GPIO_Label=FLASH_MOSI +SH.GPXTI4.0=GPIO_EXTI4 PA12.Mode=Device_Only KeepUserPlacement=false PC5.GPIO_Label=FLASH_nCS SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B -NVIC.EXTI9_5_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true +NVIC.EXTI9_5_IRQn=true\:15\:0\:true\:false\:true\:false\:true\:true PA14.Signal=SYS_JTCK-SWCLK +SH.GPXTI4.ConfNb=1 RCC.HSI_VALUE=16000000 PA2.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING Dma.ADC3.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode diff --git a/OwlPedal2/Src/OwlPedal.cpp b/OwlPedal2/Src/OwlPedal.cpp index c964f8aa..4f9d34cc 100644 --- a/OwlPedal2/Src/OwlPedal.cpp +++ b/OwlPedal2/Src/OwlPedal.cpp @@ -1,13 +1,10 @@ -#include -#include -#include "device.h" #include "Owl.h" +#include "device.h" #include "errorhandlers.h" -#include "message.h" -#include "ProgramManager.h" -#include "PatchRegistry.h" +#include "MidiController.h" #include "OpenWareMidiControl.h" +#define PATCH_RESET_COUNTER (1000/MAIN_LOOP_SLEEP_MS) void setLed(uint8_t led, uint32_t rgb){ switch(rgb){ @@ -19,11 +16,11 @@ void setLed(uint8_t led, uint32_t rgb){ HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_RESET); HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_SET); break; - // case YELLOW_COLOUR: - // // not working - // HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_SET); - // HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_SET); - // break; + case YELLOW_COLOUR: + // not working + HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_SET); + HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_SET); + break; case NO_COLOUR: HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_RESET); HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_RESET); @@ -31,10 +28,40 @@ void setLed(uint8_t led, uint32_t rgb){ } } +void onChangePin(uint16_t pin){ + switch(pin){ + case SW1_Pin: { + bool isSet = !(SW1_GPIO_Port->IDR & SW1_Pin); + setLed(0, isSet ? NO_COLOUR : GREEN_COLOUR); + break; + } + case SW2_Pin: { + bool isSet = !(SW2_GPIO_Port->IDR & SW2_Pin); + setButtonValue(PUSHBUTTON, isSet); + midi_tx.sendCc(PUSHBUTTON, isSet ? 127 : 0); + setLed(0, isSet ? RED_COLOUR : GREEN_COLOUR); + break; + } + case SW3_Pin: { + bool isSet = !(SW3_GPIO_Port->IDR & SW3_Pin); + setButtonValue(BUTTON_B, isSet); + break; + } + case SW4_Pin: { + bool isSet = !(SW4_GPIO_Port->IDR & SW4_Pin); + setButtonValue(BUTTON_C, isSet); + break; + } + } +} + void setGateValue(uint8_t ch, int16_t value){ if(ch == PUSHBUTTON){ - HAL_GPIO_TogglePin(LED_RED_GPIO_Port, LED_RED_Pin); - HAL_GPIO_TogglePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin); + HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, value ? GPIO_PIN_RESET : GPIO_PIN_SET); + HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, value ? GPIO_PIN_SET : GPIO_PIN_RESET); +#ifdef OWL_MODULAR + HAL_GPIO_WritePin(PUSH_GATE_OUT_GPIO_Port, PUSH_GATE_OUT_Pin, value ? GPIO_PIN_RESET : GPIO_PIN_SET); +#endif }else if(ch == GREEN_BUTTON){ setLed(0, GREEN_COLOUR); }else if(ch == RED_BUTTON){ @@ -45,10 +72,31 @@ void setGateValue(uint8_t ch, int16_t value){ void setup(){ setLed(0, RED_COLOUR); HAL_GPIO_WritePin(EXP_TIP_GPIO_Port, EXP_TIP_Pin, GPIO_PIN_SET); - owl_setup(); + owl.setup(); setLed(0, GREEN_COLOUR); } -void loop(void){ - owl_loop(); +void loop(){ + static uint32_t counter = PATCH_RESET_COUNTER; + switch(owl.getOperationMode()){ + case STARTUP_MODE: + case LOAD_MODE: + setLed(0, counter > PATCH_RESET_COUNTER/2 ? GREEN_COLOUR : NO_COLOUR); + break; + case RUN_MODE: + if(getErrorStatus() != NO_ERROR) + owl.setOperationMode(ERROR_MODE); + break; + case CONFIGURE_MODE: + owl.setOperationMode(RUN_MODE); + break; + case STREAM_MODE: + case ERROR_MODE: + setLed(0, counter > PATCH_RESET_COUNTER/2 ? RED_COLOUR : NO_COLOUR); + break; + } + if(--counter == 0) + counter = PATCH_RESET_COUNTER; + + owl.loop(); } diff --git a/OwlPedal2/Src/usbd_conf.c b/OwlPedal2/Src/usbd_conf.c index f8a8c35c..15eb9fd3 100644 --- a/OwlPedal2/Src/usbd_conf.c +++ b/OwlPedal2/Src/usbd_conf.c @@ -27,6 +27,7 @@ /* USER CODE BEGIN Includes */ #include "device.h" +uint8_t USBD_AUDIO_SetFiFos(PCD_HandleTypeDef *hpcd); /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -76,15 +77,16 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) __HAL_RCC_GPIOA_CLK_ENABLE(); /**USB_OTG_FS GPIO Configuration PA9 ------> USB_OTG_FS_VBUS + PA10 ------> USB_OTG_FS_ID PA11 ------> USB_OTG_FS_DM PA12 ------> USB_OTG_FS_DP */ - GPIO_InitStruct.Pin = GPIO_PIN_9; + GPIO_InitStruct.Pin = USBD_VBUS_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + HAL_GPIO_Init(USBD_VBUS_GPIO_Port, &GPIO_InitStruct); - GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12; + GPIO_InitStruct.Pin = USBD_ID_Pin|USBD_DM_Pin|USBD_DP_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; @@ -115,10 +117,11 @@ void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) /**USB_OTG_FS GPIO Configuration PA9 ------> USB_OTG_FS_VBUS + PA10 ------> USB_OTG_FS_ID PA11 ------> USB_OTG_FS_DM PA12 ------> USB_OTG_FS_DP */ - HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_12); + HAL_GPIO_DeInit(GPIOA, USBD_VBUS_Pin|USBD_ID_Pin|USBD_DM_Pin|USBD_DP_Pin); /* Peripheral interrupt Deinit*/ HAL_NVIC_DisableIRQ(OTG_FS_IRQn); @@ -366,17 +369,7 @@ USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) HAL_PCD_RegisterIsoOutIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOOUTIncompleteCallback); HAL_PCD_RegisterIsoInIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOINIncompleteCallback); #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ -#ifdef USE_USBD_AUDIO_TX - HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_FS, 0x80); - HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x20); - HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x60); - HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 2, 0x40); -#else - HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_FS, 0xa0); - HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x40); - HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x60); -#endif - /* total 0x140 words available for rx and tx fifos */ + USBD_AUDIO_SetFiFos(&hpcd_USB_OTG_FS); } return USBD_OK; } @@ -462,7 +455,8 @@ USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) { HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - + + USB_DISABLE_EP_BEFORE_CLOSE(ep_addr); hal_status = HAL_PCD_EP_Close(pdev->pData, ep_addr); usb_status = USBD_Get_USB_Status(hal_status); From d4c08db4401a60aff04f3a6c2ac6334979dfd07f Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 12 Mar 2021 01:08:10 +0100 Subject: [PATCH 020/286] cube updates --- OwlPedal2/Inc/main.h | 2 ++ OwlPedal2/Inc/stm32f4xx_it.h | 3 ++- OwlPedal2/Src/OwlPedal.cpp | 35 +++++++++++++------------ OwlPedal2/Src/main.c | 32 +++++++++++------------ OwlPedal2/Src/stm32f4xx_hal_msp.c | 43 +++++++++++++++++++++++++++++-- OwlPedal2/Src/stm32f4xx_it.c | 41 ++++++++++++++++++++--------- 6 files changed, 108 insertions(+), 48 deletions(-) diff --git a/OwlPedal2/Inc/main.h b/OwlPedal2/Inc/main.h index 4f563c0e..bf68f33d 100644 --- a/OwlPedal2/Inc/main.h +++ b/OwlPedal2/Inc/main.h @@ -118,6 +118,8 @@ void Error_Handler(void); #define SW3_Pin GPIO_PIN_3 #define SW3_GPIO_Port GPIOA #define SW3_EXTI_IRQn EXTI3_IRQn +#define BYPASS_Pin GPIO_PIN_4 +#define BYPASS_GPIO_Port GPIOA #define SW1_Pin GPIO_PIN_5 #define SW1_GPIO_Port GPIOA #define SW1_EXTI_IRQn EXTI9_5_IRQn diff --git a/OwlPedal2/Inc/stm32f4xx_it.h b/OwlPedal2/Inc/stm32f4xx_it.h index b3238d74..82c327eb 100644 --- a/OwlPedal2/Inc/stm32f4xx_it.h +++ b/OwlPedal2/Inc/stm32f4xx_it.h @@ -65,9 +65,10 @@ void SysTick_Handler(void); void EXTI2_IRQHandler(void); void EXTI3_IRQHandler(void); +void ADC_IRQHandler(void); void EXTI9_5_IRQHandler(void); -void DMA2_Stream0_IRQHandler(void); void DMA2_Stream1_IRQHandler(void); +void DMA2_Stream3_IRQHandler(void); void DMA2_Stream4_IRQHandler(void); void OTG_FS_IRQHandler(void); void SAI1_IRQHandler(void); diff --git a/OwlPedal2/Src/OwlPedal.cpp b/OwlPedal2/Src/OwlPedal.cpp index 4f9d34cc..d21eb647 100644 --- a/OwlPedal2/Src/OwlPedal.cpp +++ b/OwlPedal2/Src/OwlPedal.cpp @@ -16,11 +16,6 @@ void setLed(uint8_t led, uint32_t rgb){ HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_RESET); HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_SET); break; - case YELLOW_COLOUR: - // not working - HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_SET); - HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_SET); - break; case NO_COLOUR: HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_RESET); HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_RESET); @@ -30,26 +25,32 @@ void setLed(uint8_t led, uint32_t rgb){ void onChangePin(uint16_t pin){ switch(pin){ - case SW1_Pin: { - bool isSet = !(SW1_GPIO_Port->IDR & SW1_Pin); - setLed(0, isSet ? NO_COLOUR : GREEN_COLOUR); + case BYPASS_Pin: { + bool state = HAL_GPIO_ReadPin(BYPASS_GPIO_Port, BYPASS_Pin) == GPIO_PIN_RESET; + setLed(0, state ? NO_COLOUR : GREEN_COLOUR); + break; + } + case SW1_Pin: { // pushbutton + bool state = HAL_GPIO_ReadPin(SW1_GPIO_Port, SW1_Pin) == GPIO_PIN_RESET; + setButtonValue(PUSHBUTTON, state); + setButtonValue(BUTTON_A, state); + midi_tx.sendCc(PUSHBUTTON, state ? 127 : 0); + setLed(0, state ? RED_COLOUR : GREEN_COLOUR); break; } - case SW2_Pin: { - bool isSet = !(SW2_GPIO_Port->IDR & SW2_Pin); - setButtonValue(PUSHBUTTON, isSet); - midi_tx.sendCc(PUSHBUTTON, isSet ? 127 : 0); - setLed(0, isSet ? RED_COLOUR : GREEN_COLOUR); + case SW2_Pin: { // mode button + bool state = HAL_GPIO_ReadPin(SW2_GPIO_Port, SW2_Pin) == GPIO_PIN_RESET; + setButtonValue(BUTTON_B, state); break; } case SW3_Pin: { - bool isSet = !(SW3_GPIO_Port->IDR & SW3_Pin); - setButtonValue(BUTTON_B, isSet); + bool state = HAL_GPIO_ReadPin(SW3_GPIO_Port, SW3_Pin) == GPIO_PIN_RESET; + setButtonValue(BUTTON_C, state); break; } case SW4_Pin: { - bool isSet = !(SW4_GPIO_Port->IDR & SW4_Pin); - setButtonValue(BUTTON_C, isSet); + bool state = HAL_GPIO_ReadPin(SW4_GPIO_Port, SW4_Pin) == GPIO_PIN_RESET; + setButtonValue(BUTTON_D, state); break; } } diff --git a/OwlPedal2/Src/main.c b/OwlPedal2/Src/main.c index 60cae68e..433f9b37 100644 --- a/OwlPedal2/Src/main.c +++ b/OwlPedal2/Src/main.c @@ -318,15 +318,15 @@ static void MX_ADC1_Init(void) hadc1.Instance = ADC1; hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV8; hadc1.Init.Resolution = ADC_RESOLUTION_12B; - hadc1.Init.ScanConvMode = DISABLE; - hadc1.Init.ContinuousConvMode = DISABLE; + hadc1.Init.ScanConvMode = ENABLE; + hadc1.Init.ContinuousConvMode = ENABLE; hadc1.Init.DiscontinuousConvMode = DISABLE; hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START; hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT; hadc1.Init.NbrOfConversion = 1; hadc1.Init.DMAContinuousRequests = DISABLE; - hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV; + hadc1.Init.EOCSelection = ADC_EOC_SEQ_CONV; if (HAL_ADC_Init(&hadc1) != HAL_OK) { Error_Handler(); @@ -335,7 +335,7 @@ static void MX_ADC1_Init(void) */ sConfig.Channel = ADC_CHANNEL_9; sConfig.Rank = 1; - sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES; + sConfig.SamplingTime = ADC_SAMPLETIME_144CYCLES; if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) { Error_Handler(); @@ -605,12 +605,12 @@ static void MX_DMA_Init(void) __HAL_RCC_DMA2_CLK_ENABLE(); /* DMA interrupt init */ - /* DMA2_Stream0_IRQn interrupt configuration */ - HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 10, 0); - HAL_NVIC_EnableIRQ(DMA2_Stream0_IRQn); /* DMA2_Stream1_IRQn interrupt configuration */ - HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 5, 0); + HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 10, 0); HAL_NVIC_EnableIRQ(DMA2_Stream1_IRQn); + /* DMA2_Stream3_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA2_Stream3_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA2_Stream3_IRQn); /* DMA2_Stream4_IRQn interrupt configuration */ HAL_NVIC_SetPriority(DMA2_Stream4_IRQn, 5, 0); HAL_NVIC_EnableIRQ(DMA2_Stream4_IRQn); @@ -722,16 +722,16 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); - /*Configure GPIO pins : PA0 PA1 PA4 PA8 - PA10 PA15 */ - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_8 - |GPIO_PIN_10|GPIO_PIN_15; + /*Configure GPIO pins : PA0 PA1 PA8 PA10 + PA15 */ + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_8|GPIO_PIN_10 + |GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - /*Configure GPIO pins : SW4_Pin SW3_Pin SW1_Pin */ - GPIO_InitStruct.Pin = SW4_Pin|SW3_Pin|SW1_Pin; + /*Configure GPIO pins : SW4_Pin SW3_Pin BYPASS_Pin SW1_Pin */ + GPIO_InitStruct.Pin = SW4_Pin|SW3_Pin|BYPASS_Pin|SW1_Pin; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); @@ -776,10 +776,10 @@ static void MX_GPIO_Init(void) HAL_GPIO_Init(SW2_GPIO_Port, &GPIO_InitStruct); /* EXTI interrupt init*/ - HAL_NVIC_SetPriority(EXTI2_IRQn, 0, 0); + HAL_NVIC_SetPriority(EXTI2_IRQn, 5, 0); HAL_NVIC_EnableIRQ(EXTI2_IRQn); - HAL_NVIC_SetPriority(EXTI3_IRQn, 0, 0); + HAL_NVIC_SetPriority(EXTI3_IRQn, 5, 0); HAL_NVIC_EnableIRQ(EXTI3_IRQn); HAL_NVIC_SetPriority(EXTI9_5_IRQn, 15, 0); diff --git a/OwlPedal2/Src/stm32f4xx_hal_msp.c b/OwlPedal2/Src/stm32f4xx_hal_msp.c index b40e6d1d..3fca90a5 100644 --- a/OwlPedal2/Src/stm32f4xx_hal_msp.c +++ b/OwlPedal2/Src/stm32f4xx_hal_msp.c @@ -127,15 +127,27 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) /* Peripheral clock enable */ __HAL_RCC_ADC1_CLK_ENABLE(); + __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); /**ADC1 GPIO Configuration + PC1 ------> ADC1_IN11 + PC2 ------> ADC1_IN12 + PC3 ------> ADC1_IN13 PB1 ------> ADC1_IN9 */ + GPIO_InitStruct.Pin = ADC3_Pin|ADC2_Pin|ADC1_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + GPIO_InitStruct.Pin = EXP_RING_Pin; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(EXP_RING_GPIO_Port, &GPIO_InitStruct); + /* ADC1 interrupt Init */ + HAL_NVIC_SetPriority(ADC_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(ADC_IRQn); /* USER CODE BEGIN ADC1_MspInit 1 */ /* USER CODE END ADC1_MspInit 1 */ @@ -168,7 +180,7 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) /* ADC3 DMA Init */ /* ADC3 Init */ - hdma_adc3.Instance = DMA2_Stream0; + hdma_adc3.Instance = DMA2_Stream1; hdma_adc3.Init.Channel = DMA_CHANNEL_2; hdma_adc3.Init.Direction = DMA_PERIPH_TO_MEMORY; hdma_adc3.Init.PeriphInc = DMA_PINC_DISABLE; @@ -185,6 +197,9 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) __HAL_LINKDMA(hadc,DMA_Handle,hdma_adc3); + /* ADC3 interrupt Init */ + HAL_NVIC_SetPriority(ADC_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(ADC_IRQn); /* USER CODE BEGIN ADC3_MspInit 1 */ /* USER CODE END ADC3_MspInit 1 */ @@ -209,10 +224,24 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) __HAL_RCC_ADC1_CLK_DISABLE(); /**ADC1 GPIO Configuration + PC1 ------> ADC1_IN11 + PC2 ------> ADC1_IN12 + PC3 ------> ADC1_IN13 PB1 ------> ADC1_IN9 */ + HAL_GPIO_DeInit(GPIOC, ADC3_Pin|ADC2_Pin|ADC1_Pin); + HAL_GPIO_DeInit(EXP_RING_GPIO_Port, EXP_RING_Pin); + /* ADC1 interrupt DeInit */ + /* USER CODE BEGIN ADC1:ADC_IRQn disable */ + /** + * Uncomment the line below to disable the "ADC_IRQn" interrupt + * Be aware, disabling shared interrupt may affect other IPs + */ + /* HAL_NVIC_DisableIRQ(ADC_IRQn); */ + /* USER CODE END ADC1:ADC_IRQn disable */ + /* USER CODE BEGIN ADC1_MspDeInit 1 */ /* USER CODE END ADC1_MspDeInit 1 */ @@ -237,6 +266,16 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) /* ADC3 DMA DeInit */ HAL_DMA_DeInit(hadc->DMA_Handle); + + /* ADC3 interrupt DeInit */ + /* USER CODE BEGIN ADC3:ADC_IRQn disable */ + /** + * Uncomment the line below to disable the "ADC_IRQn" interrupt + * Be aware, disabling shared interrupt may affect other IPs + */ + /* HAL_NVIC_DisableIRQ(ADC_IRQn); */ + /* USER CODE END ADC3:ADC_IRQn disable */ + /* USER CODE BEGIN ADC3_MspDeInit 1 */ /* USER CODE END ADC3_MspDeInit 1 */ @@ -656,7 +695,7 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) /* Peripheral DMA init*/ - hdma_sai1_a.Instance = DMA2_Stream1; + hdma_sai1_a.Instance = DMA2_Stream3; hdma_sai1_a.Init.Channel = DMA_CHANNEL_0; hdma_sai1_a.Init.Direction = DMA_MEMORY_TO_PERIPH; hdma_sai1_a.Init.PeriphInc = DMA_PINC_DISABLE; diff --git a/OwlPedal2/Src/stm32f4xx_it.c b/OwlPedal2/Src/stm32f4xx_it.c index 6a5b84c3..cef751f7 100644 --- a/OwlPedal2/Src/stm32f4xx_it.c +++ b/OwlPedal2/Src/stm32f4xx_it.c @@ -75,6 +75,8 @@ /* External variables --------------------------------------------------------*/ extern PCD_HandleTypeDef hpcd_USB_OTG_FS; extern DMA_HandleTypeDef hdma_adc3; +extern ADC_HandleTypeDef hadc1; +extern ADC_HandleTypeDef hadc3; extern DMA_HandleTypeDef hdma_sai1_a; extern DMA_HandleTypeDef hdma_sai1_b; extern SAI_HandleTypeDef hsai_BlockA1; @@ -143,6 +145,21 @@ void EXTI3_IRQHandler(void) /* USER CODE END EXTI3_IRQn 1 */ } +/** + * @brief This function handles ADC1, ADC2 and ADC3 global interrupts. + */ +void ADC_IRQHandler(void) +{ + /* USER CODE BEGIN ADC_IRQn 0 */ + + /* USER CODE END ADC_IRQn 0 */ + HAL_ADC_IRQHandler(&hadc1); + HAL_ADC_IRQHandler(&hadc3); + /* USER CODE BEGIN ADC_IRQn 1 */ + + /* USER CODE END ADC_IRQn 1 */ +} + /** * @brief This function handles EXTI line[9:5] interrupts. */ @@ -159,31 +176,31 @@ void EXTI9_5_IRQHandler(void) } /** - * @brief This function handles DMA2 stream0 global interrupt. + * @brief This function handles DMA2 stream1 global interrupt. */ -void DMA2_Stream0_IRQHandler(void) +void DMA2_Stream1_IRQHandler(void) { - /* USER CODE BEGIN DMA2_Stream0_IRQn 0 */ + /* USER CODE BEGIN DMA2_Stream1_IRQn 0 */ - /* USER CODE END DMA2_Stream0_IRQn 0 */ + /* USER CODE END DMA2_Stream1_IRQn 0 */ HAL_DMA_IRQHandler(&hdma_adc3); - /* USER CODE BEGIN DMA2_Stream0_IRQn 1 */ + /* USER CODE BEGIN DMA2_Stream1_IRQn 1 */ - /* USER CODE END DMA2_Stream0_IRQn 1 */ + /* USER CODE END DMA2_Stream1_IRQn 1 */ } /** - * @brief This function handles DMA2 stream1 global interrupt. + * @brief This function handles DMA2 stream3 global interrupt. */ -void DMA2_Stream1_IRQHandler(void) +void DMA2_Stream3_IRQHandler(void) { - /* USER CODE BEGIN DMA2_Stream1_IRQn 0 */ + /* USER CODE BEGIN DMA2_Stream3_IRQn 0 */ - /* USER CODE END DMA2_Stream1_IRQn 0 */ + /* USER CODE END DMA2_Stream3_IRQn 0 */ HAL_DMA_IRQHandler(&hdma_sai1_a); - /* USER CODE BEGIN DMA2_Stream1_IRQn 1 */ + /* USER CODE BEGIN DMA2_Stream3_IRQn 1 */ - /* USER CODE END DMA2_Stream1_IRQn 1 */ + /* USER CODE END DMA2_Stream3_IRQn 1 */ } /** From e0617941812d0c3334fdf1adc8e2cfce9b5a56e1 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 12 Mar 2021 01:08:56 +0100 Subject: [PATCH 021/286] enabled bypass exti --- OwlPedal2/Inc/main.h | 1 + OwlPedal2/Inc/stm32f4xx_it.h | 1 + OwlPedal2/OwlPedal2.ioc | 1 + OwlPedal2/Src/main.c | 3 +++ OwlPedal2/Src/stm32f4xx_it.c | 14 ++++++++++++++ 5 files changed, 20 insertions(+) diff --git a/OwlPedal2/Inc/main.h b/OwlPedal2/Inc/main.h index bf68f33d..28b54c67 100644 --- a/OwlPedal2/Inc/main.h +++ b/OwlPedal2/Inc/main.h @@ -120,6 +120,7 @@ void Error_Handler(void); #define SW3_EXTI_IRQn EXTI3_IRQn #define BYPASS_Pin GPIO_PIN_4 #define BYPASS_GPIO_Port GPIOA +#define BYPASS_EXTI_IRQn EXTI4_IRQn #define SW1_Pin GPIO_PIN_5 #define SW1_GPIO_Port GPIOA #define SW1_EXTI_IRQn EXTI9_5_IRQn diff --git a/OwlPedal2/Inc/stm32f4xx_it.h b/OwlPedal2/Inc/stm32f4xx_it.h index 82c327eb..692f4f74 100644 --- a/OwlPedal2/Inc/stm32f4xx_it.h +++ b/OwlPedal2/Inc/stm32f4xx_it.h @@ -65,6 +65,7 @@ void SysTick_Handler(void); void EXTI2_IRQHandler(void); void EXTI3_IRQHandler(void); +void EXTI4_IRQHandler(void); void ADC_IRQHandler(void); void EXTI9_5_IRQHandler(void); void DMA2_Stream1_IRQHandler(void); diff --git a/OwlPedal2/OwlPedal2.ioc b/OwlPedal2/OwlPedal2.ioc index 62ac4e5d..e7a4a723 100644 --- a/OwlPedal2/OwlPedal2.ioc +++ b/OwlPedal2/OwlPedal2.ioc @@ -157,6 +157,7 @@ SH.FMC_D3_DA3.ConfNb=1 PA6.GPIOParameters=GPIO_Label USB_DEVICE.VID-AUDIO_FS=0x1209 PD6.GPIOParameters=GPIO_Label +NVIC.EXTI4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true SH.FMC_A4.0=FMC_A4,12b-sda1 SH.FMC_A7.ConfNb=1 RCC.PLLQoutputFreq_Value=48000000 diff --git a/OwlPedal2/Src/main.c b/OwlPedal2/Src/main.c index 433f9b37..74657ab7 100644 --- a/OwlPedal2/Src/main.c +++ b/OwlPedal2/Src/main.c @@ -782,6 +782,9 @@ static void MX_GPIO_Init(void) HAL_NVIC_SetPriority(EXTI3_IRQn, 5, 0); HAL_NVIC_EnableIRQ(EXTI3_IRQn); + HAL_NVIC_SetPriority(EXTI4_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(EXTI4_IRQn); + HAL_NVIC_SetPriority(EXTI9_5_IRQn, 15, 0); HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); diff --git a/OwlPedal2/Src/stm32f4xx_it.c b/OwlPedal2/Src/stm32f4xx_it.c index cef751f7..cebc1da6 100644 --- a/OwlPedal2/Src/stm32f4xx_it.c +++ b/OwlPedal2/Src/stm32f4xx_it.c @@ -145,6 +145,20 @@ void EXTI3_IRQHandler(void) /* USER CODE END EXTI3_IRQn 1 */ } +/** + * @brief This function handles EXTI line4 interrupt. + */ +void EXTI4_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI4_IRQn 0 */ + + /* USER CODE END EXTI4_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_4); + /* USER CODE BEGIN EXTI4_IRQn 1 */ + + /* USER CODE END EXTI4_IRQn 1 */ +} + /** * @brief This function handles ADC1, ADC2 and ADC3 global interrupts. */ From f68d117592552c794d76da8b8efe3e868cc1d8c9 Mon Sep 17 00:00:00 2001 From: antisvin Date: Sun, 23 May 2021 13:50:35 +0300 Subject: [PATCH 022/286] Damned tabs as usual everywher --- Source/MagusParameterController.hpp | 71 +++++++++++++++-------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/Source/MagusParameterController.hpp b/Source/MagusParameterController.hpp index 8bfa767c..b2be8229 100644 --- a/Source/MagusParameterController.hpp +++ b/Source/MagusParameterController.hpp @@ -768,29 +768,32 @@ class ParameterController { default: break; } - }else{ + } + else{ if(controlMode == EXIT){ - displayMode = STANDARD; - sensitivitySelected = false; - if(saveSettings) - settings.saveToFlash(); - }else{ - int16_t delta = value - encoders[1]; - if(delta > 0 && controlMode+1 < NOF_CONTROL_MODES){ - setControlMode(controlMode+1); - }else if(delta < 0 && controlMode > 0){ - setControlMode(controlMode-1); - } - if (controlMode == CALIBRATE) { - if (continueCalibration) - updateCalibration(); - else - calibrationConfirm = false; - } - else if (controlMode == DATA && resourceDeletePressed) { - resourceDeletePressed = false; - } - encoders[1] = value; + displayMode = STANDARD; + sensitivitySelected = false; + if(saveSettings) + settings.saveToFlash(); + } + else{ + int16_t delta = value - encoders[1]; + if(delta > 0 && controlMode+1 < NOF_CONTROL_MODES){ + setControlMode(controlMode+1); + } + else if(delta < 0 && controlMode > 0){ + setControlMode(controlMode-1); + } + if (controlMode == CALIBRATE) { + if (continueCalibration) + updateCalibration(); + else + calibrationConfirm = false; + } + else if (controlMode == DATA && resourceDeletePressed) { + resourceDeletePressed = false; + } + encoders[1] = value; } } } @@ -996,18 +999,18 @@ class ParameterController { if(delta > 0) selectBlockParameter(i, selectedPid[i]+1); } - else{ - if(encoders[i] != value){ - selectedBlock = i; - encoders[i] = value; - // We must update encoder value before calculating user value, otherwise - // previous value would be displayed - user[selectedPid[i]] = getEncoderValue(i); - } - if(displayMode == SELECTBLOCKPARAMETER && selectedBlock == i) - displayMode = STANDARD; - } - encoders[i] = value; + else{ + if(encoders[i] != value){ + selectedBlock = i; + encoders[i] = value; + // We must update encoder value before calculating user value, otherwise + // previous value would be displayed + user[selectedPid[i]] = getEncoderValue(i); + } + if(displayMode == SELECTBLOCKPARAMETER && selectedBlock == i) + displayMode = STANDARD; + } + encoders[i] = value; } if(displayMode == STANDARD && getErrorStatus() && getErrorMessage() != NULL) displayMode = ERROR; From a2cf0aa454f2085169d5003aa37c61f0f062ba0c Mon Sep 17 00:00:00 2001 From: antisvin Date: Sun, 23 May 2021 14:27:00 +0300 Subject: [PATCH 023/286] Scroll parameters with right encoder --- Source/MagusParameterController.hpp | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/Source/MagusParameterController.hpp b/Source/MagusParameterController.hpp index b2be8229..82401f28 100644 --- a/Source/MagusParameterController.hpp +++ b/Source/MagusParameterController.hpp @@ -772,6 +772,7 @@ class ParameterController { else{ if(controlMode == EXIT){ displayMode = STANDARD; + //selectedBlock = 0; sensitivitySelected = false; if(saveSettings) settings.saveToFlash(); @@ -928,6 +929,7 @@ class ParameterController { // update encoder 1 top right int16_t value = data[2]; + int16_t right_enc = encoders[1]; // Save old value for encoder scrolling in main menu if(displayMode == CONTROL){ selectControlMode(value, pressed&0x3); // action if either left or right encoder pushed if(pressed&0x3c) // exit status mode if any other encoder is pressed @@ -962,23 +964,38 @@ class ParameterController { displayMode = SELECTGLOBALPARAMETER; int16_t delta = value - encoders[0]; if(delta < 0) { - selectGlobalParameter(selectedPid[0]-1); - } + selectGlobalParameter(selectedPid[selectedBlock] - 1); + selectedBlock = 0; + } else { if(delta > 0) { - selectGlobalParameter(selectedPid[0]+1); + selectGlobalParameter(selectedPid[selectedBlock] + 1); + selectedBlock = 0; } - selectedBlock = 0; } } else{ + if (displayMode == STANDARD) { + // Quick selection of global parameter by right encoder - without popover menu + int16_t delta = data[2] - right_enc; + encoders[1] = data[2]; + if(delta < 0) { + selectGlobalParameter(selectedPid[selectedBlock] - 1); + selectedBlock = 0; + } + else + if(delta > 0) { + selectGlobalParameter(selectedPid[selectedBlock] + 1); + selectedBlock = 0; + } + } if(encoders[0] != value){ - selectedBlock = 0; encoders[0] = value; // We must update encoder value before calculating user value, otherwise // previous value would be displayed user[selectedPid[0]] = getEncoderValue(0); } + if(displayMode == SELECTGLOBALPARAMETER) displayMode = STANDARD; } From 5880d772c9e7f5762d7e5ae014afa8579b04006d Mon Sep 17 00:00:00 2001 From: antisvin Date: Sun, 23 May 2021 15:30:27 +0300 Subject: [PATCH 024/286] Pick up value from selected block when entering menu --- Source/MagusParameterController.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/MagusParameterController.hpp b/Source/MagusParameterController.hpp index 82401f28..028233b5 100644 --- a/Source/MagusParameterController.hpp +++ b/Source/MagusParameterController.hpp @@ -963,14 +963,14 @@ class ParameterController { // TODO: add 'special' parameters: Volume, Freq, Gain, Gate displayMode = SELECTGLOBALPARAMETER; int16_t delta = value - encoders[0]; + selectedPid[0] = selectedPid[selectedBlock]; + selectedBlock = 0; if(delta < 0) { selectGlobalParameter(selectedPid[selectedBlock] - 1); - selectedBlock = 0; } else { if(delta > 0) { selectGlobalParameter(selectedPid[selectedBlock] + 1); - selectedBlock = 0; } } } From df1f71bd94e9a33d00eeec5fe9fbe544ac30f633 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 15 Jun 2021 11:04:39 +0200 Subject: [PATCH 025/286] updated to storage version, added startup --- Magus3/Src/Magus.cpp | 18 +- Magus3/Src/startup_stm32h743xx.s | 749 +++++++++++++++++++++++++++++++ 2 files changed, 757 insertions(+), 10 deletions(-) create mode 100644 Magus3/Src/startup_stm32h743xx.s diff --git a/Magus3/Src/Magus.cpp b/Magus3/Src/Magus.cpp index 3e9b73cd..e3aac9c2 100644 --- a/Magus3/Src/Magus.cpp +++ b/Magus3/Src/Magus.cpp @@ -48,20 +48,18 @@ void onResourceUpdate(void){ extern const uint32_t rainbowoutputs[]; extern const uint32_t* dyn_rainbowinputs; extern const uint32_t* dyn_rainbowoutputs; - ResourceHeader* res = registry.getResource("Rainbow.in"); - if (res == NULL){ + Resource* res = storage.getResourceByName("Rainbow.in"); + if(res && res->isMemoryMapped()){ + dyn_rainbowinputs = (uint32_t*)res->getData(); + }else{ dyn_rainbowinputs = rainbowinputs; } - else { - dyn_rainbowinputs = (uint32_t*)registry.getData(res); - } - res = registry.getResource("Rainbow.out"); - if (res == NULL){ + res = storage.getResourceByName("Rainbow.out"); + if(res && res->isMemoryMapped()){ + dyn_rainbowoutputs = (uint32_t*)res->getData(); + }else{ dyn_rainbowoutputs = rainbowoutputs; } - else { - dyn_rainbowoutputs = (uint32_t*)registry.getData(res); - } } void setup(){ diff --git a/Magus3/Src/startup_stm32h743xx.s b/Magus3/Src/startup_stm32h743xx.s new file mode 100644 index 00000000..2b1034a6 --- /dev/null +++ b/Magus3/Src/startup_stm32h743xx.s @@ -0,0 +1,749 @@ +/** + ****************************************************************************** + * @file startup_stm32h743xx.s + * @author MCD Application Team + * @brief STM32H743xx Devices vector table for GCC based toolchain. + * This module performs: + * - Set the initial SP + * - Set the initial PC == Reset_Handler, + * - Set the vector table entries with the exceptions ISR address + * - Branches to main in the C library (which eventually + * calls main()). + * After Reset the Cortex-M processor is in Thread mode, + * priority is Privileged, and the Stack is set to Main. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + + .syntax unified + .cpu cortex-m7 + .fpu softvfp + .thumb + +.global g_pfnVectors +.global Default_Handler + +/* start address for the initialization values of the .data section. +defined in linker script */ +.word _sidata +/* start address for the .data section. defined in linker script */ +.word _sdata +/* end address for the .data section. defined in linker script */ +.word _edata +/* start address for the .bss section. defined in linker script */ +.word _sbss +/* end address for the .bss section. defined in linker script */ +.word _ebss +/* stack used for SystemInit_ExtMemCtl; always internal RAM used */ + +/** + * @brief This is the code that gets called when the processor first + * starts execution following a reset event. Only the absolutely + * necessary set is performed, after which the application + * supplied main() routine is called. + * @param None + * @retval : None +*/ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + ldr sp, =_estack /* set stack pointer */ + +/* Call the clock system intitialization function.*/ + bl SystemInit + +/* Copy the data segment initializers from flash to SRAM */ + movs r1, #0 + b LoopCopyDataInit + +CopyDataInit: + ldr r3, =_sidata + ldr r3, [r3, r1] + str r3, [r0, r1] + adds r1, r1, #4 + +LoopCopyDataInit: + ldr r0, =_sdata + ldr r3, =_edata + adds r2, r0, r1 + cmp r2, r3 + bcc CopyDataInit + ldr r2, =_sbss + b LoopFillZerobss +/* Zero fill the bss segment. */ +FillZerobss: + movs r3, #0 + str r3, [r2], #4 + +LoopFillZerobss: + ldr r3, = _ebss + cmp r2, r3 + bcc FillZerobss + +/* Call static constructors */ + bl __libc_init_array +/* Call the application's entry point.*/ + bl main + bx lr +.size Reset_Handler, .-Reset_Handler + +/** + * @brief This is the code that gets called when the processor receives an + * unexpected interrupt. This simply enters an infinite loop, preserving + * the system state for examination by a debugger. + * @param None + * @retval None +*/ + .section .text.Default_Handler,"ax",%progbits +Default_Handler: +Infinite_Loop: + b Infinite_Loop + .size Default_Handler, .-Default_Handler +/****************************************************************************** +* +* The minimal vector table for a Cortex M. Note that the proper constructs +* must be placed on this to ensure that it ends up at physical address +* 0x0000.0000. +* +*******************************************************************************/ + .section .isr_vector,"a",%progbits + .type g_pfnVectors, %object + .size g_pfnVectors, .-g_pfnVectors + + +g_pfnVectors: + .word _estack + .word Reset_Handler + + .word NMI_Handler + .word HardFault_Handler + .word MemManage_Handler + .word BusFault_Handler + .word UsageFault_Handler + .word 0 + .word 0 + .word 0 + .word 0 + .word SVC_Handler + .word DebugMon_Handler + .word 0 + .word PendSV_Handler + .word SysTick_Handler + + /* External Interrupts */ + .word WWDG_IRQHandler /* Window WatchDog */ + .word PVD_AVD_IRQHandler /* PVD/AVD through EXTI Line detection */ + .word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */ + .word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */ + .word FLASH_IRQHandler /* FLASH */ + .word RCC_IRQHandler /* RCC */ + .word EXTI0_IRQHandler /* EXTI Line0 */ + .word EXTI1_IRQHandler /* EXTI Line1 */ + .word EXTI2_IRQHandler /* EXTI Line2 */ + .word EXTI3_IRQHandler /* EXTI Line3 */ + .word EXTI4_IRQHandler /* EXTI Line4 */ + .word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */ + .word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */ + .word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */ + .word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */ + .word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */ + .word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */ + .word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */ + .word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */ + .word FDCAN1_IT0_IRQHandler /* FDCAN1 interrupt line 0 */ + .word FDCAN2_IT0_IRQHandler /* FDCAN2 interrupt line 0 */ + .word FDCAN1_IT1_IRQHandler /* FDCAN1 interrupt line 1 */ + .word FDCAN2_IT1_IRQHandler /* FDCAN2 interrupt line 1 */ + .word EXTI9_5_IRQHandler /* External Line[9:5]s */ + .word TIM1_BRK_IRQHandler /* TIM1 Break interrupt */ + .word TIM1_UP_IRQHandler /* TIM1 Update interrupt */ + .word TIM1_TRG_COM_IRQHandler /* TIM1 Trigger and Commutation interrupt */ + .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */ + .word TIM2_IRQHandler /* TIM2 */ + .word TIM3_IRQHandler /* TIM3 */ + .word TIM4_IRQHandler /* TIM4 */ + .word I2C1_EV_IRQHandler /* I2C1 Event */ + .word I2C1_ER_IRQHandler /* I2C1 Error */ + .word I2C2_EV_IRQHandler /* I2C2 Event */ + .word I2C2_ER_IRQHandler /* I2C2 Error */ + .word SPI1_IRQHandler /* SPI1 */ + .word SPI2_IRQHandler /* SPI2 */ + .word USART1_IRQHandler /* USART1 */ + .word USART2_IRQHandler /* USART2 */ + .word USART3_IRQHandler /* USART3 */ + .word EXTI15_10_IRQHandler /* External Line[15:10]s */ + .word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */ + .word 0 /* Reserved */ + .word TIM8_BRK_TIM12_IRQHandler /* TIM8 Break and TIM12 */ + .word TIM8_UP_TIM13_IRQHandler /* TIM8 Update and TIM13 */ + .word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */ + .word TIM8_CC_IRQHandler /* TIM8 Capture Compare */ + .word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */ + .word FMC_IRQHandler /* FMC */ + .word SDMMC1_IRQHandler /* SDMMC1 */ + .word TIM5_IRQHandler /* TIM5 */ + .word SPI3_IRQHandler /* SPI3 */ + .word UART4_IRQHandler /* UART4 */ + .word UART5_IRQHandler /* UART5 */ + .word TIM6_DAC_IRQHandler /* TIM6 and DAC1&2 underrun errors */ + .word TIM7_IRQHandler /* TIM7 */ + .word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */ + .word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */ + .word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */ + .word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */ + .word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */ + .word ETH_IRQHandler /* Ethernet */ + .word ETH_WKUP_IRQHandler /* Ethernet Wakeup through EXTI line */ + .word FDCAN_CAL_IRQHandler /* FDCAN calibration unit interrupt*/ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */ + .word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */ + .word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */ + .word USART6_IRQHandler /* USART6 */ + .word I2C3_EV_IRQHandler /* I2C3 event */ + .word I2C3_ER_IRQHandler /* I2C3 error */ + .word OTG_HS_EP1_OUT_IRQHandler /* USB OTG HS End Point 1 Out */ + .word OTG_HS_EP1_IN_IRQHandler /* USB OTG HS End Point 1 In */ + .word OTG_HS_WKUP_IRQHandler /* USB OTG HS Wakeup through EXTI */ + .word OTG_HS_IRQHandler /* USB OTG HS */ + .word DCMI_IRQHandler /* DCMI */ + .word 0 /* Reserved */ + .word RNG_IRQHandler /* Rng */ + .word FPU_IRQHandler /* FPU */ + .word UART7_IRQHandler /* UART7 */ + .word UART8_IRQHandler /* UART8 */ + .word SPI4_IRQHandler /* SPI4 */ + .word SPI5_IRQHandler /* SPI5 */ + .word SPI6_IRQHandler /* SPI6 */ + .word SAI1_IRQHandler /* SAI1 */ + .word LTDC_IRQHandler /* LTDC */ + .word LTDC_ER_IRQHandler /* LTDC error */ + .word DMA2D_IRQHandler /* DMA2D */ + .word SAI2_IRQHandler /* SAI2 */ + .word QUADSPI_IRQHandler /* QUADSPI */ + .word LPTIM1_IRQHandler /* LPTIM1 */ + .word CEC_IRQHandler /* HDMI_CEC */ + .word I2C4_EV_IRQHandler /* I2C4 Event */ + .word I2C4_ER_IRQHandler /* I2C4 Error */ + .word SPDIF_RX_IRQHandler /* SPDIF_RX */ + .word OTG_FS_EP1_OUT_IRQHandler /* USB OTG FS End Point 1 Out */ + .word OTG_FS_EP1_IN_IRQHandler /* USB OTG FS End Point 1 In */ + .word OTG_FS_WKUP_IRQHandler /* USB OTG FS Wakeup through EXTI */ + .word OTG_FS_IRQHandler /* USB OTG FS */ + .word DMAMUX1_OVR_IRQHandler /* DMAMUX1 Overrun interrupt */ + .word HRTIM1_Master_IRQHandler /* HRTIM Master Timer global Interrupt */ + .word HRTIM1_TIMA_IRQHandler /* HRTIM Timer A global Interrupt */ + .word HRTIM1_TIMB_IRQHandler /* HRTIM Timer B global Interrupt */ + .word HRTIM1_TIMC_IRQHandler /* HRTIM Timer C global Interrupt */ + .word HRTIM1_TIMD_IRQHandler /* HRTIM Timer D global Interrupt */ + .word HRTIM1_TIME_IRQHandler /* HRTIM Timer E global Interrupt */ + .word HRTIM1_FLT_IRQHandler /* HRTIM Fault global Interrupt */ + .word DFSDM1_FLT0_IRQHandler /* DFSDM Filter0 Interrupt */ + .word DFSDM1_FLT1_IRQHandler /* DFSDM Filter1 Interrupt */ + .word DFSDM1_FLT2_IRQHandler /* DFSDM Filter2 Interrupt */ + .word DFSDM1_FLT3_IRQHandler /* DFSDM Filter3 Interrupt */ + .word SAI3_IRQHandler /* SAI3 global Interrupt */ + .word SWPMI1_IRQHandler /* Serial Wire Interface 1 global interrupt */ + .word TIM15_IRQHandler /* TIM15 global Interrupt */ + .word TIM16_IRQHandler /* TIM16 global Interrupt */ + .word TIM17_IRQHandler /* TIM17 global Interrupt */ + .word MDIOS_WKUP_IRQHandler /* MDIOS Wakeup Interrupt */ + .word MDIOS_IRQHandler /* MDIOS global Interrupt */ + .word JPEG_IRQHandler /* JPEG global Interrupt */ + .word MDMA_IRQHandler /* MDMA global Interrupt */ + .word 0 /* Reserved */ + .word SDMMC2_IRQHandler /* SDMMC2 global Interrupt */ + .word HSEM1_IRQHandler /* HSEM1 global Interrupt */ + .word 0 /* Reserved */ + .word ADC3_IRQHandler /* ADC3 global Interrupt */ + .word DMAMUX2_OVR_IRQHandler /* DMAMUX Overrun interrupt */ + .word BDMA_Channel0_IRQHandler /* BDMA Channel 0 global Interrupt */ + .word BDMA_Channel1_IRQHandler /* BDMA Channel 1 global Interrupt */ + .word BDMA_Channel2_IRQHandler /* BDMA Channel 2 global Interrupt */ + .word BDMA_Channel3_IRQHandler /* BDMA Channel 3 global Interrupt */ + .word BDMA_Channel4_IRQHandler /* BDMA Channel 4 global Interrupt */ + .word BDMA_Channel5_IRQHandler /* BDMA Channel 5 global Interrupt */ + .word BDMA_Channel6_IRQHandler /* BDMA Channel 6 global Interrupt */ + .word BDMA_Channel7_IRQHandler /* BDMA Channel 7 global Interrupt */ + .word COMP1_IRQHandler /* COMP1 global Interrupt */ + .word LPTIM2_IRQHandler /* LP TIM2 global interrupt */ + .word LPTIM3_IRQHandler /* LP TIM3 global interrupt */ + .word LPTIM4_IRQHandler /* LP TIM4 global interrupt */ + .word LPTIM5_IRQHandler /* LP TIM5 global interrupt */ + .word LPUART1_IRQHandler /* LP UART1 interrupt */ + .word 0 /* Reserved */ + .word CRS_IRQHandler /* Clock Recovery Global Interrupt */ + .word ECC_IRQHandler /* ECC diagnostic Global Interrupt */ + .word SAI4_IRQHandler /* SAI4 global interrupt */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word WAKEUP_PIN_IRQHandler /* Interrupt for all 6 wake-up pins */ + +/******************************************************************************* +* +* Provide weak aliases for each Exception handler to the Default_Handler. +* As they are weak aliases, any function with the same name will override +* this definition. +* +*******************************************************************************/ + .weak NMI_Handler + .thumb_set NMI_Handler,Default_Handler + + .weak HardFault_Handler + .thumb_set HardFault_Handler,Default_Handler + + .weak MemManage_Handler + .thumb_set MemManage_Handler,Default_Handler + + .weak BusFault_Handler + .thumb_set BusFault_Handler,Default_Handler + + .weak UsageFault_Handler + .thumb_set UsageFault_Handler,Default_Handler + + .weak SVC_Handler + .thumb_set SVC_Handler,Default_Handler + + .weak DebugMon_Handler + .thumb_set DebugMon_Handler,Default_Handler + + .weak PendSV_Handler + .thumb_set PendSV_Handler,Default_Handler + + .weak SysTick_Handler + .thumb_set SysTick_Handler,Default_Handler + + .weak WWDG_IRQHandler + .thumb_set WWDG_IRQHandler,Default_Handler + + .weak PVD_AVD_IRQHandler + .thumb_set PVD_AVD_IRQHandler,Default_Handler + + .weak TAMP_STAMP_IRQHandler + .thumb_set TAMP_STAMP_IRQHandler,Default_Handler + + .weak RTC_WKUP_IRQHandler + .thumb_set RTC_WKUP_IRQHandler,Default_Handler + + .weak FLASH_IRQHandler + .thumb_set FLASH_IRQHandler,Default_Handler + + .weak RCC_IRQHandler + .thumb_set RCC_IRQHandler,Default_Handler + + .weak EXTI0_IRQHandler + .thumb_set EXTI0_IRQHandler,Default_Handler + + .weak EXTI1_IRQHandler + .thumb_set EXTI1_IRQHandler,Default_Handler + + .weak EXTI2_IRQHandler + .thumb_set EXTI2_IRQHandler,Default_Handler + + .weak EXTI3_IRQHandler + .thumb_set EXTI3_IRQHandler,Default_Handler + + .weak EXTI4_IRQHandler + .thumb_set EXTI4_IRQHandler,Default_Handler + + .weak DMA1_Stream0_IRQHandler + .thumb_set DMA1_Stream0_IRQHandler,Default_Handler + + .weak DMA1_Stream1_IRQHandler + .thumb_set DMA1_Stream1_IRQHandler,Default_Handler + + .weak DMA1_Stream2_IRQHandler + .thumb_set DMA1_Stream2_IRQHandler,Default_Handler + + .weak DMA1_Stream3_IRQHandler + .thumb_set DMA1_Stream3_IRQHandler,Default_Handler + + .weak DMA1_Stream4_IRQHandler + .thumb_set DMA1_Stream4_IRQHandler,Default_Handler + + .weak DMA1_Stream5_IRQHandler + .thumb_set DMA1_Stream5_IRQHandler,Default_Handler + + .weak DMA1_Stream6_IRQHandler + .thumb_set DMA1_Stream6_IRQHandler,Default_Handler + + .weak ADC_IRQHandler + .thumb_set ADC_IRQHandler,Default_Handler + + .weak FDCAN1_IT0_IRQHandler + .thumb_set FDCAN1_IT0_IRQHandler,Default_Handler + + .weak FDCAN2_IT0_IRQHandler + .thumb_set FDCAN2_IT0_IRQHandler,Default_Handler + + .weak FDCAN1_IT1_IRQHandler + .thumb_set FDCAN1_IT1_IRQHandler,Default_Handler + + .weak FDCAN2_IT1_IRQHandler + .thumb_set FDCAN2_IT1_IRQHandler,Default_Handler + + .weak EXTI9_5_IRQHandler + .thumb_set EXTI9_5_IRQHandler,Default_Handler + + .weak TIM1_BRK_IRQHandler + .thumb_set TIM1_BRK_IRQHandler,Default_Handler + + .weak TIM1_UP_IRQHandler + .thumb_set TIM1_UP_IRQHandler,Default_Handler + + .weak TIM1_TRG_COM_IRQHandler + .thumb_set TIM1_TRG_COM_IRQHandler,Default_Handler + + .weak TIM1_CC_IRQHandler + .thumb_set TIM1_CC_IRQHandler,Default_Handler + + .weak TIM2_IRQHandler + .thumb_set TIM2_IRQHandler,Default_Handler + + .weak TIM3_IRQHandler + .thumb_set TIM3_IRQHandler,Default_Handler + + .weak TIM4_IRQHandler + .thumb_set TIM4_IRQHandler,Default_Handler + + .weak I2C1_EV_IRQHandler + .thumb_set I2C1_EV_IRQHandler,Default_Handler + + .weak I2C1_ER_IRQHandler + .thumb_set I2C1_ER_IRQHandler,Default_Handler + + .weak I2C2_EV_IRQHandler + .thumb_set I2C2_EV_IRQHandler,Default_Handler + + .weak I2C2_ER_IRQHandler + .thumb_set I2C2_ER_IRQHandler,Default_Handler + + .weak SPI1_IRQHandler + .thumb_set SPI1_IRQHandler,Default_Handler + + .weak SPI2_IRQHandler + .thumb_set SPI2_IRQHandler,Default_Handler + + .weak USART1_IRQHandler + .thumb_set USART1_IRQHandler,Default_Handler + + .weak USART2_IRQHandler + .thumb_set USART2_IRQHandler,Default_Handler + + .weak USART3_IRQHandler + .thumb_set USART3_IRQHandler,Default_Handler + + .weak EXTI15_10_IRQHandler + .thumb_set EXTI15_10_IRQHandler,Default_Handler + + .weak RTC_Alarm_IRQHandler + .thumb_set RTC_Alarm_IRQHandler,Default_Handler + + .weak TIM8_BRK_TIM12_IRQHandler + .thumb_set TIM8_BRK_TIM12_IRQHandler,Default_Handler + + .weak TIM8_UP_TIM13_IRQHandler + .thumb_set TIM8_UP_TIM13_IRQHandler,Default_Handler + + .weak TIM8_TRG_COM_TIM14_IRQHandler + .thumb_set TIM8_TRG_COM_TIM14_IRQHandler,Default_Handler + + .weak TIM8_CC_IRQHandler + .thumb_set TIM8_CC_IRQHandler,Default_Handler + + .weak DMA1_Stream7_IRQHandler + .thumb_set DMA1_Stream7_IRQHandler,Default_Handler + + .weak FMC_IRQHandler + .thumb_set FMC_IRQHandler,Default_Handler + + .weak SDMMC1_IRQHandler + .thumb_set SDMMC1_IRQHandler,Default_Handler + + .weak TIM5_IRQHandler + .thumb_set TIM5_IRQHandler,Default_Handler + + .weak SPI3_IRQHandler + .thumb_set SPI3_IRQHandler,Default_Handler + + .weak UART4_IRQHandler + .thumb_set UART4_IRQHandler,Default_Handler + + .weak UART5_IRQHandler + .thumb_set UART5_IRQHandler,Default_Handler + + .weak TIM6_DAC_IRQHandler + .thumb_set TIM6_DAC_IRQHandler,Default_Handler + + .weak TIM7_IRQHandler + .thumb_set TIM7_IRQHandler,Default_Handler + + .weak DMA2_Stream0_IRQHandler + .thumb_set DMA2_Stream0_IRQHandler,Default_Handler + + .weak DMA2_Stream1_IRQHandler + .thumb_set DMA2_Stream1_IRQHandler,Default_Handler + + .weak DMA2_Stream2_IRQHandler + .thumb_set DMA2_Stream2_IRQHandler,Default_Handler + + .weak DMA2_Stream3_IRQHandler + .thumb_set DMA2_Stream3_IRQHandler,Default_Handler + + .weak DMA2_Stream4_IRQHandler + .thumb_set DMA2_Stream4_IRQHandler,Default_Handler + + .weak ETH_IRQHandler + .thumb_set ETH_IRQHandler,Default_Handler + + .weak ETH_WKUP_IRQHandler + .thumb_set ETH_WKUP_IRQHandler,Default_Handler + + .weak FDCAN_CAL_IRQHandler + .thumb_set FDCAN_CAL_IRQHandler,Default_Handler + + .weak DMA2_Stream5_IRQHandler + .thumb_set DMA2_Stream5_IRQHandler,Default_Handler + + .weak DMA2_Stream6_IRQHandler + .thumb_set DMA2_Stream6_IRQHandler,Default_Handler + + .weak DMA2_Stream7_IRQHandler + .thumb_set DMA2_Stream7_IRQHandler,Default_Handler + + .weak USART6_IRQHandler + .thumb_set USART6_IRQHandler,Default_Handler + + .weak I2C3_EV_IRQHandler + .thumb_set I2C3_EV_IRQHandler,Default_Handler + + .weak I2C3_ER_IRQHandler + .thumb_set I2C3_ER_IRQHandler,Default_Handler + + .weak OTG_HS_EP1_OUT_IRQHandler + .thumb_set OTG_HS_EP1_OUT_IRQHandler,Default_Handler + + .weak OTG_HS_EP1_IN_IRQHandler + .thumb_set OTG_HS_EP1_IN_IRQHandler,Default_Handler + + .weak OTG_HS_WKUP_IRQHandler + .thumb_set OTG_HS_WKUP_IRQHandler,Default_Handler + + .weak OTG_HS_IRQHandler + .thumb_set OTG_HS_IRQHandler,Default_Handler + + .weak DCMI_IRQHandler + .thumb_set DCMI_IRQHandler,Default_Handler + + .weak RNG_IRQHandler + .thumb_set RNG_IRQHandler,Default_Handler + + .weak FPU_IRQHandler + .thumb_set FPU_IRQHandler,Default_Handler + + .weak UART7_IRQHandler + .thumb_set UART7_IRQHandler,Default_Handler + + .weak UART8_IRQHandler + .thumb_set UART8_IRQHandler,Default_Handler + + .weak SPI4_IRQHandler + .thumb_set SPI4_IRQHandler,Default_Handler + + .weak SPI5_IRQHandler + .thumb_set SPI5_IRQHandler,Default_Handler + + .weak SPI6_IRQHandler + .thumb_set SPI6_IRQHandler,Default_Handler + + .weak SAI1_IRQHandler + .thumb_set SAI1_IRQHandler,Default_Handler + + .weak LTDC_IRQHandler + .thumb_set LTDC_IRQHandler,Default_Handler + + .weak LTDC_ER_IRQHandler + .thumb_set LTDC_ER_IRQHandler,Default_Handler + + .weak DMA2D_IRQHandler + .thumb_set DMA2D_IRQHandler,Default_Handler + + .weak SAI2_IRQHandler + .thumb_set SAI2_IRQHandler,Default_Handler + + .weak QUADSPI_IRQHandler + .thumb_set QUADSPI_IRQHandler,Default_Handler + + .weak LPTIM1_IRQHandler + .thumb_set LPTIM1_IRQHandler,Default_Handler + + .weak CEC_IRQHandler + .thumb_set CEC_IRQHandler,Default_Handler + + .weak I2C4_EV_IRQHandler + .thumb_set I2C4_EV_IRQHandler,Default_Handler + + .weak I2C4_ER_IRQHandler + .thumb_set I2C4_ER_IRQHandler,Default_Handler + + .weak SPDIF_RX_IRQHandler + .thumb_set SPDIF_RX_IRQHandler,Default_Handler + + .weak OTG_FS_EP1_OUT_IRQHandler + .thumb_set OTG_FS_EP1_OUT_IRQHandler,Default_Handler + + .weak OTG_FS_EP1_IN_IRQHandler + .thumb_set OTG_FS_EP1_IN_IRQHandler,Default_Handler + + .weak OTG_FS_WKUP_IRQHandler + .thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler + + .weak OTG_FS_IRQHandler + .thumb_set OTG_FS_IRQHandler,Default_Handler + + .weak DMAMUX1_OVR_IRQHandler + .thumb_set DMAMUX1_OVR_IRQHandler,Default_Handler + + .weak HRTIM1_Master_IRQHandler + .thumb_set HRTIM1_Master_IRQHandler,Default_Handler + + .weak HRTIM1_TIMA_IRQHandler + .thumb_set HRTIM1_TIMA_IRQHandler,Default_Handler + + .weak HRTIM1_TIMB_IRQHandler + .thumb_set HRTIM1_TIMB_IRQHandler,Default_Handler + + .weak HRTIM1_TIMC_IRQHandler + .thumb_set HRTIM1_TIMC_IRQHandler,Default_Handler + + .weak HRTIM1_TIMD_IRQHandler + .thumb_set HRTIM1_TIMD_IRQHandler,Default_Handler + + .weak HRTIM1_TIME_IRQHandler + .thumb_set HRTIM1_TIME_IRQHandler,Default_Handler + + .weak HRTIM1_FLT_IRQHandler + .thumb_set HRTIM1_FLT_IRQHandler,Default_Handler + + .weak DFSDM1_FLT0_IRQHandler + .thumb_set DFSDM1_FLT0_IRQHandler,Default_Handler + + .weak DFSDM1_FLT1_IRQHandler + .thumb_set DFSDM1_FLT1_IRQHandler,Default_Handler + + .weak DFSDM1_FLT2_IRQHandler + .thumb_set DFSDM1_FLT2_IRQHandler,Default_Handler + + .weak DFSDM1_FLT3_IRQHandler + .thumb_set DFSDM1_FLT3_IRQHandler,Default_Handler + + .weak SAI3_IRQHandler + .thumb_set SAI3_IRQHandler,Default_Handler + + .weak SWPMI1_IRQHandler + .thumb_set SWPMI1_IRQHandler,Default_Handler + + .weak TIM15_IRQHandler + .thumb_set TIM15_IRQHandler,Default_Handler + + .weak TIM16_IRQHandler + .thumb_set TIM16_IRQHandler,Default_Handler + + .weak TIM17_IRQHandler + .thumb_set TIM17_IRQHandler,Default_Handler + + .weak MDIOS_WKUP_IRQHandler + .thumb_set MDIOS_WKUP_IRQHandler,Default_Handler + + .weak MDIOS_IRQHandler + .thumb_set MDIOS_IRQHandler,Default_Handler + + .weak JPEG_IRQHandler + .thumb_set JPEG_IRQHandler,Default_Handler + + .weak MDMA_IRQHandler + .thumb_set MDMA_IRQHandler,Default_Handler + + .weak SDMMC2_IRQHandler + .thumb_set SDMMC2_IRQHandler,Default_Handler + + .weak HSEM1_IRQHandler + .thumb_set HSEM1_IRQHandler,Default_Handler + + .weak ADC3_IRQHandler + .thumb_set ADC3_IRQHandler,Default_Handler + + .weak DMAMUX2_OVR_IRQHandler + .thumb_set DMAMUX2_OVR_IRQHandler,Default_Handler + + .weak BDMA_Channel0_IRQHandler + .thumb_set BDMA_Channel0_IRQHandler,Default_Handler + + .weak BDMA_Channel1_IRQHandler + .thumb_set BDMA_Channel1_IRQHandler,Default_Handler + + .weak BDMA_Channel2_IRQHandler + .thumb_set BDMA_Channel2_IRQHandler,Default_Handler + + .weak BDMA_Channel3_IRQHandler + .thumb_set BDMA_Channel3_IRQHandler,Default_Handler + + .weak BDMA_Channel4_IRQHandler + .thumb_set BDMA_Channel4_IRQHandler,Default_Handler + + .weak BDMA_Channel5_IRQHandler + .thumb_set BDMA_Channel5_IRQHandler,Default_Handler + + .weak BDMA_Channel6_IRQHandler + .thumb_set BDMA_Channel6_IRQHandler,Default_Handler + + .weak BDMA_Channel7_IRQHandler + .thumb_set BDMA_Channel7_IRQHandler,Default_Handler + + .weak COMP1_IRQHandler + .thumb_set COMP1_IRQHandler,Default_Handler + + .weak LPTIM2_IRQHandler + .thumb_set LPTIM2_IRQHandler,Default_Handler + + .weak LPTIM3_IRQHandler + .thumb_set LPTIM3_IRQHandler,Default_Handler + + .weak LPTIM4_IRQHandler + .thumb_set LPTIM4_IRQHandler,Default_Handler + + .weak LPTIM5_IRQHandler + .thumb_set LPTIM5_IRQHandler,Default_Handler + + .weak LPUART1_IRQHandler + .thumb_set LPUART1_IRQHandler,Default_Handler + + .weak CRS_IRQHandler + .thumb_set CRS_IRQHandler,Default_Handler + + .weak ECC_IRQHandler + .thumb_set ECC_IRQHandler,Default_Handler + + .weak SAI4_IRQHandler + .thumb_set SAI4_IRQHandler,Default_Handler + + .weak WAKEUP_PIN_IRQHandler + .thumb_set WAKEUP_PIN_IRQHandler,Default_Handler + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ + From 782b8ee20d5241244e9e7560471609af36d02480 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 15 Jun 2021 12:15:38 +0200 Subject: [PATCH 026/286] Xibeca wip --- Xibeca/Core/Inc/FreeRTOSConfig.h | 141 +++ Xibeca/Core/Inc/hardware.h | 67 ++ Xibeca/Core/Inc/main.h | 121 +++ Xibeca/Core/Inc/stm32h7xx_hal_conf.h | 511 +++++++++ Xibeca/Core/Inc/stm32h7xx_it.h | 71 ++ Xibeca/Core/Src/freertos.c | 124 +++ Xibeca/Core/Src/main.c | 1264 ++++++++++++++++++++++ Xibeca/Core/Src/startup_stm32h743xx.s | 749 +++++++++++++ Xibeca/Core/Src/stm32h7xx_hal_msp.c | 1439 +++++++++++++++++++++++++ Xibeca/Core/Src/stm32h7xx_it.c | 248 +++++ Xibeca/Core/Src/system_stm32h7xx.c | 422 ++++++++ Xibeca/Makefile | 35 + Xibeca/USB_DEVICE/App/usb_device.c | 103 ++ Xibeca/USB_DEVICE/App/usb_device.h | 105 ++ Xibeca/USB_DEVICE/App/usbd_desc.c | 409 +++++++ Xibeca/USB_DEVICE/App/usbd_desc.h | 145 +++ Xibeca/USB_DEVICE/Target/usbd_conf.c | 683 ++++++++++++ Xibeca/USB_DEVICE/Target/usbd_conf.h | 176 +++ Xibeca/USB_HOST/App/usb_host.c | 130 +++ Xibeca/USB_HOST/App/usb_host.h | 92 ++ Xibeca/USB_HOST/Target/usbh_conf.c | 575 ++++++++++ Xibeca/USB_HOST/Target/usbh_conf.h | 196 ++++ Xibeca/Xibeca.ioc | 839 ++++++++++++++ 23 files changed, 8645 insertions(+) create mode 100644 Xibeca/Core/Inc/FreeRTOSConfig.h create mode 100644 Xibeca/Core/Inc/hardware.h create mode 100644 Xibeca/Core/Inc/main.h create mode 100644 Xibeca/Core/Inc/stm32h7xx_hal_conf.h create mode 100644 Xibeca/Core/Inc/stm32h7xx_it.h create mode 100644 Xibeca/Core/Src/freertos.c create mode 100644 Xibeca/Core/Src/main.c create mode 100644 Xibeca/Core/Src/startup_stm32h743xx.s create mode 100644 Xibeca/Core/Src/stm32h7xx_hal_msp.c create mode 100644 Xibeca/Core/Src/stm32h7xx_it.c create mode 100644 Xibeca/Core/Src/system_stm32h7xx.c create mode 100644 Xibeca/Makefile create mode 100644 Xibeca/USB_DEVICE/App/usb_device.c create mode 100644 Xibeca/USB_DEVICE/App/usb_device.h create mode 100644 Xibeca/USB_DEVICE/App/usbd_desc.c create mode 100644 Xibeca/USB_DEVICE/App/usbd_desc.h create mode 100644 Xibeca/USB_DEVICE/Target/usbd_conf.c create mode 100644 Xibeca/USB_DEVICE/Target/usbd_conf.h create mode 100644 Xibeca/USB_HOST/App/usb_host.c create mode 100644 Xibeca/USB_HOST/App/usb_host.h create mode 100644 Xibeca/USB_HOST/Target/usbh_conf.c create mode 100644 Xibeca/USB_HOST/Target/usbh_conf.h create mode 100644 Xibeca/Xibeca.ioc diff --git a/Xibeca/Core/Inc/FreeRTOSConfig.h b/Xibeca/Core/Inc/FreeRTOSConfig.h new file mode 100644 index 00000000..4d06e420 --- /dev/null +++ b/Xibeca/Core/Inc/FreeRTOSConfig.h @@ -0,0 +1,141 @@ +/* USER CODE BEGIN Header */ +/* + * FreeRTOS Kernel V10.2.1 + * Portion Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Portion Copyright (C) 2019 StMicroelectronics, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ +/* USER CODE END Header */ + +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +/*----------------------------------------------------------- + * Application specific definitions. + * + * These definitions should be adjusted for your particular hardware and + * application requirements. + * + * These parameters and more are described within the 'configuration' section of the + * FreeRTOS API documentation available on the FreeRTOS.org web site. + * + * See http://www.freertos.org/a00110.html + *----------------------------------------------------------*/ + +/* USER CODE BEGIN Includes */ +/* Section where include file can be added */ +/* USER CODE END Includes */ + +/* Ensure definitions are only used by the compiler, and not by the assembler. */ +#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) + #include + extern uint32_t SystemCoreClock; + void xPortSysTickHandler(void); +#endif +#define configENABLE_FPU 0 +#define configENABLE_MPU 0 + +#define configUSE_PREEMPTION 0 +#define configSUPPORT_STATIC_ALLOCATION 1 +#define configSUPPORT_DYNAMIC_ALLOCATION 1 +#define configUSE_IDLE_HOOK 1 +#define configUSE_TICK_HOOK 1 +#define configCPU_CLOCK_HZ ( SystemCoreClock ) +#define configTICK_RATE_HZ ((TickType_t)1000) +#define configMAX_PRIORITIES ( 7 ) +#define configMINIMAL_STACK_SIZE ((uint16_t)128) +#define configTOTAL_HEAP_SIZE ((size_t)15360) +#define configMAX_TASK_NAME_LEN ( 16 ) +#define configUSE_16_BIT_TICKS 0 +#define configUSE_MUTEXES 1 +#define configQUEUE_REGISTRY_SIZE 8 +#define configUSE_MALLOC_FAILED_HOOK 1 +#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 +/* USER CODE BEGIN MESSAGE_BUFFER_LENGTH_TYPE */ +/* Defaults to size_t for backward compatibility, but can be changed + if lengths will always be less than the number of bytes in a size_t. */ +#define configMESSAGE_BUFFER_LENGTH_TYPE size_t +/* USER CODE END MESSAGE_BUFFER_LENGTH_TYPE */ + +/* Co-routine definitions. */ +#define configUSE_CO_ROUTINES 0 +#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) + +/* Set the following definitions to 1 to include the API function, or zero +to exclude the API function. */ +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskCleanUpResources 0 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_xTaskGetSchedulerState 1 + +/* Cortex-M specific definitions. */ +#ifdef __NVIC_PRIO_BITS + /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */ + #define configPRIO_BITS __NVIC_PRIO_BITS +#else + #define configPRIO_BITS 4 +#endif + +/* The lowest interrupt priority that can be used in a call to a "set priority" +function. */ +#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15 + +/* The highest interrupt priority that can be used by any interrupt service +routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL +INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER +PRIORITY THAN THIS! (higher priorities are lower numeric values. */ +#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5 + +/* Interrupt priorities used by the kernel port layer itself. These are generic +to all Cortex-M ports, and do not rely on any particular library functions. */ +#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) +/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!! +See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ +#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) + +/* Normal assert() semantics without relying on the provision of an assert.h +header file. */ +/* USER CODE BEGIN 1 */ +#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );} +/* USER CODE END 1 */ + +/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS +standard names. */ +#define vPortSVCHandler SVC_Handler +#define xPortPendSVHandler PendSV_Handler + +/* IMPORTANT: This define is commented when used with STM32Cube firmware, when the timebase source is SysTick, + to prevent overwriting SysTick_Handler defined within STM32Cube HAL */ + +/* #define xPortSysTickHandler SysTick_Handler */ + +/* USER CODE BEGIN Defines */ +/* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */ +/* USER CODE END Defines */ + +#endif /* FREERTOS_CONFIG_H */ diff --git a/Xibeca/Core/Inc/hardware.h b/Xibeca/Core/Inc/hardware.h new file mode 100644 index 00000000..80d82fb4 --- /dev/null +++ b/Xibeca/Core/Inc/hardware.h @@ -0,0 +1,67 @@ +#include "main.h" +#include "stm32h7xx_hal.h" + +#define OWL_NOCTUA +#define HARDWARE_ID XIBECA_HARDWARE +#define HARDWARE_VERSION "Xibeca" +/* #define NO_EXTERNAL_RAM */ + +/* #define USE_BKPSRAM enable to prevent reset loops */ + +/* #define USE_RGB_LED */ +/* #define USE_ADC */ +#define ADC_PERIPH hadc1 +#define ADC_A 0 +#define ADC_B 1 +#define ADC_C 2 +#define ADC_D 3 +#define ADC_E 4 +#define ADC_F 5 +#define ADC_G 6 +#define ADC_H 7 +#define USE_CODEC +/* #define USE_IIS3DWB */ +#define USE_PCM3168A + +/* USB audio settings */ +#define AUDIO_BITS_PER_SAMPLE 16 +#define AUDIO_BYTES_PER_SAMPLE (AUDIO_BITS_PER_SAMPLE/8) +#define AUDIO_CHANNELS 8 +/* #define AUDIO_INT32_TO_SAMPLE(x) (__REV16((x)>>8)) */ +/* #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(__REV16(x))<<8) */ +#define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) +#define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) +#define USBD_AUDIO_RX_CHANNELS 4 +#define USBD_AUDIO_TX_CHANNELS 4 + +#define USE_USBD_AUDIO +#define USE_USBD_AUDIO_TX // microphone +#define USE_USBD_AUDIO_RX // speaker +#define USE_USBD_FS +#define USBD_HANDLE hUsbDeviceFS +#define USBH_HANDLE hUsbHostHS +#define USBD_MAX_POWER 100 // 200mA for iPad compatibility +#define USE_USB_HOST +#define USB_HOST_RX_BUFF_SIZE 256 /* Max Received data 64 bytes */ +#define USE_USBH_MIDI + +#define USE_UART_MIDI_RX +#define USE_UART_MIDI_TX +#define UART_MIDI_HANDLE huart2 +#define UART_MIDI_RX_BUFFER_SIZE 256 + +#define AUDIO_SAMPLINGRATE 48000 +#define TIM8_PERIOD (871*48000/AUDIO_SAMPLINGRATE) /* experimentally determined */ + +/* #define USE_PCM3168A */ +/* #define CODEC_HP_FILTER */ +#define CODEC_SPI hspi2 + +#define USB_HOST_PWR_EN_GPIO_Port GPIOB +#define USB_HOST_PWR_EN_Pin GPIO_PIN_0 // PB0 is unused +#define USB_HOST_PWR_FAULT_GPIO_Port GPIOB +#define USB_HOST_PWR_FAULT_Pin GPIO_PIN_1 // PB1 is unused + +#define NOF_ADC_VALUES 8 +#define NOF_PARAMETERS 40 +#define NOF_BUTTONS (2+4) diff --git a/Xibeca/Core/Inc/main.h b/Xibeca/Core/Inc/main.h new file mode 100644 index 00000000..04b13c5f --- /dev/null +++ b/Xibeca/Core/Inc/main.h @@ -0,0 +1,121 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : main.h + * @brief : Header for main.c file. + * This file contains the common defines of the application. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __MAIN_H +#define __MAIN_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32h7xx_hal.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* Exported macro ------------------------------------------------------------*/ +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +/* Exported functions prototypes ---------------------------------------------*/ +void Error_Handler(void); + +/* USER CODE BEGIN EFP */ + +/* USER CODE END EFP */ + +/* Private defines -----------------------------------------------------------*/ +#define FLASH_DQ2_Pin GPIO_PIN_2 +#define FLASH_DQ2_GPIO_Port GPIOE +#define EXTI10_Pin GPIO_PIN_10 +#define EXTI10_GPIO_Port GPIOG +#define EXTI13_Pin GPIO_PIN_13 +#define EXTI13_GPIO_Port GPIOC +#define EXTI14_Pin GPIO_PIN_14 +#define EXTI14_GPIO_Port GPIOC +#define EXTI11_Pin GPIO_PIN_11 +#define EXTI11_GPIO_Port GPIOI +#define EXTI15_Pin GPIO_PIN_15 +#define EXTI15_GPIO_Port GPIOC +#define EXTI4_Pin GPIO_PIN_4 +#define EXTI4_GPIO_Port GPIOH +#define FLASH_NCS_Pin GPIO_PIN_6 +#define FLASH_NCS_GPIO_Port GPIOG +#define FLASH_DQ3_Pin GPIO_PIN_6 +#define FLASH_DQ3_GPIO_Port GPIOF +#define ADC_RST_Pin GPIO_PIN_3 +#define ADC_RST_GPIO_Port GPIOG +#define FLASH_CLK_Pin GPIO_PIN_10 +#define FLASH_CLK_GPIO_Port GPIOF +#define FLASH_DQ1_Pin GPIO_PIN_9 +#define FLASH_DQ1_GPIO_Port GPIOF +#define FLASH_DQ0_Pin GPIO_PIN_8 +#define FLASH_DQ0_GPIO_Port GPIOF +#define ADC_SPI_MISO_Pin GPIO_PIN_2 +#define ADC_SPI_MISO_GPIO_Port GPIOC +#define ADC_SPI_MOSI_Pin GPIO_PIN_3 +#define ADC_SPI_MOSI_GPIO_Port GPIOC +#define EXTI0_Pin GPIO_PIN_0 +#define EXTI0_GPIO_Port GPIOA +#define DAC1_Pin GPIO_PIN_4 +#define DAC1_GPIO_Port GPIOA +#define DAC2_Pin GPIO_PIN_5 +#define DAC2_GPIO_Port GPIOA +#define EXTI3_Pin GPIO_PIN_3 +#define EXTI3_GPIO_Port GPIOA +#define EXTI7_Pin GPIO_PIN_7 +#define EXTI7_GPIO_Port GPIOA +#define ADC_SPI_CLK_Pin GPIO_PIN_10 +#define ADC_SPI_CLK_GPIO_Port GPIOB +#define ADC_SPI_NCS_Pin GPIO_PIN_11 +#define ADC_SPI_NCS_GPIO_Port GPIOB +/* USER CODE BEGIN Private defines */ + +#define ADC_NCS_Pin ADC_SPI_NCS_Pin +#define ADC_NCS_GPIO_Port ADC_SPI_NCS_GPIO_Port + +#define ADC_RESET_Pin ADC_RST_Pin +#define ADC_RESET_GPIO_Port ADC_RST_GPIO_Port + +/* USER CODE END Private defines */ + +#ifdef __cplusplus +} +#endif + +#endif /* __MAIN_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/Core/Inc/stm32h7xx_hal_conf.h b/Xibeca/Core/Inc/stm32h7xx_hal_conf.h new file mode 100644 index 00000000..e70868d7 --- /dev/null +++ b/Xibeca/Core/Inc/stm32h7xx_hal_conf.h @@ -0,0 +1,511 @@ +/** + ****************************************************************************** + * @file stm32h7xx_hal_conf.h + * @author MCD Application Team + * @brief HAL configuration file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef STM32H7xx_HAL_CONF_H +#define STM32H7xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED + + #define HAL_ADC_MODULE_ENABLED +/* #define HAL_FDCAN_MODULE_ENABLED */ +/* #define HAL_FMAC_MODULE_ENABLED */ +/* #define HAL_CEC_MODULE_ENABLED */ +/* #define HAL_COMP_MODULE_ENABLED */ +/* #define HAL_CORDIC_MODULE_ENABLED */ +/* #define HAL_CRC_MODULE_ENABLED */ +/* #define HAL_CRYP_MODULE_ENABLED */ +#define HAL_DAC_MODULE_ENABLED +/* #define HAL_DCMI_MODULE_ENABLED */ +/* #define HAL_DMA2D_MODULE_ENABLED */ +/* #define HAL_ETH_MODULE_ENABLED */ +/* #define HAL_NAND_MODULE_ENABLED */ +/* #define HAL_NOR_MODULE_ENABLED */ +/* #define HAL_OTFDEC_MODULE_ENABLED */ +/* #define HAL_SRAM_MODULE_ENABLED */ +#define HAL_SDRAM_MODULE_ENABLED +/* #define HAL_HASH_MODULE_ENABLED */ +/* #define HAL_HRTIM_MODULE_ENABLED */ +/* #define HAL_HSEM_MODULE_ENABLED */ +/* #define HAL_GFXMMU_MODULE_ENABLED */ +/* #define HAL_JPEG_MODULE_ENABLED */ +/* #define HAL_OPAMP_MODULE_ENABLED */ +/* #define HAL_OSPI_MODULE_ENABLED */ +/* #define HAL_OSPI_MODULE_ENABLED */ +/* #define HAL_I2S_MODULE_ENABLED */ +/* #define HAL_SMBUS_MODULE_ENABLED */ +/* #define HAL_IWDG_MODULE_ENABLED */ +#define HAL_LPTIM_MODULE_ENABLED +/* #define HAL_LTDC_MODULE_ENABLED */ +#define HAL_QSPI_MODULE_ENABLED +/* #define HAL_RNG_MODULE_ENABLED */ +/* #define HAL_RTC_MODULE_ENABLED */ +#define HAL_SAI_MODULE_ENABLED +/* #define HAL_SD_MODULE_ENABLED */ +/* #define HAL_MMC_MODULE_ENABLED */ +/* #define HAL_SPDIFRX_MODULE_ENABLED */ +#define HAL_SPI_MODULE_ENABLED +/* #define HAL_SWPMI_MODULE_ENABLED */ +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +/* #define HAL_USART_MODULE_ENABLED */ +/* #define HAL_IRDA_MODULE_ENABLED */ +/* #define HAL_SMARTCARD_MODULE_ENABLED */ +/* #define HAL_WWDG_MODULE_ENABLED */ +#define HAL_PCD_MODULE_ENABLED +#define HAL_HCD_MODULE_ENABLED +/* #define HAL_DFSDM_MODULE_ENABLED */ +/* #define HAL_DSI_MODULE_ENABLED */ +/* #define HAL_JPEG_MODULE_ENABLED */ +/* #define HAL_MDIOS_MODULE_ENABLED */ +/* #define HAL_PSSI_MODULE_ENABLED */ +/* #define HAL_DTS_MODULE_ENABLED */ +#define HAL_GPIO_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_MDMA_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED +#define HAL_HSEM_MODULE_ENABLED + +/* ########################## Oscillator Values adaptation ####################*/ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) +#define HSE_VALUE (8000000UL) /*!< Value of the External oscillator in Hz : FPGA case fixed to 60MHZ */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT (100UL) /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal oscillator (CSI) default value. + * This value is the default CSI value after Reset. + */ +#if !defined (CSI_VALUE) + #define CSI_VALUE (4000000UL) /*!< Value of the Internal oscillator in Hz*/ +#endif /* CSI_VALUE */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE (64000000UL) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief External Low Speed oscillator (LSE) value. + * This value is used by the UART, RTC HAL module to compute the system frequency + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE (32768UL) /*!< Value of the External oscillator in Hz*/ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT (5000UL) /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +#if !defined (LSI_VALUE) + #define LSI_VALUE (32000UL) /*!< LSI Typical Value in Hz*/ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature.*/ + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) + #define EXTERNAL_CLOCK_VALUE 12288000UL /*!< Value of the External clock in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE (3300UL) /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY (15UL) /*!< tick interrupt priority */ +#define USE_RTOS 0 +#define USE_SD_TRANSCEIVER 0U /*!< use uSD Transceiver */ +#define USE_SPI_CRC 0U /*!< use CRC in SPI */ + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_COMP_REGISTER_CALLBACKS 0U /* COMP register callback disabled */ +#define USE_HAL_CORDIC_REGISTER_CALLBACKS 0U /* CORDIC register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_DTS_REGISTER_CALLBACKS 0U /* DTS register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_FDCAN_REGISTER_CALLBACKS 0U /* FDCAN register callback disabled */ +#define USE_HAL_FMAC_REGISTER_CALLBACKS 0U /* FMAC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_GFXMMU_REGISTER_CALLBACKS 0U /* GFXMMU register callback disabled */ +#define USE_HAL_HRTIM_REGISTER_CALLBACKS 0U /* HRTIM register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_JPEG_REGISTER_CALLBACKS 0U /* JPEG register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ +#define USE_HAL_MDIOS_REGISTER_CALLBACKS 0U /* MDIO register callback disabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U /* MDIO register callback disabled */ +#define USE_HAL_OSPI_REGISTER_CALLBACKS 0U /* OSPI register callback disabled */ +#define USE_HAL_OTFDEC_REGISTER_CALLBACKS 0U /* OTFDEC register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_SWPMI_REGISTER_CALLBACKS 0U /* SWPMI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + +/* ########################### Ethernet Configuration ######################### */ +#define ETH_TX_DESC_CNT 4 /* number of Ethernet Tx DMA descriptors */ +#define ETH_RX_DESC_CNT 4 /* number of Ethernet Rx DMA descriptors */ + +#define ETH_MAC_ADDR0 (0x02UL) +#define ETH_MAC_ADDR1 (0x00UL) +#define ETH_MAC_ADDR2 (0x00UL) +#define ETH_MAC_ADDR3 (0x00UL) +#define ETH_MAC_ADDR4 (0x00UL) +#define ETH_MAC_ADDR5 (0x00UL) + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ + #define USE_FULL_ASSERT 1U + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32h7xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32h7xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32h7xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_MDMA_MODULE_ENABLED + #include "stm32h7xx_hal_mdma.h" +#endif /* HAL_MDMA_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED + #include "stm32h7xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED + #include "stm32h7xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED + #include "stm32h7xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED + #include "stm32h7xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED + #include "stm32h7xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_DTS_MODULE_ENABLED + #include "stm32h7xx_hal_dts.h" +#endif /* HAL_DTS_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED + #include "stm32h7xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32h7xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32h7xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32h7xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_FDCAN_MODULE_ENABLED + #include "stm32h7xx_hal_fdcan.h" +#endif /* HAL_FDCAN_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED + #include "stm32h7xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_COMP_MODULE_ENABLED + #include "stm32h7xx_hal_comp.h" +#endif /* HAL_COMP_MODULE_ENABLED */ + +#ifdef HAL_CORDIC_MODULE_ENABLED + #include "stm32h7xx_hal_cordic.h" +#endif /* HAL_CORDIC_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32h7xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED + #include "stm32h7xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32h7xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32h7xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_GFXMMU_MODULE_ENABLED + #include "stm32h7xx_hal_gfxmmu.h" +#endif /* HAL_GFXMMU_MODULE_ENABLED */ + +#ifdef HAL_FMAC_MODULE_ENABLED + #include "stm32h7xx_hal_fmac.h" +#endif /* HAL_FMAC_MODULE_ENABLED */ + +#ifdef HAL_HRTIM_MODULE_ENABLED + #include "stm32h7xx_hal_hrtim.h" +#endif /* HAL_HRTIM_MODULE_ENABLED */ + +#ifdef HAL_HSEM_MODULE_ENABLED + #include "stm32h7xx_hal_hsem.h" +#endif /* HAL_HSEM_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32h7xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32h7xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED + #include "stm32h7xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32h7xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32h7xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32h7xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_JPEG_MODULE_ENABLED + #include "stm32h7xx_hal_jpeg.h" +#endif /* HAL_JPEG_MODULE_ENABLED */ + +#ifdef HAL_MDIOS_MODULE_ENABLED + #include "stm32h7xx_hal_mdios.h" +#endif /* HAL_MDIOS_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED + #include "stm32h7xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED +#include "stm32h7xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED +#include "stm32h7xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_OPAMP_MODULE_ENABLED +#include "stm32h7xx_hal_opamp.h" +#endif /* HAL_OPAMP_MODULE_ENABLED */ + +#ifdef HAL_OSPI_MODULE_ENABLED + #include "stm32h7xx_hal_ospi.h" +#endif /* HAL_OSPI_MODULE_ENABLED */ + +#ifdef HAL_OTFDEC_MODULE_ENABLED +#include "stm32h7xx_hal_otfdec.h" +#endif /* HAL_OTFDEC_MODULE_ENABLED */ + +#ifdef HAL_PSSI_MODULE_ENABLED + #include "stm32h7xx_hal_pssi.h" +#endif /* HAL_PSSI_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32h7xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED + #include "stm32h7xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_RAMECC_MODULE_ENABLED + #include "stm32h7xx_hal_ramecc.h" +#endif /* HAL_RAMECC_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED + #include "stm32h7xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32h7xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED + #include "stm32h7xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED + #include "stm32h7xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED + #include "stm32h7xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32h7xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED + #include "stm32h7xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_SWPMI_MODULE_ENABLED + #include "stm32h7xx_hal_swpmi.h" +#endif /* HAL_SWPMI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32h7xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32h7xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32h7xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32h7xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32h7xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED + #include "stm32h7xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32h7xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32h7xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED + #include "stm32h7xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t *file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* STM32H7xx_HAL_CONF_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/Core/Inc/stm32h7xx_it.h b/Xibeca/Core/Inc/stm32h7xx_it.h new file mode 100644 index 00000000..3819c272 --- /dev/null +++ b/Xibeca/Core/Inc/stm32h7xx_it.h @@ -0,0 +1,71 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32h7xx_it.h + * @brief This file contains the headers of the interrupt handlers. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32H7xx_IT_H +#define __STM32H7xx_IT_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* Exported macro ------------------------------------------------------------*/ +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +/* Exported functions prototypes ---------------------------------------------*/ +void NMI_Handler(void); +void HardFault_Handler(void); +void MemManage_Handler(void); +void BusFault_Handler(void); +void UsageFault_Handler(void); +void DebugMon_Handler(void); +void SysTick_Handler(void); +void DMA1_Stream0_IRQHandler(void); +void DMA1_Stream1_IRQHandler(void); +void OTG_HS_IRQHandler(void); +void OTG_FS_IRQHandler(void); +/* USER CODE BEGIN EFP */ + +/* USER CODE END EFP */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32H7xx_IT_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/Core/Src/freertos.c b/Xibeca/Core/Src/freertos.c new file mode 100644 index 00000000..5fab4756 --- /dev/null +++ b/Xibeca/Core/Src/freertos.c @@ -0,0 +1,124 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * File Name : freertos.c + * Description : Code for freertos applications + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "FreeRTOS.h" +#include "task.h" +#include "main.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN PTD */ + +/* USER CODE END PTD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ + +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN Variables */ + +/* USER CODE END Variables */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN FunctionPrototypes */ + +/* USER CODE END FunctionPrototypes */ + +/* GetIdleTaskMemory prototype (linked to static allocation support) */ +void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ); + +/* Hook prototypes */ +void vApplicationIdleHook(void); +void vApplicationTickHook(void); +void vApplicationMallocFailedHook(void); + +/* USER CODE BEGIN 2 */ +__weak void vApplicationIdleHook( void ) +{ + /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set + to 1 in FreeRTOSConfig.h. It will be called on each iteration of the idle + task. It is essential that code added to this hook function never attempts + to block in any way (for example, call xQueueReceive() with a block time + specified, or call vTaskDelay()). If the application makes use of the + vTaskDelete() API function (as this demo application does) then it is also + important that vApplicationIdleHook() is permitted to return to its calling + function, because it is the responsibility of the idle task to clean up + memory allocated by the kernel to any task that has since been deleted. */ +} +/* USER CODE END 2 */ + +/* USER CODE BEGIN 3 */ +__weak void vApplicationTickHook( void ) +{ + /* This function will be called by each tick interrupt if + configUSE_TICK_HOOK is set to 1 in FreeRTOSConfig.h. User code can be + added here, but the tick hook is called from an interrupt context, so + code must not attempt to block, and only the interrupt safe FreeRTOS API + functions can be used (those that end in FromISR()). */ +} +/* USER CODE END 3 */ + +/* USER CODE BEGIN 5 */ +__weak void vApplicationMallocFailedHook(void) +{ + /* vApplicationMallocFailedHook() will only be called if + configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook + function that will get called if a call to pvPortMalloc() fails. + pvPortMalloc() is called internally by the kernel whenever a task, queue, + timer or semaphore is created. It is also called by various parts of the + demo application. If heap_1.c or heap_2.c are used, then the size of the + heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in + FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used + to query the size of free heap space that remains (although it does not + provide information on how the remaining heap might be fragmented). */ +} +/* USER CODE END 5 */ + +/* USER CODE BEGIN GET_IDLE_TASK_MEMORY */ +static StaticTask_t xIdleTaskTCBBuffer; +static StackType_t xIdleStack[configMINIMAL_STACK_SIZE]; + +void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ) +{ + *ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer; + *ppxIdleTaskStackBuffer = &xIdleStack[0]; + *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; + /* place for user code */ +} +/* USER CODE END GET_IDLE_TASK_MEMORY */ + +/* Private application code --------------------------------------------------*/ +/* USER CODE BEGIN Application */ + +/* USER CODE END Application */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/Core/Src/main.c b/Xibeca/Core/Src/main.c new file mode 100644 index 00000000..0f3e94de --- /dev/null +++ b/Xibeca/Core/Src/main.c @@ -0,0 +1,1264 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : main.c + * @brief : Main program body + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "cmsis_os.h" +#include "usb_device.h" +#include "usb_host.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ +#include "device.h" +#include "errorhandlers.h" +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN PTD */ + +/* USER CODE END PTD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +ADC_HandleTypeDef hadc1; + +DAC_HandleTypeDef hdac1; + +I2C_HandleTypeDef hi2c1; + +LPTIM_HandleTypeDef hlptim1; + +QSPI_HandleTypeDef hqspi; + +SAI_HandleTypeDef hsai_BlockA1; +SAI_HandleTypeDef hsai_BlockB1; +DMA_HandleTypeDef hdma_sai1_a; +DMA_HandleTypeDef hdma_sai1_b; + +SPI_HandleTypeDef hspi2; +SPI_HandleTypeDef hspi3; +SPI_HandleTypeDef hspi6; + +TIM_HandleTypeDef htim2; +TIM_HandleTypeDef htim3; +TIM_HandleTypeDef htim4; + +UART_HandleTypeDef huart5; +UART_HandleTypeDef huart7; + +SDRAM_HandleTypeDef hsdram1; + +osThreadId defaultTaskHandle; +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +void SystemClock_Config(void); +void PeriphCommonClock_Config(void); +static void MX_GPIO_Init(void); +static void MX_DMA_Init(void); +static void MX_QUADSPI_Init(void); +static void MX_DAC1_Init(void); +static void MX_FMC_Init(void); +static void MX_SAI1_Init(void); +static void MX_ADC1_Init(void); +static void MX_I2C1_Init(void); +static void MX_SPI2_Init(void); +static void MX_SPI3_Init(void); +static void MX_SPI6_Init(void); +static void MX_TIM2_Init(void); +static void MX_TIM3_Init(void); +static void MX_TIM4_Init(void); +static void MX_UART5_Init(void); +static void MX_UART7_Init(void); +static void MX_LPTIM1_Init(void); +void StartDefaultTask(void const * argument); + +/* USER CODE BEGIN PFP */ +void setup(void); +void loop(void); +void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram); +void initialise_monitor_handles(void); +/* USER CODE END PFP */ + +/* Private user code ---------------------------------------------------------*/ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/** + * @brief The application entry point. + * @retval int + */ +int main(void) +{ + /* USER CODE BEGIN 1 */ +#ifdef DEBUG +#warning "DEBUG uses printf and semihosting!" + if(CoreDebug->DHCSR & 0x01) + initialise_monitor_handles(); // remove when not semi-hosting + printf("showtime\n"); +#endif +#ifdef USE_ICACHE + /* Enable I-Cache-------------------------------------------------------------*/ + /* After reset, you must invalidate each cache before enabling (SCB_EnableICache) it. */ + SCB_InvalidateICache(); + SCB_EnableICache(); +#endif +#ifdef USE_DCACHE + /* Enable D-Cache-------------------------------------------------------------*/ + /* Before enabling the data cache, you must invalidate the entire data cache (SCB_InvalidateDCache), because external memory might have changed from when the cache was disabled. */ + SCB_InvalidateDCache(); + SCB_EnableDCache(); +#endif + + /* Enable D2 domain SRAM Clocks */ + __HAL_RCC_D2SRAM1_CLK_ENABLE(); + __HAL_RCC_D2SRAM2_CLK_ENABLE(); + __HAL_RCC_D2SRAM3_CLK_ENABLE(); + + /* USER CODE END 1 */ + + /* MCU Configuration--------------------------------------------------------*/ + + /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ + HAL_Init(); + + /* USER CODE BEGIN Init */ + + /* USER CODE END Init */ + + /* Configure the system clock */ + SystemClock_Config(); + +/* Configure the peripherals common clocks */ + PeriphCommonClock_Config(); + + /* USER CODE BEGIN SysInit */ + + /* USER CODE END SysInit */ + + /* Initialize all configured peripherals */ + MX_GPIO_Init(); + MX_DMA_Init(); + MX_QUADSPI_Init(); + MX_DAC1_Init(); + MX_FMC_Init(); + MX_SAI1_Init(); + MX_ADC1_Init(); + MX_I2C1_Init(); + MX_SPI2_Init(); + MX_SPI3_Init(); + MX_SPI6_Init(); + MX_TIM2_Init(); + MX_TIM3_Init(); + MX_TIM4_Init(); + MX_UART5_Init(); + MX_UART7_Init(); + MX_LPTIM1_Init(); + /* USER CODE BEGIN 2 */ + + SDRAM_Initialization_Sequence(&hsdram1); + + /* USER CODE END 2 */ + + /* USER CODE BEGIN RTOS_MUTEX */ + /* add mutexes, ... */ + /* USER CODE END RTOS_MUTEX */ + + /* USER CODE BEGIN RTOS_SEMAPHORES */ + /* add semaphores, ... */ + /* USER CODE END RTOS_SEMAPHORES */ + + /* USER CODE BEGIN RTOS_TIMERS */ + /* start timers, add new ones, ... */ + /* USER CODE END RTOS_TIMERS */ + + /* USER CODE BEGIN RTOS_QUEUES */ + /* add queues, ... */ + /* USER CODE END RTOS_QUEUES */ + + /* Create the thread(s) */ + /* definition and creation of defaultTask */ + osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128); + defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL); + + /* USER CODE BEGIN RTOS_THREADS */ + /* add threads, ... */ + /* USER CODE END RTOS_THREADS */ + + /* Start scheduler */ + osKernelStart(); + + /* We should never get here as control is now taken by the scheduler */ + /* Infinite loop */ + /* USER CODE BEGIN WHILE */ + while (1) + { + /* USER CODE END WHILE */ + + /* USER CODE BEGIN 3 */ + } + /* USER CODE END 3 */ +} + +/** + * @brief System Clock Configuration + * @retval None + */ +void SystemClock_Config(void) +{ + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; + + /** Supply configuration update enable + */ + HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY); + /** Configure the main internal regulator output voltage + */ + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3); + + while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {} + /** Macro to configure the PLL clock source + */ + __HAL_RCC_PLL_PLLSOURCE_CONFIG(RCC_PLLSOURCE_HSE); + /** Initializes the RCC Oscillators according to the specified parameters + * in the RCC_OscInitTypeDef structure. + */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48|RCC_OSCILLATORTYPE_HSI + |RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.HSIState = RCC_HSI_DIV1; + RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; + RCC_OscInitStruct.HSI48State = RCC_HSI48_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 1; + RCC_OscInitStruct.PLL.PLLN = 18; + RCC_OscInitStruct.PLL.PLLP = 2; + RCC_OscInitStruct.PLL.PLLQ = 2; + RCC_OscInitStruct.PLL.PLLR = 2; + RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_3; + RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOMEDIUM; + RCC_OscInitStruct.PLL.PLLFRACN = 6144; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) + { + Error_Handler(); + } + /** Initializes the CPU, AHB and APB buses clocks + */ + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK + |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2 + |RCC_CLOCKTYPE_D3PCLK1|RCC_CLOCKTYPE_D1PCLK1; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV1; + RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2; + RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV1; + RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2; + + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) + { + Error_Handler(); + } +} + +/** + * @brief Peripherals Common Clock Configuration + * @retval None + */ +void PeriphCommonClock_Config(void) +{ + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_CKPER; + PeriphClkInitStruct.CkperClockSelection = RCC_CLKPSOURCE_HSI; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } +} + +/** + * @brief ADC1 Initialization Function + * @param None + * @retval None + */ +static void MX_ADC1_Init(void) +{ + + /* USER CODE BEGIN ADC1_Init 0 */ + + /* USER CODE END ADC1_Init 0 */ + + ADC_MultiModeTypeDef multimode = {0}; + ADC_ChannelConfTypeDef sConfig = {0}; + + /* USER CODE BEGIN ADC1_Init 1 */ + + /* USER CODE END ADC1_Init 1 */ + /** Common config + */ + hadc1.Instance = ADC1; + hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1; + hadc1.Init.Resolution = ADC_RESOLUTION_16B; + hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE; + hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV; + hadc1.Init.LowPowerAutoWait = DISABLE; + hadc1.Init.ContinuousConvMode = DISABLE; + hadc1.Init.NbrOfConversion = 1; + hadc1.Init.DiscontinuousConvMode = DISABLE; + hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START; + hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; + hadc1.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DR; + hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED; + hadc1.Init.LeftBitShift = ADC_LEFTBITSHIFT_NONE; + hadc1.Init.OversamplingMode = DISABLE; + if (HAL_ADC_Init(&hadc1) != HAL_OK) + { + Error_Handler(); + } + /** Configure the ADC multi-mode + */ + multimode.Mode = ADC_MODE_INDEPENDENT; + if (HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK) + { + Error_Handler(); + } + /** Configure Regular Channel + */ + sConfig.Channel = ADC_CHANNEL_4; + sConfig.Rank = ADC_REGULAR_RANK_1; + sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5; + sConfig.SingleDiff = ADC_SINGLE_ENDED; + sConfig.OffsetNumber = ADC_OFFSET_NONE; + sConfig.Offset = 0; + sConfig.OffsetSignedSaturation = DISABLE; + if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN ADC1_Init 2 */ + + /* USER CODE END ADC1_Init 2 */ + +} + +/** + * @brief DAC1 Initialization Function + * @param None + * @retval None + */ +static void MX_DAC1_Init(void) +{ + + /* USER CODE BEGIN DAC1_Init 0 */ + + /* USER CODE END DAC1_Init 0 */ + + DAC_ChannelConfTypeDef sConfig = {0}; + + /* USER CODE BEGIN DAC1_Init 1 */ + + /* USER CODE END DAC1_Init 1 */ + /** DAC Initialization + */ + hdac1.Instance = DAC1; + if (HAL_DAC_Init(&hdac1) != HAL_OK) + { + Error_Handler(); + } + /** DAC channel OUT1 config + */ + sConfig.DAC_SampleAndHold = DAC_SAMPLEANDHOLD_DISABLE; + sConfig.DAC_Trigger = DAC_TRIGGER_NONE; + sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE; + sConfig.DAC_ConnectOnChipPeripheral = DAC_CHIPCONNECT_DISABLE; + sConfig.DAC_UserTrimming = DAC_TRIMMING_FACTORY; + if (HAL_DAC_ConfigChannel(&hdac1, &sConfig, DAC_CHANNEL_1) != HAL_OK) + { + Error_Handler(); + } + /** DAC channel OUT2 config + */ + if (HAL_DAC_ConfigChannel(&hdac1, &sConfig, DAC_CHANNEL_2) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN DAC1_Init 2 */ + + /* USER CODE END DAC1_Init 2 */ + +} + +/** + * @brief I2C1 Initialization Function + * @param None + * @retval None + */ +static void MX_I2C1_Init(void) +{ + + /* USER CODE BEGIN I2C1_Init 0 */ + + /* USER CODE END I2C1_Init 0 */ + + /* USER CODE BEGIN I2C1_Init 1 */ + + /* USER CODE END I2C1_Init 1 */ + hi2c1.Instance = I2C1; + hi2c1.Init.Timing = 0x00909FCE; + hi2c1.Init.OwnAddress1 = 0; + hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; + hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; + hi2c1.Init.OwnAddress2 = 0; + hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK; + hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; + hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; + if (HAL_I2C_Init(&hi2c1) != HAL_OK) + { + Error_Handler(); + } + /** Configure Analogue filter + */ + if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK) + { + Error_Handler(); + } + /** Configure Digital filter + */ + if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN I2C1_Init 2 */ + + /* USER CODE END I2C1_Init 2 */ + +} + +/** + * @brief LPTIM1 Initialization Function + * @param None + * @retval None + */ +static void MX_LPTIM1_Init(void) +{ + + /* USER CODE BEGIN LPTIM1_Init 0 */ + + /* USER CODE END LPTIM1_Init 0 */ + + /* USER CODE BEGIN LPTIM1_Init 1 */ + + /* USER CODE END LPTIM1_Init 1 */ + hlptim1.Instance = LPTIM1; + hlptim1.Init.Clock.Source = LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC; + hlptim1.Init.Clock.Prescaler = LPTIM_PRESCALER_DIV1; + hlptim1.Init.UltraLowPowerClock.Polarity = LPTIM_CLOCKPOLARITY_RISING; + hlptim1.Init.UltraLowPowerClock.SampleTime = LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION; + hlptim1.Init.Trigger.Source = LPTIM_TRIGSOURCE_SOFTWARE; + hlptim1.Init.OutputPolarity = LPTIM_OUTPUTPOLARITY_HIGH; + hlptim1.Init.UpdateMode = LPTIM_UPDATE_IMMEDIATE; + hlptim1.Init.CounterSource = LPTIM_COUNTERSOURCE_EXTERNAL; + hlptim1.Init.Input1Source = LPTIM_INPUT1SOURCE_GPIO; + hlptim1.Init.Input2Source = LPTIM_INPUT2SOURCE_GPIO; + if (HAL_LPTIM_Init(&hlptim1) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN LPTIM1_Init 2 */ + + /* USER CODE END LPTIM1_Init 2 */ + +} + +/** + * @brief QUADSPI Initialization Function + * @param None + * @retval None + */ +static void MX_QUADSPI_Init(void) +{ + + /* USER CODE BEGIN QUADSPI_Init 0 */ + + /* USER CODE END QUADSPI_Init 0 */ + + /* USER CODE BEGIN QUADSPI_Init 1 */ + + /* USER CODE END QUADSPI_Init 1 */ + /* QUADSPI parameter configuration*/ + hqspi.Instance = QUADSPI; + hqspi.Init.ClockPrescaler = 255; + hqspi.Init.FifoThreshold = 1; + hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_NONE; + hqspi.Init.FlashSize = 1; + hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_1_CYCLE; + hqspi.Init.ClockMode = QSPI_CLOCK_MODE_0; + hqspi.Init.FlashID = QSPI_FLASH_ID_1; + hqspi.Init.DualFlash = QSPI_DUALFLASH_DISABLE; + if (HAL_QSPI_Init(&hqspi) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN QUADSPI_Init 2 */ + + /* USER CODE END QUADSPI_Init 2 */ + +} + +/** + * @brief SAI1 Initialization Function + * @param None + * @retval None + */ +static void MX_SAI1_Init(void) +{ + + /* USER CODE BEGIN SAI1_Init 0 */ + + /* USER CODE END SAI1_Init 0 */ + + /* USER CODE BEGIN SAI1_Init 1 */ + + /* USER CODE END SAI1_Init 1 */ + hsai_BlockA1.Instance = SAI1_Block_A; + hsai_BlockA1.Init.Protocol = SAI_FREE_PROTOCOL; + hsai_BlockA1.Init.AudioMode = SAI_MODEMASTER_RX; + hsai_BlockA1.Init.DataSize = SAI_DATASIZE_24; + hsai_BlockA1.Init.FirstBit = SAI_FIRSTBIT_MSB; + hsai_BlockA1.Init.ClockStrobing = SAI_CLOCKSTROBING_FALLINGEDGE; + hsai_BlockA1.Init.Synchro = SAI_ASYNCHRONOUS; + hsai_BlockA1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; + hsai_BlockA1.Init.NoDivider = SAI_MASTERDIVIDER_ENABLE; + hsai_BlockA1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; + hsai_BlockA1.Init.AudioFrequency = SAI_AUDIO_FREQUENCY_48K; + hsai_BlockA1.Init.SynchroExt = SAI_SYNCEXT_DISABLE; + hsai_BlockA1.Init.MonoStereoMode = SAI_STEREOMODE; + hsai_BlockA1.Init.CompandingMode = SAI_NOCOMPANDING; + hsai_BlockA1.Init.PdmInit.Activation = DISABLE; + hsai_BlockA1.Init.PdmInit.MicPairsNbr = 1; + hsai_BlockA1.Init.PdmInit.ClockEnable = SAI_PDM_CLOCK1_ENABLE; + hsai_BlockA1.FrameInit.FrameLength = 256; + hsai_BlockA1.FrameInit.ActiveFrameLength = 1; + hsai_BlockA1.FrameInit.FSDefinition = SAI_FS_STARTFRAME; + hsai_BlockA1.FrameInit.FSPolarity = SAI_FS_ACTIVE_LOW; + hsai_BlockA1.FrameInit.FSOffset = SAI_FS_FIRSTBIT; + hsai_BlockA1.SlotInit.FirstBitOffset = 0; + hsai_BlockA1.SlotInit.SlotSize = SAI_SLOTSIZE_32B; + hsai_BlockA1.SlotInit.SlotNumber = 8; + hsai_BlockA1.SlotInit.SlotActive = 0x00000000; + if (HAL_SAI_Init(&hsai_BlockA1) != HAL_OK) + { + Error_Handler(); + } + hsai_BlockB1.Instance = SAI1_Block_B; + hsai_BlockB1.Init.Protocol = SAI_FREE_PROTOCOL; + hsai_BlockB1.Init.AudioMode = SAI_MODESLAVE_TX; + hsai_BlockB1.Init.DataSize = SAI_DATASIZE_24; + hsai_BlockB1.Init.FirstBit = SAI_FIRSTBIT_MSB; + hsai_BlockB1.Init.ClockStrobing = SAI_CLOCKSTROBING_FALLINGEDGE; + hsai_BlockB1.Init.Synchro = SAI_SYNCHRONOUS; + hsai_BlockB1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; + hsai_BlockB1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; + hsai_BlockB1.Init.SynchroExt = SAI_SYNCEXT_DISABLE; + hsai_BlockB1.Init.MonoStereoMode = SAI_STEREOMODE; + hsai_BlockB1.Init.CompandingMode = SAI_NOCOMPANDING; + hsai_BlockB1.Init.TriState = SAI_OUTPUT_NOTRELEASED; + hsai_BlockB1.Init.PdmInit.Activation = DISABLE; + hsai_BlockB1.Init.PdmInit.MicPairsNbr = 1; + hsai_BlockB1.Init.PdmInit.ClockEnable = SAI_PDM_CLOCK1_ENABLE; + hsai_BlockB1.FrameInit.FrameLength = 256; + hsai_BlockB1.FrameInit.ActiveFrameLength = 1; + hsai_BlockB1.FrameInit.FSDefinition = SAI_FS_STARTFRAME; + hsai_BlockB1.FrameInit.FSPolarity = SAI_FS_ACTIVE_LOW; + hsai_BlockB1.FrameInit.FSOffset = SAI_FS_FIRSTBIT; + hsai_BlockB1.SlotInit.FirstBitOffset = 0; + hsai_BlockB1.SlotInit.SlotSize = SAI_SLOTSIZE_32B; + hsai_BlockB1.SlotInit.SlotNumber = 8; + hsai_BlockB1.SlotInit.SlotActive = 0x00000000; + if (HAL_SAI_Init(&hsai_BlockB1) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN SAI1_Init 2 */ + + /* USER CODE END SAI1_Init 2 */ + +} + +/** + * @brief SPI2 Initialization Function + * @param None + * @retval None + */ +static void MX_SPI2_Init(void) +{ + + /* USER CODE BEGIN SPI2_Init 0 */ + + /* USER CODE END SPI2_Init 0 */ + + /* USER CODE BEGIN SPI2_Init 1 */ + + /* USER CODE END SPI2_Init 1 */ + /* SPI2 parameter configuration*/ + hspi2.Instance = SPI2; + hspi2.Init.Mode = SPI_MODE_MASTER; + hspi2.Init.Direction = SPI_DIRECTION_2LINES; + hspi2.Init.DataSize = SPI_DATASIZE_4BIT; + hspi2.Init.CLKPolarity = SPI_POLARITY_LOW; + hspi2.Init.CLKPhase = SPI_PHASE_1EDGE; + hspi2.Init.NSS = SPI_NSS_SOFT; + hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64; + hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB; + hspi2.Init.TIMode = SPI_TIMODE_DISABLE; + hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; + hspi2.Init.CRCPolynomial = 0x0; + hspi2.Init.NSSPMode = SPI_NSS_PULSE_ENABLE; + hspi2.Init.NSSPolarity = SPI_NSS_POLARITY_LOW; + hspi2.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA; + hspi2.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; + hspi2.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; + hspi2.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE; + hspi2.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE; + hspi2.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE; + hspi2.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE; + hspi2.Init.IOSwap = SPI_IO_SWAP_DISABLE; + if (HAL_SPI_Init(&hspi2) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN SPI2_Init 2 */ + + /* USER CODE END SPI2_Init 2 */ + +} + +/** + * @brief SPI3 Initialization Function + * @param None + * @retval None + */ +static void MX_SPI3_Init(void) +{ + + /* USER CODE BEGIN SPI3_Init 0 */ + + /* USER CODE END SPI3_Init 0 */ + + /* USER CODE BEGIN SPI3_Init 1 */ + + /* USER CODE END SPI3_Init 1 */ + /* SPI3 parameter configuration*/ + hspi3.Instance = SPI3; + hspi3.Init.Mode = SPI_MODE_MASTER; + hspi3.Init.Direction = SPI_DIRECTION_2LINES; + hspi3.Init.DataSize = SPI_DATASIZE_8BIT; + hspi3.Init.CLKPolarity = SPI_POLARITY_LOW; + hspi3.Init.CLKPhase = SPI_PHASE_1EDGE; + hspi3.Init.NSS = SPI_NSS_SOFT; + hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64; + hspi3.Init.FirstBit = SPI_FIRSTBIT_MSB; + hspi3.Init.TIMode = SPI_TIMODE_DISABLE; + hspi3.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; + hspi3.Init.CRCPolynomial = 0x0; + hspi3.Init.NSSPMode = SPI_NSS_PULSE_ENABLE; + hspi3.Init.NSSPolarity = SPI_NSS_POLARITY_LOW; + hspi3.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA; + hspi3.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; + hspi3.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; + hspi3.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE; + hspi3.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE; + hspi3.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE; + hspi3.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE; + hspi3.Init.IOSwap = SPI_IO_SWAP_DISABLE; + if (HAL_SPI_Init(&hspi3) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN SPI3_Init 2 */ + + /* USER CODE END SPI3_Init 2 */ + +} + +/** + * @brief SPI6 Initialization Function + * @param None + * @retval None + */ +static void MX_SPI6_Init(void) +{ + + /* USER CODE BEGIN SPI6_Init 0 */ + + /* USER CODE END SPI6_Init 0 */ + + /* USER CODE BEGIN SPI6_Init 1 */ + + /* USER CODE END SPI6_Init 1 */ + /* SPI6 parameter configuration*/ + hspi6.Instance = SPI6; + hspi6.Init.Mode = SPI_MODE_MASTER; + hspi6.Init.Direction = SPI_DIRECTION_2LINES; + hspi6.Init.DataSize = SPI_DATASIZE_4BIT; + hspi6.Init.CLKPolarity = SPI_POLARITY_LOW; + hspi6.Init.CLKPhase = SPI_PHASE_1EDGE; + hspi6.Init.NSS = SPI_NSS_SOFT; + hspi6.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2; + hspi6.Init.FirstBit = SPI_FIRSTBIT_MSB; + hspi6.Init.TIMode = SPI_TIMODE_DISABLE; + hspi6.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; + hspi6.Init.CRCPolynomial = 0x0; + hspi6.Init.NSSPMode = SPI_NSS_PULSE_ENABLE; + hspi6.Init.NSSPolarity = SPI_NSS_POLARITY_LOW; + hspi6.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA; + hspi6.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; + hspi6.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; + hspi6.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE; + hspi6.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE; + hspi6.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE; + hspi6.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE; + hspi6.Init.IOSwap = SPI_IO_SWAP_DISABLE; + if (HAL_SPI_Init(&hspi6) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN SPI6_Init 2 */ + + /* USER CODE END SPI6_Init 2 */ + +} + +/** + * @brief TIM2 Initialization Function + * @param None + * @retval None + */ +static void MX_TIM2_Init(void) +{ + + /* USER CODE BEGIN TIM2_Init 0 */ + + /* USER CODE END TIM2_Init 0 */ + + TIM_Encoder_InitTypeDef sConfig = {0}; + TIM_MasterConfigTypeDef sMasterConfig = {0}; + + /* USER CODE BEGIN TIM2_Init 1 */ + + /* USER CODE END TIM2_Init 1 */ + htim2.Instance = TIM2; + htim2.Init.Prescaler = 0; + htim2.Init.CounterMode = TIM_COUNTERMODE_UP; + htim2.Init.Period = 4294967295; + htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; + htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; + sConfig.EncoderMode = TIM_ENCODERMODE_TI1; + sConfig.IC1Polarity = TIM_ICPOLARITY_RISING; + sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI; + sConfig.IC1Prescaler = TIM_ICPSC_DIV1; + sConfig.IC1Filter = 0; + sConfig.IC2Polarity = TIM_ICPOLARITY_RISING; + sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI; + sConfig.IC2Prescaler = TIM_ICPSC_DIV1; + sConfig.IC2Filter = 0; + if (HAL_TIM_Encoder_Init(&htim2, &sConfig) != HAL_OK) + { + Error_Handler(); + } + sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; + sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; + if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN TIM2_Init 2 */ + + /* USER CODE END TIM2_Init 2 */ + +} + +/** + * @brief TIM3 Initialization Function + * @param None + * @retval None + */ +static void MX_TIM3_Init(void) +{ + + /* USER CODE BEGIN TIM3_Init 0 */ + + /* USER CODE END TIM3_Init 0 */ + + TIM_Encoder_InitTypeDef sConfig = {0}; + TIM_MasterConfigTypeDef sMasterConfig = {0}; + + /* USER CODE BEGIN TIM3_Init 1 */ + + /* USER CODE END TIM3_Init 1 */ + htim3.Instance = TIM3; + htim3.Init.Prescaler = 0; + htim3.Init.CounterMode = TIM_COUNTERMODE_UP; + htim3.Init.Period = 65535; + htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; + htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; + sConfig.EncoderMode = TIM_ENCODERMODE_TI1; + sConfig.IC1Polarity = TIM_ICPOLARITY_RISING; + sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI; + sConfig.IC1Prescaler = TIM_ICPSC_DIV1; + sConfig.IC1Filter = 0; + sConfig.IC2Polarity = TIM_ICPOLARITY_RISING; + sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI; + sConfig.IC2Prescaler = TIM_ICPSC_DIV1; + sConfig.IC2Filter = 0; + if (HAL_TIM_Encoder_Init(&htim3, &sConfig) != HAL_OK) + { + Error_Handler(); + } + sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; + sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; + if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN TIM3_Init 2 */ + + /* USER CODE END TIM3_Init 2 */ + +} + +/** + * @brief TIM4 Initialization Function + * @param None + * @retval None + */ +static void MX_TIM4_Init(void) +{ + + /* USER CODE BEGIN TIM4_Init 0 */ + + /* USER CODE END TIM4_Init 0 */ + + TIM_Encoder_InitTypeDef sConfig = {0}; + TIM_MasterConfigTypeDef sMasterConfig = {0}; + + /* USER CODE BEGIN TIM4_Init 1 */ + + /* USER CODE END TIM4_Init 1 */ + htim4.Instance = TIM4; + htim4.Init.Prescaler = 0; + htim4.Init.CounterMode = TIM_COUNTERMODE_UP; + htim4.Init.Period = 65535; + htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; + htim4.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; + sConfig.EncoderMode = TIM_ENCODERMODE_TI1; + sConfig.IC1Polarity = TIM_ICPOLARITY_RISING; + sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI; + sConfig.IC1Prescaler = TIM_ICPSC_DIV1; + sConfig.IC1Filter = 0; + sConfig.IC2Polarity = TIM_ICPOLARITY_RISING; + sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI; + sConfig.IC2Prescaler = TIM_ICPSC_DIV1; + sConfig.IC2Filter = 0; + if (HAL_TIM_Encoder_Init(&htim4, &sConfig) != HAL_OK) + { + Error_Handler(); + } + sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; + sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; + if (HAL_TIMEx_MasterConfigSynchronization(&htim4, &sMasterConfig) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN TIM4_Init 2 */ + + /* USER CODE END TIM4_Init 2 */ + +} + +/** + * @brief UART5 Initialization Function + * @param None + * @retval None + */ +static void MX_UART5_Init(void) +{ + + /* USER CODE BEGIN UART5_Init 0 */ + + /* USER CODE END UART5_Init 0 */ + + /* USER CODE BEGIN UART5_Init 1 */ + + /* USER CODE END UART5_Init 1 */ + huart5.Instance = UART5; + huart5.Init.BaudRate = 115200; + huart5.Init.WordLength = UART_WORDLENGTH_8B; + huart5.Init.StopBits = UART_STOPBITS_1; + huart5.Init.Parity = UART_PARITY_NONE; + huart5.Init.Mode = UART_MODE_TX_RX; + huart5.Init.HwFlowCtl = UART_HWCONTROL_NONE; + huart5.Init.OverSampling = UART_OVERSAMPLING_16; + huart5.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; + huart5.Init.ClockPrescaler = UART_PRESCALER_DIV1; + huart5.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; + if (HAL_UART_Init(&huart5) != HAL_OK) + { + Error_Handler(); + } + if (HAL_UARTEx_SetTxFifoThreshold(&huart5, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK) + { + Error_Handler(); + } + if (HAL_UARTEx_SetRxFifoThreshold(&huart5, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK) + { + Error_Handler(); + } + if (HAL_UARTEx_DisableFifoMode(&huart5) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN UART5_Init 2 */ + + /* USER CODE END UART5_Init 2 */ + +} + +/** + * @brief UART7 Initialization Function + * @param None + * @retval None + */ +static void MX_UART7_Init(void) +{ + + /* USER CODE BEGIN UART7_Init 0 */ + + /* USER CODE END UART7_Init 0 */ + + /* USER CODE BEGIN UART7_Init 1 */ + + /* USER CODE END UART7_Init 1 */ + huart7.Instance = UART7; + huart7.Init.BaudRate = 115200; + huart7.Init.WordLength = UART_WORDLENGTH_8B; + huart7.Init.StopBits = UART_STOPBITS_1; + huart7.Init.Parity = UART_PARITY_NONE; + huart7.Init.Mode = UART_MODE_TX_RX; + huart7.Init.HwFlowCtl = UART_HWCONTROL_NONE; + huart7.Init.OverSampling = UART_OVERSAMPLING_16; + huart7.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; + huart7.Init.ClockPrescaler = UART_PRESCALER_DIV1; + huart7.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; + if (HAL_UART_Init(&huart7) != HAL_OK) + { + Error_Handler(); + } + if (HAL_UARTEx_SetTxFifoThreshold(&huart7, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK) + { + Error_Handler(); + } + if (HAL_UARTEx_SetRxFifoThreshold(&huart7, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK) + { + Error_Handler(); + } + if (HAL_UARTEx_DisableFifoMode(&huart7) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN UART7_Init 2 */ + + /* USER CODE END UART7_Init 2 */ + +} + +/** + * Enable DMA controller clock + */ +static void MX_DMA_Init(void) +{ + + /* DMA controller clock enable */ + __HAL_RCC_DMA1_CLK_ENABLE(); + + /* DMA interrupt init */ + /* DMA1_Stream0_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA1_Stream0_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA1_Stream0_IRQn); + /* DMA1_Stream1_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA1_Stream1_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA1_Stream1_IRQn); + +} + +/* FMC initialization function */ +static void MX_FMC_Init(void) +{ + + /* USER CODE BEGIN FMC_Init 0 */ + + /* USER CODE END FMC_Init 0 */ + + FMC_SDRAM_TimingTypeDef SdramTiming = {0}; + + /* USER CODE BEGIN FMC_Init 1 */ + + /* USER CODE END FMC_Init 1 */ + + /** Perform the SDRAM1 memory initialization sequence + */ + hsdram1.Instance = FMC_SDRAM_DEVICE; + /* hsdram1.Init */ + hsdram1.Init.SDBank = FMC_SDRAM_BANK1; + hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8; + hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_13; + hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_32; + hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4; + hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_1; + hsdram1.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE; + hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_DISABLE; + hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_DISABLE; + hsdram1.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0; + /* SdramTiming */ + SdramTiming.LoadToActiveDelay = 16; + SdramTiming.ExitSelfRefreshDelay = 16; + SdramTiming.SelfRefreshTime = 16; + SdramTiming.RowCycleDelay = 16; + SdramTiming.WriteRecoveryTime = 16; + SdramTiming.RPDelay = 16; + SdramTiming.RCDDelay = 16; + + if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK) + { + Error_Handler( ); + } + + /* USER CODE BEGIN FMC_Init 2 */ + + /* USER CODE END FMC_Init 2 */ +} + +/** + * @brief GPIO Initialization Function + * @param None + * @retval None + */ +static void MX_GPIO_Init(void) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + + /* GPIO Ports Clock Enable */ + __HAL_RCC_GPIOE_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + __HAL_RCC_GPIOG_CLK_ENABLE(); + __HAL_RCC_GPIOD_CLK_ENABLE(); + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOI_CLK_ENABLE(); + __HAL_RCC_GPIOH_CLK_ENABLE(); + __HAL_RCC_GPIOF_CLK_ENABLE(); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(ADC_RST_GPIO_Port, ADC_RST_Pin, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(ADC_SPI_NCS_GPIO_Port, ADC_SPI_NCS_Pin, GPIO_PIN_RESET); + + /*Configure GPIO pins : PD7 PD6 PD5 PD4 + PD3 PD11 */ + GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_6|GPIO_PIN_5|GPIO_PIN_4 + |GPIO_PIN_3|GPIO_PIN_11; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + /*Configure GPIO pins : PB9 PB2 PB12 */ + GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_2|GPIO_PIN_12; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /*Configure GPIO pin : EXTI10_Pin */ + GPIO_InitStruct.Pin = EXTI10_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(EXTI10_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pin : PG9 */ + GPIO_InitStruct.Pin = GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + + /*Configure GPIO pins : EXTI13_Pin EXTI14_Pin EXTI15_Pin PC9 + PC8 */ + GPIO_InitStruct.Pin = EXTI13_Pin|EXTI14_Pin|EXTI15_Pin|GPIO_PIN_9 + |GPIO_PIN_8; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /*Configure GPIO pin : PI8 */ + GPIO_InitStruct.Pin = GPIO_PIN_8; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); + + /*Configure GPIO pin : PD2 */ + GPIO_InitStruct.Pin = GPIO_PIN_2; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + /*Configure GPIO pin : PA10 */ + GPIO_InitStruct.Pin = GPIO_PIN_10; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /*Configure GPIO pin : EXTI11_Pin */ + GPIO_InitStruct.Pin = EXTI11_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(EXTI11_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pin : EXTI4_Pin */ + GPIO_InitStruct.Pin = EXTI4_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(EXTI4_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pin : ADC_RST_Pin */ + GPIO_InitStruct.Pin = ADC_RST_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(ADC_RST_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pins : PH6 PH7 */ + GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); + + /*Configure GPIO pins : EXTI0_Pin EXTI3_Pin EXTI7_Pin */ + GPIO_InitStruct.Pin = EXTI0_Pin|EXTI3_Pin|EXTI7_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /*Configure GPIO pin : ADC_SPI_NCS_Pin */ + GPIO_InitStruct.Pin = ADC_SPI_NCS_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(ADC_SPI_NCS_GPIO_Port, &GPIO_InitStruct); + +} + +/* USER CODE BEGIN 4 */ + +/* USER CODE END 4 */ + +/* USER CODE BEGIN Header_StartDefaultTask */ +/** + * @brief Function implementing the defaultTask thread. + * @param argument: Not used + * @retval None + */ +#if 0 +/* USER CODE END Header_StartDefaultTask */ +void StartDefaultTask(void const * argument) +{ + /* init code for USB_HOST */ + MX_USB_HOST_Init(); + + /* init code for USB_DEVICE */ + MX_USB_DEVICE_Init(); + /* USER CODE BEGIN 5 */ +#else +void StartDefaultTask(void const * argument) +{ + /* NOTE: we get frequent boot failures if host is called first */ + MX_USB_DEVICE_Init(); + +#ifdef USE_USB_HOST + /* init code for USB_HOST */ + MX_USB_HOST_Init(); +#endif + + setup(); + + /* Infinite loop */ + for(;;) + { + loop(); + } +#endif + /* USER CODE END 5 */ +} + +/** + * @brief This function is executed in case of error occurrence. + * @retval None + */ +void Error_Handler(void) +{ + /* USER CODE BEGIN Error_Handler_Debug */ + /* User can add his own implementation to report the HAL error return state */ + __disable_irq(); + while (1) + { + } + /* USER CODE END Error_Handler_Debug */ +} + +#ifdef USE_FULL_ASSERT +/** + * @brief Reports the name of the source file and the source line number + * where the assert_param error has occurred. + * @param file: pointer to the source file name + * @param line: assert_param error line source number + * @retval None + */ +void assert_failed(uint8_t *file, uint32_t line) +{ + /* USER CODE BEGIN 6 */ + /* User can add his own implementation to report the file name and line number, + ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ + /* USER CODE END 6 */ +} +#endif /* USE_FULL_ASSERT */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/Core/Src/startup_stm32h743xx.s b/Xibeca/Core/Src/startup_stm32h743xx.s new file mode 100644 index 00000000..2b1034a6 --- /dev/null +++ b/Xibeca/Core/Src/startup_stm32h743xx.s @@ -0,0 +1,749 @@ +/** + ****************************************************************************** + * @file startup_stm32h743xx.s + * @author MCD Application Team + * @brief STM32H743xx Devices vector table for GCC based toolchain. + * This module performs: + * - Set the initial SP + * - Set the initial PC == Reset_Handler, + * - Set the vector table entries with the exceptions ISR address + * - Branches to main in the C library (which eventually + * calls main()). + * After Reset the Cortex-M processor is in Thread mode, + * priority is Privileged, and the Stack is set to Main. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + + .syntax unified + .cpu cortex-m7 + .fpu softvfp + .thumb + +.global g_pfnVectors +.global Default_Handler + +/* start address for the initialization values of the .data section. +defined in linker script */ +.word _sidata +/* start address for the .data section. defined in linker script */ +.word _sdata +/* end address for the .data section. defined in linker script */ +.word _edata +/* start address for the .bss section. defined in linker script */ +.word _sbss +/* end address for the .bss section. defined in linker script */ +.word _ebss +/* stack used for SystemInit_ExtMemCtl; always internal RAM used */ + +/** + * @brief This is the code that gets called when the processor first + * starts execution following a reset event. Only the absolutely + * necessary set is performed, after which the application + * supplied main() routine is called. + * @param None + * @retval : None +*/ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + ldr sp, =_estack /* set stack pointer */ + +/* Call the clock system intitialization function.*/ + bl SystemInit + +/* Copy the data segment initializers from flash to SRAM */ + movs r1, #0 + b LoopCopyDataInit + +CopyDataInit: + ldr r3, =_sidata + ldr r3, [r3, r1] + str r3, [r0, r1] + adds r1, r1, #4 + +LoopCopyDataInit: + ldr r0, =_sdata + ldr r3, =_edata + adds r2, r0, r1 + cmp r2, r3 + bcc CopyDataInit + ldr r2, =_sbss + b LoopFillZerobss +/* Zero fill the bss segment. */ +FillZerobss: + movs r3, #0 + str r3, [r2], #4 + +LoopFillZerobss: + ldr r3, = _ebss + cmp r2, r3 + bcc FillZerobss + +/* Call static constructors */ + bl __libc_init_array +/* Call the application's entry point.*/ + bl main + bx lr +.size Reset_Handler, .-Reset_Handler + +/** + * @brief This is the code that gets called when the processor receives an + * unexpected interrupt. This simply enters an infinite loop, preserving + * the system state for examination by a debugger. + * @param None + * @retval None +*/ + .section .text.Default_Handler,"ax",%progbits +Default_Handler: +Infinite_Loop: + b Infinite_Loop + .size Default_Handler, .-Default_Handler +/****************************************************************************** +* +* The minimal vector table for a Cortex M. Note that the proper constructs +* must be placed on this to ensure that it ends up at physical address +* 0x0000.0000. +* +*******************************************************************************/ + .section .isr_vector,"a",%progbits + .type g_pfnVectors, %object + .size g_pfnVectors, .-g_pfnVectors + + +g_pfnVectors: + .word _estack + .word Reset_Handler + + .word NMI_Handler + .word HardFault_Handler + .word MemManage_Handler + .word BusFault_Handler + .word UsageFault_Handler + .word 0 + .word 0 + .word 0 + .word 0 + .word SVC_Handler + .word DebugMon_Handler + .word 0 + .word PendSV_Handler + .word SysTick_Handler + + /* External Interrupts */ + .word WWDG_IRQHandler /* Window WatchDog */ + .word PVD_AVD_IRQHandler /* PVD/AVD through EXTI Line detection */ + .word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */ + .word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */ + .word FLASH_IRQHandler /* FLASH */ + .word RCC_IRQHandler /* RCC */ + .word EXTI0_IRQHandler /* EXTI Line0 */ + .word EXTI1_IRQHandler /* EXTI Line1 */ + .word EXTI2_IRQHandler /* EXTI Line2 */ + .word EXTI3_IRQHandler /* EXTI Line3 */ + .word EXTI4_IRQHandler /* EXTI Line4 */ + .word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */ + .word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */ + .word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */ + .word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */ + .word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */ + .word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */ + .word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */ + .word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */ + .word FDCAN1_IT0_IRQHandler /* FDCAN1 interrupt line 0 */ + .word FDCAN2_IT0_IRQHandler /* FDCAN2 interrupt line 0 */ + .word FDCAN1_IT1_IRQHandler /* FDCAN1 interrupt line 1 */ + .word FDCAN2_IT1_IRQHandler /* FDCAN2 interrupt line 1 */ + .word EXTI9_5_IRQHandler /* External Line[9:5]s */ + .word TIM1_BRK_IRQHandler /* TIM1 Break interrupt */ + .word TIM1_UP_IRQHandler /* TIM1 Update interrupt */ + .word TIM1_TRG_COM_IRQHandler /* TIM1 Trigger and Commutation interrupt */ + .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */ + .word TIM2_IRQHandler /* TIM2 */ + .word TIM3_IRQHandler /* TIM3 */ + .word TIM4_IRQHandler /* TIM4 */ + .word I2C1_EV_IRQHandler /* I2C1 Event */ + .word I2C1_ER_IRQHandler /* I2C1 Error */ + .word I2C2_EV_IRQHandler /* I2C2 Event */ + .word I2C2_ER_IRQHandler /* I2C2 Error */ + .word SPI1_IRQHandler /* SPI1 */ + .word SPI2_IRQHandler /* SPI2 */ + .word USART1_IRQHandler /* USART1 */ + .word USART2_IRQHandler /* USART2 */ + .word USART3_IRQHandler /* USART3 */ + .word EXTI15_10_IRQHandler /* External Line[15:10]s */ + .word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */ + .word 0 /* Reserved */ + .word TIM8_BRK_TIM12_IRQHandler /* TIM8 Break and TIM12 */ + .word TIM8_UP_TIM13_IRQHandler /* TIM8 Update and TIM13 */ + .word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */ + .word TIM8_CC_IRQHandler /* TIM8 Capture Compare */ + .word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */ + .word FMC_IRQHandler /* FMC */ + .word SDMMC1_IRQHandler /* SDMMC1 */ + .word TIM5_IRQHandler /* TIM5 */ + .word SPI3_IRQHandler /* SPI3 */ + .word UART4_IRQHandler /* UART4 */ + .word UART5_IRQHandler /* UART5 */ + .word TIM6_DAC_IRQHandler /* TIM6 and DAC1&2 underrun errors */ + .word TIM7_IRQHandler /* TIM7 */ + .word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */ + .word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */ + .word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */ + .word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */ + .word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */ + .word ETH_IRQHandler /* Ethernet */ + .word ETH_WKUP_IRQHandler /* Ethernet Wakeup through EXTI line */ + .word FDCAN_CAL_IRQHandler /* FDCAN calibration unit interrupt*/ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */ + .word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */ + .word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */ + .word USART6_IRQHandler /* USART6 */ + .word I2C3_EV_IRQHandler /* I2C3 event */ + .word I2C3_ER_IRQHandler /* I2C3 error */ + .word OTG_HS_EP1_OUT_IRQHandler /* USB OTG HS End Point 1 Out */ + .word OTG_HS_EP1_IN_IRQHandler /* USB OTG HS End Point 1 In */ + .word OTG_HS_WKUP_IRQHandler /* USB OTG HS Wakeup through EXTI */ + .word OTG_HS_IRQHandler /* USB OTG HS */ + .word DCMI_IRQHandler /* DCMI */ + .word 0 /* Reserved */ + .word RNG_IRQHandler /* Rng */ + .word FPU_IRQHandler /* FPU */ + .word UART7_IRQHandler /* UART7 */ + .word UART8_IRQHandler /* UART8 */ + .word SPI4_IRQHandler /* SPI4 */ + .word SPI5_IRQHandler /* SPI5 */ + .word SPI6_IRQHandler /* SPI6 */ + .word SAI1_IRQHandler /* SAI1 */ + .word LTDC_IRQHandler /* LTDC */ + .word LTDC_ER_IRQHandler /* LTDC error */ + .word DMA2D_IRQHandler /* DMA2D */ + .word SAI2_IRQHandler /* SAI2 */ + .word QUADSPI_IRQHandler /* QUADSPI */ + .word LPTIM1_IRQHandler /* LPTIM1 */ + .word CEC_IRQHandler /* HDMI_CEC */ + .word I2C4_EV_IRQHandler /* I2C4 Event */ + .word I2C4_ER_IRQHandler /* I2C4 Error */ + .word SPDIF_RX_IRQHandler /* SPDIF_RX */ + .word OTG_FS_EP1_OUT_IRQHandler /* USB OTG FS End Point 1 Out */ + .word OTG_FS_EP1_IN_IRQHandler /* USB OTG FS End Point 1 In */ + .word OTG_FS_WKUP_IRQHandler /* USB OTG FS Wakeup through EXTI */ + .word OTG_FS_IRQHandler /* USB OTG FS */ + .word DMAMUX1_OVR_IRQHandler /* DMAMUX1 Overrun interrupt */ + .word HRTIM1_Master_IRQHandler /* HRTIM Master Timer global Interrupt */ + .word HRTIM1_TIMA_IRQHandler /* HRTIM Timer A global Interrupt */ + .word HRTIM1_TIMB_IRQHandler /* HRTIM Timer B global Interrupt */ + .word HRTIM1_TIMC_IRQHandler /* HRTIM Timer C global Interrupt */ + .word HRTIM1_TIMD_IRQHandler /* HRTIM Timer D global Interrupt */ + .word HRTIM1_TIME_IRQHandler /* HRTIM Timer E global Interrupt */ + .word HRTIM1_FLT_IRQHandler /* HRTIM Fault global Interrupt */ + .word DFSDM1_FLT0_IRQHandler /* DFSDM Filter0 Interrupt */ + .word DFSDM1_FLT1_IRQHandler /* DFSDM Filter1 Interrupt */ + .word DFSDM1_FLT2_IRQHandler /* DFSDM Filter2 Interrupt */ + .word DFSDM1_FLT3_IRQHandler /* DFSDM Filter3 Interrupt */ + .word SAI3_IRQHandler /* SAI3 global Interrupt */ + .word SWPMI1_IRQHandler /* Serial Wire Interface 1 global interrupt */ + .word TIM15_IRQHandler /* TIM15 global Interrupt */ + .word TIM16_IRQHandler /* TIM16 global Interrupt */ + .word TIM17_IRQHandler /* TIM17 global Interrupt */ + .word MDIOS_WKUP_IRQHandler /* MDIOS Wakeup Interrupt */ + .word MDIOS_IRQHandler /* MDIOS global Interrupt */ + .word JPEG_IRQHandler /* JPEG global Interrupt */ + .word MDMA_IRQHandler /* MDMA global Interrupt */ + .word 0 /* Reserved */ + .word SDMMC2_IRQHandler /* SDMMC2 global Interrupt */ + .word HSEM1_IRQHandler /* HSEM1 global Interrupt */ + .word 0 /* Reserved */ + .word ADC3_IRQHandler /* ADC3 global Interrupt */ + .word DMAMUX2_OVR_IRQHandler /* DMAMUX Overrun interrupt */ + .word BDMA_Channel0_IRQHandler /* BDMA Channel 0 global Interrupt */ + .word BDMA_Channel1_IRQHandler /* BDMA Channel 1 global Interrupt */ + .word BDMA_Channel2_IRQHandler /* BDMA Channel 2 global Interrupt */ + .word BDMA_Channel3_IRQHandler /* BDMA Channel 3 global Interrupt */ + .word BDMA_Channel4_IRQHandler /* BDMA Channel 4 global Interrupt */ + .word BDMA_Channel5_IRQHandler /* BDMA Channel 5 global Interrupt */ + .word BDMA_Channel6_IRQHandler /* BDMA Channel 6 global Interrupt */ + .word BDMA_Channel7_IRQHandler /* BDMA Channel 7 global Interrupt */ + .word COMP1_IRQHandler /* COMP1 global Interrupt */ + .word LPTIM2_IRQHandler /* LP TIM2 global interrupt */ + .word LPTIM3_IRQHandler /* LP TIM3 global interrupt */ + .word LPTIM4_IRQHandler /* LP TIM4 global interrupt */ + .word LPTIM5_IRQHandler /* LP TIM5 global interrupt */ + .word LPUART1_IRQHandler /* LP UART1 interrupt */ + .word 0 /* Reserved */ + .word CRS_IRQHandler /* Clock Recovery Global Interrupt */ + .word ECC_IRQHandler /* ECC diagnostic Global Interrupt */ + .word SAI4_IRQHandler /* SAI4 global interrupt */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word WAKEUP_PIN_IRQHandler /* Interrupt for all 6 wake-up pins */ + +/******************************************************************************* +* +* Provide weak aliases for each Exception handler to the Default_Handler. +* As they are weak aliases, any function with the same name will override +* this definition. +* +*******************************************************************************/ + .weak NMI_Handler + .thumb_set NMI_Handler,Default_Handler + + .weak HardFault_Handler + .thumb_set HardFault_Handler,Default_Handler + + .weak MemManage_Handler + .thumb_set MemManage_Handler,Default_Handler + + .weak BusFault_Handler + .thumb_set BusFault_Handler,Default_Handler + + .weak UsageFault_Handler + .thumb_set UsageFault_Handler,Default_Handler + + .weak SVC_Handler + .thumb_set SVC_Handler,Default_Handler + + .weak DebugMon_Handler + .thumb_set DebugMon_Handler,Default_Handler + + .weak PendSV_Handler + .thumb_set PendSV_Handler,Default_Handler + + .weak SysTick_Handler + .thumb_set SysTick_Handler,Default_Handler + + .weak WWDG_IRQHandler + .thumb_set WWDG_IRQHandler,Default_Handler + + .weak PVD_AVD_IRQHandler + .thumb_set PVD_AVD_IRQHandler,Default_Handler + + .weak TAMP_STAMP_IRQHandler + .thumb_set TAMP_STAMP_IRQHandler,Default_Handler + + .weak RTC_WKUP_IRQHandler + .thumb_set RTC_WKUP_IRQHandler,Default_Handler + + .weak FLASH_IRQHandler + .thumb_set FLASH_IRQHandler,Default_Handler + + .weak RCC_IRQHandler + .thumb_set RCC_IRQHandler,Default_Handler + + .weak EXTI0_IRQHandler + .thumb_set EXTI0_IRQHandler,Default_Handler + + .weak EXTI1_IRQHandler + .thumb_set EXTI1_IRQHandler,Default_Handler + + .weak EXTI2_IRQHandler + .thumb_set EXTI2_IRQHandler,Default_Handler + + .weak EXTI3_IRQHandler + .thumb_set EXTI3_IRQHandler,Default_Handler + + .weak EXTI4_IRQHandler + .thumb_set EXTI4_IRQHandler,Default_Handler + + .weak DMA1_Stream0_IRQHandler + .thumb_set DMA1_Stream0_IRQHandler,Default_Handler + + .weak DMA1_Stream1_IRQHandler + .thumb_set DMA1_Stream1_IRQHandler,Default_Handler + + .weak DMA1_Stream2_IRQHandler + .thumb_set DMA1_Stream2_IRQHandler,Default_Handler + + .weak DMA1_Stream3_IRQHandler + .thumb_set DMA1_Stream3_IRQHandler,Default_Handler + + .weak DMA1_Stream4_IRQHandler + .thumb_set DMA1_Stream4_IRQHandler,Default_Handler + + .weak DMA1_Stream5_IRQHandler + .thumb_set DMA1_Stream5_IRQHandler,Default_Handler + + .weak DMA1_Stream6_IRQHandler + .thumb_set DMA1_Stream6_IRQHandler,Default_Handler + + .weak ADC_IRQHandler + .thumb_set ADC_IRQHandler,Default_Handler + + .weak FDCAN1_IT0_IRQHandler + .thumb_set FDCAN1_IT0_IRQHandler,Default_Handler + + .weak FDCAN2_IT0_IRQHandler + .thumb_set FDCAN2_IT0_IRQHandler,Default_Handler + + .weak FDCAN1_IT1_IRQHandler + .thumb_set FDCAN1_IT1_IRQHandler,Default_Handler + + .weak FDCAN2_IT1_IRQHandler + .thumb_set FDCAN2_IT1_IRQHandler,Default_Handler + + .weak EXTI9_5_IRQHandler + .thumb_set EXTI9_5_IRQHandler,Default_Handler + + .weak TIM1_BRK_IRQHandler + .thumb_set TIM1_BRK_IRQHandler,Default_Handler + + .weak TIM1_UP_IRQHandler + .thumb_set TIM1_UP_IRQHandler,Default_Handler + + .weak TIM1_TRG_COM_IRQHandler + .thumb_set TIM1_TRG_COM_IRQHandler,Default_Handler + + .weak TIM1_CC_IRQHandler + .thumb_set TIM1_CC_IRQHandler,Default_Handler + + .weak TIM2_IRQHandler + .thumb_set TIM2_IRQHandler,Default_Handler + + .weak TIM3_IRQHandler + .thumb_set TIM3_IRQHandler,Default_Handler + + .weak TIM4_IRQHandler + .thumb_set TIM4_IRQHandler,Default_Handler + + .weak I2C1_EV_IRQHandler + .thumb_set I2C1_EV_IRQHandler,Default_Handler + + .weak I2C1_ER_IRQHandler + .thumb_set I2C1_ER_IRQHandler,Default_Handler + + .weak I2C2_EV_IRQHandler + .thumb_set I2C2_EV_IRQHandler,Default_Handler + + .weak I2C2_ER_IRQHandler + .thumb_set I2C2_ER_IRQHandler,Default_Handler + + .weak SPI1_IRQHandler + .thumb_set SPI1_IRQHandler,Default_Handler + + .weak SPI2_IRQHandler + .thumb_set SPI2_IRQHandler,Default_Handler + + .weak USART1_IRQHandler + .thumb_set USART1_IRQHandler,Default_Handler + + .weak USART2_IRQHandler + .thumb_set USART2_IRQHandler,Default_Handler + + .weak USART3_IRQHandler + .thumb_set USART3_IRQHandler,Default_Handler + + .weak EXTI15_10_IRQHandler + .thumb_set EXTI15_10_IRQHandler,Default_Handler + + .weak RTC_Alarm_IRQHandler + .thumb_set RTC_Alarm_IRQHandler,Default_Handler + + .weak TIM8_BRK_TIM12_IRQHandler + .thumb_set TIM8_BRK_TIM12_IRQHandler,Default_Handler + + .weak TIM8_UP_TIM13_IRQHandler + .thumb_set TIM8_UP_TIM13_IRQHandler,Default_Handler + + .weak TIM8_TRG_COM_TIM14_IRQHandler + .thumb_set TIM8_TRG_COM_TIM14_IRQHandler,Default_Handler + + .weak TIM8_CC_IRQHandler + .thumb_set TIM8_CC_IRQHandler,Default_Handler + + .weak DMA1_Stream7_IRQHandler + .thumb_set DMA1_Stream7_IRQHandler,Default_Handler + + .weak FMC_IRQHandler + .thumb_set FMC_IRQHandler,Default_Handler + + .weak SDMMC1_IRQHandler + .thumb_set SDMMC1_IRQHandler,Default_Handler + + .weak TIM5_IRQHandler + .thumb_set TIM5_IRQHandler,Default_Handler + + .weak SPI3_IRQHandler + .thumb_set SPI3_IRQHandler,Default_Handler + + .weak UART4_IRQHandler + .thumb_set UART4_IRQHandler,Default_Handler + + .weak UART5_IRQHandler + .thumb_set UART5_IRQHandler,Default_Handler + + .weak TIM6_DAC_IRQHandler + .thumb_set TIM6_DAC_IRQHandler,Default_Handler + + .weak TIM7_IRQHandler + .thumb_set TIM7_IRQHandler,Default_Handler + + .weak DMA2_Stream0_IRQHandler + .thumb_set DMA2_Stream0_IRQHandler,Default_Handler + + .weak DMA2_Stream1_IRQHandler + .thumb_set DMA2_Stream1_IRQHandler,Default_Handler + + .weak DMA2_Stream2_IRQHandler + .thumb_set DMA2_Stream2_IRQHandler,Default_Handler + + .weak DMA2_Stream3_IRQHandler + .thumb_set DMA2_Stream3_IRQHandler,Default_Handler + + .weak DMA2_Stream4_IRQHandler + .thumb_set DMA2_Stream4_IRQHandler,Default_Handler + + .weak ETH_IRQHandler + .thumb_set ETH_IRQHandler,Default_Handler + + .weak ETH_WKUP_IRQHandler + .thumb_set ETH_WKUP_IRQHandler,Default_Handler + + .weak FDCAN_CAL_IRQHandler + .thumb_set FDCAN_CAL_IRQHandler,Default_Handler + + .weak DMA2_Stream5_IRQHandler + .thumb_set DMA2_Stream5_IRQHandler,Default_Handler + + .weak DMA2_Stream6_IRQHandler + .thumb_set DMA2_Stream6_IRQHandler,Default_Handler + + .weak DMA2_Stream7_IRQHandler + .thumb_set DMA2_Stream7_IRQHandler,Default_Handler + + .weak USART6_IRQHandler + .thumb_set USART6_IRQHandler,Default_Handler + + .weak I2C3_EV_IRQHandler + .thumb_set I2C3_EV_IRQHandler,Default_Handler + + .weak I2C3_ER_IRQHandler + .thumb_set I2C3_ER_IRQHandler,Default_Handler + + .weak OTG_HS_EP1_OUT_IRQHandler + .thumb_set OTG_HS_EP1_OUT_IRQHandler,Default_Handler + + .weak OTG_HS_EP1_IN_IRQHandler + .thumb_set OTG_HS_EP1_IN_IRQHandler,Default_Handler + + .weak OTG_HS_WKUP_IRQHandler + .thumb_set OTG_HS_WKUP_IRQHandler,Default_Handler + + .weak OTG_HS_IRQHandler + .thumb_set OTG_HS_IRQHandler,Default_Handler + + .weak DCMI_IRQHandler + .thumb_set DCMI_IRQHandler,Default_Handler + + .weak RNG_IRQHandler + .thumb_set RNG_IRQHandler,Default_Handler + + .weak FPU_IRQHandler + .thumb_set FPU_IRQHandler,Default_Handler + + .weak UART7_IRQHandler + .thumb_set UART7_IRQHandler,Default_Handler + + .weak UART8_IRQHandler + .thumb_set UART8_IRQHandler,Default_Handler + + .weak SPI4_IRQHandler + .thumb_set SPI4_IRQHandler,Default_Handler + + .weak SPI5_IRQHandler + .thumb_set SPI5_IRQHandler,Default_Handler + + .weak SPI6_IRQHandler + .thumb_set SPI6_IRQHandler,Default_Handler + + .weak SAI1_IRQHandler + .thumb_set SAI1_IRQHandler,Default_Handler + + .weak LTDC_IRQHandler + .thumb_set LTDC_IRQHandler,Default_Handler + + .weak LTDC_ER_IRQHandler + .thumb_set LTDC_ER_IRQHandler,Default_Handler + + .weak DMA2D_IRQHandler + .thumb_set DMA2D_IRQHandler,Default_Handler + + .weak SAI2_IRQHandler + .thumb_set SAI2_IRQHandler,Default_Handler + + .weak QUADSPI_IRQHandler + .thumb_set QUADSPI_IRQHandler,Default_Handler + + .weak LPTIM1_IRQHandler + .thumb_set LPTIM1_IRQHandler,Default_Handler + + .weak CEC_IRQHandler + .thumb_set CEC_IRQHandler,Default_Handler + + .weak I2C4_EV_IRQHandler + .thumb_set I2C4_EV_IRQHandler,Default_Handler + + .weak I2C4_ER_IRQHandler + .thumb_set I2C4_ER_IRQHandler,Default_Handler + + .weak SPDIF_RX_IRQHandler + .thumb_set SPDIF_RX_IRQHandler,Default_Handler + + .weak OTG_FS_EP1_OUT_IRQHandler + .thumb_set OTG_FS_EP1_OUT_IRQHandler,Default_Handler + + .weak OTG_FS_EP1_IN_IRQHandler + .thumb_set OTG_FS_EP1_IN_IRQHandler,Default_Handler + + .weak OTG_FS_WKUP_IRQHandler + .thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler + + .weak OTG_FS_IRQHandler + .thumb_set OTG_FS_IRQHandler,Default_Handler + + .weak DMAMUX1_OVR_IRQHandler + .thumb_set DMAMUX1_OVR_IRQHandler,Default_Handler + + .weak HRTIM1_Master_IRQHandler + .thumb_set HRTIM1_Master_IRQHandler,Default_Handler + + .weak HRTIM1_TIMA_IRQHandler + .thumb_set HRTIM1_TIMA_IRQHandler,Default_Handler + + .weak HRTIM1_TIMB_IRQHandler + .thumb_set HRTIM1_TIMB_IRQHandler,Default_Handler + + .weak HRTIM1_TIMC_IRQHandler + .thumb_set HRTIM1_TIMC_IRQHandler,Default_Handler + + .weak HRTIM1_TIMD_IRQHandler + .thumb_set HRTIM1_TIMD_IRQHandler,Default_Handler + + .weak HRTIM1_TIME_IRQHandler + .thumb_set HRTIM1_TIME_IRQHandler,Default_Handler + + .weak HRTIM1_FLT_IRQHandler + .thumb_set HRTIM1_FLT_IRQHandler,Default_Handler + + .weak DFSDM1_FLT0_IRQHandler + .thumb_set DFSDM1_FLT0_IRQHandler,Default_Handler + + .weak DFSDM1_FLT1_IRQHandler + .thumb_set DFSDM1_FLT1_IRQHandler,Default_Handler + + .weak DFSDM1_FLT2_IRQHandler + .thumb_set DFSDM1_FLT2_IRQHandler,Default_Handler + + .weak DFSDM1_FLT3_IRQHandler + .thumb_set DFSDM1_FLT3_IRQHandler,Default_Handler + + .weak SAI3_IRQHandler + .thumb_set SAI3_IRQHandler,Default_Handler + + .weak SWPMI1_IRQHandler + .thumb_set SWPMI1_IRQHandler,Default_Handler + + .weak TIM15_IRQHandler + .thumb_set TIM15_IRQHandler,Default_Handler + + .weak TIM16_IRQHandler + .thumb_set TIM16_IRQHandler,Default_Handler + + .weak TIM17_IRQHandler + .thumb_set TIM17_IRQHandler,Default_Handler + + .weak MDIOS_WKUP_IRQHandler + .thumb_set MDIOS_WKUP_IRQHandler,Default_Handler + + .weak MDIOS_IRQHandler + .thumb_set MDIOS_IRQHandler,Default_Handler + + .weak JPEG_IRQHandler + .thumb_set JPEG_IRQHandler,Default_Handler + + .weak MDMA_IRQHandler + .thumb_set MDMA_IRQHandler,Default_Handler + + .weak SDMMC2_IRQHandler + .thumb_set SDMMC2_IRQHandler,Default_Handler + + .weak HSEM1_IRQHandler + .thumb_set HSEM1_IRQHandler,Default_Handler + + .weak ADC3_IRQHandler + .thumb_set ADC3_IRQHandler,Default_Handler + + .weak DMAMUX2_OVR_IRQHandler + .thumb_set DMAMUX2_OVR_IRQHandler,Default_Handler + + .weak BDMA_Channel0_IRQHandler + .thumb_set BDMA_Channel0_IRQHandler,Default_Handler + + .weak BDMA_Channel1_IRQHandler + .thumb_set BDMA_Channel1_IRQHandler,Default_Handler + + .weak BDMA_Channel2_IRQHandler + .thumb_set BDMA_Channel2_IRQHandler,Default_Handler + + .weak BDMA_Channel3_IRQHandler + .thumb_set BDMA_Channel3_IRQHandler,Default_Handler + + .weak BDMA_Channel4_IRQHandler + .thumb_set BDMA_Channel4_IRQHandler,Default_Handler + + .weak BDMA_Channel5_IRQHandler + .thumb_set BDMA_Channel5_IRQHandler,Default_Handler + + .weak BDMA_Channel6_IRQHandler + .thumb_set BDMA_Channel6_IRQHandler,Default_Handler + + .weak BDMA_Channel7_IRQHandler + .thumb_set BDMA_Channel7_IRQHandler,Default_Handler + + .weak COMP1_IRQHandler + .thumb_set COMP1_IRQHandler,Default_Handler + + .weak LPTIM2_IRQHandler + .thumb_set LPTIM2_IRQHandler,Default_Handler + + .weak LPTIM3_IRQHandler + .thumb_set LPTIM3_IRQHandler,Default_Handler + + .weak LPTIM4_IRQHandler + .thumb_set LPTIM4_IRQHandler,Default_Handler + + .weak LPTIM5_IRQHandler + .thumb_set LPTIM5_IRQHandler,Default_Handler + + .weak LPUART1_IRQHandler + .thumb_set LPUART1_IRQHandler,Default_Handler + + .weak CRS_IRQHandler + .thumb_set CRS_IRQHandler,Default_Handler + + .weak ECC_IRQHandler + .thumb_set ECC_IRQHandler,Default_Handler + + .weak SAI4_IRQHandler + .thumb_set SAI4_IRQHandler,Default_Handler + + .weak WAKEUP_PIN_IRQHandler + .thumb_set WAKEUP_PIN_IRQHandler,Default_Handler + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ + diff --git a/Xibeca/Core/Src/stm32h7xx_hal_msp.c b/Xibeca/Core/Src/stm32h7xx_hal_msp.c new file mode 100644 index 00000000..cff62946 --- /dev/null +++ b/Xibeca/Core/Src/stm32h7xx_hal_msp.c @@ -0,0 +1,1439 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32h7xx_hal_msp.c + * @brief This file provides code for the MSP Initialization + * and de-Initialization codes. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN TD */ + +/* USER CODE END TD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN Define */ + +/* USER CODE END Define */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN Macro */ + +/* USER CODE END Macro */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* External functions --------------------------------------------------------*/ +/* USER CODE BEGIN ExternalFunctions */ + +/* USER CODE END ExternalFunctions */ + +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ +/** + * Initializes the Global MSP. + */ +void HAL_MspInit(void) +{ + /* USER CODE BEGIN MspInit 0 */ + + /* USER CODE END MspInit 0 */ + + __HAL_RCC_SYSCFG_CLK_ENABLE(); + + /* System interrupt init*/ + /* PendSV_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0); + + /* USER CODE BEGIN MspInit 1 */ + + /* USER CODE END MspInit 1 */ +} + +/** +* @brief ADC MSP Initialization +* This function configures the hardware resources used in this example +* @param hadc: ADC handle pointer +* @retval None +*/ +void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + if(hadc->Instance==ADC1) + { + /* USER CODE BEGIN ADC1_MspInit 0 */ + + /* USER CODE END ADC1_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_ADC; + PeriphClkInitStruct.PLL2.PLL2M = 1; + PeriphClkInitStruct.PLL2.PLL2N = 18; + PeriphClkInitStruct.PLL2.PLL2P = 4; + PeriphClkInitStruct.PLL2.PLL2Q = 2; + PeriphClkInitStruct.PLL2.PLL2R = 2; + PeriphClkInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_3; + PeriphClkInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOMEDIUM; + PeriphClkInitStruct.PLL2.PLL2FRACN = 6144.0; + PeriphClkInitStruct.AdcClockSelection = RCC_ADCCLKSOURCE_PLL2; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + + /* Peripheral clock enable */ + __HAL_RCC_ADC12_CLK_ENABLE(); + + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**ADC1 GPIO Configuration + PC0 ------> ADC1_INP10 + PC1 ------> ADC1_INP11 + PC4 ------> ADC1_INP4 + PA2 ------> ADC1_INP14 + PA6 ------> ADC1_INP3 + PC5 ------> ADC1_INP8 + PB1 ------> ADC1_INP5 + PB0 ------> ADC1_INP9 + */ + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_6; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_0; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* USER CODE BEGIN ADC1_MspInit 1 */ + + /* USER CODE END ADC1_MspInit 1 */ + } + +} + +/** +* @brief ADC MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hadc: ADC handle pointer +* @retval None +*/ +void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) +{ + if(hadc->Instance==ADC1) + { + /* USER CODE BEGIN ADC1_MspDeInit 0 */ + + /* USER CODE END ADC1_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_ADC12_CLK_DISABLE(); + + /**ADC1 GPIO Configuration + PC0 ------> ADC1_INP10 + PC1 ------> ADC1_INP11 + PC4 ------> ADC1_INP4 + PA2 ------> ADC1_INP14 + PA6 ------> ADC1_INP3 + PC5 ------> ADC1_INP8 + PB1 ------> ADC1_INP5 + PB0 ------> ADC1_INP9 + */ + HAL_GPIO_DeInit(GPIOC, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5); + + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_6); + + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_1|GPIO_PIN_0); + + /* USER CODE BEGIN ADC1_MspDeInit 1 */ + + /* USER CODE END ADC1_MspDeInit 1 */ + } + +} + +/** +* @brief DAC MSP Initialization +* This function configures the hardware resources used in this example +* @param hdac: DAC handle pointer +* @retval None +*/ +void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(hdac->Instance==DAC1) + { + /* USER CODE BEGIN DAC1_MspInit 0 */ + + /* USER CODE END DAC1_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_DAC12_CLK_ENABLE(); + + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**DAC1 GPIO Configuration + PA4 ------> DAC1_OUT1 + PA5 ------> DAC1_OUT2 + */ + GPIO_InitStruct.Pin = DAC1_Pin|DAC2_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* USER CODE BEGIN DAC1_MspInit 1 */ + + /* USER CODE END DAC1_MspInit 1 */ + } + +} + +/** +* @brief DAC MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hdac: DAC handle pointer +* @retval None +*/ +void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac) +{ + if(hdac->Instance==DAC1) + { + /* USER CODE BEGIN DAC1_MspDeInit 0 */ + + /* USER CODE END DAC1_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_DAC12_CLK_DISABLE(); + + /**DAC1 GPIO Configuration + PA4 ------> DAC1_OUT1 + PA5 ------> DAC1_OUT2 + */ + HAL_GPIO_DeInit(GPIOA, DAC1_Pin|DAC2_Pin); + + /* USER CODE BEGIN DAC1_MspDeInit 1 */ + + /* USER CODE END DAC1_MspDeInit 1 */ + } + +} + +/** +* @brief I2C MSP Initialization +* This function configures the hardware resources used in this example +* @param hi2c: I2C handle pointer +* @retval None +*/ +void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + if(hi2c->Instance==I2C1) + { + /* USER CODE BEGIN I2C1_MspInit 0 */ + + /* USER CODE END I2C1_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2C1; + PeriphClkInitStruct.I2c123ClockSelection = RCC_I2C123CLKSOURCE_D2PCLK1; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**I2C1 GPIO Configuration + PB8 ------> I2C1_SCL + PB7 ------> I2C1_SDA + */ + GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF4_I2C1; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* Peripheral clock enable */ + __HAL_RCC_I2C1_CLK_ENABLE(); + /* USER CODE BEGIN I2C1_MspInit 1 */ + + /* USER CODE END I2C1_MspInit 1 */ + } + +} + +/** +* @brief I2C MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hi2c: I2C handle pointer +* @retval None +*/ +void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c) +{ + if(hi2c->Instance==I2C1) + { + /* USER CODE BEGIN I2C1_MspDeInit 0 */ + + /* USER CODE END I2C1_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_I2C1_CLK_DISABLE(); + + /**I2C1 GPIO Configuration + PB8 ------> I2C1_SCL + PB7 ------> I2C1_SDA + */ + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_8); + + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_7); + + /* USER CODE BEGIN I2C1_MspDeInit 1 */ + + /* USER CODE END I2C1_MspDeInit 1 */ + } + +} + +/** +* @brief LPTIM MSP Initialization +* This function configures the hardware resources used in this example +* @param hlptim: LPTIM handle pointer +* @retval None +*/ +void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef* hlptim) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + if(hlptim->Instance==LPTIM1) + { + /* USER CODE BEGIN LPTIM1_MspInit 0 */ + + /* USER CODE END LPTIM1_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LPTIM1; + PeriphClkInitStruct.Lptim1ClockSelection = RCC_LPTIM1CLKSOURCE_D2PCLK1; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + + /* Peripheral clock enable */ + __HAL_RCC_LPTIM1_CLK_ENABLE(); + + __HAL_RCC_GPIOG_CLK_ENABLE(); + /**LPTIM1 GPIO Configuration + PG12 ------> LPTIM1_IN1 + PG11 ------> LPTIM1_IN2 + */ + GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_11; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF1_LPTIM1; + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + + /* USER CODE BEGIN LPTIM1_MspInit 1 */ + + /* USER CODE END LPTIM1_MspInit 1 */ + } + +} + +/** +* @brief LPTIM MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hlptim: LPTIM handle pointer +* @retval None +*/ +void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef* hlptim) +{ + if(hlptim->Instance==LPTIM1) + { + /* USER CODE BEGIN LPTIM1_MspDeInit 0 */ + + /* USER CODE END LPTIM1_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_LPTIM1_CLK_DISABLE(); + + /**LPTIM1 GPIO Configuration + PG12 ------> LPTIM1_IN1 + PG11 ------> LPTIM1_IN2 + */ + HAL_GPIO_DeInit(GPIOG, GPIO_PIN_12|GPIO_PIN_11); + + /* USER CODE BEGIN LPTIM1_MspDeInit 1 */ + + /* USER CODE END LPTIM1_MspDeInit 1 */ + } + +} + +/** +* @brief QSPI MSP Initialization +* This function configures the hardware resources used in this example +* @param hqspi: QSPI handle pointer +* @retval None +*/ +void HAL_QSPI_MspInit(QSPI_HandleTypeDef* hqspi) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + if(hqspi->Instance==QUADSPI) + { + /* USER CODE BEGIN QUADSPI_MspInit 0 */ + + /* USER CODE END QUADSPI_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_QSPI; + PeriphClkInitStruct.QspiClockSelection = RCC_QSPICLKSOURCE_D1HCLK; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + + /* Peripheral clock enable */ + __HAL_RCC_QSPI_CLK_ENABLE(); + + __HAL_RCC_GPIOE_CLK_ENABLE(); + __HAL_RCC_GPIOG_CLK_ENABLE(); + __HAL_RCC_GPIOF_CLK_ENABLE(); + /**QUADSPI GPIO Configuration + PE2 ------> QUADSPI_BK1_IO2 + PG6 ------> QUADSPI_BK1_NCS + PF6 ------> QUADSPI_BK1_IO3 + PF10 ------> QUADSPI_CLK + PF9 ------> QUADSPI_BK1_IO1 + PF8 ------> QUADSPI_BK1_IO0 + */ + GPIO_InitStruct.Pin = FLASH_DQ2_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI; + HAL_GPIO_Init(FLASH_DQ2_GPIO_Port, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = FLASH_NCS_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF10_QUADSPI; + HAL_GPIO_Init(FLASH_NCS_GPIO_Port, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = FLASH_DQ3_Pin|FLASH_CLK_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI; + HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = FLASH_DQ1_Pin|FLASH_DQ0_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF10_QUADSPI; + HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + + /* USER CODE BEGIN QUADSPI_MspInit 1 */ + + /* USER CODE END QUADSPI_MspInit 1 */ + } + +} + +/** +* @brief QSPI MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hqspi: QSPI handle pointer +* @retval None +*/ +void HAL_QSPI_MspDeInit(QSPI_HandleTypeDef* hqspi) +{ + if(hqspi->Instance==QUADSPI) + { + /* USER CODE BEGIN QUADSPI_MspDeInit 0 */ + + /* USER CODE END QUADSPI_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_QSPI_CLK_DISABLE(); + + /**QUADSPI GPIO Configuration + PE2 ------> QUADSPI_BK1_IO2 + PG6 ------> QUADSPI_BK1_NCS + PF6 ------> QUADSPI_BK1_IO3 + PF10 ------> QUADSPI_CLK + PF9 ------> QUADSPI_BK1_IO1 + PF8 ------> QUADSPI_BK1_IO0 + */ + HAL_GPIO_DeInit(FLASH_DQ2_GPIO_Port, FLASH_DQ2_Pin); + + HAL_GPIO_DeInit(FLASH_NCS_GPIO_Port, FLASH_NCS_Pin); + + HAL_GPIO_DeInit(GPIOF, FLASH_DQ3_Pin|FLASH_CLK_Pin|FLASH_DQ1_Pin|FLASH_DQ0_Pin); + + /* USER CODE BEGIN QUADSPI_MspDeInit 1 */ + + /* USER CODE END QUADSPI_MspDeInit 1 */ + } + +} + +/** +* @brief SPI MSP Initialization +* This function configures the hardware resources used in this example +* @param hspi: SPI handle pointer +* @retval None +*/ +void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + if(hspi->Instance==SPI2) + { + /* USER CODE BEGIN SPI2_MspInit 0 */ + + /* USER CODE END SPI2_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SPI2; + PeriphClkInitStruct.Spi123ClockSelection = RCC_SPI123CLKSOURCE_PLL; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + + /* Peripheral clock enable */ + __HAL_RCC_SPI2_CLK_ENABLE(); + + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**SPI2 GPIO Configuration + PC2_C ------> SPI2_MISO + PC3_C ------> SPI2_MOSI + PB10 ------> SPI2_SCK + */ + GPIO_InitStruct.Pin = ADC_SPI_MISO_Pin|ADC_SPI_MOSI_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF5_SPI2; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = ADC_SPI_CLK_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF5_SPI2; + HAL_GPIO_Init(ADC_SPI_CLK_GPIO_Port, &GPIO_InitStruct); + + /* USER CODE BEGIN SPI2_MspInit 1 */ + + /* USER CODE END SPI2_MspInit 1 */ + } + else if(hspi->Instance==SPI3) + { + /* USER CODE BEGIN SPI3_MspInit 0 */ + + /* USER CODE END SPI3_MspInit 0 */ + + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SPI3; + PeriphClkInitStruct.Spi123ClockSelection = RCC_SPI123CLKSOURCE_PLL; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + + /* Peripheral clock enable */ + __HAL_RCC_SPI3_CLK_ENABLE(); + + __HAL_RCC_GPIOC_CLK_ENABLE(); + /**SPI3 GPIO Configuration + PC12 ------> SPI3_MOSI + PC11 ------> SPI3_MISO + PC10 ------> SPI3_SCK + */ + GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_11|GPIO_PIN_10; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF6_SPI3; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /* USER CODE BEGIN SPI3_MspInit 1 */ + + /* USER CODE END SPI3_MspInit 1 */ + } + else if(hspi->Instance==SPI6) + { + /* USER CODE BEGIN SPI6_MspInit 0 */ + + /* USER CODE END SPI6_MspInit 0 */ + + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SPI6; + PeriphClkInitStruct.Spi6ClockSelection = RCC_SPI6CLKSOURCE_D3PCLK1; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + + /* Peripheral clock enable */ + __HAL_RCC_SPI6_CLK_ENABLE(); + + __HAL_RCC_GPIOG_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**SPI6 GPIO Configuration + PG14 ------> SPI6_MOSI + PG13 ------> SPI6_SCK + PB4 (NJTRST) ------> SPI6_MISO + */ + GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_13; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF5_SPI6; + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_4; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF8_SPI6; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* USER CODE BEGIN SPI6_MspInit 1 */ + + /* USER CODE END SPI6_MspInit 1 */ + } + +} + +/** +* @brief SPI MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hspi: SPI handle pointer +* @retval None +*/ +void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) +{ + if(hspi->Instance==SPI2) + { + /* USER CODE BEGIN SPI2_MspDeInit 0 */ + + /* USER CODE END SPI2_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_SPI2_CLK_DISABLE(); + + /**SPI2 GPIO Configuration + PC2_C ------> SPI2_MISO + PC3_C ------> SPI2_MOSI + PB10 ------> SPI2_SCK + */ + HAL_GPIO_DeInit(GPIOC, ADC_SPI_MISO_Pin|ADC_SPI_MOSI_Pin); + + HAL_GPIO_DeInit(ADC_SPI_CLK_GPIO_Port, ADC_SPI_CLK_Pin); + + /* USER CODE BEGIN SPI2_MspDeInit 1 */ + + /* USER CODE END SPI2_MspDeInit 1 */ + } + else if(hspi->Instance==SPI3) + { + /* USER CODE BEGIN SPI3_MspDeInit 0 */ + + /* USER CODE END SPI3_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_SPI3_CLK_DISABLE(); + + /**SPI3 GPIO Configuration + PC12 ------> SPI3_MOSI + PC11 ------> SPI3_MISO + PC10 ------> SPI3_SCK + */ + HAL_GPIO_DeInit(GPIOC, GPIO_PIN_12|GPIO_PIN_11|GPIO_PIN_10); + + /* USER CODE BEGIN SPI3_MspDeInit 1 */ + + /* USER CODE END SPI3_MspDeInit 1 */ + } + else if(hspi->Instance==SPI6) + { + /* USER CODE BEGIN SPI6_MspDeInit 0 */ + + /* USER CODE END SPI6_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_SPI6_CLK_DISABLE(); + + /**SPI6 GPIO Configuration + PG14 ------> SPI6_MOSI + PG13 ------> SPI6_SCK + PB4 (NJTRST) ------> SPI6_MISO + */ + HAL_GPIO_DeInit(GPIOG, GPIO_PIN_14|GPIO_PIN_13); + + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_4); + + /* USER CODE BEGIN SPI6_MspDeInit 1 */ + + /* USER CODE END SPI6_MspDeInit 1 */ + } + +} + +/** +* @brief TIM_Encoder MSP Initialization +* This function configures the hardware resources used in this example +* @param htim_encoder: TIM_Encoder handle pointer +* @retval None +*/ +void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef* htim_encoder) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(htim_encoder->Instance==TIM2) + { + /* USER CODE BEGIN TIM2_MspInit 0 */ + + /* USER CODE END TIM2_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_TIM2_CLK_ENABLE(); + + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**TIM2 GPIO Configuration + PA15 (JTDI) ------> TIM2_CH1 + PA1 ------> TIM2_CH2 + */ + GPIO_InitStruct.Pin = GPIO_PIN_15|GPIO_PIN_1; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF1_TIM2; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* USER CODE BEGIN TIM2_MspInit 1 */ + + /* USER CODE END TIM2_MspInit 1 */ + } + else if(htim_encoder->Instance==TIM3) + { + /* USER CODE BEGIN TIM3_MspInit 0 */ + + /* USER CODE END TIM3_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_TIM3_CLK_ENABLE(); + + __HAL_RCC_GPIOC_CLK_ENABLE(); + /**TIM3 GPIO Configuration + PC7 ------> TIM3_CH2 + PC6 ------> TIM3_CH1 + */ + GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_6; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF2_TIM3; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /* USER CODE BEGIN TIM3_MspInit 1 */ + + /* USER CODE END TIM3_MspInit 1 */ + } + else if(htim_encoder->Instance==TIM4) + { + /* USER CODE BEGIN TIM4_MspInit 0 */ + + /* USER CODE END TIM4_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_TIM4_CLK_ENABLE(); + + __HAL_RCC_GPIOD_CLK_ENABLE(); + /**TIM4 GPIO Configuration + PD13 ------> TIM4_CH2 + PD12 ------> TIM4_CH1 + */ + GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_12; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF2_TIM4; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + /* USER CODE BEGIN TIM4_MspInit 1 */ + + /* USER CODE END TIM4_MspInit 1 */ + } + +} + +/** +* @brief TIM_Encoder MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param htim_encoder: TIM_Encoder handle pointer +* @retval None +*/ +void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef* htim_encoder) +{ + if(htim_encoder->Instance==TIM2) + { + /* USER CODE BEGIN TIM2_MspDeInit 0 */ + + /* USER CODE END TIM2_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_TIM2_CLK_DISABLE(); + + /**TIM2 GPIO Configuration + PA15 (JTDI) ------> TIM2_CH1 + PA1 ------> TIM2_CH2 + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_15|GPIO_PIN_1); + + /* USER CODE BEGIN TIM2_MspDeInit 1 */ + + /* USER CODE END TIM2_MspDeInit 1 */ + } + else if(htim_encoder->Instance==TIM3) + { + /* USER CODE BEGIN TIM3_MspDeInit 0 */ + + /* USER CODE END TIM3_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_TIM3_CLK_DISABLE(); + + /**TIM3 GPIO Configuration + PC7 ------> TIM3_CH2 + PC6 ------> TIM3_CH1 + */ + HAL_GPIO_DeInit(GPIOC, GPIO_PIN_7|GPIO_PIN_6); + + /* USER CODE BEGIN TIM3_MspDeInit 1 */ + + /* USER CODE END TIM3_MspDeInit 1 */ + } + else if(htim_encoder->Instance==TIM4) + { + /* USER CODE BEGIN TIM4_MspDeInit 0 */ + + /* USER CODE END TIM4_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_TIM4_CLK_DISABLE(); + + /**TIM4 GPIO Configuration + PD13 ------> TIM4_CH2 + PD12 ------> TIM4_CH1 + */ + HAL_GPIO_DeInit(GPIOD, GPIO_PIN_13|GPIO_PIN_12); + + /* USER CODE BEGIN TIM4_MspDeInit 1 */ + + /* USER CODE END TIM4_MspDeInit 1 */ + } + +} + +/** +* @brief UART MSP Initialization +* This function configures the hardware resources used in this example +* @param huart: UART handle pointer +* @retval None +*/ +void HAL_UART_MspInit(UART_HandleTypeDef* huart) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + if(huart->Instance==UART5) + { + /* USER CODE BEGIN UART5_MspInit 0 */ + + /* USER CODE END UART5_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_UART5; + PeriphClkInitStruct.Usart234578ClockSelection = RCC_USART234578CLKSOURCE_D2PCLK1; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + + /* Peripheral clock enable */ + __HAL_RCC_UART5_CLK_ENABLE(); + + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**UART5 GPIO Configuration + PB5 ------> UART5_RX + PB6 ------> UART5_TX + */ + GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF14_UART5; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* USER CODE BEGIN UART5_MspInit 1 */ + + /* USER CODE END UART5_MspInit 1 */ + } + else if(huart->Instance==UART7) + { + /* USER CODE BEGIN UART7_MspInit 0 */ + + /* USER CODE END UART7_MspInit 0 */ + + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_UART7; + PeriphClkInitStruct.Usart234578ClockSelection = RCC_USART234578CLKSOURCE_D2PCLK1; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + + /* Peripheral clock enable */ + __HAL_RCC_UART7_CLK_ENABLE(); + + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOF_CLK_ENABLE(); + /**UART7 GPIO Configuration + PA8 ------> UART7_RX + PF7 ------> UART7_TX + */ + GPIO_InitStruct.Pin = GPIO_PIN_8; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF11_UART7; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF7_UART7; + HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + + /* USER CODE BEGIN UART7_MspInit 1 */ + + /* USER CODE END UART7_MspInit 1 */ + } + +} + +/** +* @brief UART MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param huart: UART handle pointer +* @retval None +*/ +void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) +{ + if(huart->Instance==UART5) + { + /* USER CODE BEGIN UART5_MspDeInit 0 */ + + /* USER CODE END UART5_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_UART5_CLK_DISABLE(); + + /**UART5 GPIO Configuration + PB5 ------> UART5_RX + PB6 ------> UART5_TX + */ + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_5|GPIO_PIN_6); + + /* USER CODE BEGIN UART5_MspDeInit 1 */ + + /* USER CODE END UART5_MspDeInit 1 */ + } + else if(huart->Instance==UART7) + { + /* USER CODE BEGIN UART7_MspDeInit 0 */ + + /* USER CODE END UART7_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_UART7_CLK_DISABLE(); + + /**UART7 GPIO Configuration + PA8 ------> UART7_RX + PF7 ------> UART7_TX + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_8); + + HAL_GPIO_DeInit(GPIOF, GPIO_PIN_7); + + /* USER CODE BEGIN UART7_MspDeInit 1 */ + + /* USER CODE END UART7_MspDeInit 1 */ + } + +} + +static uint32_t FMC_Initialized = 0; + +static void HAL_FMC_MspInit(void){ + /* USER CODE BEGIN FMC_MspInit 0 */ + + /* USER CODE END FMC_MspInit 0 */ + GPIO_InitTypeDef GPIO_InitStruct ={0}; + if (FMC_Initialized) { + return; + } + FMC_Initialized = 1; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_FMC; + PeriphClkInitStruct.FmcClockSelection = RCC_FMCCLKSOURCE_D1HCLK; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + + /* Peripheral clock enable */ + __HAL_RCC_FMC_CLK_ENABLE(); + + /** FMC GPIO Configuration + PE1 ------> FMC_NBL1 + PE0 ------> FMC_NBL0 + PG15 ------> FMC_SDNCAS + PD0 ------> FMC_D2 + PI7 ------> FMC_D29 + PI6 ------> FMC_D28 + PI5 ------> FMC_NBL3 + PD1 ------> FMC_D3 + PI3 ------> FMC_D27 + PI2 ------> FMC_D26 + PI9 ------> FMC_D30 + PI4 ------> FMC_NBL2 + PH15 ------> FMC_D23 + PI1 ------> FMC_D25 + PF0 ------> FMC_A0 + PI10 ------> FMC_D31 + PH13 ------> FMC_D21 + PH14 ------> FMC_D22 + PI0 ------> FMC_D24 + PH2 ------> FMC_SDCKE0 + PH3 ------> FMC_SDNE0 + PF2 ------> FMC_A2 + PF1 ------> FMC_A1 + PG8 ------> FMC_SDCLK + PF3 ------> FMC_A3 + PF4 ------> FMC_A4 + PH5 ------> FMC_SDNWE + PF5 ------> FMC_A5 + PH12 ------> FMC_D20 + PG5 ------> FMC_BA1 + PG4 ------> FMC_BA0 + PH11 ------> FMC_D19 + PH10 ------> FMC_D18 + PD15 ------> FMC_D1 + PG2 ------> FMC_A12 + PG1 ------> FMC_A11 + PH8 ------> FMC_D16 + PH9 ------> FMC_D17 + PD14 ------> FMC_D0 + PF13 ------> FMC_A7 + PG0 ------> FMC_A10 + PE13 ------> FMC_D10 + PD10 ------> FMC_D15 + PF12 ------> FMC_A6 + PF15 ------> FMC_A9 + PE8 ------> FMC_D5 + PE9 ------> FMC_D6 + PE11 ------> FMC_D8 + PE14 ------> FMC_D11 + PD9 ------> FMC_D14 + PD8 ------> FMC_D13 + PF11 ------> FMC_SDNRAS + PF14 ------> FMC_A8 + PE7 ------> FMC_D4 + PE10 ------> FMC_D7 + PE12 ------> FMC_D9 + PE15 ------> FMC_D12 + */ + GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_0|GPIO_PIN_13|GPIO_PIN_8 + |GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_14|GPIO_PIN_7 + |GPIO_PIN_10|GPIO_PIN_12|GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_15|GPIO_PIN_8|GPIO_PIN_5|GPIO_PIN_4 + |GPIO_PIN_2|GPIO_PIN_1|GPIO_PIN_0; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_15|GPIO_PIN_14 + |GPIO_PIN_10|GPIO_PIN_9|GPIO_PIN_8; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_6|GPIO_PIN_5|GPIO_PIN_3 + |GPIO_PIN_2|GPIO_PIN_9|GPIO_PIN_4|GPIO_PIN_1 + |GPIO_PIN_10|GPIO_PIN_0; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_15|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_2 + |GPIO_PIN_3|GPIO_PIN_5|GPIO_PIN_12|GPIO_PIN_11 + |GPIO_PIN_10|GPIO_PIN_8|GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_1|GPIO_PIN_3 + |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_13|GPIO_PIN_12 + |GPIO_PIN_15|GPIO_PIN_11|GPIO_PIN_14; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + + /* USER CODE BEGIN FMC_MspInit 1 */ + + /* USER CODE END FMC_MspInit 1 */ +} + +void HAL_SDRAM_MspInit(SDRAM_HandleTypeDef* hsdram){ + /* USER CODE BEGIN SDRAM_MspInit 0 */ + + /* USER CODE END SDRAM_MspInit 0 */ + HAL_FMC_MspInit(); + /* USER CODE BEGIN SDRAM_MspInit 1 */ + + /* USER CODE END SDRAM_MspInit 1 */ +} + +static uint32_t FMC_DeInitialized = 0; + +static void HAL_FMC_MspDeInit(void){ + /* USER CODE BEGIN FMC_MspDeInit 0 */ + + /* USER CODE END FMC_MspDeInit 0 */ + if (FMC_DeInitialized) { + return; + } + FMC_DeInitialized = 1; + /* Peripheral clock enable */ + __HAL_RCC_FMC_CLK_DISABLE(); + + /** FMC GPIO Configuration + PE1 ------> FMC_NBL1 + PE0 ------> FMC_NBL0 + PG15 ------> FMC_SDNCAS + PD0 ------> FMC_D2 + PI7 ------> FMC_D29 + PI6 ------> FMC_D28 + PI5 ------> FMC_NBL3 + PD1 ------> FMC_D3 + PI3 ------> FMC_D27 + PI2 ------> FMC_D26 + PI9 ------> FMC_D30 + PI4 ------> FMC_NBL2 + PH15 ------> FMC_D23 + PI1 ------> FMC_D25 + PF0 ------> FMC_A0 + PI10 ------> FMC_D31 + PH13 ------> FMC_D21 + PH14 ------> FMC_D22 + PI0 ------> FMC_D24 + PH2 ------> FMC_SDCKE0 + PH3 ------> FMC_SDNE0 + PF2 ------> FMC_A2 + PF1 ------> FMC_A1 + PG8 ------> FMC_SDCLK + PF3 ------> FMC_A3 + PF4 ------> FMC_A4 + PH5 ------> FMC_SDNWE + PF5 ------> FMC_A5 + PH12 ------> FMC_D20 + PG5 ------> FMC_BA1 + PG4 ------> FMC_BA0 + PH11 ------> FMC_D19 + PH10 ------> FMC_D18 + PD15 ------> FMC_D1 + PG2 ------> FMC_A12 + PG1 ------> FMC_A11 + PH8 ------> FMC_D16 + PH9 ------> FMC_D17 + PD14 ------> FMC_D0 + PF13 ------> FMC_A7 + PG0 ------> FMC_A10 + PE13 ------> FMC_D10 + PD10 ------> FMC_D15 + PF12 ------> FMC_A6 + PF15 ------> FMC_A9 + PE8 ------> FMC_D5 + PE9 ------> FMC_D6 + PE11 ------> FMC_D8 + PE14 ------> FMC_D11 + PD9 ------> FMC_D14 + PD8 ------> FMC_D13 + PF11 ------> FMC_SDNRAS + PF14 ------> FMC_A8 + PE7 ------> FMC_D4 + PE10 ------> FMC_D7 + PE12 ------> FMC_D9 + PE15 ------> FMC_D12 + */ + HAL_GPIO_DeInit(GPIOE, GPIO_PIN_1|GPIO_PIN_0|GPIO_PIN_13|GPIO_PIN_8 + |GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_14|GPIO_PIN_7 + |GPIO_PIN_10|GPIO_PIN_12|GPIO_PIN_15); + + HAL_GPIO_DeInit(GPIOG, GPIO_PIN_15|GPIO_PIN_8|GPIO_PIN_5|GPIO_PIN_4 + |GPIO_PIN_2|GPIO_PIN_1|GPIO_PIN_0); + + HAL_GPIO_DeInit(GPIOD, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_15|GPIO_PIN_14 + |GPIO_PIN_10|GPIO_PIN_9|GPIO_PIN_8); + + HAL_GPIO_DeInit(GPIOI, GPIO_PIN_7|GPIO_PIN_6|GPIO_PIN_5|GPIO_PIN_3 + |GPIO_PIN_2|GPIO_PIN_9|GPIO_PIN_4|GPIO_PIN_1 + |GPIO_PIN_10|GPIO_PIN_0); + + HAL_GPIO_DeInit(GPIOH, GPIO_PIN_15|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_2 + |GPIO_PIN_3|GPIO_PIN_5|GPIO_PIN_12|GPIO_PIN_11 + |GPIO_PIN_10|GPIO_PIN_8|GPIO_PIN_9); + + HAL_GPIO_DeInit(GPIOF, GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_1|GPIO_PIN_3 + |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_13|GPIO_PIN_12 + |GPIO_PIN_15|GPIO_PIN_11|GPIO_PIN_14); + + /* USER CODE BEGIN FMC_MspDeInit 1 */ + + /* USER CODE END FMC_MspDeInit 1 */ +} + +void HAL_SDRAM_MspDeInit(SDRAM_HandleTypeDef* hsdram){ + /* USER CODE BEGIN SDRAM_MspDeInit 0 */ + + /* USER CODE END SDRAM_MspDeInit 0 */ + HAL_FMC_MspDeInit(); + /* USER CODE BEGIN SDRAM_MspDeInit 1 */ + + /* USER CODE END SDRAM_MspDeInit 1 */ +} + +extern DMA_HandleTypeDef hdma_sai1_a; + +extern DMA_HandleTypeDef hdma_sai1_b; + +static uint32_t SAI1_client =0; + +void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) +{ + + GPIO_InitTypeDef GPIO_InitStruct; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; +/* SAI1 */ + if(hsai->Instance==SAI1_Block_A) + { + /* Peripheral clock enable */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SAI1; + PeriphClkInitStruct.Sai1ClockSelection = RCC_SAI1CLKSOURCE_CLKP; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + + if (SAI1_client == 0) + { + __HAL_RCC_SAI1_CLK_ENABLE(); + } + SAI1_client ++; + + /**SAI1_A_Block_A GPIO Configuration + PE4 ------> SAI1_FS_A + PE5 ------> SAI1_SCK_A + PE6 ------> SAI1_SD_A + PG7 ------> SAI1_MCLK_A + */ + GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; + HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + + /* Peripheral DMA init*/ + + hdma_sai1_a.Instance = DMA1_Stream0; + hdma_sai1_a.Init.Request = DMA_REQUEST_SAI1_A; + hdma_sai1_a.Init.Direction = DMA_PERIPH_TO_MEMORY; + hdma_sai1_a.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_sai1_a.Init.MemInc = DMA_MINC_ENABLE; + hdma_sai1_a.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; + hdma_sai1_a.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; + hdma_sai1_a.Init.Mode = DMA_CIRCULAR; + hdma_sai1_a.Init.Priority = DMA_PRIORITY_VERY_HIGH; + hdma_sai1_a.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + if (HAL_DMA_Init(&hdma_sai1_a) != HAL_OK) + { + Error_Handler(); + } + + /* Several peripheral DMA handle pointers point to the same DMA handle. + Be aware that there is only one channel to perform all the requested DMAs. */ + __HAL_LINKDMA(hsai,hdmarx,hdma_sai1_a); + + __HAL_LINKDMA(hsai,hdmatx,hdma_sai1_a); + + } + if(hsai->Instance==SAI1_Block_B) + { + /* Peripheral clock enable */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SAI1; + PeriphClkInitStruct.Sai1ClockSelection = RCC_SAI1CLKSOURCE_CLKP; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + + if (SAI1_client == 0) + { + __HAL_RCC_SAI1_CLK_ENABLE(); + } + SAI1_client ++; + + /**SAI1_B_Block_B GPIO Configuration + PE3 ------> SAI1_SD_B + */ + GPIO_InitStruct.Pin = GPIO_PIN_3; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; + HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + + /* Peripheral DMA init*/ + + hdma_sai1_b.Instance = DMA1_Stream1; + hdma_sai1_b.Init.Request = DMA_REQUEST_SAI1_B; + hdma_sai1_b.Init.Direction = DMA_MEMORY_TO_PERIPH; + hdma_sai1_b.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_sai1_b.Init.MemInc = DMA_MINC_ENABLE; + hdma_sai1_b.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; + hdma_sai1_b.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; + hdma_sai1_b.Init.Mode = DMA_CIRCULAR; + hdma_sai1_b.Init.Priority = DMA_PRIORITY_VERY_HIGH; + hdma_sai1_b.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + if (HAL_DMA_Init(&hdma_sai1_b) != HAL_OK) + { + Error_Handler(); + } + + /* Several peripheral DMA handle pointers point to the same DMA handle. + Be aware that there is only one channel to perform all the requested DMAs. */ + __HAL_LINKDMA(hsai,hdmarx,hdma_sai1_b); + __HAL_LINKDMA(hsai,hdmatx,hdma_sai1_b); + } +} + +void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) +{ +/* SAI1 */ + if(hsai->Instance==SAI1_Block_A) + { + SAI1_client --; + if (SAI1_client == 0) + { + /* Peripheral clock disable */ + __HAL_RCC_SAI1_CLK_DISABLE(); + } + + /**SAI1_A_Block_A GPIO Configuration + PE4 ------> SAI1_FS_A + PE5 ------> SAI1_SCK_A + PE6 ------> SAI1_SD_A + PG7 ------> SAI1_MCLK_A + */ + HAL_GPIO_DeInit(GPIOE, GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6); + + HAL_GPIO_DeInit(GPIOG, GPIO_PIN_7); + + HAL_DMA_DeInit(hsai->hdmarx); + HAL_DMA_DeInit(hsai->hdmatx); + } + if(hsai->Instance==SAI1_Block_B) + { + SAI1_client --; + if (SAI1_client == 0) + { + /* Peripheral clock disable */ + __HAL_RCC_SAI1_CLK_DISABLE(); + } + + /**SAI1_B_Block_B GPIO Configuration + PE3 ------> SAI1_SD_B + */ + HAL_GPIO_DeInit(GPIOE, GPIO_PIN_3); + + HAL_DMA_DeInit(hsai->hdmarx); + HAL_DMA_DeInit(hsai->hdmatx); + } +} + +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/Core/Src/stm32h7xx_it.c b/Xibeca/Core/Src/stm32h7xx_it.c new file mode 100644 index 00000000..0ff7731c --- /dev/null +++ b/Xibeca/Core/Src/stm32h7xx_it.c @@ -0,0 +1,248 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32h7xx_it.c + * @brief Interrupt Service Routines. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "stm32h7xx_it.h" +#include "FreeRTOS.h" +#include "task.h" +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN TD */ + +/* USER CODE END TD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ + +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* Private user code ---------------------------------------------------------*/ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* External variables --------------------------------------------------------*/ +extern PCD_HandleTypeDef hpcd_USB_OTG_HS; +extern HCD_HandleTypeDef hhcd_USB_OTG_FS; +extern DMA_HandleTypeDef hdma_sai1_a; +extern DMA_HandleTypeDef hdma_sai1_b; +/* USER CODE BEGIN EV */ + +/* USER CODE END EV */ + +/******************************************************************************/ +/* Cortex Processor Interruption and Exception Handlers */ +/******************************************************************************/ +/** + * @brief This function handles Non maskable interrupt. + */ +void NMI_Handler(void) +{ + /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ + + /* USER CODE END NonMaskableInt_IRQn 0 */ + /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ + while (1) + { + } + /* USER CODE END NonMaskableInt_IRQn 1 */ +} + +/** + * @brief This function handles Hard fault interrupt. + */ +void HardFault_Handler(void) +{ + /* USER CODE BEGIN HardFault_IRQn 0 */ + + /* USER CODE END HardFault_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_HardFault_IRQn 0 */ + /* USER CODE END W1_HardFault_IRQn 0 */ + } +} + +/** + * @brief This function handles Memory management fault. + */ +void MemManage_Handler(void) +{ + /* USER CODE BEGIN MemoryManagement_IRQn 0 */ + + /* USER CODE END MemoryManagement_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ + /* USER CODE END W1_MemoryManagement_IRQn 0 */ + } +} + +/** + * @brief This function handles Pre-fetch fault, memory access fault. + */ +void BusFault_Handler(void) +{ + /* USER CODE BEGIN BusFault_IRQn 0 */ + + /* USER CODE END BusFault_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_BusFault_IRQn 0 */ + /* USER CODE END W1_BusFault_IRQn 0 */ + } +} + +/** + * @brief This function handles Undefined instruction or illegal state. + */ +void UsageFault_Handler(void) +{ + /* USER CODE BEGIN UsageFault_IRQn 0 */ + + /* USER CODE END UsageFault_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ + /* USER CODE END W1_UsageFault_IRQn 0 */ + } +} + +/** + * @brief This function handles Debug monitor. + */ +void DebugMon_Handler(void) +{ + /* USER CODE BEGIN DebugMonitor_IRQn 0 */ + + /* USER CODE END DebugMonitor_IRQn 0 */ + /* USER CODE BEGIN DebugMonitor_IRQn 1 */ + + /* USER CODE END DebugMonitor_IRQn 1 */ +} + +/** + * @brief This function handles System tick timer. + */ +void SysTick_Handler(void) +{ + /* USER CODE BEGIN SysTick_IRQn 0 */ + + /* USER CODE END SysTick_IRQn 0 */ + HAL_IncTick(); +#if (INCLUDE_xTaskGetSchedulerState == 1 ) + if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) + { +#endif /* INCLUDE_xTaskGetSchedulerState */ + xPortSysTickHandler(); +#if (INCLUDE_xTaskGetSchedulerState == 1 ) + } +#endif /* INCLUDE_xTaskGetSchedulerState */ + /* USER CODE BEGIN SysTick_IRQn 1 */ + + /* USER CODE END SysTick_IRQn 1 */ +} + +/******************************************************************************/ +/* STM32H7xx Peripheral Interrupt Handlers */ +/* Add here the Interrupt Handlers for the used peripherals. */ +/* For the available peripheral interrupt handler names, */ +/* please refer to the startup file (startup_stm32h7xx.s). */ +/******************************************************************************/ + +/** + * @brief This function handles DMA1 stream0 global interrupt. + */ +void DMA1_Stream0_IRQHandler(void) +{ + /* USER CODE BEGIN DMA1_Stream0_IRQn 0 */ + + /* USER CODE END DMA1_Stream0_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_sai1_a); + /* USER CODE BEGIN DMA1_Stream0_IRQn 1 */ + + /* USER CODE END DMA1_Stream0_IRQn 1 */ +} + +/** + * @brief This function handles DMA1 stream1 global interrupt. + */ +void DMA1_Stream1_IRQHandler(void) +{ + /* USER CODE BEGIN DMA1_Stream1_IRQn 0 */ + + /* USER CODE END DMA1_Stream1_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_sai1_b); + /* USER CODE BEGIN DMA1_Stream1_IRQn 1 */ + + /* USER CODE END DMA1_Stream1_IRQn 1 */ +} + +/** + * @brief This function handles USB On The Go HS global interrupt. + */ +void OTG_HS_IRQHandler(void) +{ + /* USER CODE BEGIN OTG_HS_IRQn 0 */ + + /* USER CODE END OTG_HS_IRQn 0 */ + HAL_PCD_IRQHandler(&hpcd_USB_OTG_HS); + /* USER CODE BEGIN OTG_HS_IRQn 1 */ + + /* USER CODE END OTG_HS_IRQn 1 */ +} + +/** + * @brief This function handles USB On The Go FS global interrupt. + */ +void OTG_FS_IRQHandler(void) +{ + /* USER CODE BEGIN OTG_FS_IRQn 0 */ + + /* USER CODE END OTG_FS_IRQn 0 */ + HAL_HCD_IRQHandler(&hhcd_USB_OTG_FS); + /* USER CODE BEGIN OTG_FS_IRQn 1 */ + + /* USER CODE END OTG_FS_IRQn 1 */ +} + +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/Core/Src/system_stm32h7xx.c b/Xibeca/Core/Src/system_stm32h7xx.c new file mode 100644 index 00000000..8dccfb9b --- /dev/null +++ b/Xibeca/Core/Src/system_stm32h7xx.c @@ -0,0 +1,422 @@ +/** + ****************************************************************************** + * @file system_stm32h7xx.c + * @author MCD Application Team + * @brief CMSIS Cortex-Mx Device Peripheral Access Layer System Source File. + * + * This file provides two functions and one global variable to be called from + * user application: + * - SystemInit(): This function is called at startup just after reset and + * before branch to main program. This call is made inside + * the "startup_stm32h7xx.s" file. + * + * - SystemCoreClock variable: Contains the core clock, it can be used + * by the user application to setup the SysTick + * timer or configure other parameters. + * + * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must + * be called whenever the core clock is changed + * during program execution. + * + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup stm32h7xx_system + * @{ + */ + +/** @addtogroup STM32H7xx_System_Private_Includes + * @{ + */ + +#include "stm32h7xx.h" +#include +#if !defined (HSE_VALUE) +#define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (CSI_VALUE) + #define CSI_VALUE ((uint32_t)4000000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* CSI_VALUE */ + +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)64000000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_Defines + * @{ + */ + +/************************* Miscellaneous Configuration ************************/ +/*!< Uncomment the following line if you need to use initialized data in D2 domain SRAM (AHB SRAM) */ +/* #define DATA_IN_D2_SRAM */ + +/*!< Uncomment the following line if you need to relocate your vector Table in + Internal SRAM. */ +/* #define VECT_TAB_SRAM */ +#define VECT_TAB_OFFSET 0x00000000UL /*!< Vector Table base offset field. + This value must be a multiple of 0x200. */ +/******************************************************************************/ + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_Variables + * @{ + */ + /* This variable is updated in three ways: + 1) by calling CMSIS function SystemCoreClockUpdate() + 2) by calling HAL API function HAL_RCC_GetHCLKFreq() + 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency + Note: If you use this function to configure the system clock; then there + is no need to call the 2 first functions listed above, since SystemCoreClock + variable is updated automatically. + */ + uint32_t SystemCoreClock = 64000000; + uint32_t SystemD2Clock = 64000000; + const uint8_t D1CorePrescTable[16] = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, 8, 9}; + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system + * Initialize the FPU setting and vector table location + * configuration. + * @param None + * @retval None + */ +void SystemInit (void) +{ +#if defined (DATA_IN_D2_SRAM) + __IO uint32_t tmpreg; +#endif /* DATA_IN_D2_SRAM */ + + /* FPU settings ------------------------------------------------------------*/ + #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) + SCB->CPACR |= ((3UL << (10*2))|(3UL << (11*2))); /* set CP10 and CP11 Full Access */ + #endif + /* Reset the RCC clock configuration to the default reset state ------------*/ + + /* Increasing the CPU frequency */ + if(FLASH_LATENCY_DEFAULT > (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY))) + { + /* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */ + MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (uint32_t)(FLASH_LATENCY_DEFAULT)); + } + + /* Set HSION bit */ + RCC->CR |= RCC_CR_HSION; + + /* Reset CFGR register */ + RCC->CFGR = 0x00000000; + + /* Reset HSEON, HSECSSON, CSION, HSI48ON, CSIKERON, PLL1ON, PLL2ON and PLL3ON bits */ + RCC->CR &= 0xEAF6ED7FU; + + /* Decreasing the number of wait states because of lower CPU frequency */ + if(FLASH_LATENCY_DEFAULT < (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY))) + { + /* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */ + MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (uint32_t)(FLASH_LATENCY_DEFAULT)); + } + +#if defined(D3_SRAM_BASE) + /* Reset D1CFGR register */ + RCC->D1CFGR = 0x00000000; + + /* Reset D2CFGR register */ + RCC->D2CFGR = 0x00000000; + + /* Reset D3CFGR register */ + RCC->D3CFGR = 0x00000000; +#else + /* Reset CDCFGR1 register */ + RCC->CDCFGR1 = 0x00000000; + + /* Reset CDCFGR2 register */ + RCC->CDCFGR2 = 0x00000000; + + /* Reset SRDCFGR register */ + RCC->SRDCFGR = 0x00000000; +#endif + /* Reset PLLCKSELR register */ + RCC->PLLCKSELR = 0x02020200; + + /* Reset PLLCFGR register */ + RCC->PLLCFGR = 0x01FF0000; + /* Reset PLL1DIVR register */ + RCC->PLL1DIVR = 0x01010280; + /* Reset PLL1FRACR register */ + RCC->PLL1FRACR = 0x00000000; + + /* Reset PLL2DIVR register */ + RCC->PLL2DIVR = 0x01010280; + + /* Reset PLL2FRACR register */ + + RCC->PLL2FRACR = 0x00000000; + /* Reset PLL3DIVR register */ + RCC->PLL3DIVR = 0x01010280; + + /* Reset PLL3FRACR register */ + RCC->PLL3FRACR = 0x00000000; + + /* Reset HSEBYP bit */ + RCC->CR &= 0xFFFBFFFFU; + + /* Disable all interrupts */ + RCC->CIER = 0x00000000; + +#if (STM32H7_DEV_ID == 0x450UL) + /* dual core CM7 or single core line */ + if((DBGMCU->IDCODE & 0xFFFF0000U) < 0x20000000U) + { + /* if stm32h7 revY*/ + /* Change the switch matrix read issuing capability to 1 for the AXI SRAM target (Target 7) */ + *((__IO uint32_t*)0x51008108) = 0x000000001U; + } +#endif + +#if defined (DATA_IN_D2_SRAM) + /* in case of initialized data in D2 SRAM (AHB SRAM) , enable the D2 SRAM clock (AHB SRAM clock) */ +#if defined(RCC_AHB2ENR_D2SRAM3EN) + RCC->AHB2ENR |= (RCC_AHB2ENR_D2SRAM1EN | RCC_AHB2ENR_D2SRAM2EN | RCC_AHB2ENR_D2SRAM3EN); +#elif defined(RCC_AHB2ENR_D2SRAM2EN) + RCC->AHB2ENR |= (RCC_AHB2ENR_D2SRAM1EN | RCC_AHB2ENR_D2SRAM2EN); +#else + RCC->AHB2ENR |= (RCC_AHB2ENR_AHBSRAM1EN | RCC_AHB2ENR_AHBSRAM2EN); +#endif /* RCC_AHB2ENR_D2SRAM3EN */ + + tmpreg = RCC->AHB2ENR; + (void) tmpreg; +#endif /* DATA_IN_D2_SRAM */ + +#if defined(DUAL_CORE) && defined(CORE_CM4) + /* Configure the Vector Table location add offset address for cortex-M4 ------------------*/ +#ifdef VECT_TAB_SRAM + SCB->VTOR = D2_AXISRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ +#else + SCB->VTOR = FLASH_BANK2_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ +#endif /* VECT_TAB_SRAM */ + +#else + + /* + * Disable the FMC bank1 (enabled after reset). + * This, prevents CPU speculation access on this bank which blocks the use of FMC during + * 24us. During this time the others FMC master (such as LTDC) cannot use it! + */ + FMC_Bank1_R->BTCR[0] = 0x000030D2; + + /* Configure the Vector Table location add offset address for cortex-M7 ------------------*/ +#ifdef VECT_TAB_SRAM + SCB->VTOR = D1_AXISRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal AXI-RAM */ +#else + SCB->VTOR = FLASH_BANK1_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ +#endif + +#endif /*DUAL_CORE && CORE_CM4*/ + +} + +/** + * @brief Update SystemCoreClock variable according to Clock Register Values. + * The SystemCoreClock variable contains the core clock , it can + * be used by the user application to setup the SysTick timer or configure + * other parameters. + * + * @note Each time the core clock changes, this function must be called + * to update SystemCoreClock variable value. Otherwise, any configuration + * based on this variable will be incorrect. + * + * @note - The system frequency computed by this function is not the real + * frequency in the chip. It is calculated based on the predefined + * constant and the selected clock source: + * + * - If SYSCLK source is CSI, SystemCoreClock will contain the CSI_VALUE(*) + * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(**) + * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(***) + * - If SYSCLK source is PLL, SystemCoreClock will contain the CSI_VALUE(*), + * HSI_VALUE(**) or HSE_VALUE(***) multiplied/divided by the PLL factors. + * + * (*) CSI_VALUE is a constant defined in stm32h7xx_hal.h file (default value + * 4 MHz) but the real value may vary depending on the variations + * in voltage and temperature. + * (**) HSI_VALUE is a constant defined in stm32h7xx_hal.h file (default value + * 64 MHz) but the real value may vary depending on the variations + * in voltage and temperature. + * + * (***)HSE_VALUE is a constant defined in stm32h7xx_hal.h file (default value + * 25 MHz), user has to ensure that HSE_VALUE is same as the real + * frequency of the crystal used. Otherwise, this function may + * have wrong result. + * + * - The result of this function could be not correct when using fractional + * value for HSE crystal. + * @param None + * @retval None + */ +void SystemCoreClockUpdate (void) +{ + uint32_t pllp, pllsource, pllm, pllfracen, hsivalue, tmp; + uint32_t common_system_clock; + float_t fracn1, pllvco; + + + /* Get SYSCLK source -------------------------------------------------------*/ + + switch (RCC->CFGR & RCC_CFGR_SWS) + { + case RCC_CFGR_SWS_HSI: /* HSI used as system clock source */ + common_system_clock = (uint32_t) (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)); + break; + + case RCC_CFGR_SWS_CSI: /* CSI used as system clock source */ + common_system_clock = CSI_VALUE; + break; + + case RCC_CFGR_SWS_HSE: /* HSE used as system clock source */ + common_system_clock = HSE_VALUE; + break; + + case RCC_CFGR_SWS_PLL1: /* PLL1 used as system clock source */ + + /* PLL_VCO = (HSE_VALUE or HSI_VALUE or CSI_VALUE/ PLLM) * PLLN + SYSCLK = PLL_VCO / PLLR + */ + pllsource = (RCC->PLLCKSELR & RCC_PLLCKSELR_PLLSRC); + pllm = ((RCC->PLLCKSELR & RCC_PLLCKSELR_DIVM1)>> 4) ; + pllfracen = ((RCC->PLLCFGR & RCC_PLLCFGR_PLL1FRACEN)>>RCC_PLLCFGR_PLL1FRACEN_Pos); + fracn1 = (float_t)(uint32_t)(pllfracen* ((RCC->PLL1FRACR & RCC_PLL1FRACR_FRACN1)>> 3)); + + if (pllm != 0U) + { + switch (pllsource) + { + case RCC_PLLCKSELR_PLLSRC_HSI: /* HSI used as PLL clock source */ + + hsivalue = (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)) ; + pllvco = ( (float_t)hsivalue / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 ); + + break; + + case RCC_PLLCKSELR_PLLSRC_CSI: /* CSI used as PLL clock source */ + pllvco = ((float_t)CSI_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 ); + break; + + case RCC_PLLCKSELR_PLLSRC_HSE: /* HSE used as PLL clock source */ + pllvco = ((float_t)HSE_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 ); + break; + + default: + hsivalue = (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)) ; + pllvco = ((float_t)hsivalue / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 ); + break; + } + pllp = (((RCC->PLL1DIVR & RCC_PLL1DIVR_P1) >>9) + 1U ) ; + common_system_clock = (uint32_t)(float_t)(pllvco/(float_t)pllp); + } + else + { + common_system_clock = 0U; + } + break; + + default: + common_system_clock = (uint32_t) (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)); + break; + } + + /* Compute SystemClock frequency --------------------------------------------------*/ +#if defined (RCC_D1CFGR_D1CPRE) + tmp = D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_D1CPRE)>> RCC_D1CFGR_D1CPRE_Pos]; + + /* common_system_clock frequency : CM7 CPU frequency */ + common_system_clock >>= tmp; + + /* SystemD2Clock frequency : CM4 CPU, AXI and AHBs Clock frequency */ + SystemD2Clock = (common_system_clock >> ((D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_HPRE)>> RCC_D1CFGR_HPRE_Pos]) & 0x1FU)); + +#else + tmp = D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_CDCPRE)>> RCC_CDCFGR1_CDCPRE_Pos]; + + /* common_system_clock frequency : CM7 CPU frequency */ + common_system_clock >>= tmp; + + /* SystemD2Clock frequency : AXI and AHBs Clock frequency */ + SystemD2Clock = (common_system_clock >> ((D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_HPRE)>> RCC_CDCFGR1_HPRE_Pos]) & 0x1FU)); + +#endif + +#if defined(DUAL_CORE) && defined(CORE_CM4) + SystemCoreClock = SystemD2Clock; +#else + SystemCoreClock = common_system_clock; +#endif /* DUAL_CORE && CORE_CM4 */ +} + + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/Makefile b/Xibeca/Makefile new file mode 100644 index 00000000..9d09fe0b --- /dev/null +++ b/Xibeca/Makefile @@ -0,0 +1,35 @@ +PROJECT = Xibeca +BUILDROOT = . +OPENWARE ?= $(BUILDROOT)/.. + +include $(OPENWARE)/Hardware/owl3.mk + +C_SRC = $(wildcard Core/Src/*.c) +CPP_SRC = $(wildcard Core/Src/*.cpp) +C_SRC += $(OPENWARE)/Source/sdram.c +C_SRC += $(OPENWARE)/Source/pcm3168a.c +C_SRC += $(OPENWARE)/Source/usbd_audio.c +CPP_SRC += $(OPENWARE)/Source/usbh_midi.cpp + +# C_SRC += $(OPENWARE)/Source/ssd1309.c +# CPP_SRC += $(OPENWARE)/Source/ScreenBuffer.cpp +# CPP_SRC += $(OPENWARE)/Source/ScreenBufferMono.cpp +# CPP_SRC += $(OPENWARE)/Source/Graphics.cpp + +# CPP_SRC += $(OPENWARE)/Source/uart.cpp +# CPP_SRC += $(OPENWARE)/Source/MidiStreamReader.cpp + +S_SRC = $(BUILDROOT)/Core/Src/startup_stm32h743xx.s + +include $(OPENWARE)/Hardware/sources.mk + +C_SRC += $(C_SRC_SAI) +C_SRC += $(C_SRC_DAC) +C_SRC += $(C_SRC_SDRAM) +C_SRC += $(C_SRC_USBD) +C_SRC += $(C_SRC_USBH) +C_SRC += $(C_SRC_DSP) +C_SRC += $(C_SRC_OS) +# C_SRC += $(C_SRC_UART) + +include $(OPENWARE)/Hardware/h7.mk diff --git a/Xibeca/USB_DEVICE/App/usb_device.c b/Xibeca/USB_DEVICE/App/usb_device.c new file mode 100644 index 00000000..cacbd5b6 --- /dev/null +++ b/Xibeca/USB_DEVICE/App/usb_device.c @@ -0,0 +1,103 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usb_device.c + * @version : v1.0_Cube + * @brief : This file implements the USB Device + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ + +#include "usb_device.h" +#include "usbd_core.h" +#include "usbd_desc.h" +#include "usbd_audio.h" +#include "usbd_audio_if.h" + +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +/* USER CODE BEGIN PFP */ +/* Private function prototypes -----------------------------------------------*/ + +/* USER CODE END PFP */ + +/* USB Device Core handle declaration. */ +USBD_HandleTypeDef hUsbDeviceHS; + +/* + * -- Insert your variables declaration here -- + */ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* + * -- Insert your external function declaration here -- + */ +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ + +/** + * Init USB device Library, add supported class and start the library + * @retval None + */ +void MX_USB_DEVICE_Init(void) +{ + /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */ + + /* USER CODE END USB_DEVICE_Init_PreTreatment */ + + /* Init Device Library, add supported class and start the library. */ + if (USBD_Init(&hUsbDeviceHS, &HS_Desc, DEVICE_HS) != USBD_OK) + { + Error_Handler(); + } + if (USBD_RegisterClass(&hUsbDeviceHS, &USBD_AUDIO) != USBD_OK) + { + Error_Handler(); + } + if (USBD_AUDIO_RegisterInterface(&hUsbDeviceHS, &USBD_AUDIO_fops_HS) != USBD_OK) + { + Error_Handler(); + } + if (USBD_Start(&hUsbDeviceHS) != USBD_OK) + { + Error_Handler(); + } + + /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */ + HAL_PWREx_EnableUSBVoltageDetector(); + + /* USER CODE END USB_DEVICE_Init_PostTreatment */ +} + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/USB_DEVICE/App/usb_device.h b/Xibeca/USB_DEVICE/App/usb_device.h new file mode 100644 index 00000000..7c91b657 --- /dev/null +++ b/Xibeca/USB_DEVICE/App/usb_device.h @@ -0,0 +1,105 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usb_device.h + * @version : v1.0_Cube + * @brief : Header for usb_device.c file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USB_DEVICE__H__ +#define __USB_DEVICE__H__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32h7xx.h" +#include "stm32h7xx_hal.h" +#include "usbd_def.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/** @addtogroup USBD_OTG_DRIVER + * @{ + */ + +/** @defgroup USBD_DEVICE USBD_DEVICE + * @brief Device file for Usb otg low level driver. + * @{ + */ + +/** @defgroup USBD_DEVICE_Exported_Variables USBD_DEVICE_Exported_Variables + * @brief Public variables. + * @{ + */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* + * -- Insert your variables declaration here -- + */ +/* USER CODE BEGIN VARIABLES */ + +/* USER CODE END VARIABLES */ +/** + * @} + */ + +/** @defgroup USBD_DEVICE_Exported_FunctionsPrototype USBD_DEVICE_Exported_FunctionsPrototype + * @brief Declaration of public functions for Usb device. + * @{ + */ + +/** USB Device initialization function. */ +void MX_USB_DEVICE_Init(void); + +/* + * -- Insert functions declaration here -- + */ +/* USER CODE BEGIN FD */ + +/* USER CODE END FD */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __USB_DEVICE__H__ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/USB_DEVICE/App/usbd_desc.c b/Xibeca/USB_DEVICE/App/usbd_desc.c new file mode 100644 index 00000000..e49759c7 --- /dev/null +++ b/Xibeca/USB_DEVICE/App/usbd_desc.c @@ -0,0 +1,409 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : App/usbd_desc.c + * @version : v1.0_Cube + * @brief : This file implements the USB device descriptors. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "usbd_core.h" +#include "usbd_desc.h" +#include "usbd_conf.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ + +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY + * @{ + */ + +/** @addtogroup USBD_DESC + * @{ + */ + +/** @defgroup USBD_DESC_Private_TypesDefinitions USBD_DESC_Private_TypesDefinitions + * @brief Private types. + * @{ + */ + +/* USER CODE BEGIN PRIVATE_TYPES */ + +/* USER CODE END PRIVATE_TYPES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Defines USBD_DESC_Private_Defines + * @brief Private defines. + * @{ + */ + +#define USBD_VID 0x1209 +#define USBD_LANGID_STRING 1033 +#define USBD_MANUFACTURER_STRING "Rebel Technology" +#define USBD_PID_HS 0xDADA +#define USBD_PRODUCT_STRING_HS "OWL-XIBECA" +#define USBD_CONFIGURATION_STRING_HS "AUDIO Config" +#define USBD_INTERFACE_STRING_HS "AUDIO Interface" + +/* USER CODE BEGIN PRIVATE_DEFINES */ + +/* USER CODE END PRIVATE_DEFINES */ + +/** + * @} + */ + +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/** @defgroup USBD_DESC_Private_Macros USBD_DESC_Private_Macros + * @brief Private macros. + * @{ + */ + +/* USER CODE BEGIN PRIVATE_MACRO */ + +/* USER CODE END PRIVATE_MACRO */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes + * @brief Private functions declaration. + * @{ + */ + +static void Get_SerialNum(void); +static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len); + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes + * @brief Private functions declaration for HS. + * @{ + */ + +uint8_t * USBD_HS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_HS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_HS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_HS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_HS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_HS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_HS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables + * @brief Private variables. + * @{ + */ + +USBD_DescriptorsTypeDef HS_Desc = +{ + USBD_HS_DeviceDescriptor +, USBD_HS_LangIDStrDescriptor +, USBD_HS_ManufacturerStrDescriptor +, USBD_HS_ProductStrDescriptor +, USBD_HS_SerialStrDescriptor +, USBD_HS_ConfigStrDescriptor +, USBD_HS_InterfaceStrDescriptor +}; + +#if defined ( __ICCARM__ ) /* IAR Compiler */ + #pragma data_alignment=4 +#endif /* defined ( __ICCARM__ ) */ +/** USB standard device descriptor. */ +__ALIGN_BEGIN uint8_t USBD_HS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = +{ + 0x12, /*bLength */ + USB_DESC_TYPE_DEVICE, /*bDescriptorType*/ + 0x00, /*bcdUSB */ + + 0x02, + 0x00, /*bDeviceClass*/ + 0x00, /*bDeviceSubClass*/ + 0x00, /*bDeviceProtocol*/ + USB_MAX_EP0_SIZE, /*bMaxPacketSize*/ + LOBYTE(USBD_VID), /*idVendor*/ + HIBYTE(USBD_VID), /*idVendor*/ + LOBYTE(USBD_PID_HS), /*idProduct*/ + HIBYTE(USBD_PID_HS), /*idProduct*/ + 0x00, /*bcdDevice rel. 2.00*/ + 0x02, + USBD_IDX_MFC_STR, /*Index of manufacturer string*/ + USBD_IDX_PRODUCT_STR, /*Index of product string*/ + USBD_IDX_SERIAL_STR, /*Index of serial number string*/ + USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/ +}; + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables + * @brief Private variables. + * @{ + */ + +#if defined ( __ICCARM__ ) /* IAR Compiler */ + #pragma data_alignment=4 +#endif /* defined ( __ICCARM__ ) */ + +/** USB lang indentifier descriptor. */ +__ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = +{ + USB_LEN_LANGID_STR_DESC, + USB_DESC_TYPE_STRING, + LOBYTE(USBD_LANGID_STRING), + HIBYTE(USBD_LANGID_STRING) +}; + +#if defined ( __ICCARM__ ) /* IAR Compiler */ + #pragma data_alignment=4 +#endif /* defined ( __ICCARM__ ) */ +/* Internal string descriptor. */ +__ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END; + +#if defined ( __ICCARM__ ) /*!< IAR Compiler */ + #pragma data_alignment=4 +#endif +__ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { + USB_SIZ_STRING_SERIAL, + USB_DESC_TYPE_STRING, +}; + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Functions USBD_DESC_Private_Functions + * @brief Private functions. + * @{ + */ + +/** + * @brief Return the device descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_HS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = sizeof(USBD_HS_DeviceDesc); + return USBD_HS_DeviceDesc; +} + +/** + * @brief Return the LangID string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_HS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = sizeof(USBD_LangIDDesc); + return USBD_LangIDDesc; +} + +/** + * @brief Return the product string descriptor + * @param speed : current device speed + * @param length : pointer to data length variable + * @retval pointer to descriptor buffer + */ +uint8_t * USBD_HS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == 0) + { + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_HS, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_HS, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +/** + * @brief Return the manufacturer string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_HS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length); + return USBD_StrDesc; +} + +/** + * @brief Return the serial number string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_HS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = USB_SIZ_STRING_SERIAL; + + /* Update the serial number string descriptor with the data from the unique + * ID */ + Get_SerialNum(); + /* USER CODE BEGIN USBD_HS_SerialStrDescriptor */ + + /* USER CODE END USBD_HS_SerialStrDescriptor */ + + return (uint8_t *) USBD_StringSerial; +} + +/** + * @brief Return the configuration string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_HS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == USBD_SPEED_HIGH) + { + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_HS, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_HS, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +/** + * @brief Return the interface string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_HS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == 0) + { + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_HS, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_HS, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +#if (USBD_LPM_ENABLED == 1) +/** + * @brief Return the BOS descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_HS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = sizeof(USBD_HS_BOSDesc); + return (uint8_t*)USBD_HS_BOSDesc; +} +#endif /* (USBD_LPM_ENABLED == 1) */ + +/** + * @brief Create the serial number string descriptor + * @param None + * @retval None + */ +static void Get_SerialNum(void) +{ + uint32_t deviceserial0, deviceserial1, deviceserial2; + + deviceserial0 = *(uint32_t *) DEVICE_ID1; + deviceserial1 = *(uint32_t *) DEVICE_ID2; + deviceserial2 = *(uint32_t *) DEVICE_ID3; + + deviceserial0 += deviceserial2; + + if (deviceserial0 != 0) + { + IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8); + IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4); + } +} + +/** + * @brief Convert Hex 32Bits value into char + * @param value: value to convert + * @param pbuf: pointer to the buffer + * @param len: buffer length + * @retval None + */ +static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len) +{ + uint8_t idx = 0; + + for (idx = 0; idx < len; idx++) + { + if (((value >> 28)) < 0xA) + { + pbuf[2 * idx] = (value >> 28) + '0'; + } + else + { + pbuf[2 * idx] = (value >> 28) + 'A' - 10; + } + + value = value << 4; + + pbuf[2 * idx + 1] = 0; + } +} +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/USB_DEVICE/App/usbd_desc.h b/Xibeca/USB_DEVICE/App/usbd_desc.h new file mode 100644 index 00000000..4033860d --- /dev/null +++ b/Xibeca/USB_DEVICE/App/usbd_desc.h @@ -0,0 +1,145 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usbd_desc.c + * @version : v1.0_Cube + * @brief : Header for usbd_conf.c file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USBD_DESC__C__ +#define __USBD_DESC__C__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "usbd_def.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY + * @{ + */ + +/** @defgroup USBD_DESC USBD_DESC + * @brief Usb device descriptors module. + * @{ + */ + +/** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants + * @brief Constants. + * @{ + */ +#define DEVICE_ID1 (UID_BASE) +#define DEVICE_ID2 (UID_BASE + 0x4) +#define DEVICE_ID3 (UID_BASE + 0x8) + +#define USB_SIZ_STRING_SERIAL 0x1A + +/* USER CODE BEGIN EXPORTED_CONSTANTS */ + +/* USER CODE END EXPORTED_CONSTANTS */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_Defines USBD_DESC_Exported_Defines + * @brief Defines. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_DEFINES */ + +/* USER CODE END EXPORTED_DEFINES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_TypesDefinitions USBD_DESC_Exported_TypesDefinitions + * @brief Types. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_TYPES */ + +/* USER CODE END EXPORTED_TYPES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_Macros USBD_DESC_Exported_Macros + * @brief Aliases. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_MACRO */ + +/* USER CODE END EXPORTED_MACRO */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_Variables USBD_DESC_Exported_Variables + * @brief Public variables. + * @{ + */ + +/** Descriptor for the Usb device. */ +extern USBD_DescriptorsTypeDef HS_Desc; + +/* USER CODE BEGIN EXPORTED_VARIABLES */ + +/* USER CODE END EXPORTED_VARIABLES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_FunctionsPrototype USBD_DESC_Exported_FunctionsPrototype + * @brief Public functions declaration. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_FUNCTIONS */ + +/* USER CODE END EXPORTED_FUNCTIONS */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __USBD_DESC__C__ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/USB_DEVICE/Target/usbd_conf.c b/Xibeca/USB_DEVICE/Target/usbd_conf.c new file mode 100644 index 00000000..d80383be --- /dev/null +++ b/Xibeca/USB_DEVICE/Target/usbd_conf.c @@ -0,0 +1,683 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : Target/usbd_conf.c + * @version : v1.0_Cube + * @brief : This file implements the board support package for the USB device library + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32h7xx.h" +#include "stm32h7xx_hal.h" +#include "usbd_def.h" +#include "usbd_core.h" +#include "usbd_audio.h" + +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ + +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +PCD_HandleTypeDef hpcd_USB_OTG_HS; +void Error_Handler(void); + +/* External functions --------------------------------------------------------*/ + +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* USER CODE BEGIN PFP */ +/* Private function prototypes -----------------------------------------------*/ +USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status); + +/* USER CODE END PFP */ + +/* Private functions ---------------------------------------------------------*/ + +/* USER CODE BEGIN 1 */ +/* USER CODE END 1 */ + +/******************************************************************************* + LL Driver Callbacks (PCD -> USB Device Library) +*******************************************************************************/ +/* MSP Init */ + +void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + if(pcdHandle->Instance==USB_OTG_HS) + { + /* USER CODE BEGIN USB_OTG_HS_MspInit 0 */ + + /* USER CODE END USB_OTG_HS_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB; + PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + /** Enable USB Voltage detector + */ + HAL_PWREx_EnableUSBVoltageDetector(); + + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**USB_OTG_HS GPIO Configuration + PB13 ------> USB_OTG_HS_VBUS + PB14 ------> USB_OTG_HS_DM + PB15 ------> USB_OTG_HS_DP + */ + GPIO_InitStruct.Pin = GPIO_PIN_13; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF12_OTG2_FS; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* Peripheral clock enable */ + __HAL_RCC_USB_OTG_HS_CLK_ENABLE(); + + /* Peripheral interrupt init */ + HAL_NVIC_SetPriority(OTG_HS_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(OTG_HS_IRQn); + /* USER CODE BEGIN USB_OTG_HS_MspInit 1 */ + + /* USER CODE END USB_OTG_HS_MspInit 1 */ + } +} + +void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) +{ + if(pcdHandle->Instance==USB_OTG_HS) + { + /* USER CODE BEGIN USB_OTG_HS_MspDeInit 0 */ + + /* USER CODE END USB_OTG_HS_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_USB_OTG_HS_CLK_DISABLE(); + + /**USB_OTG_HS GPIO Configuration + PB13 ------> USB_OTG_HS_VBUS + PB14 ------> USB_OTG_HS_DM + PB15 ------> USB_OTG_HS_DP + */ + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15); + + /* Peripheral interrupt Deinit*/ + HAL_NVIC_DisableIRQ(OTG_HS_IRQn); + + /* USER CODE BEGIN USB_OTG_HS_MspDeInit 1 */ + + /* USER CODE END USB_OTG_HS_MspDeInit 1 */ + } +} + +/** + * @brief Setup stage callback + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_SetupStage((USBD_HandleTypeDef*)hpcd->pData, (uint8_t *)hpcd->Setup); +} + +/** + * @brief Data Out stage callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#else +void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_DataOutStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff); +} + +/** + * @brief Data In stage callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#else +void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_DataInStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff); +} + +/** + * @brief SOF callback. + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_SOFCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_SOF((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief Reset callback. + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ResetCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_SpeedTypeDef speed = USBD_SPEED_FULL; + + if ( hpcd->Init.speed == PCD_SPEED_HIGH) + { + speed = USBD_SPEED_HIGH; + } + else if ( hpcd->Init.speed == PCD_SPEED_FULL) + { + speed = USBD_SPEED_FULL; + } + else + { + Error_Handler(); + } + /* Set Speed. */ + USBD_LL_SetSpeed((USBD_HandleTypeDef*)hpcd->pData, speed); + + /* Reset Device. */ + USBD_LL_Reset((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief Suspend callback. + * When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it) + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + /* Inform USB library that core enters in suspend Mode. */ + USBD_LL_Suspend((USBD_HandleTypeDef*)hpcd->pData); + __HAL_PCD_GATE_PHYCLOCK(hpcd); + /* Enter in STOP mode. */ + /* USER CODE BEGIN 2 */ + if (hpcd->Init.low_power_enable) + { + /* Set SLEEPDEEP bit and SleepOnExit of Cortex System Control Register. */ + SCB->SCR |= (uint32_t)((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk)); + } + /* USER CODE END 2 */ +} + +/** + * @brief Resume callback. + * When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it) + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + /* USER CODE BEGIN 3 */ + + /* USER CODE END 3 */ + USBD_LL_Resume((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief ISOOUTIncomplete callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#else +void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_IsoOUTIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); +} + +/** + * @brief ISOINIncomplete callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#else +void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_IsoINIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); +} + +/** + * @brief Connect callback. + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_DevConnected((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief Disconnect callback. + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_DevDisconnected((USBD_HandleTypeDef*)hpcd->pData); +} + +/******************************************************************************* + LL Driver Interface (USB Device Library --> PCD) +*******************************************************************************/ + +/** + * @brief Initializes the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) +{ + /* Init USB Ip. */ + if (pdev->id == DEVICE_HS) { + /* Link the driver to the stack. */ + hpcd_USB_OTG_HS.pData = pdev; + pdev->pData = &hpcd_USB_OTG_HS; + + hpcd_USB_OTG_HS.Instance = USB_OTG_HS; + hpcd_USB_OTG_HS.Init.dev_endpoints = 9; + hpcd_USB_OTG_HS.Init.speed = PCD_SPEED_FULL; + hpcd_USB_OTG_HS.Init.dma_enable = DISABLE; + hpcd_USB_OTG_HS.Init.phy_itface = USB_OTG_EMBEDDED_PHY; + hpcd_USB_OTG_HS.Init.Sof_enable = DISABLE; + hpcd_USB_OTG_HS.Init.low_power_enable = DISABLE; + hpcd_USB_OTG_HS.Init.lpm_enable = DISABLE; + hpcd_USB_OTG_HS.Init.battery_charging_enable = ENABLE; + hpcd_USB_OTG_HS.Init.vbus_sensing_enable = ENABLE; + hpcd_USB_OTG_HS.Init.use_dedicated_ep1 = DISABLE; + hpcd_USB_OTG_HS.Init.use_external_vbus = DISABLE; + if (HAL_PCD_Init(&hpcd_USB_OTG_HS) != HAL_OK) + { + Error_Handler( ); + } + +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) + /* Register USB PCD CallBacks */ + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_SOF_CB_ID, PCD_SOFCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_SETUPSTAGE_CB_ID, PCD_SetupStageCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_RESET_CB_ID, PCD_ResetCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_SUSPEND_CB_ID, PCD_SuspendCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_RESUME_CB_ID, PCD_ResumeCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_CONNECT_CB_ID, PCD_ConnectCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_DISCONNECT_CB_ID, PCD_DisconnectCallback); + + HAL_PCD_RegisterDataOutStageCallback(&hpcd_USB_OTG_HS, PCD_DataOutStageCallback); + HAL_PCD_RegisterDataInStageCallback(&hpcd_USB_OTG_HS, PCD_DataInStageCallback); + HAL_PCD_RegisterIsoOutIncpltCallback(&hpcd_USB_OTG_HS, PCD_ISOOUTIncompleteCallback); + HAL_PCD_RegisterIsoInIncpltCallback(&hpcd_USB_OTG_HS, PCD_ISOINIncompleteCallback); +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ + HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_HS, 0x200); + HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 0, 0x80); + HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 1, 0x174); + } + return USBD_OK; +} + +/** + * @brief De-Initializes the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_DeInit(pdev->pData); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Starts the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_Start(pdev->pData); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Stops the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_Stop(pdev->pData); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Opens an endpoint of the low level driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @param ep_type: Endpoint type + * @param ep_mps: Endpoint max packet size + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Open(pdev->pData, ep_addr, ep_mps, ep_type); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Closes an endpoint of the low level driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Close(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Flushes an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Flush(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Sets a Stall condition on an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_SetStall(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Clears a Stall condition on an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_ClrStall(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Returns Stall condition. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval Stall (1: Yes, 0: No) + */ +uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef*) pdev->pData; + + if((ep_addr & 0x80) == 0x80) + { + return hpcd->IN_ep[ep_addr & 0x7F].is_stall; + } + else + { + return hpcd->OUT_ep[ep_addr & 0x7F].is_stall; + } +} + +/** + * @brief Assigns a USB address to the device. + * @param pdev: Device handle + * @param dev_addr: Device address + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_SetAddress(pdev->pData, dev_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Transmits data over an endpoint. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @param pbuf: Pointer to data to be sent + * @param size: Data size + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Transmit(pdev->pData, ep_addr, pbuf, size); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Prepares an endpoint for reception. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @param pbuf: Pointer to data to be received + * @param size: Data size + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Receive(pdev->pData, ep_addr, pbuf, size); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Returns the last transfered packet size. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval Recived Data Size + */ +uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef*) pdev->pData, ep_addr); +} +/** + * @brief Static single allocation. + * @param size: Size of allocated memory + * @retval None + */ +void *USBD_static_malloc(uint32_t size) +{ + static uint32_t mem[(sizeof(USBD_AUDIO_HandleTypeDef)/4)+1];/* On 32-bit boundary */ + return mem; +} + +/** + * @brief Dummy memory free + * @param p: Pointer to allocated memory address + * @retval None + */ +void USBD_static_free(void *p) +{ + +} + +/** + * @brief Delays routine for the USB device library. + * @param Delay: Delay in ms + * @retval None + */ +void USBD_LL_Delay(uint32_t Delay) +{ + HAL_Delay(Delay); +} + +/** + * @brief Retuns the USB status depending on the HAL status: + * @param hal_status: HAL status + * @retval USB status + */ +USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status) +{ + USBD_StatusTypeDef usb_status = USBD_OK; + + switch (hal_status) + { + case HAL_OK : + usb_status = USBD_OK; + break; + case HAL_ERROR : + usb_status = USBD_FAIL; + break; + case HAL_BUSY : + usb_status = USBD_BUSY; + break; + case HAL_TIMEOUT : + usb_status = USBD_FAIL; + break; + default : + usb_status = USBD_FAIL; + break; + } + return usb_status; +} + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/USB_DEVICE/Target/usbd_conf.h b/Xibeca/USB_DEVICE/Target/usbd_conf.h new file mode 100644 index 00000000..b8e568d2 --- /dev/null +++ b/Xibeca/USB_DEVICE/Target/usbd_conf.h @@ -0,0 +1,176 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usbd_conf.h + * @version : v1.0_Cube + * @brief : Header for usbd_conf.c file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USBD_CONF__H__ +#define __USBD_CONF__H__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include +#include +#include +#include "main.h" +#include "stm32h7xx.h" +#include "stm32h7xx_hal.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/** @addtogroup USBD_OTG_DRIVER + * @brief Driver for Usb device. + * @{ + */ + +/** @defgroup USBD_CONF USBD_CONF + * @brief Configuration file for Usb otg low level driver. + * @{ + */ + +/** @defgroup USBD_CONF_Exported_Variables USBD_CONF_Exported_Variables + * @brief Public variables. + * @{ + */ + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_Defines USBD_CONF_Exported_Defines + * @brief Defines for configuration of the Usb device. + * @{ + */ + +/*---------- -----------*/ +#define USBD_MAX_NUM_INTERFACES 1U +/*---------- -----------*/ +#define USBD_MAX_NUM_CONFIGURATION 1U +/*---------- -----------*/ +#define USBD_MAX_STR_DESC_SIZ 512U +/*---------- -----------*/ +#define USBD_DEBUG_LEVEL 0U +/*---------- -----------*/ +#define USBD_LPM_ENABLED 0U +/*---------- -----------*/ +#define USBD_SELF_POWERED 1U +/*---------- -----------*/ +#define USBD_AUDIO_FREQ 22100U + +/****************************************/ +/* #define for FS and HS identification */ +#define DEVICE_FS 0 +#define DEVICE_HS 1 + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_Macros USBD_CONF_Exported_Macros + * @brief Aliases. + * @{ + */ + +/* Memory management macros make sure to use static memory allocation */ +/** Alias for memory allocation. */ +#define USBD_malloc (void *)USBD_static_malloc + +/** Alias for memory release. */ +#define USBD_free USBD_static_free + +/** Alias for memory set. */ +#define USBD_memset memset + +/** Alias for memory copy. */ +#define USBD_memcpy memcpy + +/** Alias for delay. */ +#define USBD_Delay HAL_Delay + +/* DEBUG macros */ + +#if (USBD_DEBUG_LEVEL > 0) +#define USBD_UsrLog(...) printf(__VA_ARGS__);\ + printf("\n"); +#else +#define USBD_UsrLog(...) +#endif + +#if (USBD_DEBUG_LEVEL > 1) + +#define USBD_ErrLog(...) printf("ERROR: ") ;\ + printf(__VA_ARGS__);\ + printf("\n"); +#else +#define USBD_ErrLog(...) +#endif + +#if (USBD_DEBUG_LEVEL > 2) +#define USBD_DbgLog(...) printf("DEBUG : ") ;\ + printf(__VA_ARGS__);\ + printf("\n"); +#else +#define USBD_DbgLog(...) +#endif + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_Types USBD_CONF_Exported_Types + * @brief Types. + * @{ + */ + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_FunctionsPrototype USBD_CONF_Exported_FunctionsPrototype + * @brief Declaration of public functions for Usb device. + * @{ + */ + +/* Exported functions -------------------------------------------------------*/ +void *USBD_static_malloc(uint32_t size); +void USBD_static_free(void *p); +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __USBD_CONF__H__ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/USB_HOST/App/usb_host.c b/Xibeca/USB_HOST/App/usb_host.c new file mode 100644 index 00000000..5952ec21 --- /dev/null +++ b/Xibeca/USB_HOST/App/usb_host.c @@ -0,0 +1,130 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usb_host.c + * @version : v1.0_Cube + * @brief : This file implements the USB Host + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ + +#include "usb_host.h" +#include "usbh_core.h" +#include "usbh_audio.h" + +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +/* USER CODE BEGIN PFP */ +/* Private function prototypes -----------------------------------------------*/ + +/* USER CODE END PFP */ + +/* USB Host core handle declaration */ +USBH_HandleTypeDef hUsbHostFS; +ApplicationTypeDef Appli_state = APPLICATION_IDLE; + +/* + * -- Insert your variables declaration here -- + */ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* + * user callback declaration + */ +static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id); + +/* + * -- Insert your external function declaration here -- + */ +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ + +/** + * Init USB host library, add supported class and start the library + * @retval None + */ +void MX_USB_HOST_Init(void) +{ + /* USER CODE BEGIN USB_HOST_Init_PreTreatment */ + + /* USER CODE END USB_HOST_Init_PreTreatment */ + + /* Init host Library, add supported class and start the library. */ + if (USBH_Init(&hUsbHostFS, USBH_UserProcess, HOST_FS) != USBH_OK) + { + Error_Handler(); + } + if (USBH_RegisterClass(&hUsbHostFS, USBH_AUDIO_CLASS) != USBH_OK) + { + Error_Handler(); + } + if (USBH_Start(&hUsbHostFS) != USBH_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN USB_HOST_Init_PostTreatment */ + + /* USER CODE END USB_HOST_Init_PostTreatment */ +} + +/* + * user callback definition + */ +static void USBH_UserProcess (USBH_HandleTypeDef *phost, uint8_t id) +{ + /* USER CODE BEGIN CALL_BACK_1 */ + switch(id) + { + case HOST_USER_SELECT_CONFIGURATION: + break; + + case HOST_USER_DISCONNECTION: + Appli_state = APPLICATION_DISCONNECT; + break; + + case HOST_USER_CLASS_ACTIVE: + Appli_state = APPLICATION_READY; + break; + + case HOST_USER_CONNECTION: + Appli_state = APPLICATION_START; + break; + + default: + break; + } + /* USER CODE END CALL_BACK_1 */ +} + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/USB_HOST/App/usb_host.h b/Xibeca/USB_HOST/App/usb_host.h new file mode 100644 index 00000000..d261dea2 --- /dev/null +++ b/Xibeca/USB_HOST/App/usb_host.h @@ -0,0 +1,92 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usb_host.h + * @version : v1.0_Cube + * @brief : Header for usb_host.c file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USB_HOST__H__ +#define __USB_HOST__H__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32h7xx.h" +#include "stm32h7xx_hal.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/** @addtogroup USBH_OTG_DRIVER + * @{ + */ + +/** @defgroup USBH_HOST USBH_HOST + * @brief Host file for Usb otg low level driver. + * @{ + */ + +/** @defgroup USBH_HOST_Exported_Variables USBH_HOST_Exported_Variables + * @brief Public variables. + * @{ + */ + +/** + * @} + */ + +/** Status of the application. */ +typedef enum { + APPLICATION_IDLE = 0, + APPLICATION_START, + APPLICATION_READY, + APPLICATION_DISCONNECT +}ApplicationTypeDef; + +/** @defgroup USBH_HOST_Exported_FunctionsPrototype USBH_HOST_Exported_FunctionsPrototype + * @brief Declaration of public functions for Usb host. + * @{ + */ + +/* Exported functions -------------------------------------------------------*/ + +/** @brief USB Host initialization function. */ +void MX_USB_HOST_Init(void); + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __USB_HOST__H__ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/USB_HOST/Target/usbh_conf.c b/Xibeca/USB_HOST/Target/usbh_conf.c new file mode 100644 index 00000000..9cbf8103 --- /dev/null +++ b/Xibeca/USB_HOST/Target/usbh_conf.c @@ -0,0 +1,575 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : Target/usbh_conf.c + * @version : v1.0_Cube + * @brief : This file implements the board support package for the USB host library + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "usbh_core.h" + +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ + +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +HCD_HandleTypeDef hhcd_USB_OTG_FS; +void Error_Handler(void); + +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* USER CODE BEGIN PFP */ +/* Private function prototypes -----------------------------------------------*/ +USBH_StatusTypeDef USBH_Get_USB_Status(HAL_StatusTypeDef hal_status); + +/* USER CODE END PFP */ + +/* Private functions ---------------------------------------------------------*/ + +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ + +/******************************************************************************* + LL Driver Callbacks (HCD -> USB Host Library) +*******************************************************************************/ +/* MSP Init */ + +void HAL_HCD_MspInit(HCD_HandleTypeDef* hcdHandle) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + if(hcdHandle->Instance==USB_OTG_FS) + { + /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */ + + /* USER CODE END USB_OTG_FS_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB; + PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + /** Enable USB Voltage detector + */ + HAL_PWREx_EnableUSBVoltageDetector(); + + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**USB_OTG_FS GPIO Configuration + PA12 ------> USB_OTG_FS_DP + PA11 ------> USB_OTG_FS_DM + PA9 ------> USB_OTG_FS_VBUS + */ + GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_11; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF10_OTG1_FS; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* Peripheral clock enable */ + __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); + + /* Peripheral interrupt init */ + HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(OTG_FS_IRQn); + /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */ + + /* USER CODE END USB_OTG_FS_MspInit 1 */ + } +} + +void HAL_HCD_MspDeInit(HCD_HandleTypeDef* hcdHandle) +{ + if(hcdHandle->Instance==USB_OTG_FS) + { + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */ + + /* USER CODE END USB_OTG_FS_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); + + /**USB_OTG_FS GPIO Configuration + PA12 ------> USB_OTG_FS_DP + PA11 ------> USB_OTG_FS_DM + PA9 ------> USB_OTG_FS_VBUS + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_12|GPIO_PIN_11|GPIO_PIN_9); + + /* Peripheral interrupt Deinit*/ + HAL_NVIC_DisableIRQ(OTG_FS_IRQn); + + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */ + + /* USER CODE END USB_OTG_FS_MspDeInit 1 */ + } +} + +/** + * @brief SOF callback. + * @param hhcd: HCD handle + * @retval None + */ +void HAL_HCD_SOF_Callback(HCD_HandleTypeDef *hhcd) +{ + USBH_LL_IncTimer(hhcd->pData); +} + +/** + * @brief SOF callback. + * @param hhcd: HCD handle + * @retval None + */ +void HAL_HCD_Connect_Callback(HCD_HandleTypeDef *hhcd) +{ + USBH_LL_Connect(hhcd->pData); +} + +/** + * @brief SOF callback. + * @param hhcd: HCD handle + * @retval None + */ +void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd) +{ + USBH_LL_Disconnect(hhcd->pData); +} + +/** + * @brief Notify URB state change callback. + * @param hhcd: HCD handle + * @param chnum: channel number + * @param urb_state: state + * @retval None + */ +void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) +{ + /* To be used with OS to sync URB state with the global state machine */ +#if (USBH_USE_OS == 1) + USBH_LL_NotifyURBChange(hhcd->pData); +#endif +} +/** +* @brief Port Port Enabled callback. + * @param hhcd: HCD handle + * @retval None + */ +void HAL_HCD_PortEnabled_Callback(HCD_HandleTypeDef *hhcd) +{ + USBH_LL_PortEnabled(hhcd->pData); +} + +/** + * @brief Port Port Disabled callback. + * @param hhcd: HCD handle + * @retval None + */ +void HAL_HCD_PortDisabled_Callback(HCD_HandleTypeDef *hhcd) +{ + USBH_LL_PortDisabled(hhcd->pData); +} + +/******************************************************************************* + LL Driver Interface (USB Host Library --> HCD) +*******************************************************************************/ + +/** + * @brief Initialize the low level portion of the host driver. + * @param phost: Host handle + * @retval USBH status + */ +USBH_StatusTypeDef USBH_LL_Init(USBH_HandleTypeDef *phost) +{ + /* Init USB_IP */ + if (phost->id == HOST_FS) { + /* Link the driver to the stack. */ + hhcd_USB_OTG_FS.pData = phost; + phost->pData = &hhcd_USB_OTG_FS; + + hhcd_USB_OTG_FS.Instance = USB_OTG_FS; + hhcd_USB_OTG_FS.Init.Host_channels = 16; + hhcd_USB_OTG_FS.Init.speed = HCD_SPEED_FULL; + hhcd_USB_OTG_FS.Init.dma_enable = DISABLE; + hhcd_USB_OTG_FS.Init.phy_itface = HCD_PHY_EMBEDDED; + hhcd_USB_OTG_FS.Init.Sof_enable = DISABLE; + if (HAL_HCD_Init(&hhcd_USB_OTG_FS) != HAL_OK) + { + Error_Handler( ); + } + + USBH_LL_SetTimer(phost, HAL_HCD_GetCurrentFrame(&hhcd_USB_OTG_FS)); + } + return USBH_OK; +} + +/** + * @brief De-Initialize the low level portion of the host driver. + * @param phost: Host handle + * @retval USBH status + */ +USBH_StatusTypeDef USBH_LL_DeInit(USBH_HandleTypeDef *phost) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBH_StatusTypeDef usb_status = USBH_OK; + + hal_status = HAL_HCD_DeInit(phost->pData); + + usb_status = USBH_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Start the low level portion of the host driver. + * @param phost: Host handle + * @retval USBH status + */ +USBH_StatusTypeDef USBH_LL_Start(USBH_HandleTypeDef *phost) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBH_StatusTypeDef usb_status = USBH_OK; + + hal_status = HAL_HCD_Start(phost->pData); + + usb_status = USBH_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Stop the low level portion of the host driver. + * @param phost: Host handle + * @retval USBH status + */ +USBH_StatusTypeDef USBH_LL_Stop(USBH_HandleTypeDef *phost) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBH_StatusTypeDef usb_status = USBH_OK; + + hal_status = HAL_HCD_Stop(phost->pData); + + usb_status = USBH_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Return the USB host speed from the low level driver. + * @param phost: Host handle + * @retval USBH speeds + */ +USBH_SpeedTypeDef USBH_LL_GetSpeed(USBH_HandleTypeDef *phost) +{ + USBH_SpeedTypeDef speed = USBH_SPEED_FULL; + + switch (HAL_HCD_GetCurrentSpeed(phost->pData)) + { + case 0 : + speed = USBH_SPEED_HIGH; + break; + + case 1 : + speed = USBH_SPEED_FULL; + break; + + case 2 : + speed = USBH_SPEED_LOW; + break; + + default: + speed = USBH_SPEED_FULL; + break; + } + return speed; +} + +/** + * @brief Reset the Host port of the low level driver. + * @param phost: Host handle + * @retval USBH status + */ +USBH_StatusTypeDef USBH_LL_ResetPort(USBH_HandleTypeDef *phost) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBH_StatusTypeDef usb_status = USBH_OK; + + hal_status = HAL_HCD_ResetPort(phost->pData); + + usb_status = USBH_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Return the last transfered packet size. + * @param phost: Host handle + * @param pipe: Pipe index + * @retval Packet size + */ +uint32_t USBH_LL_GetLastXferSize(USBH_HandleTypeDef *phost, uint8_t pipe) +{ + return HAL_HCD_HC_GetXferCount(phost->pData, pipe); +} + +/** + * @brief Open a pipe of the low level driver. + * @param phost: Host handle + * @param pipe_num: Pipe index + * @param epnum: Endpoint number + * @param dev_address: Device USB address + * @param speed: Device Speed + * @param ep_type: Endpoint type + * @param mps: Endpoint max packet size + * @retval USBH status + */ +USBH_StatusTypeDef USBH_LL_OpenPipe(USBH_HandleTypeDef *phost, uint8_t pipe_num, uint8_t epnum, + uint8_t dev_address, uint8_t speed, uint8_t ep_type, uint16_t mps) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBH_StatusTypeDef usb_status = USBH_OK; + + hal_status = HAL_HCD_HC_Init(phost->pData, pipe_num, epnum, + dev_address, speed, ep_type, mps); + + usb_status = USBH_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Close a pipe of the low level driver. + * @param phost: Host handle + * @param pipe: Pipe index + * @retval USBH status + */ +USBH_StatusTypeDef USBH_LL_ClosePipe(USBH_HandleTypeDef *phost, uint8_t pipe) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBH_StatusTypeDef usb_status = USBH_OK; + + hal_status = HAL_HCD_HC_Halt(phost->pData, pipe); + + usb_status = USBH_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Submit a new URB to the low level driver. + * @param phost: Host handle + * @param pipe: Pipe index + * This parameter can be a value from 1 to 15 + * @param direction : Channel number + * This parameter can be one of the these values: + * 0 : Output + * 1 : Input + * @param ep_type : Endpoint Type + * This parameter can be one of the these values: + * @arg EP_TYPE_CTRL: Control type + * @arg EP_TYPE_ISOC: Isochrounous type + * @arg EP_TYPE_BULK: Bulk type + * @arg EP_TYPE_INTR: Interrupt type + * @param token : Endpoint Type + * This parameter can be one of the these values: + * @arg 0: PID_SETUP + * @arg 1: PID_DATA + * @param pbuff : pointer to URB data + * @param length : Length of URB data + * @param do_ping : activate do ping protocol (for high speed only) + * This parameter can be one of the these values: + * 0 : do ping inactive + * 1 : do ping active + * @retval Status + */ +USBH_StatusTypeDef USBH_LL_SubmitURB(USBH_HandleTypeDef *phost, uint8_t pipe, uint8_t direction, + uint8_t ep_type, uint8_t token, uint8_t *pbuff, uint16_t length, + uint8_t do_ping) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBH_StatusTypeDef usb_status = USBH_OK; + + hal_status = HAL_HCD_HC_SubmitRequest(phost->pData, pipe, direction , + ep_type, token, pbuff, length, + do_ping); + usb_status = USBH_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Get a URB state from the low level driver. + * @param phost: Host handle + * @param pipe: Pipe index + * This parameter can be a value from 1 to 15 + * @retval URB state + * This parameter can be one of the these values: + * @arg URB_IDLE + * @arg URB_DONE + * @arg URB_NOTREADY + * @arg URB_NYET + * @arg URB_ERROR + * @arg URB_STALL + */ +USBH_URBStateTypeDef USBH_LL_GetURBState(USBH_HandleTypeDef *phost, uint8_t pipe) +{ + return (USBH_URBStateTypeDef)HAL_HCD_HC_GetURBState (phost->pData, pipe); +} + +/** + * @brief Drive VBUS. + * @param phost: Host handle + * @param state : VBUS state + * This parameter can be one of the these values: + * 0 : VBUS Inactive + * 1 : VBUS Active + * @retval Status + */ +USBH_StatusTypeDef USBH_LL_DriverVBUS(USBH_HandleTypeDef *phost, uint8_t state) +{ + + /* USER CODE BEGIN 0 */ + + /* USER CODE END 0*/ + + if (phost->id == HOST_FS) + { + if (state == 0) + { + /* Drive high Charge pump */ + /* ToDo: Add IOE driver control */ + /* USER CODE BEGIN DRIVE_HIGH_CHARGE_FOR_FS */ + + /* USER CODE END DRIVE_HIGH_CHARGE_FOR_FS */ + } + else + { + /* Drive low Charge pump */ + /* ToDo: Add IOE driver control */ + /* USER CODE BEGIN DRIVE_LOW_CHARGE_FOR_FS */ + + /* USER CODE END DRIVE_LOW_CHARGE_FOR_FS */ + } + } + HAL_Delay(200); + return USBH_OK; +} + +/** + * @brief Set toggle for a pipe. + * @param phost: Host handle + * @param pipe: Pipe index + * @param toggle: toggle (0/1) + * @retval Status + */ +USBH_StatusTypeDef USBH_LL_SetToggle(USBH_HandleTypeDef *phost, uint8_t pipe, uint8_t toggle) +{ + HCD_HandleTypeDef *pHandle; + pHandle = phost->pData; + + if(pHandle->hc[pipe].ep_is_in) + { + pHandle->hc[pipe].toggle_in = toggle; + } + else + { + pHandle->hc[pipe].toggle_out = toggle; + } + + return USBH_OK; +} + +/** + * @brief Return the current toggle of a pipe. + * @param phost: Host handle + * @param pipe: Pipe index + * @retval toggle (0/1) + */ +uint8_t USBH_LL_GetToggle(USBH_HandleTypeDef *phost, uint8_t pipe) +{ + uint8_t toggle = 0; + HCD_HandleTypeDef *pHandle; + pHandle = phost->pData; + + if(pHandle->hc[pipe].ep_is_in) + { + toggle = pHandle->hc[pipe].toggle_in; + } + else + { + toggle = pHandle->hc[pipe].toggle_out; + } + return toggle; +} + +/** + * @brief Delay routine for the USB Host Library + * @param Delay: Delay in ms + * @retval None + */ +void USBH_Delay(uint32_t Delay) +{ + HAL_Delay(Delay); +} + +/** + * @brief Retuns the USB status depending on the HAL status: + * @param hal_status: HAL status + * @retval USB status + */ +USBH_StatusTypeDef USBH_Get_USB_Status(HAL_StatusTypeDef hal_status) +{ + USBH_StatusTypeDef usb_status = USBH_OK; + + switch (hal_status) + { + case HAL_OK : + usb_status = USBH_OK; + break; + case HAL_ERROR : + usb_status = USBH_FAIL; + break; + case HAL_BUSY : + usb_status = USBH_BUSY; + break; + case HAL_TIMEOUT : + usb_status = USBH_FAIL; + break; + default : + usb_status = USBH_FAIL; + break; + } + return usb_status; +} + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/USB_HOST/Target/usbh_conf.h b/Xibeca/USB_HOST/Target/usbh_conf.h new file mode 100644 index 00000000..2f3f0fcb --- /dev/null +++ b/Xibeca/USB_HOST/Target/usbh_conf.h @@ -0,0 +1,196 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : Target/usbh_conf.h + * @version : v1.0_Cube + * @brief : Header for usbh_conf.c file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USBH_CONF__H__ +#define __USBH_CONF__H__ +#ifdef __cplusplus + extern "C" { +#endif +/* Includes ------------------------------------------------------------------*/ + +#include +#include +#include +#include "main.h" + +#include "stm32h7xx.h" +#include "stm32h7xx_hal.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/** @addtogroup STM32_USB_HOST_LIBRARY + * @{ + */ + +/** @defgroup USBH_CONF + * @brief usb host low level driver configuration file + * @{ + */ + +/** @defgroup USBH_CONF_Exported_Variables USBH_CONF_Exported_Variables + * @brief Public variables. + * @{ + */ + +/** + * @} + */ + +/** @defgroup USBH_CONF_Exported_Defines USBH_CONF_Exported_Defines + * @brief Defines for configuration of the Usb host. + * @{ + */ + +/*---------- -----------*/ +#define USBH_MAX_NUM_ENDPOINTS 2U + +/*---------- -----------*/ +#define USBH_MAX_NUM_INTERFACES 10U + +/*---------- -----------*/ +#define USBH_MAX_NUM_CONFIGURATION 1U + +/*---------- -----------*/ +#define USBH_KEEP_CFG_DESCRIPTOR 1U + +/*---------- -----------*/ +#define USBH_MAX_NUM_SUPPORTED_CLASS 1U + +/*---------- -----------*/ +#define USBH_MAX_SIZE_CONFIGURATION 256U + +/*---------- -----------*/ +#define USBH_MAX_DATA_BUFFER 512U + +/*---------- -----------*/ +#define USBH_DEBUG_LEVEL 0U + +/*---------- -----------*/ +#define USBH_USE_OS 1U + +/****************************************/ +/* #define for FS and HS identification */ +#define HOST_HS 0 +#define HOST_FS 1 + +#if (USBH_USE_OS == 1) + #include "cmsis_os.h" + #define USBH_PROCESS_PRIO osPriorityNormal + #define USBH_PROCESS_STACK_SIZE ((uint16_t)128) +#endif /* (USBH_USE_OS == 1) */ + +/** + * @} + */ + +/** @defgroup USBH_CONF_Exported_Macros USBH_CONF_Exported_Macros + * @brief Aliases. + * @{ + */ + +/* Memory management macros */ + +/** Alias for memory allocation. */ +#define USBH_malloc malloc + +/** Alias for memory release. */ +#define USBH_free free + +/** Alias for memory set. */ +#define USBH_memset memset + +/** Alias for memory copy. */ +#define USBH_memcpy memcpy + +/* DEBUG macros */ + +#if (USBH_DEBUG_LEVEL > 0U) +#define USBH_UsrLog(...) do { \ + printf(__VA_ARGS__); \ + printf("\n"); \ +} while (0) +#else +#define USBH_UsrLog(...) do {} while (0) +#endif + +#if (USBH_DEBUG_LEVEL > 1U) + +#define USBH_ErrLog(...) do { \ + printf("ERROR: ") ; \ + printf(__VA_ARGS__); \ + printf("\n"); \ +} while (0) +#else +#define USBH_ErrLog(...) do {} while (0) +#endif + +#if (USBH_DEBUG_LEVEL > 2U) +#define USBH_DbgLog(...) do { \ + printf("DEBUG : ") ; \ + printf(__VA_ARGS__); \ + printf("\n"); \ +} while (0) +#else +#define USBH_DbgLog(...) do {} while (0) +#endif + +/** + * @} + */ + +/** @defgroup USBH_CONF_Exported_Types USBH_CONF_Exported_Types + * @brief Types. + * @{ + */ + +/** + * @} + */ + +/** @defgroup USBH_CONF_Exported_FunctionsPrototype USBH_CONF_Exported_FunctionsPrototype + * @brief Declaration of public functions for Usb host. + * @{ + */ + +/* Exported functions -------------------------------------------------------*/ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __USBH_CONF__H__ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/Xibeca.ioc b/Xibeca/Xibeca.ioc new file mode 100644 index 00000000..88ccd2f6 --- /dev/null +++ b/Xibeca/Xibeca.ioc @@ -0,0 +1,839 @@ +#MicroXplorer Configuration settings - do not modify +USB_DEVICE.PID_AUDIO_HS=0xDADA +SH.FMC_D0_DA0.ConfNb=1 +SH.FMC_A8.ConfNb=1 +SH.FMC_A0.ConfNb=1 +SH.FMC_D6_DA6.ConfNb=1 +SH.FMC_D9_DA9.ConfNb=1 +SH.FMC_A0.0=FMC_A0,13b-sda1 +PG8.Signal=FMC_SDCLK +SH.GPXTI14.0=GPIO_EXTI14 +PG0.Signal=FMC_A10 +RCC.PLLFRACN=6144 +PC3_C.Mode=Full_Duplex_Master +DAC1.IPParameters=DAC_Channel-DAC_OUT2,DAC_Channel-DAC_OUT1 +SAI1.Instance-SAI_A_MasterWithClock=SAI$Index_Block_A +RCC.RTCFreq_Value=32000 +PA15\ (JTDI).Signal=S_TIM2_CH1 +RCC.CpuClockFreq_Value=75000000 +PD2.GPIOParameters=GPIO_Label +SH.FMC_SDNWE.ConfNb=1 +SH.ADCx_INP5.0=ADC1_INP5,IN5-Single-Ended +SH.FMC_D5_DA5.0=FMC_D5,sd-32b-d1 +SH.FMC_D9_DA9.0=FMC_D9,sd-32b-d1 +RCC.LPTIM1Freq_Value=37500000 +SH.GPXTI7.ConfNb=1 +NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false +SH.FMC_D25.0=FMC_D25,sd-32b-d1 +SH.FMC_NBL2.ConfNb=1 +SH.S_TIM3_CH2.ConfNb=1 +PF7.Signal=UART7_TX +SH.FMC_SDNWE.0=FMC_SDNWE,13b-sda1 +PH9.Signal=FMC_D17 +SPI3.VirtualNSS=VM_NSSHARD +SH.FMC_D11_DA11.0=FMC_D11,sd-32b-d1 +RCC.I2C4Freq_Value=37500000 +PB6.Signal=UART5_TX +PC7.Signal=S_TIM3_CH2 +PD0.Signal=FMC_D2_DA2 +SAI1.AudioMode-SAI_A_MasterWithClock=SAI_MODEMASTER_RX +PD8.Signal=FMC_D13_DA13 +PE1.Signal=FMC_NBL1 +ProjectManager.ProjectBuild=false +NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +PA0.Locked=true +USB_OTG_FS.phy_itface=HCD_PHY_EMBEDDED +PG14.Mode=Full_Duplex_Master +ProjectManager.FirmwarePackage=STM32Cube FW_H7 V1.9.0 +ProjectManager.BackupPrevious=false +RCC.FMCFreq_Value=75000000 +RCC.SAI1CLockSelection=RCC_SAI1CLKSOURCE_CLKP +PE9.Signal=FMC_D6_DA6 +Dma.SAI1_A.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING +SH.FMC_A2.0=FMC_A2,13b-sda1 +PB14.Mode=Device_Only_FS +RCC.USART16Freq_Value=75000000 +PA8.Signal=UART7_RX +SH.FMC_D1_DA1.0=FMC_D1,sd-32b-d1 +USB_OTG_HS.IPParameters=VirtualMode-Device_Only_FS +VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 +ProjectManager.HalAssertFull=true +RCC.DIVP2Freq_Value=37500000 +SH.ADCx_INP3.0=ADC1_INP3,IN3-Single-Ended +PA0.Signal=GPXTI0 +USB_DEVICE.MANUFACTURER_STRING-AUDIO_HS=Rebel Technology +SH.ADCx_INP4.ConfNb=1 +Mcu.Package=UFBGA176 +SAI1.AudioFrequency-SAI_A_MasterWithClock=SAI_AUDIO_FREQUENCY_48K +PB1.Signal=ADCx_INP5 +PC10.Stacked=true +SPI2.Mode=SPI_MODE_MASTER +RCC.PLL3FRACN=0 +SPI3.Mode=SPI_MODE_MASTER +PD12.Signal=S_TIM4_CH1 +SH.FMC_SDNCAS.ConfNb=1 +VP_SYS_VS_Systick.Signal=SYS_VS_Systick +PC3_C.GPIO_Label=ADC_SPI_MOSI +SH.FMC_A11.ConfNb=1 +SH.FMC_D27.0=FMC_D27,sd-32b-d1 +Dma.SAI1_A.0.SyncSignalID=NONE +SH.S_TIM4_CH1.0=TIM4_CH1,Encoder_Interface +RCC.LPUART1Freq_Value=75000000 +PF10.Mode=Single Bank 1 +USB_OTG_FS.IPParameters=VirtualMode,phy_itface +PB13.Mode=Activate_VBUS_FS +PA4.GPIO_Label=DAC1 +PD15.Signal=FMC_D1_DA1 +SH.ADCx_INP10.ConfNb=1 +RCC.VCO3OutputFreq_Value=32250000 +SH.FMC_D3_DA3.ConfNb=1 +PG12.Signal=LPTIM1_IN1 +Dma.SAI1_B.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +SH.GPXTI10.0=GPIO_EXTI10 +Mcu.Pin80=PG2 +Mcu.Pin81=PC0 +SH.S_TIM4_CH1.ConfNb=1 +SH.FMC_A4.0=FMC_A4,13b-sda1 +ProjectManager.ProjectFileName=Xibeca.ioc +SH.FMC_A5.ConfNb=1 +FREERTOS.Tasks01=defaultTask,0,128,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL +PH13.Signal=FMC_D21 +Mcu.Pin79=PD15 +Mcu.PinsNb=130 +PC14-OSC32_IN\ (OSC32_IN).GPIOParameters=GPIO_Label +PC11.Locked=true +Mcu.Pin73=PG3 +Mcu.Pin74=PF10 +Dma.SAI1_B.1.MemInc=DMA_MINC_ENABLE +Mcu.Pin71=PG5 +Mcu.Pin72=PG4 +Mcu.Pin77=PH11 +PC13.Locked=true +SAI1.MClockEnable-SAI_A_MasterWithClock=SAI_MASTERCLOCK_ENABLE +PG5.Signal=FMC_A15_BA1 +Mcu.Pin78=PH10 +ADC1.OffsetNumber-0\#ChannelRegularConversion=ADC_OFFSET_NONE +Mcu.Pin75=PF9 +PC13.Signal=GPXTI13 +PG3.Locked=true +Mcu.Pin76=PF8 +SH.FMC_D10_DA10.0=FMC_D10,sd-32b-d1 +FREERTOS.INCLUDE_vTaskDelayUntil=1 +Mcu.Pin70=PH12 +SAI1.ErrorAudioFreq-SAI_A_MasterWithClock=30.2 % +SH.FMC_D16.0=FMC_D16,sd-32b-d1 +Mcu.Pin68=PF6 +Mcu.Pin69=PF5 +SH.ADCx_INP9.0=ADC1_INP9,IN9-Single-Ended +Mcu.Pin62=PF3 +VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_HS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_HS +USB_OTG_HS.VirtualMode-Device_Only_FS=Device_Only_FS +Mcu.Pin63=PF4 +Mcu.Pin60=PG8 +Mcu.Pin61=PC6 +Mcu.Pin66=PG6 +Mcu.Pin67=PF7 +Mcu.Pin64=PH5 +Mcu.Pin65=PG7 +USB_DEVICE.VID-AUDIO_HS=0x1209 +PF8.GPIO_Label=FLASH_DQ0 +PD10.Signal=FMC_D15_DA15 +RCC.D1CPREFreq_Value=75000000 +RCC.Tim1OutputFreq_Value=75000000 +SH.FMC_D29.0=FMC_D29,sd-32b-d1 +Mcu.Pin59=PH4 +Mcu.Pin57=PF2 +PC15-OSC32_OUT\ (OSC32_OUT).Locked=true +Mcu.Pin58=PF1 +PH4.Locked=true +Mcu.Pin51=PA8 +Mcu.Pin52=PH0-OSC_IN (PH0) +Mcu.Pin50=PC9 +SH.COMP_DAC11_group.0=DAC1_OUT1,DAC_OUT1 +Mcu.Pin55=PC7 +Mcu.Pin56=PH1-OSC_OUT (PH1) +Mcu.Pin53=PH3 +Mcu.Pin54=PC8 +PB11.GPIOParameters=GPIO_Label +Mcu.Pin48=PC15-OSC32_OUT (OSC32_OUT) +Mcu.Pin49=PH2 +Mcu.Pin46=PI0 +Mcu.Pin47=PA9 +SAI1.VirtualMode-SAI_A_MasterWithClock=VM_MASTER +PB14.Signal=USB_OTG_HS_DM +PG6.GPIOParameters=GPIO_Label +Mcu.Pin40=PC14-OSC32_IN (OSC32_IN) +PA5.Signal=COMP_DAC12_group +Mcu.Pin41=PF0 +Mcu.Pin44=PH13 +Mcu.Pin45=PH14 +Mcu.Pin42=PI10 +Mcu.Pin43=PI11 +PI7.Signal=FMC_D29 +PC2_C.GPIO_Label=ADC_SPI_MISO +SH.FMC_A6.0=FMC_A6,13b-sda1 +RCC.AHB12Freq_Value=75000000 +PE14.Signal=FMC_D11_DA11 +PE6.Mode=SAI_A_MasterWithClock +Mcu.Pin37=PD2 +Mcu.Pin38=PH15 +SAI1.SlotNumber-SAI_B_SyncSlave=8 +Mcu.Pin35=PI9 +Mcu.Pin36=PI4 +SH.FMC_D14_DA14.ConfNb=1 +Mcu.Pin39=PI1 +PI2.Signal=FMC_D26 +Mcu.Pin30=PD1 +Mcu.Pin33=PA11 +Mcu.Pin34=PC13 +Mcu.Pin31=PI3 +Mcu.Pin32=PI2 +Dma.SAI1_A.0.SyncRequestNumber=1 +NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +PF13.Signal=FMC_A7 +SH.SharedStack_PC8.0=SDMMC1_D0 +SH.SharedStack_PC8.1=GPIO_EXTI8 +SH.FMC_NBL2.0=FMC_NBL2,Sd4ByteEnable1 +PC9.GPIOParameters=GPIO_Label +PF9.GPIOParameters=GPIO_Label +Mcu.Pin26=PA12 +SH.FMC_D18.0=FMC_D18,sd-32b-d1 +Mcu.Pin27=PI7 +Mcu.Pin24=PC11 +SH.FMC_D21.ConfNb=1 +Mcu.Pin25=PC10 +Mcu.Pin28=PI6 +Mcu.Pin29=PI5 +Mcu.Pin22=PG10 +Mcu.Pin23=PD0 +Mcu.Pin20=PG12 +ADC1.master=1 +PA3.Locked=true +Mcu.Pin21=PG11 +PC14-OSC32_IN\ (OSC32_IN).GPIO_Label=EXTI14 +PA5.GPIO_Label=DAC2 +NVIC.ForceEnableDMAVector=true +NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +SH.FMC_SDNRAS.ConfNb=1 +ProjectManager.HeapSize=0x200 +Mcu.Pin15=PE5 +PA0.GPIOParameters=GPIO_Label +NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +Mcu.Pin16=PE6 +Mcu.Pin13=PA13 (JTMS/SWDIO) +Mcu.Pin14=PE4 +Mcu.Pin19=PG15 +PF10.GPIOParameters=GPIO_Label +SH.GPXTI15.ConfNb=1 +Mcu.Pin17=PB7 +Mcu.Pin18=PB6 +NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 +Mcu.Pin11=PA15 (JTDI) +Mcu.Pin12=PA14 (JTCK/SWCLK) +Mcu.Pin10=PC12 +SH.GPXTI10.ConfNb=1 +PI11.GPIO_Label=EXTI11 +PE3.Signal=SAI1_SD_B +PF4.Signal=FMC_A4 +SH.FMC_D26.ConfNb=1 +PD2.Signal=SharedStack_PD2 +Mcu.Family=STM32H7 +SH.SharedStack_PC12.1=SPI3_MOSI,Full_Duplex_Master +NVIC.OTG_HS_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +ProjectManager.MainLocation=Core/Src +SH.SharedStack_PC12.0=SDMMC1_CK +SH.FMC_A6.ConfNb=1 +SH.FMC_A8.0=FMC_A8,13b-sda1 +ProjectManager.KeepUserCode=true +PH14.Signal=FMC_D22 +PH10.Signal=FMC_D18 +SH.FMC_D14_DA14.0=FMC_D14,sd-32b-d1 +PH0-OSC_IN\ (PH0).Signal=RCC_OSC_IN +PG2.Signal=FMC_A12 +SH.COMP_DAC12_group.0=DAC1_OUT2,DAC_OUT2 +SAI1.FrameLength-SAI_B_SyncSlave=256 +PA0.GPIO_Label=EXTI0 +PA11.Mode=Host_Only +RCC.PLL2FRACN=6144 +PD2.Locked=true +SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 +RCC.VCO2OutputFreq_Value=150000000 +SH.FMC_A11.0=FMC_A11,13b-sda1 +SH.ADCx_INP11.ConfNb=1 +PB15.Signal=USB_OTG_HS_DP +PG11.Signal=LPTIM1_IN2 +PG15.Signal=FMC_SDNCAS +PD13.Signal=S_TIM4_CH2 +Mcu.IP4=DMA +Mcu.IP5=FMC +Mcu.IP2=DAC1 +I2C1.IPParameters=Timing +Mcu.IP3=DEBUG +Mcu.IP0=ADC1 +Mcu.IP1=CORTEX_M7 +SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE +Dma.SAI1_B.1.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +RCC.DIVP3Freq_Value=16125000 +RCC.SDMMCFreq_Value=75000000 +ProjectManager.PreviousToolchain= +SH.COMP_DAC12_group.ConfNb=1 +SH.FMC_NBL1.0=FMC_NBL1,Sd4ByteEnable1 +FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configUSE_IDLE_HOOK,configUSE_TICK_HOOK,configUSE_MALLOC_FAILED_HOOK,INCLUDE_vTaskDelayUntil +Dma.SAI1_B.1.Instance=DMA1_Stream1 +Dma.SAI1_B.1.FIFOMode=DMA_FIFOMODE_DISABLE +FREERTOS.configUSE_PREEMPTION=0 +RCC.HRTIMFreq_Value=75000000 +ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_4 +PH1-OSC_OUT\ (PH1).Mode=HSE-External-Oscillator +RCC.DIVR3Freq_Value=16125000 +RCC.HSE_VALUE=8000000 +NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +SH.FMC_A14_BA0.ConfNb=1 +Mcu.IP10=QUADSPI +NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:false\:true +Mcu.IP12=SAI1 +Mcu.IP11=RCC +SH.SharedStack_PC10.1=SPI3_SCK,Full_Duplex_Master +SH.SharedStack_PC10.0=SDMMC1_D2 +Mcu.IP18=TIM3 +Mcu.IP17=TIM2 +Mcu.IP19=TIM4 +RCC.DIVP1Freq_Value=75000000 +Mcu.IP14=SPI3 +PF9.Mode=Single Bank 1 +Mcu.IP13=SPI2 +Mcu.IP16=SYS +Mcu.IP15=SPI6 +PF11.Signal=FMC_SDNRAS +PB5.Mode=Asynchronous +PB7.Signal=I2C1_SDA +Mcu.IP21=UART7 +Mcu.IP20=UART5 +Mcu.IP23=USB_HOST +Mcu.IP22=USB_DEVICE +SH.S_TIM3_CH1.0=TIM3_CH1,Encoder_Interface +Mcu.IP25=USB_OTG_HS +SH.FMC_D27.ConfNb=1 +Mcu.IP24=USB_OTG_FS +SH.FMC_D16.ConfNb=1 +PA6.Signal=ADCx_INP3 +Dma.SAI1_A.0.MemDataAlignment=DMA_MDATAALIGN_WORD +SH.FMC_D4_DA4.ConfNb=1 +NVIC.OTG_FS_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +ProjectManager.ToolChainLocation= +SH.GPXTI0.0=GPIO_EXTI0 +USB_DEVICE.CLASS_NAME_HS=AUDIO +PF8.Signal=QUADSPI_BK1_IO0 +SH.FMC_D30.ConfNb=1 +RCC.DIVR1Freq_Value=75000000 +USB_DEVICE.VirtualMode-AUDIO_HS=Audio +Mcu.Pin95=PG0 +Mcu.Pin96=PE13 +Mcu.Pin93=PC4 +Mcu.Pin94=PF13 +Mcu.Pin99=PA2 +Mcu.Pin97=PD12 +Mcu.Pin98=PD10 +Dma.Request1=SAI1_B +Dma.SAI1_B.1.PeriphInc=DMA_PINC_DISABLE +FREERTOS.configUSE_TICK_HOOK=1 +Mcu.Pin91=PA0 +Mcu.Pin92=PA4 +NVIC.DMA1_Stream0_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +Mcu.Pin90=PA1 +PC5.Signal=ADCx_INP8 +PH2.Mode=SdramChipSelect1_1 +PE7.Signal=FMC_D4_DA4 +Dma.Request0=SAI1_A +SH.FMC_D22.ConfNb=1 +Dma.SAI1_B.1.Priority=DMA_PRIORITY_VERY_HIGH +PE2.GPIO_Label=FLASH_DQ2 +Mcu.Pin84=PC3_C +USB_DEVICE.PRODUCT_STRING_AUDIO_HS=OWL-XIBECA +Mcu.Pin85=PG1 +Mcu.Pin82=PC1 +Mcu.Pin83=PC2_C +Mcu.Pin88=PD14 +PA3.Signal=GPXTI3 +Mcu.Pin89=PD13 +Mcu.Pin86=PH8 +Mcu.Pin87=PH9 +SH.FMC_A3.ConfNb=1 +USB_HOST.IPParameters=USBH_HandleTypeDef-AUDIO_FS,VirtualModeFS,USBH_USE_OS-AUDIO_FS +SH.FMC_D20.0=FMC_D20,sd-32b-d1 +SH.S_TIM2_CH1.0=TIM2_CH1,Encoder_Interface +Dma.SAI1_B.1.Mode=DMA_CIRCULAR +PG7.Signal=SAI1_MCLK_A +PC9.GPIO_Label=EXTI9 +Dma.SAI1_B.1.RequestNumber=1 +NVIC.SavedSvcallIrqHandlerGenerated=true +Dma.SAI1_A.0.Direction=DMA_PERIPH_TO_MEMORY +PC11.Signal=SharedStack_PC11 +Dma.SAI1_A.0.SignalID=NONE +PC8.Signal=SharedStack_PC8 +SH.ADCx_INP14.0=ADC1_INP14,IN14-Single-Ended +SH.FMC_D31.0=FMC_D31,sd-32b-d1 +ProjectManager.DefaultFWLocation=true +PD9.Signal=FMC_D14_DA14 +PC12.Stacked=true +ProjectManager.DeletePrevious=true +PB10.Locked=true +USB_DEVICE.IPParameters=VirtualMode-AUDIO_HS,VirtualModeHS,CLASS_NAME_HS,VID-AUDIO_HS,MANUFACTURER_STRING-AUDIO_HS,PRODUCT_STRING_AUDIO_HS,PID_AUDIO_HS +PinOutPanel.CurrentBGAView=Top +RCC.FamilyName=M +PH1-OSC_OUT\ (PH1).Signal=RCC_OSC_OUT +FREERTOS.configUSE_IDLE_HOOK=1 +VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 +SAI1.RealAudioFreq-SAI_A_MasterWithClock=62.5 KHz +PA9.Mode=Activate_VBUS +SH.FMC_A15_BA1.ConfNb=1 +SH.SharedStack_PD2.0=SDMMC1_CMD +PF6.Signal=QUADSPI_BK1_IO3 +PC15-OSC32_OUT\ (OSC32_OUT).Signal=GPXTI15 +SH.SharedStack_PD2.1=GPIO_EXTI2 +PB10.GPIO_Label=ADC_SPI_CLK +Dma.SAI1_A.0.Mode=DMA_CIRCULAR +RCC.VCO1OutputFreq_Value=150000000 +SH.FMC_D13_DA13.0=FMC_D13,sd-32b-d1 +PH8.Signal=FMC_D16 +RCC.AXIClockFreq_Value=75000000 +VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_HS.Mode=AUDIO_HS +SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler +PG10.GPIOParameters=GPIO_Label +PE2.GPIOParameters=GPIO_Label +RCC.USBFreq_Value=48000000 +PF9.GPIO_Label=FLASH_DQ1 +SH.FMC_D24.ConfNb=1 +Dma.SAI1_B.1.SyncEnable=DISABLE +PA1.Signal=S_TIM2_CH2 +RCC.CKPERFreq_Value=64000000 +board=custom +PG12.Mode=Encoder_mode_occur1 +PI9.Signal=FMC_D30 +PH4.GPIO_Label=EXTI4 +PB15.Mode=Device_Only_FS +SH.FMC_D22.0=FMC_D22,sd-32b-d1 +MxCube.Version=6.2.1 +RCC.FDCANFreq_Value=75000000 +PI4.Signal=FMC_NBL2 +PE5.Mode=SAI_A_MasterWithClock +RCC.ADCFreq_Value=37500000 +VP_SYS_VS_Systick.Mode=SysTick +SH.FMC_D12_DA12.0=FMC_D12,sd-32b-d1 +SAI1.SlotNumber-SAI_A_MasterWithClock=8 +SH.SharedStack_PC11.ConfNb=2 +SH.FMC_D29.ConfNb=1 +SH.FMC_D18.ConfNb=1 +PF1.Signal=FMC_A1 +SH.FMC_D11_DA11.ConfNb=1 +RCC.IPParameters=ADCFreq_Value,AHB12Freq_Value,AHB4Freq_Value,APB1Freq_Value,APB2Freq_Value,APB3Freq_Value,APB4Freq_Value,AXIClockFreq_Value,CECFreq_Value,CKPERFreq_Value,CortexFreq_Value,CpuClockFreq_Value,D1CPREFreq_Value,D2PPRE1,D3PPRE,DFSDMACLkFreq_Value,DFSDMFreq_Value,DIVM1,DIVM2,DIVN1,DIVN2,DIVP1Freq_Value,DIVP2,DIVP2Freq_Value,DIVP3Freq_Value,DIVQ1Freq_Value,DIVQ2Freq_Value,DIVQ3Freq_Value,DIVR1Freq_Value,DIVR2Freq_Value,DIVR3Freq_Value,FDCANFreq_Value,FMCFreq_Value,FamilyName,HCLK3ClockFreq_Value,HCLKFreq_Value,HRTIMFreq_Value,HSE_VALUE,I2C123Freq_Value,I2C4Freq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPTIM345Freq_Value,LPUART1Freq_Value,LTDCFreq_Value,MCO1PinFreq_Value,MCO2PinFreq_Value,PLL2FRACN,PLL3FRACN,PLLFRACN,PLLSourceVirtual,QSPIFreq_Value,RNGFreq_Value,RTCFreq_Value,SAI1CLockSelection,SAI1Freq_Value,SAI23Freq_Value,SAI4AFreq_Value,SAI4BFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SPI123Freq_Value,SPI45Freq_Value,SPI6Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,Tim1OutputFreq_Value,Tim2OutputFreq_Value,TraceFreq_Value,USART16Freq_Value,USART234578Freq_Value,USBCLockSelection,USBFreq_Value,VCO1OutputFreq_Value,VCO2OutputFreq_Value,VCO3OutputFreq_Value,VCOInput1Freq_Value,VCOInput2Freq_Value,VCOInput3Freq_Value +ProjectManager.AskForMigrate=true +PE0.Signal=FMC_NBL0 +Dma.SAI1_B.1.SyncSignalID=NONE +PE12.Signal=FMC_D9_DA9 +NVIC.SavedPendsvIrqHandlerGenerated=true +Mcu.IP8=LPTIM1 +SH.ADCx_INP8.ConfNb=1 +Mcu.IP9=NVIC +Mcu.IP6=FREERTOS +Mcu.IP7=I2C1 +ProjectManager.CoupleFile=false +RCC.SYSCLKFreq_VALUE=75000000 +RCC.I2C123Freq_Value=37500000 +SH.SharedStack_PC8.ConfNb=2 +SH.GPXTI4.0=GPIO_EXTI4 +KeepUserPlacement=false +PC15-OSC32_OUT\ (OSC32_OUT).GPIO_Label=EXTI15 +SH.ADCx_INP14.ConfNb=1 +SH.GPXTI4.ConfNb=1 +SH.GPXTI15.0=GPIO_EXTI15 +PH3.Signal=FMC_SDNE0 +PC3_C.Signal=SPI2_MOSI +PB7.Locked=true +PC8.Locked=true +SH.ADCx_INP3.ConfNb=1 +SH.FMC_D8_DA8.ConfNb=1 +Dma.SAI1_A.0.SyncEnable=DISABLE +PA3.GPIO_Label=EXTI3 +PB4\ (NJTRST).Signal=SPI6_MISO +SPI6.Mode=SPI_MODE_MASTER +SH.FMC_D7_DA7.0=FMC_D7,sd-32b-d1 +SH.FMC_D24.0=FMC_D24,sd-32b-d1 +SH.FMC_A4.ConfNb=1 +SPI3.Direction=SPI_DIRECTION_2LINES +SPI3.VirtualType=VM_MASTER +PH12.Signal=FMC_D20 +SPI2.VirtualType=VM_MASTER +PB10.Mode=Full_Duplex_Master +PC12.Locked=true +SH.ADCx_INP10.0=ADC1_INP10,IN10-Single-Ended +PG4.Signal=FMC_A14_BA0 +PC12.Signal=SharedStack_PC12 +PG6.GPIO_Label=FLASH_NCS +PG3.GPIOParameters=GPIO_Label +PI11.Locked=true +PA3.GPIOParameters=GPIO_Label +PB13.Signal=USB_OTG_HS_VBUS +PG13.Signal=SPI6_SCK +PG6.Mode=Single Bank 1 +PinOutPanel.RotationAngle=0 +PF6.GPIO_Label=FLASH_DQ3 +RCC.MCO1PinFreq_Value=64000000 +RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK +RCC.AHB4Freq_Value=75000000 +SH.GPXTI13.0=GPIO_EXTI13 +SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 +PA14\ (JTCK/SWCLK).Signal=DEBUG_JTCK-SWCLK +SH.FMC_A12.ConfNb=1 +PH5.Signal=FMC_SDNWE +SH.GPXTI3.ConfNb=1 +PE2.Mode=Single Bank 1 +USB_HOST.USBH_USE_OS-AUDIO_FS=0 +SH.FMC_D10_DA10.ConfNb=1 +PB6.Mode=Asynchronous +RCC.DIVQ3Freq_Value=16125000 +SH.FMC_D17.ConfNb=1 +PE5.Signal=SAI1_SCK_A +PF10.GPIO_Label=FLASH_CLK +SH.ADCx_INP4.0=ADC1_INP4,IN4-Single-Ended +Dma.SAI1_B.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD +RCC.DIVM2=1 +RCC.DIVM1=1 +SH.GPXTI7.0=GPIO_EXTI7 +MxDb.Version=DB.6.0.21 +SH.FMC_D26.0=FMC_D26,sd-32b-d1 +PI6.Signal=FMC_D28 +PI3.Signal=FMC_D27 +SH.FMC_D15_DA15.ConfNb=1 +SPI2.CalculateBaudRate=1.171875 MBits/s +SH.S_TIM4_CH2.0=TIM4_CH2,Encoder_Interface +SH.SharedStack_PC12.ConfNb=2 +PE2.Signal=QUADSPI_BK1_IO2 +PF8.Mode=Single Bank 1 +PA14\ (JTCK/SWCLK).Mode=Trace_Asynchronous_SW +SH.GPXTI11.ConfNb=1 +NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:false +PF3.Signal=FMC_A3 +SH.FMC_D25.ConfNb=1 +RCC.DIVR2Freq_Value=75000000 +PE10.Signal=FMC_D7_DA7 +ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_1CYCLE_5 +RCC.MCO2PinFreq_Value=75000000 +PC8.GPIOParameters=GPIO_Label +PF8.GPIOParameters=GPIO_Label +SH.GPXTI11.0=GPIO_EXTI11 +RCC.DFSDMFreq_Value=75000000 +PA5.GPIOParameters=GPIO_Label +SH.FMC_A1.0=FMC_A1,13b-sda1 +SH.GPXTI14.ConfNb=1 +PH2.Signal=FMC_SDCKE0 +SH.FMC_SDCLK.0=FMC_SDCLK,13b-sda1 +RCC.TraceFreq_Value=75000000 +RCC.APB4Freq_Value=37500000 +RCC.CECFreq_Value=32000 +RCC.SAI23Freq_Value=75000000 +PF14.Signal=FMC_A8 +NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +SAI1.FrameLength-SAI_A_MasterWithClock=256 +PB10.GPIOParameters=GPIO_Label +PI11.Signal=GPXTI11 +PH0-OSC_IN\ (PH0).Mode=HSE-External-Oscillator +SH.FMC_D3_DA3.0=FMC_D3,sd-32b-d1 +ProjectManager.CustomerFirmwarePackage= +SH.SharedStack_PD2.ConfNb=2 +SH.SharedStack_PC9.ConfNb=2 +Dma.SAI1_B.1.EventEnable=DISABLE +SH.FMC_A7.ConfNb=1 +PH15.Signal=FMC_D23 +SH.FMC_A1.ConfNb=1 +SAI1.DataSize-SAI_B_SyncSlave=SAI_DATASIZE_24 +ADC1.Rank-0\#ChannelRegularConversion=1 +DAC1.DAC_Channel-DAC_OUT2=DAC_CHANNEL_2 +SH.FMC_D28.0=FMC_D28,sd-32b-d1 +DAC1.DAC_Channel-DAC_OUT1=DAC_CHANNEL_1 +ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,master +RCC.SWPMI1Freq_Value=37500000 +PC6.Signal=S_TIM3_CH1 +PB11.GPIO_Label=ADC_SPI_NCS +PD1.Signal=FMC_D3_DA3 +SH.GPXTI0.ConfNb=1 +RCC.DIVP2=4 +PC0.Signal=ADCx_INP10 +RCC.QSPIFreq_Value=75000000 +PC9.Stacked=true +PG10.Signal=GPXTI10 +PG10.Locked=true +SH.FMC_A3.0=FMC_A3,13b-sda1 +RCC.USART234578Freq_Value=37500000 +SH.FMC_D31.ConfNb=1 +SPI6.CalculateBaudRate=18.75 MBits/s +RCC.SPI123Freq_Value=75000000 +Dma.SAI1_A.0.RequestNumber=1 +SH.FMC_D15_DA15.0=FMC_D15,sd-32b-d1 +PC3_C.GPIOParameters=GPIO_Label +PA9.Signal=USB_OTG_FS_VBUS +SH.S_TIM2_CH2.ConfNb=1 +RCC.DIVN2=18 +I2C1.Timing=0x00909FCE +RCC.DIVN1=18 +PC2_C.Mode=Full_Duplex_Master +SH.SharedStack_PC9.0=SDMMC1_D1 +SH.SharedStack_PC9.1=GPIO_EXTI9 +SH.FMC_D17.0=FMC_D17,sd-32b-d1 +ADC1.OffsetSignedSaturation-0\#ChannelRegularConversion=DISABLE +PB10.Signal=SPI2_SCK +SH.ADCx_INP8.0=ADC1_INP8,IN8-Single-Ended +SH.ADCx_INP5.ConfNb=1 +RCC.USBCLockSelection=RCC_USBCLKSOURCE_HSI48 +ProjectManager.LastFirmware=true +USB_HOST.VirtualModeFS=Audio +Mcu.Pin116=PF11 +Mcu.Pin117=PF14 +Mcu.Pin118=PE7 +Mcu.Pin119=PE10 +Dma.SAI1_A.0.PeriphInc=DMA_PINC_DISABLE +SH.FMC_D20.ConfNb=1 +PE15.Signal=FMC_D12_DA12 +PE8.Signal=FMC_D5_DA5 +PI1.Signal=FMC_D25 +RCC.RNGFreq_Value=48000000 +Mcu.Pin112=PA3 +Mcu.Pin113=PA7 +Mcu.Pin114=PB1 +Mcu.Pin115=PB0 +Mcu.Pin110=PD9 +Mcu.Pin111=PD8 +Mcu.Pin127=VP_SYS_VS_Systick +Mcu.Pin128=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_HS +Mcu.Pin129=VP_USB_HOST_VS_USB_HOST_AUDIO_FS +PB4\ (NJTRST).Mode=Full_Duplex_Master +SH.FMC_SDNCAS.0=FMC_SDNCAS,13b-sda1 +ProjectManager.FreePins=true +RCC.LPTIM2Freq_Value=37500000 +SH.FMC_NBL1.ConfNb=1 +ProjectManager.UnderRoot=false +SH.FMC_D7_DA7.ConfNb=1 +Mcu.Pin123=PB11 +Dma.SAI1_B.1.MemDataAlignment=DMA_MDATAALIGN_WORD +Mcu.Pin124=PB14 +PA4.Signal=COMP_DAC11_group +Mcu.Pin125=PB15 +Mcu.Pin126=VP_FREERTOS_VS_CMSIS_V1 +PB5.Signal=UART5_RX +Mcu.Pin120=PE12 +Mcu.Pin121=PE15 +Mcu.Pin122=PB10 +SH.FMC_A10.ConfNb=1 +ProjectManager.CompilerOptimize=6 +PG11.Mode=Encoder_mode_occur1 +SH.FMC_A5.0=FMC_A5,13b-sda1 +PA11.Signal=USB_OTG_FS_DM +SH.S_TIM3_CH1.ConfNb=1 +PF6.Mode=Single Bank 1 +RCC.LPTIM345Freq_Value=37500000 +ProjectManager.ComputerToolchain=false +PF9.Signal=QUADSPI_BK1_IO1 +RCC.LTDCFreq_Value=16125000 +PB3\ (JTDO/TRACESWO).Mode=Trace_Asynchronous_SW +PB8.Mode=I2C +Mcu.Pin109=PB13 +Mcu.Pin105=PE8 +PA8.Mode=Asynchronous +Mcu.Pin106=PE9 +Mcu.Pin107=PE11 +Mcu.Pin108=PE14 +SH.FMC_NBL3.0=FMC_NBL3,Sd4ByteEnable1 +PG3.GPIO_Label=ADC_RST +SH.FMC_D12_DA12.ConfNb=1 +RCC.HCLK3ClockFreq_Value=75000000 +PB0.Signal=ADCx_INP9 +SAI1.SlotSize-SAI_B_SyncSlave=SAI_SLOTSIZE_32B +SH.FMC_D19.0=FMC_D19,sd-32b-d1 +Dma.SAI1_A.0.FIFOMode=DMA_FIFOMODE_DISABLE +PA7.GPIOParameters=GPIO_Label +PC1.Signal=ADCx_INP11 +Dma.SAI1_A.0.Instance=DMA1_Stream0 +PG10.GPIO_Label=EXTI10 +PD2.GPIO_Label=EXTI2 +Dma.SAI1_A.0.PeriphDataAlignment=DMA_PDATAALIGN_WORD +Mcu.Pin101=PA5 +PA13\ (JTMS/SWDIO).Signal=DEBUG_JTMS-SWDIO +Mcu.Pin102=PC5 +SPI6.VirtualType=VM_MASTER +Mcu.Pin103=PF12 +Mcu.Pin104=PF15 +Mcu.Pin100=PA6 +Dma.SAI1_A.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +RCC.DIVQ2Freq_Value=75000000 +VP_USB_HOST_VS_USB_HOST_AUDIO_FS.Signal=USB_HOST_VS_USB_HOST_AUDIO_FS +SH.S_TIM4_CH2.ConfNb=1 +RCC.SAI1Freq_Value=64000000 +RCC.CortexFreq_Value=75000000 +SH.FMC_A2.ConfNb=1 +PG6.Signal=QUADSPI_BK1_NCS +Mcu.UserName=STM32H743IIKx +PC10.Locked=true +PC10.Signal=SharedStack_PC10 +SH.FMC_NBL0.0=FMC_NBL0,Sd4ByteEnable1 +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_QUADSPI_Init-QUADSPI-false-HAL-true,5-MX_DAC1_Init-DAC1-false-HAL-true,6-MX_FMC_Init-FMC-false-HAL-true,7-MX_SAI1_Init-SAI1-false-HAL-true,8-MX_ADC1_Init-ADC1-false-HAL-true,9-MX_I2C1_Init-I2C1-false-HAL-true,10-MX_SPI2_Init-SPI2-false-HAL-true,11-MX_SPI3_Init-SPI3-false-HAL-true,12-MX_SPI6_Init-SPI6-false-HAL-true,13-MX_TIM2_Init-TIM2-false-HAL-true,14-MX_TIM3_Init-TIM3-false-HAL-true,15-MX_TIM4_Init-TIM4-false-HAL-true,16-MX_UART5_Init-UART5-false-HAL-true,17-MX_UART7_Init-UART7-false-HAL-true,18-MX_LPTIM1_Init-LPTIM1-false-HAL-true,19-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,20-MX_USB_HOST_Init-USB_HOST-false-HAL-false,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true +SH.FMC_D6_DA6.0=FMC_D6,sd-32b-d1 +PC9.Locked=true +PC13.GPIO_Label=EXTI13 +PB11.Signal=GPIO_Output +ProjectManager.StackSize=0x400 +PI11.GPIOParameters=GPIO_Label +RCC.VCOInput3Freq_Value=250000 +PH3.Mode=SdramChipSelect1_1 +SH.SharedStack_PC11.0=SDMMC1_D3 +SH.SharedStack_PC11.1=SPI3_MISO,Full_Duplex_Master +SH.FMC_A7.0=FMC_A7,13b-sda1 +PA12.Signal=USB_OTG_FS_DP +PH4.GPIOParameters=GPIO_Label +Mcu.UserConstants= +SH.GPXTI13.ConfNb=1 +Mcu.ThirdPartyNb=0 +RCC.HCLKFreq_Value=75000000 +Mcu.IPNb=26 +RCC.SPDIFRXFreq_Value=75000000 +SPI6.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate +PF12.Signal=FMC_A6 +FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 +Mcu.Pin6=PG14 +Mcu.Pin7=PG13 +Mcu.Pin8=PB4 (NJTRST) +Mcu.Pin9=PB3 (JTDO/TRACESWO) +Dma.SAI1_A.0.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +PC2_C.Signal=SPI2_MISO +SH.FMC_A10.0=FMC_A10,13b-sda1 +SPI2.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_64 +Mcu.Pin0=PE3 +SPI3.DataSize=SPI_DATASIZE_8BIT +Mcu.Pin1=PE2 +GPIO.groupedBy=Group By Peripherals +Mcu.Pin2=PE1 +Mcu.Pin3=PE0 +PC11.Stacked=true +Mcu.Pin4=PB8 +Mcu.Pin5=PB5 +SH.FMC_D8_DA8.0=FMC_D8,sd-32b-d1 +PC8.Stacked=true +SH.FMC_D2_DA2.0=FMC_D2,sd-32b-d1 +PE13.Signal=FMC_D10_DA10 +PI5.Signal=FMC_NBL3 +PI0.Signal=FMC_D24 +File.Version=6 +Dma.SAI1_A.0.EventEnable=DISABLE +SH.FMC_D5_DA5.ConfNb=1 +SH.SharedStack_PC10.ConfNb=2 +SH.S_TIM2_CH1.ConfNb=1 +SH.FMC_D2_DA2.ConfNb=1 +PG13.Mode=Full_Duplex_Master +PE4.Mode=SAI_A_MasterWithClock +SH.FMC_SDNRAS.0=FMC_SDNRAS,13b-sda1 +PE4.Signal=SAI1_FS_A +Dma.RequestsNb=2 +ProjectManager.ProjectName=Xibeca +RCC.APB3Freq_Value=75000000 +PA7.Locked=true +SH.FMC_D0_DA0.0=FMC_D0,sd-32b-d1 +VP_USB_HOST_VS_USB_HOST_AUDIO_FS.Mode=AUDIO_FS +USB_OTG_FS.VirtualMode=Host_Only +SH.FMC_A9.0=FMC_A9,13b-sda1 +SH.FMC_D4_DA4.0=FMC_D4,sd-32b-d1 +PF5.Signal=FMC_A5 +USB_DEVICE.VirtualModeHS=Audio_HS +Dma.SAI1_B.1.SignalID=NONE +SH.FMC_D19.ConfNb=1 +SH.FMC_D30.0=FMC_D30,sd-32b-d1 +SPI3.IPParameters=VirtualType,Mode,Direction,BaudRatePrescaler,CalculateBaudRate,DataSize,VirtualNSS +SPI2.Direction=SPI_DIRECTION_2LINES +PF0.Signal=FMC_A0 +SH.FMC_NBL0.ConfNb=1 +SH.COMP_DAC11_group.ConfNb=1 +PE3.Mode=SAI_B_SyncSlave +RCC.Tim2OutputFreq_Value=75000000 +RCC.DFSDMACLkFreq_Value=64000000 +SH.FMC_A12.0=FMC_A12,13b-sda1 +RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE +SH.FMC_A9.ConfNb=1 +PA13\ (JTMS/SWDIO).Mode=Trace_Asynchronous_SW +Dma.SAI1_B.1.Polarity=HAL_DMAMUX_REQ_GEN_RISING +PH11.Signal=FMC_D19 +ProjectManager.NoMain=false +PG3.Signal=GPIO_Output +PG1.Signal=FMC_A11 +RCC.SAI4BFreq_Value=75000000 +SH.FMC_SDCLK.ConfNb=1 +PC4.Signal=ADCx_INP4 +RCC.D2PPRE1=RCC_APB1_DIV2 +PI10.Signal=FMC_D31 +NVIC.DMA1_Stream1_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +Dma.SAI1_A.0.MemInc=DMA_MINC_ENABLE +PD2.Stacked=true +PC14-OSC32_IN\ (OSC32_IN).Locked=true +RCC.SPI6Freq_Value=37500000 +PC8.GPIO_Label=EXTI8 +SH.FMC_D21.0=FMC_D21,sd-32b-d1 +PF7.Mode=Asynchronous +SH.ADCx_INP9.ConfNb=1 +SH.S_TIM2_CH2.0=TIM2_CH2,Encoder_Interface +SH.FMC_NBL3.ConfNb=1 +RCC.SPI45Freq_Value=75000000 +PH4.Signal=GPXTI4 +PB3\ (JTDO/TRACESWO).Signal=DEBUG_JTDO-SWO +ProjectManager.TargetToolchain=Other Toolchains (GPDSC) +SAI1.SlotSize-SAI_A_MasterWithClock=SAI_SLOTSIZE_32B +SH.FMC_D1_DA1.ConfNb=1 +PC15-OSC32_OUT\ (OSC32_OUT).GPIOParameters=GPIO_Label +SAI1.DataSize-SAI_A_MasterWithClock=SAI_DATASIZE_24 +PF2.Signal=FMC_A2 +ProjectManager.RegisterCallBack= +SH.FMC_D28.ConfNb=1 +PG7.Mode=SAI_A_MasterWithClock +PE11.Signal=FMC_D8_DA8 +SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_TX +Dma.SAI1_A.0.Priority=DMA_PRIORITY_VERY_HIGH +PG14.Signal=SPI6_MOSI +SH.S_TIM3_CH2.0=TIM3_CH2,Encoder_Interface +SAI1.IPParameters=Instance-SAI_A_MasterWithClock,VirtualMode-SAI_A_MasterWithClock,MClockEnable-SAI_A_MasterWithClock,RealAudioFreq-SAI_A_MasterWithClock,ErrorAudioFreq-SAI_A_MasterWithClock,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,FrameLength-SAI_A_MasterWithClock,FrameLength-SAI_B_SyncSlave,DataSize-SAI_A_MasterWithClock,SlotSize-SAI_A_MasterWithClock,SlotSize-SAI_B_SyncSlave,SlotNumber-SAI_A_MasterWithClock,AudioFrequency-SAI_A_MasterWithClock,DataSize-SAI_B_SyncSlave,SlotNumber-SAI_B_SyncSlave,AudioMode-SAI_A_MasterWithClock,AudioMode-SAI_B_SyncSlave +SH.GPXTI3.0=GPIO_EXTI3 +RCC.VCOInput1Freq_Value=8000000 +NVIC.SavedSystickIrqHandlerGenerated=true +RCC.APB2Freq_Value=75000000 +SPI3.CalculateBaudRate=1.171875 MBits/s +SH.FMC_D13_DA13.ConfNb=1 +PC13.GPIOParameters=GPIO_Label +USB_HOST.USBH_HandleTypeDef-AUDIO_FS=hUsbHostFS +PF10.Signal=QUADSPI_CLK +SPI3.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_64 +SPI6.Direction=SPI_DIRECTION_2LINES +PF15.Signal=FMC_A9 +PA4.GPIOParameters=GPIO_Label +PE6.Signal=SAI1_SD_A +Mcu.Name=STM32H743IIKx +SH.FMC_D23.ConfNb=1 +PA2.Signal=ADCx_INP14 +PD14.Signal=FMC_D0_DA0 +PA7.GPIO_Label=EXTI7 +PA12.Mode=Host_Only +Dma.SAI1_B.1.Direction=DMA_MEMORY_TO_PERIPH +PC14-OSC32_IN\ (OSC32_IN).Signal=GPXTI14 +SH.FMC_D23.0=FMC_D23,sd-32b-d1 +SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B +PB7.Mode=I2C +PF6.GPIOParameters=GPIO_Label +RCC.SAI4AFreq_Value=75000000 +SH.ADCx_INP11.0=ADC1_INP11,IN11-Single-Ended +ADC1.NbrOfConversionFlag=1 +RCC.DIVQ1Freq_Value=75000000 +PB8.Signal=I2C1_SCL +PC2_C.GPIOParameters=GPIO_Label +Dma.SAI1_B.1.SyncRequestNumber=1 +RCC.D3PPRE=RCC_APB4_DIV2 +PC9.Signal=SharedStack_PC9 +RCC.VCOInput2Freq_Value=8000000 +RCC.APB1Freq_Value=37500000 +PB11.Locked=true +ProjectManager.DeviceId=STM32H743IIKx +ProjectManager.LibraryCopy=1 +PA7.Signal=GPXTI7 From 3e3c693ff054663a0bce2815396c83ad9c8f21cc Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 15 Jun 2021 12:47:54 +0200 Subject: [PATCH 027/286] fixing up dependencies --- Xibeca/Core/Inc/hardware.h | 16 ++--- Xibeca/Core/Src/stm32h7xx_it.c | 87 ---------------------------- Xibeca/Makefile | 12 +++- Xibeca/USB_DEVICE/App/usb_device.c | 23 ++++---- Xibeca/USB_DEVICE/Target/usbd_conf.c | 28 +++++---- Xibeca/Xibeca.ioc | 66 ++++++++++----------- 6 files changed, 72 insertions(+), 160 deletions(-) diff --git a/Xibeca/Core/Inc/hardware.h b/Xibeca/Core/Inc/hardware.h index 80d82fb4..df80f396 100644 --- a/Xibeca/Core/Inc/hardware.h +++ b/Xibeca/Core/Inc/hardware.h @@ -39,16 +39,16 @@ #define USE_USBD_AUDIO_RX // speaker #define USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS +/* #define USBD_MAX_POWER 100 // 200mA for iPad compatibility */ +/* #define USE_USB_HOST */ +/* #define USB_HOST_RX_BUFF_SIZE 256 /\* Max Received data 64 bytes *\/ */ +/* #define USE_USBH_MIDI */ #define USBH_HANDLE hUsbHostHS -#define USBD_MAX_POWER 100 // 200mA for iPad compatibility -#define USE_USB_HOST -#define USB_HOST_RX_BUFF_SIZE 256 /* Max Received data 64 bytes */ -#define USE_USBH_MIDI -#define USE_UART_MIDI_RX -#define USE_UART_MIDI_TX -#define UART_MIDI_HANDLE huart2 -#define UART_MIDI_RX_BUFFER_SIZE 256 +/* #define USE_UART_MIDI_RX */ +/* #define USE_UART_MIDI_TX */ +/* #define UART_MIDI_HANDLE huart2 */ +/* #define UART_MIDI_RX_BUFFER_SIZE 256 */ #define AUDIO_SAMPLINGRATE 48000 #define TIM8_PERIOD (871*48000/AUDIO_SAMPLINGRATE) /* experimentally determined */ diff --git a/Xibeca/Core/Src/stm32h7xx_it.c b/Xibeca/Core/Src/stm32h7xx_it.c index 0ff7731c..c4adaf70 100644 --- a/Xibeca/Core/Src/stm32h7xx_it.c +++ b/Xibeca/Core/Src/stm32h7xx_it.c @@ -69,93 +69,6 @@ extern DMA_HandleTypeDef hdma_sai1_b; /******************************************************************************/ /* Cortex Processor Interruption and Exception Handlers */ /******************************************************************************/ -/** - * @brief This function handles Non maskable interrupt. - */ -void NMI_Handler(void) -{ - /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ - - /* USER CODE END NonMaskableInt_IRQn 0 */ - /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ - while (1) - { - } - /* USER CODE END NonMaskableInt_IRQn 1 */ -} - -/** - * @brief This function handles Hard fault interrupt. - */ -void HardFault_Handler(void) -{ - /* USER CODE BEGIN HardFault_IRQn 0 */ - - /* USER CODE END HardFault_IRQn 0 */ - while (1) - { - /* USER CODE BEGIN W1_HardFault_IRQn 0 */ - /* USER CODE END W1_HardFault_IRQn 0 */ - } -} - -/** - * @brief This function handles Memory management fault. - */ -void MemManage_Handler(void) -{ - /* USER CODE BEGIN MemoryManagement_IRQn 0 */ - - /* USER CODE END MemoryManagement_IRQn 0 */ - while (1) - { - /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ - /* USER CODE END W1_MemoryManagement_IRQn 0 */ - } -} - -/** - * @brief This function handles Pre-fetch fault, memory access fault. - */ -void BusFault_Handler(void) -{ - /* USER CODE BEGIN BusFault_IRQn 0 */ - - /* USER CODE END BusFault_IRQn 0 */ - while (1) - { - /* USER CODE BEGIN W1_BusFault_IRQn 0 */ - /* USER CODE END W1_BusFault_IRQn 0 */ - } -} - -/** - * @brief This function handles Undefined instruction or illegal state. - */ -void UsageFault_Handler(void) -{ - /* USER CODE BEGIN UsageFault_IRQn 0 */ - - /* USER CODE END UsageFault_IRQn 0 */ - while (1) - { - /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ - /* USER CODE END W1_UsageFault_IRQn 0 */ - } -} - -/** - * @brief This function handles Debug monitor. - */ -void DebugMon_Handler(void) -{ - /* USER CODE BEGIN DebugMonitor_IRQn 0 */ - - /* USER CODE END DebugMonitor_IRQn 0 */ - /* USER CODE BEGIN DebugMonitor_IRQn 1 */ - - /* USER CODE END DebugMonitor_IRQn 1 */ -} /** * @brief This function handles System tick timer. diff --git a/Xibeca/Makefile b/Xibeca/Makefile index 9d09fe0b..5d6ab6d9 100644 --- a/Xibeca/Makefile +++ b/Xibeca/Makefile @@ -9,7 +9,7 @@ CPP_SRC = $(wildcard Core/Src/*.cpp) C_SRC += $(OPENWARE)/Source/sdram.c C_SRC += $(OPENWARE)/Source/pcm3168a.c C_SRC += $(OPENWARE)/Source/usbd_audio.c -CPP_SRC += $(OPENWARE)/Source/usbh_midi.cpp +# CPP_SRC += $(OPENWARE)/Source/usbh_midi.cpp # C_SRC += $(OPENWARE)/Source/ssd1309.c # CPP_SRC += $(OPENWARE)/Source/ScreenBuffer.cpp @@ -21,6 +21,12 @@ CPP_SRC += $(OPENWARE)/Source/usbh_midi.cpp S_SRC = $(BUILDROOT)/Core/Src/startup_stm32h743xx.s +C_SRC += $(BUILDROOT)/USB_DEVICE/App/usb_device.c +C_SRC += $(BUILDROOT)/USB_DEVICE/App/usbd_desc.c +C_SRC += $(BUILDROOT)/USB_DEVICE/Target/usbd_conf.c + +C_SRC += $(BUILDROOT)/USB_HOST/Target/usbh_conf.c + include $(OPENWARE)/Hardware/sources.mk C_SRC += $(C_SRC_SAI) @@ -30,6 +36,8 @@ C_SRC += $(C_SRC_USBD) C_SRC += $(C_SRC_USBH) C_SRC += $(C_SRC_DSP) C_SRC += $(C_SRC_OS) -# C_SRC += $(C_SRC_UART) +C_SRC += $(C_SRC_UART) +C_SRC += $(C_SRC_I2C) +C_SRC += $(C_SRC_QSPI) include $(OPENWARE)/Hardware/h7.mk diff --git a/Xibeca/USB_DEVICE/App/usb_device.c b/Xibeca/USB_DEVICE/App/usb_device.c index cacbd5b6..9b34c972 100644 --- a/Xibeca/USB_DEVICE/App/usb_device.c +++ b/Xibeca/USB_DEVICE/App/usb_device.c @@ -7,7 +7,7 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2021 STMicroelectronics. + *

© Copyright (c) 2019 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under Ultimate Liberty license @@ -24,11 +24,9 @@ #include "usb_device.h" #include "usbd_core.h" #include "usbd_desc.h" -#include "usbd_audio.h" -#include "usbd_audio_if.h" /* USER CODE BEGIN Includes */ - +#include "usbd_audio.h" /* USER CODE END Includes */ /* USER CODE BEGIN PV */ @@ -42,7 +40,7 @@ /* USER CODE END PFP */ /* USB Device Core handle declaration. */ -USBD_HandleTypeDef hUsbDeviceHS; +USBD_HandleTypeDef hUsbDeviceFS; /* * -- Insert your variables declaration here -- @@ -65,30 +63,29 @@ USBD_HandleTypeDef hUsbDeviceHS; void MX_USB_DEVICE_Init(void) { /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */ - + /* USER CODE END USB_DEVICE_Init_PreTreatment */ - + /* Init Device Library, add supported class and start the library. */ - if (USBD_Init(&hUsbDeviceHS, &HS_Desc, DEVICE_HS) != USBD_OK) + if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK) { Error_Handler(); } - if (USBD_RegisterClass(&hUsbDeviceHS, &USBD_AUDIO) != USBD_OK) + if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_AUDIO) != USBD_OK) { Error_Handler(); } - if (USBD_AUDIO_RegisterInterface(&hUsbDeviceHS, &USBD_AUDIO_fops_HS) != USBD_OK) + if (USBD_AUDIO_RegisterInterface(&hUsbDeviceFS, NULL) != USBD_OK) { Error_Handler(); } - if (USBD_Start(&hUsbDeviceHS) != USBD_OK) + if (USBD_Start(&hUsbDeviceFS) != USBD_OK) { Error_Handler(); } /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */ - HAL_PWREx_EnableUSBVoltageDetector(); - + /* USER CODE END USB_DEVICE_Init_PostTreatment */ } diff --git a/Xibeca/USB_DEVICE/Target/usbd_conf.c b/Xibeca/USB_DEVICE/Target/usbd_conf.c index d80383be..7855f976 100644 --- a/Xibeca/USB_DEVICE/Target/usbd_conf.c +++ b/Xibeca/USB_DEVICE/Target/usbd_conf.c @@ -24,10 +24,10 @@ #include "stm32h7xx_hal.h" #include "usbd_def.h" #include "usbd_core.h" -#include "usbd_audio.h" /* USER CODE BEGIN Includes */ - +#include "device.h" +uint8_t USBD_AUDIO_SetFiFos(PCD_HandleTypeDef *hpcd); /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -381,9 +381,7 @@ USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) HAL_PCD_RegisterIsoOutIncpltCallback(&hpcd_USB_OTG_HS, PCD_ISOOUTIncompleteCallback); HAL_PCD_RegisterIsoInIncpltCallback(&hpcd_USB_OTG_HS, PCD_ISOINIncompleteCallback); #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ - HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_HS, 0x200); - HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 0, 0x80); - HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 1, 0x174); + USBD_AUDIO_SetFiFos(&hpcd_USB_OTG_HS); } return USBD_OK; } @@ -619,16 +617,16 @@ uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr) { return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef*) pdev->pData, ep_addr); } -/** - * @brief Static single allocation. - * @param size: Size of allocated memory - * @retval None - */ -void *USBD_static_malloc(uint32_t size) -{ - static uint32_t mem[(sizeof(USBD_AUDIO_HandleTypeDef)/4)+1];/* On 32-bit boundary */ - return mem; -} +/* /\** */ +/* * @brief Static single allocation. */ +/* * @param size: Size of allocated memory */ +/* * @retval None */ +/* *\/ */ +/* void *USBD_static_malloc(uint32_t size) */ +/* { */ +/* static uint32_t mem[(sizeof(USBD_AUDIO_HandleTypeDef)/4)+1];/\* On 32-bit boundary *\/ */ +/* return mem; */ +/* } */ /** * @brief Dummy memory free diff --git a/Xibeca/Xibeca.ioc b/Xibeca/Xibeca.ioc index 88ccd2f6..40406ae1 100644 --- a/Xibeca/Xibeca.ioc +++ b/Xibeca/Xibeca.ioc @@ -1,5 +1,4 @@ #MicroXplorer Configuration settings - do not modify -USB_DEVICE.PID_AUDIO_HS=0xDADA SH.FMC_D0_DA0.ConfNb=1 SH.FMC_A8.ConfNb=1 SH.FMC_A0.ConfNb=1 @@ -40,9 +39,9 @@ SAI1.AudioMode-SAI_A_MasterWithClock=SAI_MODEMASTER_RX PD8.Signal=FMC_D13_DA13 PE1.Signal=FMC_NBL1 ProjectManager.ProjectBuild=false -NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false PA0.Locked=true -USB_OTG_FS.phy_itface=HCD_PHY_EMBEDDED +VP_USB_HOST_VS_USB_HOST_AUDIO_HS.Mode=AUDIO_HS PG14.Mode=Full_Duplex_Master ProjectManager.FirmwarePackage=STM32Cube FW_H7 V1.9.0 ProjectManager.BackupPrevious=false @@ -51,17 +50,17 @@ RCC.SAI1CLockSelection=RCC_SAI1CLKSOURCE_CLKP PE9.Signal=FMC_D6_DA6 Dma.SAI1_A.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING SH.FMC_A2.0=FMC_A2,13b-sda1 -PB14.Mode=Device_Only_FS +PB14.Mode=Host_FS RCC.USART16Freq_Value=75000000 +VP_USB_HOST_VS_USB_HOST_AUDIO_HS.Signal=USB_HOST_VS_USB_HOST_AUDIO_HS PA8.Signal=UART7_RX SH.FMC_D1_DA1.0=FMC_D1,sd-32b-d1 -USB_OTG_HS.IPParameters=VirtualMode-Device_Only_FS +USB_OTG_HS.IPParameters=VirtualMode-Host_FS VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 ProjectManager.HalAssertFull=true RCC.DIVP2Freq_Value=37500000 SH.ADCx_INP3.0=ADC1_INP3,IN3-Single-Ended PA0.Signal=GPXTI0 -USB_DEVICE.MANUFACTURER_STRING-AUDIO_HS=Rebel Technology SH.ADCx_INP4.ConfNb=1 Mcu.Package=UFBGA176 SAI1.AudioFrequency-SAI_A_MasterWithClock=SAI_AUDIO_FREQUENCY_48K @@ -80,7 +79,7 @@ Dma.SAI1_A.0.SyncSignalID=NONE SH.S_TIM4_CH1.0=TIM4_CH1,Encoder_Interface RCC.LPUART1Freq_Value=75000000 PF10.Mode=Single Bank 1 -USB_OTG_FS.IPParameters=VirtualMode,phy_itface +USB_OTG_FS.IPParameters=VirtualMode PB13.Mode=Activate_VBUS_FS PA4.GPIO_Label=DAC1 PD15.Signal=FMC_D1_DA1 @@ -99,6 +98,7 @@ SH.FMC_A5.ConfNb=1 FREERTOS.Tasks01=defaultTask,0,128,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL PH13.Signal=FMC_D21 Mcu.Pin79=PD15 +USB_DEVICE.VirtualMode-AUDIO_FS=Audio Mcu.PinsNb=130 PC14-OSC32_IN\ (OSC32_IN).GPIOParameters=GPIO_Label PC11.Locked=true @@ -126,8 +126,6 @@ Mcu.Pin68=PF6 Mcu.Pin69=PF5 SH.ADCx_INP9.0=ADC1_INP9,IN9-Single-Ended Mcu.Pin62=PF3 -VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_HS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_HS -USB_OTG_HS.VirtualMode-Device_Only_FS=Device_Only_FS Mcu.Pin63=PF4 Mcu.Pin60=PG8 Mcu.Pin61=PC6 @@ -135,7 +133,6 @@ Mcu.Pin66=PG6 Mcu.Pin67=PF7 Mcu.Pin64=PH5 Mcu.Pin65=PG7 -USB_DEVICE.VID-AUDIO_HS=0x1209 PF8.GPIO_Label=FLASH_DQ0 PD10.Signal=FMC_D15_DA15 RCC.D1CPREFreq_Value=75000000 @@ -189,7 +186,7 @@ Mcu.Pin34=PC13 Mcu.Pin31=PI3 Mcu.Pin32=PI2 Dma.SAI1_A.0.SyncRequestNumber=1 -NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false PF13.Signal=FMC_A7 SH.SharedStack_PC8.0=SDMMC1_D0 SH.SharedStack_PC8.1=GPIO_EXTI8 @@ -213,12 +210,12 @@ Mcu.Pin21=PG11 PC14-OSC32_IN\ (OSC32_IN).GPIO_Label=EXTI14 PA5.GPIO_Label=DAC2 NVIC.ForceEnableDMAVector=true -NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false SH.FMC_SDNRAS.ConfNb=1 ProjectManager.HeapSize=0x200 Mcu.Pin15=PE5 PA0.GPIOParameters=GPIO_Label -NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false Mcu.Pin16=PE6 Mcu.Pin13=PA13 (JTMS/SWDIO) Mcu.Pin14=PE4 @@ -243,6 +240,7 @@ NVIC.OTG_HS_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true ProjectManager.MainLocation=Core/Src SH.SharedStack_PC12.0=SDMMC1_CK SH.FMC_A6.ConfNb=1 +USB_DEVICE.CLASS_NAME_FS=AUDIO SH.FMC_A8.0=FMC_A8,13b-sda1 ProjectManager.KeepUserCode=true PH14.Signal=FMC_D22 @@ -253,7 +251,7 @@ PG2.Signal=FMC_A12 SH.COMP_DAC12_group.0=DAC1_OUT2,DAC_OUT2 SAI1.FrameLength-SAI_B_SyncSlave=256 PA0.GPIO_Label=EXTI0 -PA11.Mode=Host_Only +PA11.Mode=Device_Only RCC.PLL2FRACN=6144 PD2.Locked=true SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 @@ -287,7 +285,7 @@ ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_4 PH1-OSC_OUT\ (PH1).Mode=HSE-External-Oscillator RCC.DIVR3Freq_Value=16125000 RCC.HSE_VALUE=8000000 -NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false SH.FMC_A14_BA0.ConfNb=1 Mcu.IP10=QUADSPI NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:false\:true @@ -319,14 +317,12 @@ SH.FMC_D16.ConfNb=1 PA6.Signal=ADCx_INP3 Dma.SAI1_A.0.MemDataAlignment=DMA_MDATAALIGN_WORD SH.FMC_D4_DA4.ConfNb=1 -NVIC.OTG_FS_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.OTG_FS_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true ProjectManager.ToolChainLocation= SH.GPXTI0.0=GPIO_EXTI0 -USB_DEVICE.CLASS_NAME_HS=AUDIO PF8.Signal=QUADSPI_BK1_IO0 SH.FMC_D30.ConfNb=1 RCC.DIVR1Freq_Value=75000000 -USB_DEVICE.VirtualMode-AUDIO_HS=Audio Mcu.Pin95=PG0 Mcu.Pin96=PE13 Mcu.Pin93=PC4 @@ -349,7 +345,6 @@ SH.FMC_D22.ConfNb=1 Dma.SAI1_B.1.Priority=DMA_PRIORITY_VERY_HIGH PE2.GPIO_Label=FLASH_DQ2 Mcu.Pin84=PC3_C -USB_DEVICE.PRODUCT_STRING_AUDIO_HS=OWL-XIBECA Mcu.Pin85=PG1 Mcu.Pin82=PC1 Mcu.Pin83=PC2_C @@ -359,7 +354,7 @@ Mcu.Pin89=PD13 Mcu.Pin86=PH8 Mcu.Pin87=PH9 SH.FMC_A3.ConfNb=1 -USB_HOST.IPParameters=USBH_HandleTypeDef-AUDIO_FS,VirtualModeFS,USBH_USE_OS-AUDIO_FS +USB_HOST.IPParameters=USBH_HandleTypeDef-AUDIO_HS,VirtualModeHS SH.FMC_D20.0=FMC_D20,sd-32b-d1 SH.S_TIM2_CH1.0=TIM2_CH1,Encoder_Interface Dma.SAI1_B.1.Mode=DMA_CIRCULAR @@ -370,6 +365,7 @@ NVIC.SavedSvcallIrqHandlerGenerated=true Dma.SAI1_A.0.Direction=DMA_PERIPH_TO_MEMORY PC11.Signal=SharedStack_PC11 Dma.SAI1_A.0.SignalID=NONE +SPI2.NSSPMode=SPI_NSS_PULSE_DISABLE PC8.Signal=SharedStack_PC8 SH.ADCx_INP14.0=ADC1_INP14,IN14-Single-Ended SH.FMC_D31.0=FMC_D31,sd-32b-d1 @@ -378,7 +374,7 @@ PD9.Signal=FMC_D14_DA14 PC12.Stacked=true ProjectManager.DeletePrevious=true PB10.Locked=true -USB_DEVICE.IPParameters=VirtualMode-AUDIO_HS,VirtualModeHS,CLASS_NAME_HS,VID-AUDIO_HS,MANUFACTURER_STRING-AUDIO_HS,PRODUCT_STRING_AUDIO_HS,PID_AUDIO_HS +USB_DEVICE.IPParameters=VirtualMode-AUDIO_FS,VirtualModeFS,CLASS_NAME_FS PinOutPanel.CurrentBGAView=Top RCC.FamilyName=M PH1-OSC_OUT\ (PH1).Signal=RCC_OSC_OUT @@ -397,8 +393,7 @@ RCC.VCO1OutputFreq_Value=150000000 SH.FMC_D13_DA13.0=FMC_D13,sd-32b-d1 PH8.Signal=FMC_D16 RCC.AXIClockFreq_Value=75000000 -VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_HS.Mode=AUDIO_HS -SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler +SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,DataSize,NSSPMode PG10.GPIOParameters=GPIO_Label PE2.GPIOParameters=GPIO_Label RCC.USBFreq_Value=48000000 @@ -411,7 +406,7 @@ board=custom PG12.Mode=Encoder_mode_occur1 PI9.Signal=FMC_D30 PH4.GPIO_Label=EXTI4 -PB15.Mode=Device_Only_FS +PB15.Mode=Host_FS SH.FMC_D22.0=FMC_D22,sd-32b-d1 MxCube.Version=6.2.1 RCC.FDCANFreq_Value=75000000 @@ -425,6 +420,8 @@ SH.SharedStack_PC11.ConfNb=2 SH.FMC_D29.ConfNb=1 SH.FMC_D18.ConfNb=1 PF1.Signal=FMC_A1 +VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_FS +VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Mode=AUDIO_FS SH.FMC_D11_DA11.ConfNb=1 RCC.IPParameters=ADCFreq_Value,AHB12Freq_Value,AHB4Freq_Value,APB1Freq_Value,APB2Freq_Value,APB3Freq_Value,APB4Freq_Value,AXIClockFreq_Value,CECFreq_Value,CKPERFreq_Value,CortexFreq_Value,CpuClockFreq_Value,D1CPREFreq_Value,D2PPRE1,D3PPRE,DFSDMACLkFreq_Value,DFSDMFreq_Value,DIVM1,DIVM2,DIVN1,DIVN2,DIVP1Freq_Value,DIVP2,DIVP2Freq_Value,DIVP3Freq_Value,DIVQ1Freq_Value,DIVQ2Freq_Value,DIVQ3Freq_Value,DIVR1Freq_Value,DIVR2Freq_Value,DIVR3Freq_Value,FDCANFreq_Value,FMCFreq_Value,FamilyName,HCLK3ClockFreq_Value,HCLKFreq_Value,HRTIMFreq_Value,HSE_VALUE,I2C123Freq_Value,I2C4Freq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPTIM345Freq_Value,LPUART1Freq_Value,LTDCFreq_Value,MCO1PinFreq_Value,MCO2PinFreq_Value,PLL2FRACN,PLL3FRACN,PLLFRACN,PLLSourceVirtual,QSPIFreq_Value,RNGFreq_Value,RTCFreq_Value,SAI1CLockSelection,SAI1Freq_Value,SAI23Freq_Value,SAI4AFreq_Value,SAI4BFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SPI123Freq_Value,SPI45Freq_Value,SPI6Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,Tim1OutputFreq_Value,Tim2OutputFreq_Value,TraceFreq_Value,USART16Freq_Value,USART234578Freq_Value,USBCLockSelection,USBFreq_Value,VCO1OutputFreq_Value,VCO2OutputFreq_Value,VCO3OutputFreq_Value,VCOInput1Freq_Value,VCOInput2Freq_Value,VCOInput3Freq_Value ProjectManager.AskForMigrate=true @@ -457,6 +454,7 @@ Dma.SAI1_A.0.SyncEnable=DISABLE PA3.GPIO_Label=EXTI3 PB4\ (NJTRST).Signal=SPI6_MISO SPI6.Mode=SPI_MODE_MASTER +USB_OTG_HS.VirtualMode-Host_FS=Host_FS SH.FMC_D7_DA7.0=FMC_D7,sd-32b-d1 SH.FMC_D24.0=FMC_D24,sd-32b-d1 SH.FMC_A4.ConfNb=1 @@ -488,7 +486,6 @@ SH.FMC_A12.ConfNb=1 PH5.Signal=FMC_SDNWE SH.GPXTI3.ConfNb=1 PE2.Mode=Single Bank 1 -USB_HOST.USBH_USE_OS-AUDIO_FS=0 SH.FMC_D10_DA10.ConfNb=1 PB6.Mode=Asynchronous RCC.DIVQ3Freq_Value=16125000 @@ -533,7 +530,7 @@ RCC.APB4Freq_Value=37500000 RCC.CECFreq_Value=32000 RCC.SAI23Freq_Value=75000000 PF14.Signal=FMC_A8 -NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false SAI1.FrameLength-SAI_A_MasterWithClock=256 PB10.GPIOParameters=GPIO_Label PI11.Signal=GPXTI11 @@ -571,6 +568,7 @@ RCC.SPI123Freq_Value=75000000 Dma.SAI1_A.0.RequestNumber=1 SH.FMC_D15_DA15.0=FMC_D15,sd-32b-d1 PC3_C.GPIOParameters=GPIO_Label +USB_HOST.VirtualModeHS=Audio PA9.Signal=USB_OTG_FS_VBUS SH.S_TIM2_CH2.ConfNb=1 RCC.DIVN2=18 @@ -586,7 +584,6 @@ SH.ADCx_INP8.0=ADC1_INP8,IN8-Single-Ended SH.ADCx_INP5.ConfNb=1 RCC.USBCLockSelection=RCC_USBCLKSOURCE_HSI48 ProjectManager.LastFirmware=true -USB_HOST.VirtualModeFS=Audio Mcu.Pin116=PF11 Mcu.Pin117=PF14 Mcu.Pin118=PE7 @@ -604,8 +601,8 @@ Mcu.Pin115=PB0 Mcu.Pin110=PD9 Mcu.Pin111=PD8 Mcu.Pin127=VP_SYS_VS_Systick -Mcu.Pin128=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_HS -Mcu.Pin129=VP_USB_HOST_VS_USB_HOST_AUDIO_FS +Mcu.Pin128=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS +Mcu.Pin129=VP_USB_HOST_VS_USB_HOST_AUDIO_HS PB4\ (NJTRST).Mode=Full_Duplex_Master SH.FMC_SDNCAS.0=FMC_SDNCAS,13b-sda1 ProjectManager.FreePins=true @@ -640,6 +637,7 @@ Mcu.Pin109=PB13 Mcu.Pin105=PE8 PA8.Mode=Asynchronous Mcu.Pin106=PE9 +SPI2.DataSize=SPI_DATASIZE_8BIT Mcu.Pin107=PE11 Mcu.Pin108=PE14 SH.FMC_NBL3.0=FMC_NBL3,Sd4ByteEnable1 @@ -665,7 +663,6 @@ Mcu.Pin104=PF15 Mcu.Pin100=PA6 Dma.SAI1_A.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber RCC.DIVQ2Freq_Value=75000000 -VP_USB_HOST_VS_USB_HOST_AUDIO_FS.Signal=USB_HOST_VS_USB_HOST_AUDIO_FS SH.S_TIM4_CH2.ConfNb=1 RCC.SAI1Freq_Value=64000000 RCC.CortexFreq_Value=75000000 @@ -686,6 +683,7 @@ RCC.VCOInput3Freq_Value=250000 PH3.Mode=SdramChipSelect1_1 SH.SharedStack_PC11.0=SDMMC1_D3 SH.SharedStack_PC11.1=SPI3_MISO,Full_Duplex_Master +USB_HOST.USBH_HandleTypeDef-AUDIO_HS=hUsbHostHS SH.FMC_A7.0=FMC_A7,13b-sda1 PA12.Signal=USB_OTG_FS_DP PH4.GPIOParameters=GPIO_Label @@ -736,12 +734,10 @@ ProjectManager.ProjectName=Xibeca RCC.APB3Freq_Value=75000000 PA7.Locked=true SH.FMC_D0_DA0.0=FMC_D0,sd-32b-d1 -VP_USB_HOST_VS_USB_HOST_AUDIO_FS.Mode=AUDIO_FS -USB_OTG_FS.VirtualMode=Host_Only +USB_OTG_FS.VirtualMode=Device_Only SH.FMC_A9.0=FMC_A9,13b-sda1 SH.FMC_D4_DA4.0=FMC_D4,sd-32b-d1 PF5.Signal=FMC_A5 -USB_DEVICE.VirtualModeHS=Audio_HS Dma.SAI1_B.1.SignalID=NONE SH.FMC_D19.ConfNb=1 SH.FMC_D30.0=FMC_D30,sd-32b-d1 @@ -760,6 +756,7 @@ PA13\ (JTMS/SWDIO).Mode=Trace_Asynchronous_SW Dma.SAI1_B.1.Polarity=HAL_DMAMUX_REQ_GEN_RISING PH11.Signal=FMC_D19 ProjectManager.NoMain=false +USB_DEVICE.VirtualModeFS=Audio_FS PG3.Signal=GPIO_Output PG1.Signal=FMC_A11 RCC.SAI4BFreq_Value=75000000 @@ -803,7 +800,6 @@ RCC.APB2Freq_Value=75000000 SPI3.CalculateBaudRate=1.171875 MBits/s SH.FMC_D13_DA13.ConfNb=1 PC13.GPIOParameters=GPIO_Label -USB_HOST.USBH_HandleTypeDef-AUDIO_FS=hUsbHostFS PF10.Signal=QUADSPI_CLK SPI3.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_64 SPI6.Direction=SPI_DIRECTION_2LINES @@ -815,7 +811,7 @@ SH.FMC_D23.ConfNb=1 PA2.Signal=ADCx_INP14 PD14.Signal=FMC_D0_DA0 PA7.GPIO_Label=EXTI7 -PA12.Mode=Host_Only +PA12.Mode=Device_Only Dma.SAI1_B.1.Direction=DMA_MEMORY_TO_PERIPH PC14-OSC32_IN\ (OSC32_IN).Signal=GPXTI14 SH.FMC_D23.0=FMC_D23,sd-32b-d1 From 02c28db669d0553c34fe4dd072bab8d21a342d6e Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 15 Jun 2021 12:56:14 +0200 Subject: [PATCH 028/286] swapped usb hs/fs --- Xibeca/Core/Inc/stm32h7xx_it.h | 6 -- Xibeca/Core/Src/main.c | 20 +--- Xibeca/Core/Src/stm32h7xx_it.c | 9 +- Xibeca/USB_DEVICE/App/usbd_desc.c | 105 +++++++++----------- Xibeca/USB_DEVICE/App/usbd_desc.h | 2 +- Xibeca/USB_DEVICE/Target/usbd_conf.c | 137 +++++++++++++-------------- Xibeca/USB_HOST/App/usb_host.c | 8 +- Xibeca/USB_HOST/Target/usbh_conf.c | 104 ++++++++++---------- Xibeca/USB_HOST/Target/usbh_conf.h | 2 +- Xibeca/Xibeca.ioc | 6 +- 10 files changed, 185 insertions(+), 214 deletions(-) diff --git a/Xibeca/Core/Inc/stm32h7xx_it.h b/Xibeca/Core/Inc/stm32h7xx_it.h index 3819c272..8fd73ca2 100644 --- a/Xibeca/Core/Inc/stm32h7xx_it.h +++ b/Xibeca/Core/Inc/stm32h7xx_it.h @@ -47,12 +47,6 @@ /* USER CODE END EM */ /* Exported functions prototypes ---------------------------------------------*/ -void NMI_Handler(void); -void HardFault_Handler(void); -void MemManage_Handler(void); -void BusFault_Handler(void); -void UsageFault_Handler(void); -void DebugMon_Handler(void); void SysTick_Handler(void); void DMA1_Stream0_IRQHandler(void); void DMA1_Stream1_IRQHandler(void); diff --git a/Xibeca/Core/Src/main.c b/Xibeca/Core/Src/main.c index 0f3e94de..a51bce8c 100644 --- a/Xibeca/Core/Src/main.c +++ b/Xibeca/Core/Src/main.c @@ -635,7 +635,7 @@ static void MX_SPI2_Init(void) hspi2.Instance = SPI2; hspi2.Init.Mode = SPI_MODE_MASTER; hspi2.Init.Direction = SPI_DIRECTION_2LINES; - hspi2.Init.DataSize = SPI_DATASIZE_4BIT; + hspi2.Init.DataSize = SPI_DATASIZE_8BIT; hspi2.Init.CLKPolarity = SPI_POLARITY_LOW; hspi2.Init.CLKPhase = SPI_PHASE_1EDGE; hspi2.Init.NSS = SPI_NSS_SOFT; @@ -644,7 +644,7 @@ static void MX_SPI2_Init(void) hspi2.Init.TIMode = SPI_TIMODE_DISABLE; hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; hspi2.Init.CRCPolynomial = 0x0; - hspi2.Init.NSSPMode = SPI_NSS_PULSE_ENABLE; + hspi2.Init.NSSPMode = SPI_NSS_PULSE_DISABLE; hspi2.Init.NSSPolarity = SPI_NSS_POLARITY_LOW; hspi2.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA; hspi2.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; @@ -1197,26 +1197,15 @@ static void MX_GPIO_Init(void) * @param argument: Not used * @retval None */ -#if 0 /* USER CODE END Header_StartDefaultTask */ void StartDefaultTask(void const * argument) { - /* init code for USB_HOST */ - MX_USB_HOST_Init(); - /* init code for USB_DEVICE */ MX_USB_DEVICE_Init(); - /* USER CODE BEGIN 5 */ -#else -void StartDefaultTask(void const * argument) -{ - /* NOTE: we get frequent boot failures if host is called first */ - MX_USB_DEVICE_Init(); - -#ifdef USE_USB_HOST + /* init code for USB_HOST */ MX_USB_HOST_Init(); -#endif + /* USER CODE BEGIN 5 */ setup(); @@ -1225,7 +1214,6 @@ void StartDefaultTask(void const * argument) { loop(); } -#endif /* USER CODE END 5 */ } diff --git a/Xibeca/Core/Src/stm32h7xx_it.c b/Xibeca/Core/Src/stm32h7xx_it.c index c4adaf70..f4c77e77 100644 --- a/Xibeca/Core/Src/stm32h7xx_it.c +++ b/Xibeca/Core/Src/stm32h7xx_it.c @@ -58,8 +58,8 @@ /* USER CODE END 0 */ /* External variables --------------------------------------------------------*/ -extern PCD_HandleTypeDef hpcd_USB_OTG_HS; -extern HCD_HandleTypeDef hhcd_USB_OTG_FS; +extern PCD_HandleTypeDef hpcd_USB_OTG_FS; +extern HCD_HandleTypeDef hhcd_USB_OTG_HS; extern DMA_HandleTypeDef hdma_sai1_a; extern DMA_HandleTypeDef hdma_sai1_b; /* USER CODE BEGIN EV */ @@ -69,7 +69,6 @@ extern DMA_HandleTypeDef hdma_sai1_b; /******************************************************************************/ /* Cortex Processor Interruption and Exception Handlers */ /******************************************************************************/ - /** * @brief This function handles System tick timer. */ @@ -135,7 +134,7 @@ void OTG_HS_IRQHandler(void) /* USER CODE BEGIN OTG_HS_IRQn 0 */ /* USER CODE END OTG_HS_IRQn 0 */ - HAL_PCD_IRQHandler(&hpcd_USB_OTG_HS); + HAL_HCD_IRQHandler(&hhcd_USB_OTG_HS); /* USER CODE BEGIN OTG_HS_IRQn 1 */ /* USER CODE END OTG_HS_IRQn 1 */ @@ -149,7 +148,7 @@ void OTG_FS_IRQHandler(void) /* USER CODE BEGIN OTG_FS_IRQn 0 */ /* USER CODE END OTG_FS_IRQn 0 */ - HAL_HCD_IRQHandler(&hhcd_USB_OTG_FS); + HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS); /* USER CODE BEGIN OTG_FS_IRQn 1 */ /* USER CODE END OTG_FS_IRQn 1 */ diff --git a/Xibeca/USB_DEVICE/App/usbd_desc.c b/Xibeca/USB_DEVICE/App/usbd_desc.c index e49759c7..6ea9c473 100644 --- a/Xibeca/USB_DEVICE/App/usbd_desc.c +++ b/Xibeca/USB_DEVICE/App/usbd_desc.c @@ -66,10 +66,10 @@ #define USBD_VID 0x1209 #define USBD_LANGID_STRING 1033 #define USBD_MANUFACTURER_STRING "Rebel Technology" -#define USBD_PID_HS 0xDADA -#define USBD_PRODUCT_STRING_HS "OWL-XIBECA" -#define USBD_CONFIGURATION_STRING_HS "AUDIO Config" -#define USBD_INTERFACE_STRING_HS "AUDIO Interface" +#define USBD_PID_FS 0xDADA +#define USBD_PRODUCT_STRING_FS "OWL-XIBECA" +#define USBD_CONFIGURATION_STRING_FS "AUDIO Config" +#define USBD_INTERFACE_STRING_FS "AUDIO Interface" /* USER CODE BEGIN PRIVATE_DEFINES */ @@ -109,17 +109,17 @@ static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len); */ /** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes - * @brief Private functions declaration for HS. + * @brief Private functions declaration for FS. * @{ */ -uint8_t * USBD_HS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_HS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_HS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_HS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_HS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_HS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_HS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); /** * @} @@ -130,27 +130,26 @@ uint8_t * USBD_HS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *leng * @{ */ -USBD_DescriptorsTypeDef HS_Desc = +USBD_DescriptorsTypeDef FS_Desc = { - USBD_HS_DeviceDescriptor -, USBD_HS_LangIDStrDescriptor -, USBD_HS_ManufacturerStrDescriptor -, USBD_HS_ProductStrDescriptor -, USBD_HS_SerialStrDescriptor -, USBD_HS_ConfigStrDescriptor -, USBD_HS_InterfaceStrDescriptor + USBD_FS_DeviceDescriptor +, USBD_FS_LangIDStrDescriptor +, USBD_FS_ManufacturerStrDescriptor +, USBD_FS_ProductStrDescriptor +, USBD_FS_SerialStrDescriptor +, USBD_FS_ConfigStrDescriptor +, USBD_FS_InterfaceStrDescriptor }; #if defined ( __ICCARM__ ) /* IAR Compiler */ #pragma data_alignment=4 #endif /* defined ( __ICCARM__ ) */ /** USB standard device descriptor. */ -__ALIGN_BEGIN uint8_t USBD_HS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = +__ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = { 0x12, /*bLength */ USB_DESC_TYPE_DEVICE, /*bDescriptorType*/ 0x00, /*bcdUSB */ - 0x02, 0x00, /*bDeviceClass*/ 0x00, /*bDeviceSubClass*/ @@ -158,8 +157,8 @@ __ALIGN_BEGIN uint8_t USBD_HS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = USB_MAX_EP0_SIZE, /*bMaxPacketSize*/ LOBYTE(USBD_VID), /*idVendor*/ HIBYTE(USBD_VID), /*idVendor*/ - LOBYTE(USBD_PID_HS), /*idProduct*/ - HIBYTE(USBD_PID_HS), /*idProduct*/ + LOBYTE(USBD_PID_FS), /*idProduct*/ + HIBYTE(USBD_PID_FS), /*idProduct*/ 0x00, /*bcdDevice rel. 2.00*/ 0x02, USBD_IDX_MFC_STR, /*Index of manufacturer string*/ @@ -168,6 +167,8 @@ __ALIGN_BEGIN uint8_t USBD_HS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/ }; +/* USB_DeviceDescriptor */ + /** * @} */ @@ -219,11 +220,11 @@ __ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_HS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); - *length = sizeof(USBD_HS_DeviceDesc); - return USBD_HS_DeviceDesc; + *length = sizeof(USBD_FS_DeviceDesc); + return USBD_FS_DeviceDesc; } /** @@ -232,7 +233,7 @@ uint8_t * USBD_HS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_HS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); *length = sizeof(USBD_LangIDDesc); @@ -241,19 +242,19 @@ uint8_t * USBD_HS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) /** * @brief Return the product string descriptor - * @param speed : current device speed - * @param length : pointer to data length variable - * @retval pointer to descriptor buffer + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer */ -uint8_t * USBD_HS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { if(speed == 0) { - USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_HS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); } else { - USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_HS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); } return USBD_StrDesc; } @@ -264,7 +265,7 @@ uint8_t * USBD_HS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_HS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length); @@ -277,7 +278,7 @@ uint8_t * USBD_HS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *l * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_HS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); *length = USB_SIZ_STRING_SERIAL; @@ -285,10 +286,9 @@ uint8_t * USBD_HS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) /* Update the serial number string descriptor with the data from the unique * ID */ Get_SerialNum(); - /* USER CODE BEGIN USBD_HS_SerialStrDescriptor */ - - /* USER CODE END USBD_HS_SerialStrDescriptor */ + /* USER CODE BEGIN USBD_FS_SerialStrDescriptor */ + /* USER CODE END USBD_FS_SerialStrDescriptor */ return (uint8_t *) USBD_StringSerial; } @@ -298,15 +298,15 @@ uint8_t * USBD_HS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_HS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { if(speed == USBD_SPEED_HIGH) { - USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_HS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); } else { - USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_HS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); } return USBD_StrDesc; } @@ -317,34 +317,19 @@ uint8_t * USBD_HS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_HS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { if(speed == 0) { - USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_HS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); } else { - USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_HS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); } return USBD_StrDesc; } -#if (USBD_LPM_ENABLED == 1) -/** - * @brief Return the BOS descriptor - * @param speed : Current device speed - * @param length : Pointer to data length variable - * @retval Pointer to descriptor buffer - */ -uint8_t * USBD_HS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) -{ - UNUSED(speed); - *length = sizeof(USBD_HS_BOSDesc); - return (uint8_t*)USBD_HS_BOSDesc; -} -#endif /* (USBD_LPM_ENABLED == 1) */ - /** * @brief Create the serial number string descriptor * @param None diff --git a/Xibeca/USB_DEVICE/App/usbd_desc.h b/Xibeca/USB_DEVICE/App/usbd_desc.h index 4033860d..51de9706 100644 --- a/Xibeca/USB_DEVICE/App/usbd_desc.h +++ b/Xibeca/USB_DEVICE/App/usbd_desc.h @@ -105,7 +105,7 @@ */ /** Descriptor for the Usb device. */ -extern USBD_DescriptorsTypeDef HS_Desc; +extern USBD_DescriptorsTypeDef FS_Desc; /* USER CODE BEGIN EXPORTED_VARIABLES */ diff --git a/Xibeca/USB_DEVICE/Target/usbd_conf.c b/Xibeca/USB_DEVICE/Target/usbd_conf.c index 7855f976..073b6145 100644 --- a/Xibeca/USB_DEVICE/Target/usbd_conf.c +++ b/Xibeca/USB_DEVICE/Target/usbd_conf.c @@ -39,7 +39,7 @@ uint8_t USBD_AUDIO_SetFiFos(PCD_HandleTypeDef *hpcd); /* USER CODE END PV */ -PCD_HandleTypeDef hpcd_USB_OTG_HS; +PCD_HandleTypeDef hpcd_USB_OTG_FS; void Error_Handler(void); /* External functions --------------------------------------------------------*/ @@ -68,11 +68,11 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) { GPIO_InitTypeDef GPIO_InitStruct = {0}; RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; - if(pcdHandle->Instance==USB_OTG_HS) + if(pcdHandle->Instance==USB_OTG_FS) { - /* USER CODE BEGIN USB_OTG_HS_MspInit 0 */ + /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */ - /* USER CODE END USB_OTG_HS_MspInit 0 */ + /* USER CODE END USB_OTG_FS_MspInit 0 */ /** Initializes the peripherals clock */ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB; @@ -85,59 +85,59 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) */ HAL_PWREx_EnableUSBVoltageDetector(); - __HAL_RCC_GPIOB_CLK_ENABLE(); - /**USB_OTG_HS GPIO Configuration - PB13 ------> USB_OTG_HS_VBUS - PB14 ------> USB_OTG_HS_DM - PB15 ------> USB_OTG_HS_DP + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**USB_OTG_FS GPIO Configuration + PA12 ------> USB_OTG_FS_DP + PA11 ------> USB_OTG_FS_DM + PA9 ------> USB_OTG_FS_VBUS */ - GPIO_InitStruct.Pin = GPIO_PIN_13; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15; + GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_11; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF12_OTG2_FS; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + GPIO_InitStruct.Alternate = GPIO_AF10_OTG1_FS; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* Peripheral clock enable */ - __HAL_RCC_USB_OTG_HS_CLK_ENABLE(); + __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); /* Peripheral interrupt init */ - HAL_NVIC_SetPriority(OTG_HS_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(OTG_HS_IRQn); - /* USER CODE BEGIN USB_OTG_HS_MspInit 1 */ + HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(OTG_FS_IRQn); + /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */ - /* USER CODE END USB_OTG_HS_MspInit 1 */ + /* USER CODE END USB_OTG_FS_MspInit 1 */ } } void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) { - if(pcdHandle->Instance==USB_OTG_HS) + if(pcdHandle->Instance==USB_OTG_FS) { - /* USER CODE BEGIN USB_OTG_HS_MspDeInit 0 */ + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */ - /* USER CODE END USB_OTG_HS_MspDeInit 0 */ + /* USER CODE END USB_OTG_FS_MspDeInit 0 */ /* Peripheral clock disable */ - __HAL_RCC_USB_OTG_HS_CLK_DISABLE(); + __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); - /**USB_OTG_HS GPIO Configuration - PB13 ------> USB_OTG_HS_VBUS - PB14 ------> USB_OTG_HS_DM - PB15 ------> USB_OTG_HS_DP + /**USB_OTG_FS GPIO Configuration + PA12 ------> USB_OTG_FS_DP + PA11 ------> USB_OTG_FS_DM + PA9 ------> USB_OTG_FS_VBUS */ - HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15); + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_12|GPIO_PIN_11|GPIO_PIN_9); /* Peripheral interrupt Deinit*/ - HAL_NVIC_DisableIRQ(OTG_HS_IRQn); + HAL_NVIC_DisableIRQ(OTG_FS_IRQn); - /* USER CODE BEGIN USB_OTG_HS_MspDeInit 1 */ + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */ - /* USER CODE END USB_OTG_HS_MspDeInit 1 */ + /* USER CODE END USB_OTG_FS_MspDeInit 1 */ } } @@ -344,44 +344,43 @@ void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) { /* Init USB Ip. */ - if (pdev->id == DEVICE_HS) { + if (pdev->id == DEVICE_FS) { /* Link the driver to the stack. */ - hpcd_USB_OTG_HS.pData = pdev; - pdev->pData = &hpcd_USB_OTG_HS; - - hpcd_USB_OTG_HS.Instance = USB_OTG_HS; - hpcd_USB_OTG_HS.Init.dev_endpoints = 9; - hpcd_USB_OTG_HS.Init.speed = PCD_SPEED_FULL; - hpcd_USB_OTG_HS.Init.dma_enable = DISABLE; - hpcd_USB_OTG_HS.Init.phy_itface = USB_OTG_EMBEDDED_PHY; - hpcd_USB_OTG_HS.Init.Sof_enable = DISABLE; - hpcd_USB_OTG_HS.Init.low_power_enable = DISABLE; - hpcd_USB_OTG_HS.Init.lpm_enable = DISABLE; - hpcd_USB_OTG_HS.Init.battery_charging_enable = ENABLE; - hpcd_USB_OTG_HS.Init.vbus_sensing_enable = ENABLE; - hpcd_USB_OTG_HS.Init.use_dedicated_ep1 = DISABLE; - hpcd_USB_OTG_HS.Init.use_external_vbus = DISABLE; - if (HAL_PCD_Init(&hpcd_USB_OTG_HS) != HAL_OK) + hpcd_USB_OTG_FS.pData = pdev; + pdev->pData = &hpcd_USB_OTG_FS; + + hpcd_USB_OTG_FS.Instance = USB_OTG_FS; + hpcd_USB_OTG_FS.Init.dev_endpoints = 9; + hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; + hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; + hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; + hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; + hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; + hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; + hpcd_USB_OTG_FS.Init.battery_charging_enable = ENABLE; + hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE; + hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE; + if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) { Error_Handler( ); } #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) /* Register USB PCD CallBacks */ - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_SOF_CB_ID, PCD_SOFCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_SETUPSTAGE_CB_ID, PCD_SetupStageCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_RESET_CB_ID, PCD_ResetCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_SUSPEND_CB_ID, PCD_SuspendCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_RESUME_CB_ID, PCD_ResumeCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_CONNECT_CB_ID, PCD_ConnectCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_DISCONNECT_CB_ID, PCD_DisconnectCallback); - - HAL_PCD_RegisterDataOutStageCallback(&hpcd_USB_OTG_HS, PCD_DataOutStageCallback); - HAL_PCD_RegisterDataInStageCallback(&hpcd_USB_OTG_HS, PCD_DataInStageCallback); - HAL_PCD_RegisterIsoOutIncpltCallback(&hpcd_USB_OTG_HS, PCD_ISOOUTIncompleteCallback); - HAL_PCD_RegisterIsoInIncpltCallback(&hpcd_USB_OTG_HS, PCD_ISOINIncompleteCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SOF_CB_ID, PCD_SOFCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SETUPSTAGE_CB_ID, PCD_SetupStageCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESET_CB_ID, PCD_ResetCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SUSPEND_CB_ID, PCD_SuspendCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESUME_CB_ID, PCD_ResumeCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_CONNECT_CB_ID, PCD_ConnectCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_DISCONNECT_CB_ID, PCD_DisconnectCallback); + + HAL_PCD_RegisterDataOutStageCallback(&hpcd_USB_OTG_FS, PCD_DataOutStageCallback); + HAL_PCD_RegisterDataInStageCallback(&hpcd_USB_OTG_FS, PCD_DataInStageCallback); + HAL_PCD_RegisterIsoOutIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOOUTIncompleteCallback); + HAL_PCD_RegisterIsoInIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOINIncompleteCallback); #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ - USBD_AUDIO_SetFiFos(&hpcd_USB_OTG_HS); + USBD_AUDIO_SetFiFos(&hpcd_USB_OTG_FS); } return USBD_OK; } @@ -617,11 +616,11 @@ uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr) { return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef*) pdev->pData, ep_addr); } -/* /\** */ -/* * @brief Static single allocation. */ -/* * @param size: Size of allocated memory */ -/* * @retval None */ -/* *\/ */ +/** + * @brief Static single allocation. + * @param size: Size of allocated memory + * @retval None + */ /* void *USBD_static_malloc(uint32_t size) */ /* { */ /* static uint32_t mem[(sizeof(USBD_AUDIO_HandleTypeDef)/4)+1];/\* On 32-bit boundary *\/ */ diff --git a/Xibeca/USB_HOST/App/usb_host.c b/Xibeca/USB_HOST/App/usb_host.c index 5952ec21..88f10a11 100644 --- a/Xibeca/USB_HOST/App/usb_host.c +++ b/Xibeca/USB_HOST/App/usb_host.c @@ -40,7 +40,7 @@ /* USER CODE END PFP */ /* USB Host core handle declaration */ -USBH_HandleTypeDef hUsbHostFS; +USBH_HandleTypeDef hUsbHostHS; ApplicationTypeDef Appli_state = APPLICATION_IDLE; /* @@ -73,15 +73,15 @@ void MX_USB_HOST_Init(void) /* USER CODE END USB_HOST_Init_PreTreatment */ /* Init host Library, add supported class and start the library. */ - if (USBH_Init(&hUsbHostFS, USBH_UserProcess, HOST_FS) != USBH_OK) + if (USBH_Init(&hUsbHostHS, USBH_UserProcess, HOST_HS) != USBH_OK) { Error_Handler(); } - if (USBH_RegisterClass(&hUsbHostFS, USBH_AUDIO_CLASS) != USBH_OK) + if (USBH_RegisterClass(&hUsbHostHS, USBH_AUDIO_CLASS) != USBH_OK) { Error_Handler(); } - if (USBH_Start(&hUsbHostFS) != USBH_OK) + if (USBH_Start(&hUsbHostHS) != USBH_OK) { Error_Handler(); } diff --git a/Xibeca/USB_HOST/Target/usbh_conf.c b/Xibeca/USB_HOST/Target/usbh_conf.c index 9cbf8103..2b7afd8e 100644 --- a/Xibeca/USB_HOST/Target/usbh_conf.c +++ b/Xibeca/USB_HOST/Target/usbh_conf.c @@ -35,7 +35,7 @@ /* USER CODE END PV */ -HCD_HandleTypeDef hhcd_USB_OTG_FS; +HCD_HandleTypeDef hhcd_USB_OTG_HS; void Error_Handler(void); /* USER CODE BEGIN 0 */ @@ -63,11 +63,11 @@ void HAL_HCD_MspInit(HCD_HandleTypeDef* hcdHandle) { GPIO_InitTypeDef GPIO_InitStruct = {0}; RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; - if(hcdHandle->Instance==USB_OTG_FS) + if(hcdHandle->Instance==USB_OTG_HS) { - /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */ + /* USER CODE BEGIN USB_OTG_HS_MspInit 0 */ - /* USER CODE END USB_OTG_FS_MspInit 0 */ + /* USER CODE END USB_OTG_HS_MspInit 0 */ /** Initializes the peripherals clock */ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB; @@ -80,59 +80,59 @@ void HAL_HCD_MspInit(HCD_HandleTypeDef* hcdHandle) */ HAL_PWREx_EnableUSBVoltageDetector(); - __HAL_RCC_GPIOA_CLK_ENABLE(); - /**USB_OTG_FS GPIO Configuration - PA12 ------> USB_OTG_FS_DP - PA11 ------> USB_OTG_FS_DM - PA9 ------> USB_OTG_FS_VBUS + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**USB_OTG_HS GPIO Configuration + PB13 ------> USB_OTG_HS_VBUS + PB14 ------> USB_OTG_HS_DM + PB15 ------> USB_OTG_HS_DP */ - GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_11; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pin = GPIO_PIN_13; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF10_OTG1_FS; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - GPIO_InitStruct.Pin = GPIO_PIN_9; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF12_OTG2_FS; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /* Peripheral clock enable */ - __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); + __HAL_RCC_USB_OTG_HS_CLK_ENABLE(); /* Peripheral interrupt init */ - HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(OTG_FS_IRQn); - /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */ + HAL_NVIC_SetPriority(OTG_HS_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(OTG_HS_IRQn); + /* USER CODE BEGIN USB_OTG_HS_MspInit 1 */ - /* USER CODE END USB_OTG_FS_MspInit 1 */ + /* USER CODE END USB_OTG_HS_MspInit 1 */ } } void HAL_HCD_MspDeInit(HCD_HandleTypeDef* hcdHandle) { - if(hcdHandle->Instance==USB_OTG_FS) + if(hcdHandle->Instance==USB_OTG_HS) { - /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */ + /* USER CODE BEGIN USB_OTG_HS_MspDeInit 0 */ - /* USER CODE END USB_OTG_FS_MspDeInit 0 */ + /* USER CODE END USB_OTG_HS_MspDeInit 0 */ /* Peripheral clock disable */ - __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); + __HAL_RCC_USB_OTG_HS_CLK_DISABLE(); - /**USB_OTG_FS GPIO Configuration - PA12 ------> USB_OTG_FS_DP - PA11 ------> USB_OTG_FS_DM - PA9 ------> USB_OTG_FS_VBUS + /**USB_OTG_HS GPIO Configuration + PB13 ------> USB_OTG_HS_VBUS + PB14 ------> USB_OTG_HS_DM + PB15 ------> USB_OTG_HS_DP */ - HAL_GPIO_DeInit(GPIOA, GPIO_PIN_12|GPIO_PIN_11|GPIO_PIN_9); + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15); /* Peripheral interrupt Deinit*/ - HAL_NVIC_DisableIRQ(OTG_FS_IRQn); + HAL_NVIC_DisableIRQ(OTG_HS_IRQn); - /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */ + /* USER CODE BEGIN USB_OTG_HS_MspDeInit 1 */ - /* USER CODE END USB_OTG_FS_MspDeInit 1 */ + /* USER CODE END USB_OTG_HS_MspDeInit 1 */ } } @@ -212,23 +212,25 @@ void HAL_HCD_PortDisabled_Callback(HCD_HandleTypeDef *hhcd) USBH_StatusTypeDef USBH_LL_Init(USBH_HandleTypeDef *phost) { /* Init USB_IP */ - if (phost->id == HOST_FS) { + if (phost->id == HOST_HS) { /* Link the driver to the stack. */ - hhcd_USB_OTG_FS.pData = phost; - phost->pData = &hhcd_USB_OTG_FS; - - hhcd_USB_OTG_FS.Instance = USB_OTG_FS; - hhcd_USB_OTG_FS.Init.Host_channels = 16; - hhcd_USB_OTG_FS.Init.speed = HCD_SPEED_FULL; - hhcd_USB_OTG_FS.Init.dma_enable = DISABLE; - hhcd_USB_OTG_FS.Init.phy_itface = HCD_PHY_EMBEDDED; - hhcd_USB_OTG_FS.Init.Sof_enable = DISABLE; - if (HAL_HCD_Init(&hhcd_USB_OTG_FS) != HAL_OK) + hhcd_USB_OTG_HS.pData = phost; + phost->pData = &hhcd_USB_OTG_HS; + + hhcd_USB_OTG_HS.Instance = USB_OTG_HS; + hhcd_USB_OTG_HS.Init.Host_channels = 16; + hhcd_USB_OTG_HS.Init.speed = HCD_SPEED_FULL; + hhcd_USB_OTG_HS.Init.dma_enable = DISABLE; + hhcd_USB_OTG_HS.Init.phy_itface = USB_OTG_EMBEDDED_PHY; + hhcd_USB_OTG_HS.Init.Sof_enable = DISABLE; + hhcd_USB_OTG_HS.Init.low_power_enable = DISABLE; + hhcd_USB_OTG_HS.Init.use_external_vbus = DISABLE; + if (HAL_HCD_Init(&hhcd_USB_OTG_HS) != HAL_OK) { Error_Handler( ); } - USBH_LL_SetTimer(phost, HAL_HCD_GetCurrentFrame(&hhcd_USB_OTG_FS)); + USBH_LL_SetTimer(phost, HAL_HCD_GetCurrentFrame(&hhcd_USB_OTG_HS)); } return USBH_OK; } @@ -462,23 +464,23 @@ USBH_StatusTypeDef USBH_LL_DriverVBUS(USBH_HandleTypeDef *phost, uint8_t state) /* USER CODE END 0*/ - if (phost->id == HOST_FS) + if (phost->id == HOST_HS) { if (state == 0) { /* Drive high Charge pump */ /* ToDo: Add IOE driver control */ - /* USER CODE BEGIN DRIVE_HIGH_CHARGE_FOR_FS */ + /* USER CODE BEGIN DRIVE_HIGH_CHARGE_FOR_HS */ - /* USER CODE END DRIVE_HIGH_CHARGE_FOR_FS */ + /* USER CODE END DRIVE_HIGH_CHARGE_FOR_HS */ } else { /* Drive low Charge pump */ /* ToDo: Add IOE driver control */ - /* USER CODE BEGIN DRIVE_LOW_CHARGE_FOR_FS */ + /* USER CODE BEGIN DRIVE_LOW_CHARGE_FOR_HS */ - /* USER CODE END DRIVE_LOW_CHARGE_FOR_FS */ + /* USER CODE END DRIVE_LOW_CHARGE_FOR_HS */ } } HAL_Delay(200); diff --git a/Xibeca/USB_HOST/Target/usbh_conf.h b/Xibeca/USB_HOST/Target/usbh_conf.h index 2f3f0fcb..8857272b 100644 --- a/Xibeca/USB_HOST/Target/usbh_conf.h +++ b/Xibeca/USB_HOST/Target/usbh_conf.h @@ -63,7 +63,7 @@ */ /*---------- -----------*/ -#define USBH_MAX_NUM_ENDPOINTS 2U +#define USBH_MAX_NUM_ENDPOINTS 5U /*---------- -----------*/ #define USBH_MAX_NUM_INTERFACES 10U diff --git a/Xibeca/Xibeca.ioc b/Xibeca/Xibeca.ioc index 40406ae1..7c1b62f0 100644 --- a/Xibeca/Xibeca.ioc +++ b/Xibeca/Xibeca.ioc @@ -21,6 +21,7 @@ SH.ADCx_INP5.0=ADC1_INP5,IN5-Single-Ended SH.FMC_D5_DA5.0=FMC_D5,sd-32b-d1 SH.FMC_D9_DA9.0=FMC_D9,sd-32b-d1 RCC.LPTIM1Freq_Value=37500000 +USB_DEVICE.PID_AUDIO_FS=0xDADA SH.GPXTI7.ConfNb=1 NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false SH.FMC_D25.0=FMC_D25,sd-32b-d1 @@ -44,6 +45,7 @@ PA0.Locked=true VP_USB_HOST_VS_USB_HOST_AUDIO_HS.Mode=AUDIO_HS PG14.Mode=Full_Duplex_Master ProjectManager.FirmwarePackage=STM32Cube FW_H7 V1.9.0 +USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology ProjectManager.BackupPrevious=false RCC.FMCFreq_Value=75000000 RCC.SAI1CLockSelection=RCC_SAI1CLKSOURCE_CLKP @@ -89,6 +91,7 @@ SH.FMC_D3_DA3.ConfNb=1 PG12.Signal=LPTIM1_IN1 Dma.SAI1_B.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber SH.GPXTI10.0=GPIO_EXTI10 +USB_DEVICE.VID-AUDIO_FS=0x1209 Mcu.Pin80=PG2 Mcu.Pin81=PC0 SH.S_TIM4_CH1.ConfNb=1 @@ -314,6 +317,7 @@ Mcu.IP25=USB_OTG_HS SH.FMC_D27.ConfNb=1 Mcu.IP24=USB_OTG_FS SH.FMC_D16.ConfNb=1 +USB_DEVICE.PRODUCT_STRING_AUDIO_FS=OWL-XIBECA PA6.Signal=ADCx_INP3 Dma.SAI1_A.0.MemDataAlignment=DMA_MDATAALIGN_WORD SH.FMC_D4_DA4.ConfNb=1 @@ -374,7 +378,7 @@ PD9.Signal=FMC_D14_DA14 PC12.Stacked=true ProjectManager.DeletePrevious=true PB10.Locked=true -USB_DEVICE.IPParameters=VirtualMode-AUDIO_FS,VirtualModeFS,CLASS_NAME_FS +USB_DEVICE.IPParameters=VirtualMode-AUDIO_FS,VirtualModeFS,CLASS_NAME_FS,VID-AUDIO_FS,MANUFACTURER_STRING-AUDIO_FS,PID_AUDIO_FS,PRODUCT_STRING_AUDIO_FS PinOutPanel.CurrentBGAView=Top RCC.FamilyName=M PH1-OSC_OUT\ (PH1).Signal=RCC_OSC_OUT From 5ec073e2b3f244fe5618f6203a7b0d22860f5dcb Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 15 Jun 2021 13:06:08 +0200 Subject: [PATCH 029/286] xibeca build fixes --- Hardware/h7-libs.mk | 3 ++- Hardware/h7.mk | 3 +++ Source/hardware_ids.h | 1 + Xibeca/Core/Inc/FreeRTOSConfig.h | 6 +++++- Xibeca/Core/Inc/hardware.h | 6 +++--- Xibeca/Makefile | 3 ++- Xibeca/USB_HOST/App/usb_host.c | 12 ++++++++---- 7 files changed, 24 insertions(+), 10 deletions(-) diff --git a/Hardware/h7-libs.mk b/Hardware/h7-libs.mk index 2f56b8b8..6756fcc1 100644 --- a/Hardware/h7-libs.mk +++ b/Hardware/h7-libs.mk @@ -13,10 +13,10 @@ C_SRC += $(DRIVERS)/Src/stm32h7xx_hal_flash.c C_SRC += $(DRIVERS)/Src/stm32h7xx_hal_flash_ex.c C_SRC += $(DRIVERS)/Src/stm32h7xx_hal_tim_ex.c C_SRC += $(DRIVERS)/Src/stm32h7xx_hal_tim.c +C_SRC += $(DRIVERS)/Src/stm32h7xx_hal_lptim.c C_SRC += $(DRIVERS)/Src/stm32h7xx_hal_cortex.c C_SRC += $(DRIVERS)/Src/stm32h7xx_hal_spi.c # C_SRC += $(DRIVERS)/Src/stm32h7xx_hal_rng.c -# C_SRC += $(DRIVERS)/Src/stm32h7xx_hal_qspi.c # C_SRC += $(DRIVERS)/Src/stm32h7xx_hal_dma2d.c # optionals @@ -29,6 +29,7 @@ C_SRC_RTC = $(DRIVERS)/Src/stm32h7xx_hal_rtc.c C_SRC_RTC += $(DRIVERS)/Src/stm32h7xx_hal_pwr.c C_SRC_RTC += $(DRIVERS)/Src/stm32h7xx_hal_rtc_ex.c C_SRC_IWDG = $(DRIVERS)/Src/stm32h7xx_hal_iwdg.c +C_SRC_QSPI = $(DRIVERS)/Src/stm32h7xx_hal_qspi.c # required by OWL 2 C_SRC_SAI = $(DRIVERS)/Src/stm32h7xx_hal_sai.c diff --git a/Hardware/h7.mk b/Hardware/h7.mk index 2083e1e1..1eee4af8 100644 --- a/Hardware/h7.mk +++ b/Hardware/h7.mk @@ -19,6 +19,9 @@ FREERTOS_DIR=$(OPENWARE)/Libraries/Middlewares/Third_Party/FreeRTOS/Source INC_FLAGS = -I$(CMSIS_CORE) -I$(CMSIS_DEVICE)/Include -I$(DRIVERS)/Inc INC_FLAGS += -I$(OPENWARE)/Source -I$(BUILDROOT)/Inc +INC_FLAGS += -I$(BUILDROOT)/Core/Inc +INC_FLAGS += -I$(BUILDROOT)/USB_DEVICE/App -I$(BUILDROOT)/USB_DEVICE/Target +INC_FLAGS += -I$(BUILDROOT)/USB_HOST/App -I$(BUILDROOT)/USB_HOST/Target INC_FLAGS += -I$(USB_HOST_FILE)/Core/Inc INC_FLAGS += -I$(USB_DEVICE_FILE)/Core/Inc INC_FLAGS += -I$(USB_OTG_FILE)/inc diff --git a/Source/hardware_ids.h b/Source/hardware_ids.h index f202a288..6c40aeca 100644 --- a/Source/hardware_ids.h +++ b/Source/hardware_ids.h @@ -19,6 +19,7 @@ #define GENIUS_HARDWARE 0x20 #define OWL_PEDAL_HARDWARE 0x21 #define OWL_MODULAR_HARDWARE 0x22 +#define XIBECA_HARDWARE 0x23 #define OTHER_HARDWARE 0xf0 #endif /* __HARDWARE_IDS_H */ diff --git a/Xibeca/Core/Inc/FreeRTOSConfig.h b/Xibeca/Core/Inc/FreeRTOSConfig.h index 4d06e420..ff70ac0e 100644 --- a/Xibeca/Core/Inc/FreeRTOSConfig.h +++ b/Xibeca/Core/Inc/FreeRTOSConfig.h @@ -44,7 +44,11 @@ *----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ -/* Section where include file can be added */ +#include "device.h" +#ifdef DEBUG_STACK +#define configUSE_TRACE_FACILITY 1 +#define INCLUDE_uxTaskGetStackHighWaterMark 1 +#endif /* DEBUG_STACK */ /* USER CODE END Includes */ /* Ensure definitions are only used by the compiler, and not by the assembler. */ diff --git a/Xibeca/Core/Inc/hardware.h b/Xibeca/Core/Inc/hardware.h index df80f396..83a6e42b 100644 --- a/Xibeca/Core/Inc/hardware.h +++ b/Xibeca/Core/Inc/hardware.h @@ -40,9 +40,9 @@ #define USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS /* #define USBD_MAX_POWER 100 // 200mA for iPad compatibility */ -/* #define USE_USB_HOST */ -/* #define USB_HOST_RX_BUFF_SIZE 256 /\* Max Received data 64 bytes *\/ */ -/* #define USE_USBH_MIDI */ +#define USE_USB_HOST +#define USB_HOST_RX_BUFF_SIZE 256 /* Max Received data 64 bytes */ +#define USE_USBH_MIDI #define USBH_HANDLE hUsbHostHS /* #define USE_UART_MIDI_RX */ diff --git a/Xibeca/Makefile b/Xibeca/Makefile index 5d6ab6d9..010d0175 100644 --- a/Xibeca/Makefile +++ b/Xibeca/Makefile @@ -9,7 +9,7 @@ CPP_SRC = $(wildcard Core/Src/*.cpp) C_SRC += $(OPENWARE)/Source/sdram.c C_SRC += $(OPENWARE)/Source/pcm3168a.c C_SRC += $(OPENWARE)/Source/usbd_audio.c -# CPP_SRC += $(OPENWARE)/Source/usbh_midi.cpp +CPP_SRC += $(OPENWARE)/Source/usbh_midi.cpp # C_SRC += $(OPENWARE)/Source/ssd1309.c # CPP_SRC += $(OPENWARE)/Source/ScreenBuffer.cpp @@ -26,6 +26,7 @@ C_SRC += $(BUILDROOT)/USB_DEVICE/App/usbd_desc.c C_SRC += $(BUILDROOT)/USB_DEVICE/Target/usbd_conf.c C_SRC += $(BUILDROOT)/USB_HOST/Target/usbh_conf.c +C_SRC += $(BUILDROOT)/USB_HOST/App/usb_host.c include $(OPENWARE)/Hardware/sources.mk diff --git a/Xibeca/USB_HOST/App/usb_host.c b/Xibeca/USB_HOST/App/usb_host.c index 88f10a11..02c1c118 100644 --- a/Xibeca/USB_HOST/App/usb_host.c +++ b/Xibeca/USB_HOST/App/usb_host.c @@ -7,7 +7,7 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2021 STMicroelectronics. + *

© Copyright (c) 2020 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under Ultimate Liberty license @@ -23,7 +23,7 @@ #include "usb_host.h" #include "usbh_core.h" -#include "usbh_audio.h" +#include "usbh_midi.h" /* USER CODE BEGIN Includes */ @@ -59,7 +59,11 @@ static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id); * -- Insert your external function declaration here -- */ /* USER CODE BEGIN 1 */ - +void MX_USB_HOST_Process() +{ + /* USB Host Background task */ + USBH_Process(&hUsbHostHS); +} /* USER CODE END 1 */ /** @@ -77,7 +81,7 @@ void MX_USB_HOST_Init(void) { Error_Handler(); } - if (USBH_RegisterClass(&hUsbHostHS, USBH_AUDIO_CLASS) != USBH_OK) + if (USBH_RegisterClass(&hUsbHostHS, USBH_MIDI_CLASS) != USBH_OK) { Error_Handler(); } From 99d6d0e783fd8cb25f6676bc4324ec4b0bebb0e6 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 16 Jun 2021 16:04:13 +0200 Subject: [PATCH 030/286] SAI and SPI2 updates, set clockspeed to 480Mhz --- Xibeca/Xibeca.ioc | 143 ++++++++++++++++++++++++++++------------------ 1 file changed, 86 insertions(+), 57 deletions(-) diff --git a/Xibeca/Xibeca.ioc b/Xibeca/Xibeca.ioc index 7c1b62f0..83231d22 100644 --- a/Xibeca/Xibeca.ioc +++ b/Xibeca/Xibeca.ioc @@ -8,19 +8,19 @@ SH.FMC_A0.0=FMC_A0,13b-sda1 PG8.Signal=FMC_SDCLK SH.GPXTI14.0=GPIO_EXTI14 PG0.Signal=FMC_A10 -RCC.PLLFRACN=6144 +RCC.PLLFRACN=0 PC3_C.Mode=Full_Duplex_Master DAC1.IPParameters=DAC_Channel-DAC_OUT2,DAC_Channel-DAC_OUT1 SAI1.Instance-SAI_A_MasterWithClock=SAI$Index_Block_A RCC.RTCFreq_Value=32000 PA15\ (JTDI).Signal=S_TIM2_CH1 -RCC.CpuClockFreq_Value=75000000 +RCC.CpuClockFreq_Value=480000000 PD2.GPIOParameters=GPIO_Label SH.FMC_SDNWE.ConfNb=1 SH.ADCx_INP5.0=ADC1_INP5,IN5-Single-Ended SH.FMC_D5_DA5.0=FMC_D5,sd-32b-d1 SH.FMC_D9_DA9.0=FMC_D9,sd-32b-d1 -RCC.LPTIM1Freq_Value=37500000 +RCC.LPTIM1Freq_Value=120000000 USB_DEVICE.PID_AUDIO_FS=0xDADA SH.GPXTI7.ConfNb=1 NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false @@ -32,7 +32,7 @@ SH.FMC_SDNWE.0=FMC_SDNWE,13b-sda1 PH9.Signal=FMC_D17 SPI3.VirtualNSS=VM_NSSHARD SH.FMC_D11_DA11.0=FMC_D11,sd-32b-d1 -RCC.I2C4Freq_Value=37500000 +RCC.I2C4Freq_Value=120000000 PB6.Signal=UART5_TX PC7.Signal=S_TIM3_CH2 PD0.Signal=FMC_D2_DA2 @@ -47,20 +47,20 @@ PG14.Mode=Full_Duplex_Master ProjectManager.FirmwarePackage=STM32Cube FW_H7 V1.9.0 USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology ProjectManager.BackupPrevious=false -RCC.FMCFreq_Value=75000000 +RCC.FMCFreq_Value=240000000 RCC.SAI1CLockSelection=RCC_SAI1CLKSOURCE_CLKP PE9.Signal=FMC_D6_DA6 Dma.SAI1_A.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING SH.FMC_A2.0=FMC_A2,13b-sda1 PB14.Mode=Host_FS -RCC.USART16Freq_Value=75000000 +RCC.USART16Freq_Value=120000000 VP_USB_HOST_VS_USB_HOST_AUDIO_HS.Signal=USB_HOST_VS_USB_HOST_AUDIO_HS PA8.Signal=UART7_RX SH.FMC_D1_DA1.0=FMC_D1,sd-32b-d1 USB_OTG_HS.IPParameters=VirtualMode-Host_FS VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 ProjectManager.HalAssertFull=true -RCC.DIVP2Freq_Value=37500000 +RCC.DIVP2Freq_Value=75000000 SH.ADCx_INP3.0=ADC1_INP3,IN3-Single-Ended PA0.Signal=GPXTI0 SH.ADCx_INP4.ConfNb=1 @@ -68,18 +68,20 @@ Mcu.Package=UFBGA176 SAI1.AudioFrequency-SAI_A_MasterWithClock=SAI_AUDIO_FREQUENCY_48K PB1.Signal=ADCx_INP5 PC10.Stacked=true +SAI1.SlotActive-SAI_B_SyncSlave=0x0000FFFF SPI2.Mode=SPI_MODE_MASTER RCC.PLL3FRACN=0 SPI3.Mode=SPI_MODE_MASTER PD12.Signal=S_TIM4_CH1 SH.FMC_SDNCAS.ConfNb=1 VP_SYS_VS_Systick.Signal=SYS_VS_Systick +SAI1.FSPolarity-SAI_B_SyncSlave=SAI_FS_ACTIVE_HIGH PC3_C.GPIO_Label=ADC_SPI_MOSI SH.FMC_A11.ConfNb=1 SH.FMC_D27.0=FMC_D27,sd-32b-d1 Dma.SAI1_A.0.SyncSignalID=NONE SH.S_TIM4_CH1.0=TIM4_CH1,Encoder_Interface -RCC.LPUART1Freq_Value=75000000 +RCC.LPUART1Freq_Value=120000000 PF10.Mode=Single Bank 1 USB_OTG_FS.IPParameters=VirtualMode PB13.Mode=Activate_VBUS_FS @@ -89,6 +91,7 @@ SH.ADCx_INP10.ConfNb=1 RCC.VCO3OutputFreq_Value=32250000 SH.FMC_D3_DA3.ConfNb=1 PG12.Signal=LPTIM1_IN1 +SAI1.NoDivider-SAI_A_MasterWithClock=SAI_MASTERDIVIDER_ENABLE Dma.SAI1_B.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber SH.GPXTI10.0=GPIO_EXTI10 USB_DEVICE.VID-AUDIO_FS=0x1209 @@ -133,13 +136,14 @@ Mcu.Pin63=PF4 Mcu.Pin60=PG8 Mcu.Pin61=PC6 Mcu.Pin66=PG6 +RCC.PWR_Regulator_Voltage_Scale=PWR_REGULATOR_VOLTAGE_SCALE0 Mcu.Pin67=PF7 Mcu.Pin64=PH5 Mcu.Pin65=PG7 PF8.GPIO_Label=FLASH_DQ0 PD10.Signal=FMC_D15_DA15 -RCC.D1CPREFreq_Value=75000000 -RCC.Tim1OutputFreq_Value=75000000 +RCC.D1CPREFreq_Value=480000000 +RCC.Tim1OutputFreq_Value=240000000 SH.FMC_D29.0=FMC_D29,sd-32b-d1 Mcu.Pin59=PH4 Mcu.Pin57=PF2 @@ -172,7 +176,7 @@ Mcu.Pin43=PI11 PI7.Signal=FMC_D29 PC2_C.GPIO_Label=ADC_SPI_MISO SH.FMC_A6.0=FMC_A6,13b-sda1 -RCC.AHB12Freq_Value=75000000 +RCC.AHB12Freq_Value=240000000 PE14.Signal=FMC_D11_DA11 PE6.Mode=SAI_A_MasterWithClock Mcu.Pin37=PD2 @@ -256,14 +260,15 @@ SAI1.FrameLength-SAI_B_SyncSlave=256 PA0.GPIO_Label=EXTI0 PA11.Mode=Device_Only RCC.PLL2FRACN=6144 +SAI1.OutputDrive-SAI_B_SyncSlave=SAI_OUTPUTDRIVE_ENABLE PD2.Locked=true SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 RCC.VCO2OutputFreq_Value=150000000 SH.FMC_A11.0=FMC_A11,13b-sda1 SH.ADCx_INP11.ConfNb=1 PB15.Signal=USB_OTG_HS_DP -PG11.Signal=LPTIM1_IN2 PG15.Signal=FMC_SDNCAS +PG11.Signal=LPTIM1_IN2 PD13.Signal=S_TIM4_CH2 Mcu.IP4=DMA Mcu.IP5=FMC @@ -272,10 +277,11 @@ I2C1.IPParameters=Timing Mcu.IP3=DEBUG Mcu.IP0=ADC1 Mcu.IP1=CORTEX_M7 +PE4.GPIOParameters=GPIO_Speed SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE Dma.SAI1_B.1.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT RCC.DIVP3Freq_Value=16125000 -RCC.SDMMCFreq_Value=75000000 +RCC.SDMMCFreq_Value=192000000 ProjectManager.PreviousToolchain= SH.COMP_DAC12_group.ConfNb=1 SH.FMC_NBL1.0=FMC_NBL1,Sd4ByteEnable1 @@ -283,7 +289,7 @@ FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configUSE_IDLE_HOOK,configUSE Dma.SAI1_B.1.Instance=DMA1_Stream1 Dma.SAI1_B.1.FIFOMode=DMA_FIFOMODE_DISABLE FREERTOS.configUSE_PREEMPTION=0 -RCC.HRTIMFreq_Value=75000000 +RCC.HRTIMFreq_Value=240000000 ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_4 PH1-OSC_OUT\ (PH1).Mode=HSE-External-Oscillator RCC.DIVR3Freq_Value=16125000 @@ -299,7 +305,7 @@ SH.SharedStack_PC10.0=SDMMC1_D2 Mcu.IP18=TIM3 Mcu.IP17=TIM2 Mcu.IP19=TIM4 -RCC.DIVP1Freq_Value=75000000 +RCC.DIVP1Freq_Value=480000000 Mcu.IP14=SPI3 PF9.Mode=Single Bank 1 Mcu.IP13=SPI2 @@ -307,6 +313,7 @@ Mcu.IP16=SYS Mcu.IP15=SPI6 PF11.Signal=FMC_SDNRAS PB5.Mode=Asynchronous +PE3.GPIOParameters=GPIO_Speed PB7.Signal=I2C1_SDA Mcu.IP21=UART7 Mcu.IP20=UART5 @@ -317,6 +324,7 @@ Mcu.IP25=USB_OTG_HS SH.FMC_D27.ConfNb=1 Mcu.IP24=USB_OTG_FS SH.FMC_D16.ConfNb=1 +SAI1.OutputDrive-SAI_A_MasterWithClock=SAI_OUTPUTDRIVE_ENABLE USB_DEVICE.PRODUCT_STRING_AUDIO_FS=OWL-XIBECA PA6.Signal=ADCx_INP3 Dma.SAI1_A.0.MemDataAlignment=DMA_MDATAALIGN_WORD @@ -324,9 +332,10 @@ SH.FMC_D4_DA4.ConfNb=1 NVIC.OTG_FS_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true ProjectManager.ToolChainLocation= SH.GPXTI0.0=GPIO_EXTI0 +SAI1.FSOffset-SAI_A_MasterWithClock=SAI_FS_BEFOREFIRSTBIT PF8.Signal=QUADSPI_BK1_IO0 SH.FMC_D30.ConfNb=1 -RCC.DIVR1Freq_Value=75000000 +RCC.DIVR1Freq_Value=480000000 Mcu.Pin95=PG0 Mcu.Pin96=PE13 Mcu.Pin93=PC4 @@ -358,6 +367,7 @@ Mcu.Pin89=PD13 Mcu.Pin86=PH8 Mcu.Pin87=PH9 SH.FMC_A3.ConfNb=1 +SAI1.VirtualSlotActive-SAI_A_MasterWithClock=SAI_SLOTACTIVE_ALL USB_HOST.IPParameters=USBH_HandleTypeDef-AUDIO_HS,VirtualModeHS SH.FMC_D20.0=FMC_D20,sd-32b-d1 SH.S_TIM2_CH1.0=TIM2_CH1,Encoder_Interface @@ -393,11 +403,11 @@ PC15-OSC32_OUT\ (OSC32_OUT).Signal=GPXTI15 SH.SharedStack_PD2.1=GPIO_EXTI2 PB10.GPIO_Label=ADC_SPI_CLK Dma.SAI1_A.0.Mode=DMA_CIRCULAR -RCC.VCO1OutputFreq_Value=150000000 +RCC.VCO1OutputFreq_Value=960000000 SH.FMC_D13_DA13.0=FMC_D13,sd-32b-d1 PH8.Signal=FMC_D16 -RCC.AXIClockFreq_Value=75000000 -SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,DataSize,NSSPMode +RCC.AXIClockFreq_Value=240000000 +SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,DataSize,NSSPMode,CLKPolarity,CLKPhase PG10.GPIOParameters=GPIO_Label PE2.GPIOParameters=GPIO_Label RCC.USBFreq_Value=48000000 @@ -413,10 +423,10 @@ PH4.GPIO_Label=EXTI4 PB15.Mode=Host_FS SH.FMC_D22.0=FMC_D22,sd-32b-d1 MxCube.Version=6.2.1 -RCC.FDCANFreq_Value=75000000 +RCC.FDCANFreq_Value=192000000 PI4.Signal=FMC_NBL2 PE5.Mode=SAI_A_MasterWithClock -RCC.ADCFreq_Value=37500000 +RCC.ADCFreq_Value=75000000 VP_SYS_VS_Systick.Mode=SysTick SH.FMC_D12_DA12.0=FMC_D12,sd-32b-d1 SAI1.SlotNumber-SAI_A_MasterWithClock=8 @@ -427,7 +437,7 @@ PF1.Signal=FMC_A1 VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_FS VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Mode=AUDIO_FS SH.FMC_D11_DA11.ConfNb=1 -RCC.IPParameters=ADCFreq_Value,AHB12Freq_Value,AHB4Freq_Value,APB1Freq_Value,APB2Freq_Value,APB3Freq_Value,APB4Freq_Value,AXIClockFreq_Value,CECFreq_Value,CKPERFreq_Value,CortexFreq_Value,CpuClockFreq_Value,D1CPREFreq_Value,D2PPRE1,D3PPRE,DFSDMACLkFreq_Value,DFSDMFreq_Value,DIVM1,DIVM2,DIVN1,DIVN2,DIVP1Freq_Value,DIVP2,DIVP2Freq_Value,DIVP3Freq_Value,DIVQ1Freq_Value,DIVQ2Freq_Value,DIVQ3Freq_Value,DIVR1Freq_Value,DIVR2Freq_Value,DIVR3Freq_Value,FDCANFreq_Value,FMCFreq_Value,FamilyName,HCLK3ClockFreq_Value,HCLKFreq_Value,HRTIMFreq_Value,HSE_VALUE,I2C123Freq_Value,I2C4Freq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPTIM345Freq_Value,LPUART1Freq_Value,LTDCFreq_Value,MCO1PinFreq_Value,MCO2PinFreq_Value,PLL2FRACN,PLL3FRACN,PLLFRACN,PLLSourceVirtual,QSPIFreq_Value,RNGFreq_Value,RTCFreq_Value,SAI1CLockSelection,SAI1Freq_Value,SAI23Freq_Value,SAI4AFreq_Value,SAI4BFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SPI123Freq_Value,SPI45Freq_Value,SPI6Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,Tim1OutputFreq_Value,Tim2OutputFreq_Value,TraceFreq_Value,USART16Freq_Value,USART234578Freq_Value,USBCLockSelection,USBFreq_Value,VCO1OutputFreq_Value,VCO2OutputFreq_Value,VCO3OutputFreq_Value,VCOInput1Freq_Value,VCOInput2Freq_Value,VCOInput3Freq_Value +RCC.IPParameters=ADCFreq_Value,AHB12Freq_Value,AHB4Freq_Value,APB1Freq_Value,APB2Freq_Value,APB3Freq_Value,APB4Freq_Value,AXIClockFreq_Value,CECFreq_Value,CKPERFreq_Value,CortexFreq_Value,CpuClockFreq_Value,D1CPREFreq_Value,D1PPRE,D2PPRE1,D2PPRE2,D3PPRE,DFSDMACLkFreq_Value,DFSDMFreq_Value,DIVM1,DIVM2,DIVN1,DIVN2,DIVP1Freq_Value,DIVP2Freq_Value,DIVP3Freq_Value,DIVQ1,DIVQ1Freq_Value,DIVQ2Freq_Value,DIVQ3Freq_Value,DIVR1Freq_Value,DIVR2Freq_Value,DIVR3Freq_Value,FDCANFreq_Value,FMCFreq_Value,FamilyName,HCLK3ClockFreq_Value,HCLKFreq_Value,HPRE,HRTIMFreq_Value,HSE_VALUE,I2C123Freq_Value,I2C4Freq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPTIM345Freq_Value,LPUART1Freq_Value,LTDCFreq_Value,MCO1PinFreq_Value,MCO2PinFreq_Value,PLL2FRACN,PLL3FRACN,PLLFRACN,PLLSourceVirtual,PWR_Regulator_Voltage_Scale,QSPIFreq_Value,RNGFreq_Value,RTCFreq_Value,SAI1CLockSelection,SAI1Freq_Value,SAI23Freq_Value,SAI4AFreq_Value,SAI4BFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SPI123Freq_Value,SPI45Freq_Value,SPI6Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,Tim1OutputFreq_Value,Tim2OutputFreq_Value,TraceFreq_Value,USART16Freq_Value,USART234578Freq_Value,USBCLockSelection,USBFreq_Value,VCO1OutputFreq_Value,VCO2OutputFreq_Value,VCO3OutputFreq_Value,VCOInput1Freq_Value,VCOInput2Freq_Value,VCOInput3Freq_Value ProjectManager.AskForMigrate=true PE0.Signal=FMC_NBL0 Dma.SAI1_B.1.SyncSignalID=NONE @@ -439,8 +449,8 @@ Mcu.IP9=NVIC Mcu.IP6=FREERTOS Mcu.IP7=I2C1 ProjectManager.CoupleFile=false -RCC.SYSCLKFreq_VALUE=75000000 -RCC.I2C123Freq_Value=37500000 +RCC.SYSCLKFreq_VALUE=480000000 +RCC.I2C123Freq_Value=120000000 SH.SharedStack_PC8.ConfNb=2 SH.GPXTI4.0=GPIO_EXTI4 KeepUserPlacement=false @@ -450,6 +460,7 @@ SH.GPXTI4.ConfNb=1 SH.GPXTI15.0=GPIO_EXTI15 PH3.Signal=FMC_SDNE0 PC3_C.Signal=SPI2_MOSI +PE5.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH PB7.Locked=true PC8.Locked=true SH.ADCx_INP3.ConfNb=1 @@ -458,6 +469,7 @@ Dma.SAI1_A.0.SyncEnable=DISABLE PA3.GPIO_Label=EXTI3 PB4\ (NJTRST).Signal=SPI6_MISO SPI6.Mode=SPI_MODE_MASTER +SAI1.SlotActive-SAI_A_MasterWithClock=0x0000FFFF USB_OTG_HS.VirtualMode-Host_FS=Host_FS SH.FMC_D7_DA7.0=FMC_D7,sd-32b-d1 SH.FMC_D24.0=FMC_D24,sd-32b-d1 @@ -482,7 +494,7 @@ PinOutPanel.RotationAngle=0 PF6.GPIO_Label=FLASH_DQ3 RCC.MCO1PinFreq_Value=64000000 RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK -RCC.AHB4Freq_Value=75000000 +RCC.AHB4Freq_Value=240000000 SH.GPXTI13.0=GPIO_EXTI13 SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 PA14\ (JTCK/SWCLK).Signal=DEBUG_JTCK-SWCLK @@ -506,7 +518,7 @@ SH.FMC_D26.0=FMC_D26,sd-32b-d1 PI6.Signal=FMC_D28 PI3.Signal=FMC_D27 SH.FMC_D15_DA15.ConfNb=1 -SPI2.CalculateBaudRate=1.171875 MBits/s +SPI2.CalculateBaudRate=750.0 KBits/s SH.S_TIM4_CH2.0=TIM4_CH2,Encoder_Interface SH.SharedStack_PC12.ConfNb=2 PE2.Signal=QUADSPI_BK1_IO2 @@ -516,29 +528,31 @@ SH.GPXTI11.ConfNb=1 NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:false PF3.Signal=FMC_A3 SH.FMC_D25.ConfNb=1 +NVIC.SAI1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true RCC.DIVR2Freq_Value=75000000 PE10.Signal=FMC_D7_DA7 ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_1CYCLE_5 -RCC.MCO2PinFreq_Value=75000000 +RCC.MCO2PinFreq_Value=480000000 PC8.GPIOParameters=GPIO_Label PF8.GPIOParameters=GPIO_Label SH.GPXTI11.0=GPIO_EXTI11 -RCC.DFSDMFreq_Value=75000000 +RCC.DFSDMFreq_Value=120000000 PA5.GPIOParameters=GPIO_Label SH.FMC_A1.0=FMC_A1,13b-sda1 SH.GPXTI14.ConfNb=1 PH2.Signal=FMC_SDCKE0 SH.FMC_SDCLK.0=FMC_SDCLK,13b-sda1 -RCC.TraceFreq_Value=75000000 -RCC.APB4Freq_Value=37500000 +RCC.TraceFreq_Value=480000000 +RCC.APB4Freq_Value=120000000 RCC.CECFreq_Value=32000 -RCC.SAI23Freq_Value=75000000 +RCC.SAI23Freq_Value=192000000 PF14.Signal=FMC_A8 NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false SAI1.FrameLength-SAI_A_MasterWithClock=256 PB10.GPIOParameters=GPIO_Label PI11.Signal=GPXTI11 PH0-OSC_IN\ (PH0).Mode=HSE-External-Oscillator +PE6.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH SH.FMC_D3_DA3.0=FMC_D3,sd-32b-d1 ProjectManager.CustomerFirmwarePackage= SH.SharedStack_PD2.ConfNb=2 @@ -548,27 +562,27 @@ SH.FMC_A7.ConfNb=1 PH15.Signal=FMC_D23 SH.FMC_A1.ConfNb=1 SAI1.DataSize-SAI_B_SyncSlave=SAI_DATASIZE_24 +RCC.DIVQ1=5 ADC1.Rank-0\#ChannelRegularConversion=1 DAC1.DAC_Channel-DAC_OUT2=DAC_CHANNEL_2 SH.FMC_D28.0=FMC_D28,sd-32b-d1 DAC1.DAC_Channel-DAC_OUT1=DAC_CHANNEL_1 ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,master -RCC.SWPMI1Freq_Value=37500000 +RCC.SWPMI1Freq_Value=120000000 PC6.Signal=S_TIM3_CH1 PB11.GPIO_Label=ADC_SPI_NCS PD1.Signal=FMC_D3_DA3 SH.GPXTI0.ConfNb=1 -RCC.DIVP2=4 PC0.Signal=ADCx_INP10 -RCC.QSPIFreq_Value=75000000 +RCC.QSPIFreq_Value=240000000 PC9.Stacked=true PG10.Signal=GPXTI10 PG10.Locked=true SH.FMC_A3.0=FMC_A3,13b-sda1 -RCC.USART234578Freq_Value=37500000 +RCC.USART234578Freq_Value=120000000 SH.FMC_D31.ConfNb=1 -SPI6.CalculateBaudRate=18.75 MBits/s -RCC.SPI123Freq_Value=75000000 +SPI6.CalculateBaudRate=60.0 MBits/s +RCC.SPI123Freq_Value=192000000 Dma.SAI1_A.0.RequestNumber=1 SH.FMC_D15_DA15.0=FMC_D15,sd-32b-d1 PC3_C.GPIOParameters=GPIO_Label @@ -576,8 +590,8 @@ USB_HOST.VirtualModeHS=Audio PA9.Signal=USB_OTG_FS_VBUS SH.S_TIM2_CH2.ConfNb=1 RCC.DIVN2=18 -I2C1.Timing=0x00909FCE -RCC.DIVN1=18 +I2C1.Timing=0x307075B1 +RCC.DIVN1=120 PC2_C.Mode=Full_Duplex_Master SH.SharedStack_PC9.0=SDMMC1_D1 SH.SharedStack_PC9.1=GPIO_EXTI9 @@ -610,7 +624,7 @@ Mcu.Pin129=VP_USB_HOST_VS_USB_HOST_AUDIO_HS PB4\ (NJTRST).Mode=Full_Duplex_Master SH.FMC_SDNCAS.0=FMC_SDNCAS,13b-sda1 ProjectManager.FreePins=true -RCC.LPTIM2Freq_Value=37500000 +RCC.LPTIM2Freq_Value=120000000 SH.FMC_NBL1.ConfNb=1 ProjectManager.UnderRoot=false SH.FMC_D7_DA7.ConfNb=1 @@ -624,6 +638,7 @@ PB5.Signal=UART5_RX Mcu.Pin120=PE12 Mcu.Pin121=PE15 Mcu.Pin122=PB10 +PE3.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH SH.FMC_A10.ConfNb=1 ProjectManager.CompilerOptimize=6 PG11.Mode=Encoder_mode_occur1 @@ -631,7 +646,7 @@ SH.FMC_A5.0=FMC_A5,13b-sda1 PA11.Signal=USB_OTG_FS_DM SH.S_TIM3_CH1.ConfNb=1 PF6.Mode=Single Bank 1 -RCC.LPTIM345Freq_Value=37500000 +RCC.LPTIM345Freq_Value=120000000 ProjectManager.ComputerToolchain=false PF9.Signal=QUADSPI_BK1_IO1 RCC.LTDCFreq_Value=16125000 @@ -647,7 +662,7 @@ Mcu.Pin108=PE14 SH.FMC_NBL3.0=FMC_NBL3,Sd4ByteEnable1 PG3.GPIO_Label=ADC_RST SH.FMC_D12_DA12.ConfNb=1 -RCC.HCLK3ClockFreq_Value=75000000 +RCC.HCLK3ClockFreq_Value=240000000 PB0.Signal=ADCx_INP9 SAI1.SlotSize-SAI_B_SyncSlave=SAI_SLOTSIZE_32B SH.FMC_D19.0=FMC_D19,sd-32b-d1 @@ -657,6 +672,7 @@ PC1.Signal=ADCx_INP11 Dma.SAI1_A.0.Instance=DMA1_Stream0 PG10.GPIO_Label=EXTI10 PD2.GPIO_Label=EXTI2 +PG7.GPIOParameters=GPIO_Speed Dma.SAI1_A.0.PeriphDataAlignment=DMA_PDATAALIGN_WORD Mcu.Pin101=PA5 PA13\ (JTMS/SWDIO).Signal=DEBUG_JTMS-SWDIO @@ -669,10 +685,11 @@ Dma.SAI1_A.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAli RCC.DIVQ2Freq_Value=75000000 SH.S_TIM4_CH2.ConfNb=1 RCC.SAI1Freq_Value=64000000 -RCC.CortexFreq_Value=75000000 +RCC.CortexFreq_Value=480000000 SH.FMC_A2.ConfNb=1 PG6.Signal=QUADSPI_BK1_NCS Mcu.UserName=STM32H743IIKx +RCC.HPRE=RCC_HCLK_DIV2 PC10.Locked=true PC10.Signal=SharedStack_PC10 SH.FMC_NBL0.0=FMC_NBL0,Sd4ByteEnable1 @@ -681,6 +698,7 @@ SH.FMC_D6_DA6.0=FMC_D6,sd-32b-d1 PC9.Locked=true PC13.GPIO_Label=EXTI13 PB11.Signal=GPIO_Output +PE5.GPIOParameters=GPIO_Speed ProjectManager.StackSize=0x400 PI11.GPIOParameters=GPIO_Label RCC.VCOInput3Freq_Value=250000 @@ -691,12 +709,13 @@ USB_HOST.USBH_HandleTypeDef-AUDIO_HS=hUsbHostHS SH.FMC_A7.0=FMC_A7,13b-sda1 PA12.Signal=USB_OTG_FS_DP PH4.GPIOParameters=GPIO_Label +SPI2.CLKPolarity=SPI_POLARITY_HIGH Mcu.UserConstants= SH.GPXTI13.ConfNb=1 Mcu.ThirdPartyNb=0 -RCC.HCLKFreq_Value=75000000 +RCC.HCLKFreq_Value=240000000 Mcu.IPNb=26 -RCC.SPDIFRXFreq_Value=75000000 +RCC.SPDIFRXFreq_Value=192000000 SPI6.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate PF12.Signal=FMC_A6 FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 @@ -707,7 +726,7 @@ Mcu.Pin9=PB3 (JTDO/TRACESWO) Dma.SAI1_A.0.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT PC2_C.Signal=SPI2_MISO SH.FMC_A10.0=FMC_A10,13b-sda1 -SPI2.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_64 +SPI2.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_256 Mcu.Pin0=PE3 SPI3.DataSize=SPI_DATASIZE_8BIT Mcu.Pin1=PE2 @@ -722,6 +741,7 @@ PC8.Stacked=true SH.FMC_D2_DA2.0=FMC_D2,sd-32b-d1 PE13.Signal=FMC_D10_DA10 PI5.Signal=FMC_NBL3 +PE4.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH PI0.Signal=FMC_D24 File.Version=6 Dma.SAI1_A.0.EventEnable=DISABLE @@ -733,14 +753,18 @@ PG13.Mode=Full_Duplex_Master PE4.Mode=SAI_A_MasterWithClock SH.FMC_SDNRAS.0=FMC_SDNRAS,13b-sda1 PE4.Signal=SAI1_FS_A +PE6.GPIOParameters=GPIO_Speed Dma.RequestsNb=2 ProjectManager.ProjectName=Xibeca -RCC.APB3Freq_Value=75000000 +RCC.APB3Freq_Value=120000000 +SAI1.VirtualSlotActive-SAI_B_SyncSlave=SAI_SLOTACTIVE_ALL PA7.Locked=true SH.FMC_D0_DA0.0=FMC_D0,sd-32b-d1 +RCC.D1PPRE=RCC_APB3_DIV2 USB_OTG_FS.VirtualMode=Device_Only SH.FMC_A9.0=FMC_A9,13b-sda1 SH.FMC_D4_DA4.0=FMC_D4,sd-32b-d1 +SPI2.CLKPhase=SPI_PHASE_2EDGE PF5.Signal=FMC_A5 Dma.SAI1_B.1.SignalID=NONE SH.FMC_D19.ConfNb=1 @@ -751,7 +775,7 @@ PF0.Signal=FMC_A0 SH.FMC_NBL0.ConfNb=1 SH.COMP_DAC11_group.ConfNb=1 PE3.Mode=SAI_B_SyncSlave -RCC.Tim2OutputFreq_Value=75000000 +RCC.Tim2OutputFreq_Value=240000000 RCC.DFSDMACLkFreq_Value=64000000 SH.FMC_A12.0=FMC_A12,13b-sda1 RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE @@ -763,23 +787,25 @@ ProjectManager.NoMain=false USB_DEVICE.VirtualModeFS=Audio_FS PG3.Signal=GPIO_Output PG1.Signal=FMC_A11 -RCC.SAI4BFreq_Value=75000000 +SAI1.FSPolarity-SAI_A_MasterWithClock=SAI_FS_ACTIVE_HIGH +RCC.SAI4BFreq_Value=192000000 SH.FMC_SDCLK.ConfNb=1 PC4.Signal=ADCx_INP4 +RCC.D2PPRE2=RCC_APB2_DIV2 RCC.D2PPRE1=RCC_APB1_DIV2 PI10.Signal=FMC_D31 NVIC.DMA1_Stream1_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true Dma.SAI1_A.0.MemInc=DMA_MINC_ENABLE PD2.Stacked=true PC14-OSC32_IN\ (OSC32_IN).Locked=true -RCC.SPI6Freq_Value=37500000 +RCC.SPI6Freq_Value=120000000 PC8.GPIO_Label=EXTI8 SH.FMC_D21.0=FMC_D21,sd-32b-d1 PF7.Mode=Asynchronous SH.ADCx_INP9.ConfNb=1 SH.S_TIM2_CH2.0=TIM2_CH2,Encoder_Interface SH.FMC_NBL3.ConfNb=1 -RCC.SPI45Freq_Value=75000000 +RCC.SPI45Freq_Value=120000000 PH4.Signal=GPXTI4 PB3\ (JTDO/TRACESWO).Signal=DEBUG_JTDO-SWO ProjectManager.TargetToolchain=Other Toolchains (GPDSC) @@ -796,12 +822,13 @@ SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_TX Dma.SAI1_A.0.Priority=DMA_PRIORITY_VERY_HIGH PG14.Signal=SPI6_MOSI SH.S_TIM3_CH2.0=TIM3_CH2,Encoder_Interface -SAI1.IPParameters=Instance-SAI_A_MasterWithClock,VirtualMode-SAI_A_MasterWithClock,MClockEnable-SAI_A_MasterWithClock,RealAudioFreq-SAI_A_MasterWithClock,ErrorAudioFreq-SAI_A_MasterWithClock,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,FrameLength-SAI_A_MasterWithClock,FrameLength-SAI_B_SyncSlave,DataSize-SAI_A_MasterWithClock,SlotSize-SAI_A_MasterWithClock,SlotSize-SAI_B_SyncSlave,SlotNumber-SAI_A_MasterWithClock,AudioFrequency-SAI_A_MasterWithClock,DataSize-SAI_B_SyncSlave,SlotNumber-SAI_B_SyncSlave,AudioMode-SAI_A_MasterWithClock,AudioMode-SAI_B_SyncSlave +SAI1.IPParameters=Instance-SAI_A_MasterWithClock,VirtualMode-SAI_A_MasterWithClock,MClockEnable-SAI_A_MasterWithClock,RealAudioFreq-SAI_A_MasterWithClock,ErrorAudioFreq-SAI_A_MasterWithClock,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,FrameLength-SAI_A_MasterWithClock,FrameLength-SAI_B_SyncSlave,DataSize-SAI_A_MasterWithClock,SlotSize-SAI_A_MasterWithClock,SlotSize-SAI_B_SyncSlave,SlotNumber-SAI_A_MasterWithClock,AudioFrequency-SAI_A_MasterWithClock,DataSize-SAI_B_SyncSlave,SlotNumber-SAI_B_SyncSlave,AudioMode-SAI_A_MasterWithClock,AudioMode-SAI_B_SyncSlave,FSOffset-SAI_A_MasterWithClock,FSOffset-SAI_B_SyncSlave,FSPolarity-SAI_A_MasterWithClock,FSPolarity-SAI_B_SyncSlave,VirtualSlotActive-SAI_A_MasterWithClock,SlotActive-SAI_A_MasterWithClock,NoDivider-SAI_A_MasterWithClock,ClockStrobing-SAI_A_MasterWithClock,OutputDrive-SAI_A_MasterWithClock,VirtualSlotActive-SAI_B_SyncSlave,SlotActive-SAI_B_SyncSlave,OutputDrive-SAI_B_SyncSlave SH.GPXTI3.0=GPIO_EXTI3 RCC.VCOInput1Freq_Value=8000000 +PG7.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH NVIC.SavedSystickIrqHandlerGenerated=true -RCC.APB2Freq_Value=75000000 -SPI3.CalculateBaudRate=1.171875 MBits/s +RCC.APB2Freq_Value=120000000 +SPI3.CalculateBaudRate=3.0 MBits/s SH.FMC_D13_DA13.ConfNb=1 PC13.GPIOParameters=GPIO_Label PF10.Signal=QUADSPI_CLK @@ -822,18 +849,20 @@ SH.FMC_D23.0=FMC_D23,sd-32b-d1 SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B PB7.Mode=I2C PF6.GPIOParameters=GPIO_Label -RCC.SAI4AFreq_Value=75000000 +RCC.SAI4AFreq_Value=192000000 SH.ADCx_INP11.0=ADC1_INP11,IN11-Single-Ended ADC1.NbrOfConversionFlag=1 -RCC.DIVQ1Freq_Value=75000000 +SAI1.FSOffset-SAI_B_SyncSlave=SAI_FS_BEFOREFIRSTBIT +RCC.DIVQ1Freq_Value=192000000 PB8.Signal=I2C1_SCL PC2_C.GPIOParameters=GPIO_Label Dma.SAI1_B.1.SyncRequestNumber=1 RCC.D3PPRE=RCC_APB4_DIV2 PC9.Signal=SharedStack_PC9 RCC.VCOInput2Freq_Value=8000000 -RCC.APB1Freq_Value=37500000 +RCC.APB1Freq_Value=120000000 PB11.Locked=true ProjectManager.DeviceId=STM32H743IIKx ProjectManager.LibraryCopy=1 +SAI1.ClockStrobing-SAI_A_MasterWithClock=SAI_CLOCKSTROBING_RISINGEDGE PA7.Signal=GPXTI7 From 12b7c6a038e61db1eaafd3d5cebc04cdae930fc4 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 16 Jun 2021 16:07:12 +0200 Subject: [PATCH 031/286] reduced SPI and SAI clock speeds, 1.72% off 48kHz SAI --- Xibeca/Xibeca.ioc | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Xibeca/Xibeca.ioc b/Xibeca/Xibeca.ioc index 83231d22..63c80674 100644 --- a/Xibeca/Xibeca.ioc +++ b/Xibeca/Xibeca.ioc @@ -48,7 +48,7 @@ ProjectManager.FirmwarePackage=STM32Cube FW_H7 V1.9.0 USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology ProjectManager.BackupPrevious=false RCC.FMCFreq_Value=240000000 -RCC.SAI1CLockSelection=RCC_SAI1CLKSOURCE_CLKP +RCC.SAI1CLockSelection=RCC_SAI1CLKSOURCE_PLL2 PE9.Signal=FMC_D6_DA6 Dma.SAI1_A.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING SH.FMC_A2.0=FMC_A2,13b-sda1 @@ -60,7 +60,7 @@ SH.FMC_D1_DA1.0=FMC_D1,sd-32b-d1 USB_OTG_HS.IPParameters=VirtualMode-Host_FS VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 ProjectManager.HalAssertFull=true -RCC.DIVP2Freq_Value=75000000 +RCC.DIVP2Freq_Value=25000000 SH.ADCx_INP3.0=ADC1_INP3,IN3-Single-Ended PA0.Signal=GPXTI0 SH.ADCx_INP4.ConfNb=1 @@ -126,7 +126,7 @@ Mcu.Pin76=PF8 SH.FMC_D10_DA10.0=FMC_D10,sd-32b-d1 FREERTOS.INCLUDE_vTaskDelayUntil=1 Mcu.Pin70=PH12 -SAI1.ErrorAudioFreq-SAI_A_MasterWithClock=30.2 % +SAI1.ErrorAudioFreq-SAI_A_MasterWithClock=1.72 % SH.FMC_D16.0=FMC_D16,sd-32b-d1 Mcu.Pin68=PF6 Mcu.Pin69=PF5 @@ -394,7 +394,7 @@ RCC.FamilyName=M PH1-OSC_OUT\ (PH1).Signal=RCC_OSC_OUT FREERTOS.configUSE_IDLE_HOOK=1 VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 -SAI1.RealAudioFreq-SAI_A_MasterWithClock=62.5 KHz +SAI1.RealAudioFreq-SAI_A_MasterWithClock=48.828 KHz PA9.Mode=Activate_VBUS SH.FMC_A15_BA1.ConfNb=1 SH.SharedStack_PD2.0=SDMMC1_CMD @@ -426,7 +426,7 @@ MxCube.Version=6.2.1 RCC.FDCANFreq_Value=192000000 PI4.Signal=FMC_NBL2 PE5.Mode=SAI_A_MasterWithClock -RCC.ADCFreq_Value=75000000 +RCC.ADCFreq_Value=25000000 VP_SYS_VS_Systick.Mode=SysTick SH.FMC_D12_DA12.0=FMC_D12,sd-32b-d1 SAI1.SlotNumber-SAI_A_MasterWithClock=8 @@ -437,7 +437,7 @@ PF1.Signal=FMC_A1 VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_FS VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Mode=AUDIO_FS SH.FMC_D11_DA11.ConfNb=1 -RCC.IPParameters=ADCFreq_Value,AHB12Freq_Value,AHB4Freq_Value,APB1Freq_Value,APB2Freq_Value,APB3Freq_Value,APB4Freq_Value,AXIClockFreq_Value,CECFreq_Value,CKPERFreq_Value,CortexFreq_Value,CpuClockFreq_Value,D1CPREFreq_Value,D1PPRE,D2PPRE1,D2PPRE2,D3PPRE,DFSDMACLkFreq_Value,DFSDMFreq_Value,DIVM1,DIVM2,DIVN1,DIVN2,DIVP1Freq_Value,DIVP2Freq_Value,DIVP3Freq_Value,DIVQ1,DIVQ1Freq_Value,DIVQ2Freq_Value,DIVQ3Freq_Value,DIVR1Freq_Value,DIVR2Freq_Value,DIVR3Freq_Value,FDCANFreq_Value,FMCFreq_Value,FamilyName,HCLK3ClockFreq_Value,HCLKFreq_Value,HPRE,HRTIMFreq_Value,HSE_VALUE,I2C123Freq_Value,I2C4Freq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPTIM345Freq_Value,LPUART1Freq_Value,LTDCFreq_Value,MCO1PinFreq_Value,MCO2PinFreq_Value,PLL2FRACN,PLL3FRACN,PLLFRACN,PLLSourceVirtual,PWR_Regulator_Voltage_Scale,QSPIFreq_Value,RNGFreq_Value,RTCFreq_Value,SAI1CLockSelection,SAI1Freq_Value,SAI23Freq_Value,SAI4AFreq_Value,SAI4BFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SPI123Freq_Value,SPI45Freq_Value,SPI6Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,Tim1OutputFreq_Value,Tim2OutputFreq_Value,TraceFreq_Value,USART16Freq_Value,USART234578Freq_Value,USBCLockSelection,USBFreq_Value,VCO1OutputFreq_Value,VCO2OutputFreq_Value,VCO3OutputFreq_Value,VCOInput1Freq_Value,VCOInput2Freq_Value,VCOInput3Freq_Value +RCC.IPParameters=ADCFreq_Value,AHB12Freq_Value,AHB4Freq_Value,APB1Freq_Value,APB2Freq_Value,APB3Freq_Value,APB4Freq_Value,AXIClockFreq_Value,CECFreq_Value,CKPERFreq_Value,CortexFreq_Value,CpuClockFreq_Value,D1CPREFreq_Value,D1PPRE,D2PPRE1,D2PPRE2,D3PPRE,DFSDMACLkFreq_Value,DFSDMFreq_Value,DIVM1,DIVM2,DIVN1,DIVN2,DIVP1Freq_Value,DIVP2,DIVP2Freq_Value,DIVP3Freq_Value,DIVQ1,DIVQ1Freq_Value,DIVQ2Freq_Value,DIVQ3Freq_Value,DIVR1Freq_Value,DIVR2Freq_Value,DIVR3Freq_Value,FDCANFreq_Value,FMCFreq_Value,FamilyName,HCLK3ClockFreq_Value,HCLKFreq_Value,HPRE,HRTIMFreq_Value,HSE_VALUE,I2C123Freq_Value,I2C4Freq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPTIM345Freq_Value,LPUART1Freq_Value,LTDCFreq_Value,MCO1PinFreq_Value,MCO2PinFreq_Value,PLL2FRACN,PLL3FRACN,PLLFRACN,PLLSourceVirtual,PWR_Regulator_Voltage_Scale,QSPIFreq_Value,RNGFreq_Value,RTCFreq_Value,SAI1CLockSelection,SAI1Freq_Value,SAI23Freq_Value,SAI4AFreq_Value,SAI4BFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SPI123CLockSelection,SPI123Freq_Value,SPI45Freq_Value,SPI6Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,Tim1OutputFreq_Value,Tim2OutputFreq_Value,TraceFreq_Value,USART16Freq_Value,USART234578Freq_Value,USBCLockSelection,USBFreq_Value,VCO1OutputFreq_Value,VCO2OutputFreq_Value,VCO3OutputFreq_Value,VCOInput1Freq_Value,VCOInput2Freq_Value,VCOInput3Freq_Value ProjectManager.AskForMigrate=true PE0.Signal=FMC_NBL0 Dma.SAI1_B.1.SyncSignalID=NONE @@ -497,6 +497,7 @@ RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK RCC.AHB4Freq_Value=240000000 SH.GPXTI13.0=GPIO_EXTI13 SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 +RCC.SPI123CLockSelection=RCC_SPI123CLKSOURCE_PLL2 PA14\ (JTCK/SWCLK).Signal=DEBUG_JTCK-SWCLK SH.FMC_A12.ConfNb=1 PH5.Signal=FMC_SDNWE @@ -518,7 +519,7 @@ SH.FMC_D26.0=FMC_D26,sd-32b-d1 PI6.Signal=FMC_D28 PI3.Signal=FMC_D27 SH.FMC_D15_DA15.ConfNb=1 -SPI2.CalculateBaudRate=750.0 KBits/s +SPI2.CalculateBaudRate=97.656 KBits/s SH.S_TIM4_CH2.0=TIM4_CH2,Encoder_Interface SH.SharedStack_PC12.ConfNb=2 PE2.Signal=QUADSPI_BK1_IO2 @@ -573,6 +574,7 @@ PC6.Signal=S_TIM3_CH1 PB11.GPIO_Label=ADC_SPI_NCS PD1.Signal=FMC_D3_DA3 SH.GPXTI0.ConfNb=1 +RCC.DIVP2=6 PC0.Signal=ADCx_INP10 RCC.QSPIFreq_Value=240000000 PC9.Stacked=true @@ -582,7 +584,7 @@ SH.FMC_A3.0=FMC_A3,13b-sda1 RCC.USART234578Freq_Value=120000000 SH.FMC_D31.ConfNb=1 SPI6.CalculateBaudRate=60.0 MBits/s -RCC.SPI123Freq_Value=192000000 +RCC.SPI123Freq_Value=25000000 Dma.SAI1_A.0.RequestNumber=1 SH.FMC_D15_DA15.0=FMC_D15,sd-32b-d1 PC3_C.GPIOParameters=GPIO_Label @@ -684,7 +686,7 @@ Mcu.Pin100=PA6 Dma.SAI1_A.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber RCC.DIVQ2Freq_Value=75000000 SH.S_TIM4_CH2.ConfNb=1 -RCC.SAI1Freq_Value=64000000 +RCC.SAI1Freq_Value=25000000 RCC.CortexFreq_Value=480000000 SH.FMC_A2.ConfNb=1 PG6.Signal=QUADSPI_BK1_NCS @@ -776,7 +778,7 @@ SH.FMC_NBL0.ConfNb=1 SH.COMP_DAC11_group.ConfNb=1 PE3.Mode=SAI_B_SyncSlave RCC.Tim2OutputFreq_Value=240000000 -RCC.DFSDMACLkFreq_Value=64000000 +RCC.DFSDMACLkFreq_Value=25000000 SH.FMC_A12.0=FMC_A12,13b-sda1 RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE SH.FMC_A9.ConfNb=1 @@ -828,7 +830,7 @@ RCC.VCOInput1Freq_Value=8000000 PG7.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH NVIC.SavedSystickIrqHandlerGenerated=true RCC.APB2Freq_Value=120000000 -SPI3.CalculateBaudRate=3.0 MBits/s +SPI3.CalculateBaudRate=390.625 KBits/s SH.FMC_D13_DA13.ConfNb=1 PC13.GPIOParameters=GPIO_Label PF10.Signal=QUADSPI_CLK From a5fcac20e5bc1ecc0a980fc3d9d8283f31440510 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 16 Jun 2021 16:26:12 +0200 Subject: [PATCH 032/286] SAI at -0.01% --- Xibeca/Xibeca.ioc | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/Xibeca/Xibeca.ioc b/Xibeca/Xibeca.ioc index 63c80674..731e88ca 100644 --- a/Xibeca/Xibeca.ioc +++ b/Xibeca/Xibeca.ioc @@ -48,7 +48,7 @@ ProjectManager.FirmwarePackage=STM32Cube FW_H7 V1.9.0 USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology ProjectManager.BackupPrevious=false RCC.FMCFreq_Value=240000000 -RCC.SAI1CLockSelection=RCC_SAI1CLKSOURCE_PLL2 +RCC.SAI1CLockSelection=RCC_SAI1CLKSOURCE_PLL3 PE9.Signal=FMC_D6_DA6 Dma.SAI1_A.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING SH.FMC_A2.0=FMC_A2,13b-sda1 @@ -88,7 +88,7 @@ PB13.Mode=Activate_VBUS_FS PA4.GPIO_Label=DAC1 PD15.Signal=FMC_D1_DA1 SH.ADCx_INP10.ConfNb=1 -RCC.VCO3OutputFreq_Value=32250000 +RCC.VCO3OutputFreq_Value=196571428.5714286 SH.FMC_D3_DA3.ConfNb=1 PG12.Signal=LPTIM1_IN1 SAI1.NoDivider-SAI_A_MasterWithClock=SAI_MASTERDIVIDER_ENABLE @@ -126,7 +126,7 @@ Mcu.Pin76=PF8 SH.FMC_D10_DA10.0=FMC_D10,sd-32b-d1 FREERTOS.INCLUDE_vTaskDelayUntil=1 Mcu.Pin70=PH12 -SAI1.ErrorAudioFreq-SAI_A_MasterWithClock=1.72 % +SAI1.ErrorAudioFreq-SAI_A_MasterWithClock=-0.01 % SH.FMC_D16.0=FMC_D16,sd-32b-d1 Mcu.Pin68=PF6 Mcu.Pin69=PF5 @@ -280,7 +280,7 @@ Mcu.IP1=CORTEX_M7 PE4.GPIOParameters=GPIO_Speed SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE Dma.SAI1_B.1.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -RCC.DIVP3Freq_Value=16125000 +RCC.DIVP3Freq_Value=98285714.2857143 RCC.SDMMCFreq_Value=192000000 ProjectManager.PreviousToolchain= SH.COMP_DAC12_group.ConfNb=1 @@ -292,7 +292,7 @@ FREERTOS.configUSE_PREEMPTION=0 RCC.HRTIMFreq_Value=240000000 ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_4 PH1-OSC_OUT\ (PH1).Mode=HSE-External-Oscillator -RCC.DIVR3Freq_Value=16125000 +RCC.DIVR3Freq_Value=98285714.2857143 RCC.HSE_VALUE=8000000 NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false SH.FMC_A14_BA0.ConfNb=1 @@ -394,7 +394,7 @@ RCC.FamilyName=M PH1-OSC_OUT\ (PH1).Signal=RCC_OSC_OUT FREERTOS.configUSE_IDLE_HOOK=1 VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 -SAI1.RealAudioFreq-SAI_A_MasterWithClock=48.828 KHz +SAI1.RealAudioFreq-SAI_A_MasterWithClock=47.991 KHz PA9.Mode=Activate_VBUS SH.FMC_A15_BA1.ConfNb=1 SH.SharedStack_PD2.0=SDMMC1_CMD @@ -437,7 +437,7 @@ PF1.Signal=FMC_A1 VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_FS VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Mode=AUDIO_FS SH.FMC_D11_DA11.ConfNb=1 -RCC.IPParameters=ADCFreq_Value,AHB12Freq_Value,AHB4Freq_Value,APB1Freq_Value,APB2Freq_Value,APB3Freq_Value,APB4Freq_Value,AXIClockFreq_Value,CECFreq_Value,CKPERFreq_Value,CortexFreq_Value,CpuClockFreq_Value,D1CPREFreq_Value,D1PPRE,D2PPRE1,D2PPRE2,D3PPRE,DFSDMACLkFreq_Value,DFSDMFreq_Value,DIVM1,DIVM2,DIVN1,DIVN2,DIVP1Freq_Value,DIVP2,DIVP2Freq_Value,DIVP3Freq_Value,DIVQ1,DIVQ1Freq_Value,DIVQ2Freq_Value,DIVQ3Freq_Value,DIVR1Freq_Value,DIVR2Freq_Value,DIVR3Freq_Value,FDCANFreq_Value,FMCFreq_Value,FamilyName,HCLK3ClockFreq_Value,HCLKFreq_Value,HPRE,HRTIMFreq_Value,HSE_VALUE,I2C123Freq_Value,I2C4Freq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPTIM345Freq_Value,LPUART1Freq_Value,LTDCFreq_Value,MCO1PinFreq_Value,MCO2PinFreq_Value,PLL2FRACN,PLL3FRACN,PLLFRACN,PLLSourceVirtual,PWR_Regulator_Voltage_Scale,QSPIFreq_Value,RNGFreq_Value,RTCFreq_Value,SAI1CLockSelection,SAI1Freq_Value,SAI23Freq_Value,SAI4AFreq_Value,SAI4BFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SPI123CLockSelection,SPI123Freq_Value,SPI45Freq_Value,SPI6Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,Tim1OutputFreq_Value,Tim2OutputFreq_Value,TraceFreq_Value,USART16Freq_Value,USART234578Freq_Value,USBCLockSelection,USBFreq_Value,VCO1OutputFreq_Value,VCO2OutputFreq_Value,VCO3OutputFreq_Value,VCOInput1Freq_Value,VCOInput2Freq_Value,VCOInput3Freq_Value +RCC.IPParameters=ADCFreq_Value,AHB12Freq_Value,AHB4Freq_Value,APB1Freq_Value,APB2Freq_Value,APB3Freq_Value,APB4Freq_Value,AXIClockFreq_Value,CECFreq_Value,CKPERFreq_Value,CortexFreq_Value,CpuClockFreq_Value,D1CPREFreq_Value,D1PPRE,D2PPRE1,D2PPRE2,D3PPRE,DFSDMACLkFreq_Value,DFSDMFreq_Value,DIVM1,DIVM2,DIVM3,DIVN1,DIVN2,DIVN3,DIVP1Freq_Value,DIVP2,DIVP2Freq_Value,DIVP3Freq_Value,DIVQ1,DIVQ1Freq_Value,DIVQ2Freq_Value,DIVQ3Freq_Value,DIVR1Freq_Value,DIVR2Freq_Value,DIVR3Freq_Value,FDCANFreq_Value,FMCFreq_Value,FamilyName,HCLK3ClockFreq_Value,HCLKFreq_Value,HPRE,HRTIMFreq_Value,HSE_VALUE,I2C123Freq_Value,I2C4Freq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPTIM345Freq_Value,LPUART1Freq_Value,LTDCFreq_Value,MCO1PinFreq_Value,MCO2PinFreq_Value,PLL2FRACN,PLL3FRACN,PLLFRACN,PLLSourceVirtual,PWR_Regulator_Voltage_Scale,QSPIFreq_Value,RNGFreq_Value,RTCFreq_Value,SAI1CLockSelection,SAI1Freq_Value,SAI23Freq_Value,SAI4AFreq_Value,SAI4BFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SPI123CLockSelection,SPI123Freq_Value,SPI45Freq_Value,SPI6Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,Tim1OutputFreq_Value,Tim2OutputFreq_Value,TraceFreq_Value,USART16Freq_Value,USART234578Freq_Value,USBCLockSelection,USBFreq_Value,VCO1OutputFreq_Value,VCO2OutputFreq_Value,VCO3OutputFreq_Value,VCOInput1Freq_Value,VCOInput2Freq_Value,VCOInput3Freq_Value ProjectManager.AskForMigrate=true PE0.Signal=FMC_NBL0 Dma.SAI1_B.1.SyncSignalID=NONE @@ -505,12 +505,13 @@ SH.GPXTI3.ConfNb=1 PE2.Mode=Single Bank 1 SH.FMC_D10_DA10.ConfNb=1 PB6.Mode=Asynchronous -RCC.DIVQ3Freq_Value=16125000 +RCC.DIVQ3Freq_Value=98285714.2857143 SH.FMC_D17.ConfNb=1 PE5.Signal=SAI1_SCK_A PF10.GPIO_Label=FLASH_CLK SH.ADCx_INP4.0=ADC1_INP4,IN4-Single-Ended Dma.SAI1_B.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD +RCC.DIVM3=7 RCC.DIVM2=1 RCC.DIVM1=1 SH.GPXTI7.0=GPIO_EXTI7 @@ -590,6 +591,7 @@ SH.FMC_D15_DA15.0=FMC_D15,sd-32b-d1 PC3_C.GPIOParameters=GPIO_Label USB_HOST.VirtualModeHS=Audio PA9.Signal=USB_OTG_FS_VBUS +RCC.DIVN3=172 SH.S_TIM2_CH2.ConfNb=1 RCC.DIVN2=18 I2C1.Timing=0x307075B1 @@ -651,7 +653,7 @@ PF6.Mode=Single Bank 1 RCC.LPTIM345Freq_Value=120000000 ProjectManager.ComputerToolchain=false PF9.Signal=QUADSPI_BK1_IO1 -RCC.LTDCFreq_Value=16125000 +RCC.LTDCFreq_Value=98285714.2857143 PB3\ (JTDO/TRACESWO).Mode=Trace_Asynchronous_SW PB8.Mode=I2C Mcu.Pin109=PB13 @@ -686,7 +688,7 @@ Mcu.Pin100=PA6 Dma.SAI1_A.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber RCC.DIVQ2Freq_Value=75000000 SH.S_TIM4_CH2.ConfNb=1 -RCC.SAI1Freq_Value=25000000 +RCC.SAI1Freq_Value=98285714.2857143 RCC.CortexFreq_Value=480000000 SH.FMC_A2.ConfNb=1 PG6.Signal=QUADSPI_BK1_NCS @@ -703,7 +705,7 @@ PB11.Signal=GPIO_Output PE5.GPIOParameters=GPIO_Speed ProjectManager.StackSize=0x400 PI11.GPIOParameters=GPIO_Label -RCC.VCOInput3Freq_Value=250000 +RCC.VCOInput3Freq_Value=1142857.142857143 PH3.Mode=SdramChipSelect1_1 SH.SharedStack_PC11.0=SDMMC1_D3 SH.SharedStack_PC11.1=SPI3_MISO,Full_Duplex_Master @@ -778,7 +780,7 @@ SH.FMC_NBL0.ConfNb=1 SH.COMP_DAC11_group.ConfNb=1 PE3.Mode=SAI_B_SyncSlave RCC.Tim2OutputFreq_Value=240000000 -RCC.DFSDMACLkFreq_Value=25000000 +RCC.DFSDMACLkFreq_Value=98285714.2857143 SH.FMC_A12.0=FMC_A12,13b-sda1 RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE SH.FMC_A9.ConfNb=1 From 4bcff70fb0abd7c4fec52a5bd816ce1a0355f6cb Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 16 Jun 2021 16:29:20 +0200 Subject: [PATCH 033/286] clock changes --- Xibeca/Core/Inc/stm32h7xx_it.h | 1 + Xibeca/Core/Src/main.c | 72 ++++++++++++++++++----------- Xibeca/Core/Src/stm32h7xx_hal_msp.c | 71 ++++++---------------------- Xibeca/Core/Src/stm32h7xx_it.c | 17 +++++++ 4 files changed, 75 insertions(+), 86 deletions(-) diff --git a/Xibeca/Core/Inc/stm32h7xx_it.h b/Xibeca/Core/Inc/stm32h7xx_it.h index 8fd73ca2..56211af7 100644 --- a/Xibeca/Core/Inc/stm32h7xx_it.h +++ b/Xibeca/Core/Inc/stm32h7xx_it.h @@ -51,6 +51,7 @@ void SysTick_Handler(void); void DMA1_Stream0_IRQHandler(void); void DMA1_Stream1_IRQHandler(void); void OTG_HS_IRQHandler(void); +void SAI1_IRQHandler(void); void OTG_FS_IRQHandler(void); /* USER CODE BEGIN EFP */ diff --git a/Xibeca/Core/Src/main.c b/Xibeca/Core/Src/main.c index a51bce8c..5cdd2e5a 100644 --- a/Xibeca/Core/Src/main.c +++ b/Xibeca/Core/Src/main.c @@ -241,7 +241,7 @@ void SystemClock_Config(void) HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY); /** Configure the main internal regulator output voltage */ - __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3); + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE0); while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {} /** Macro to configure the PLL clock source @@ -250,22 +250,19 @@ void SystemClock_Config(void) /** Initializes the RCC Oscillators according to the specified parameters * in the RCC_OscInitTypeDef structure. */ - RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48|RCC_OSCILLATORTYPE_HSI - |RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48|RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSEState = RCC_HSE_ON; - RCC_OscInitStruct.HSIState = RCC_HSI_DIV1; - RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; RCC_OscInitStruct.HSI48State = RCC_HSI48_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLM = 1; - RCC_OscInitStruct.PLL.PLLN = 18; + RCC_OscInitStruct.PLL.PLLN = 120; RCC_OscInitStruct.PLL.PLLP = 2; - RCC_OscInitStruct.PLL.PLLQ = 2; + RCC_OscInitStruct.PLL.PLLQ = 5; RCC_OscInitStruct.PLL.PLLR = 2; RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_3; - RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOMEDIUM; - RCC_OscInitStruct.PLL.PLLFRACN = 6144; + RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE; + RCC_OscInitStruct.PLL.PLLFRACN = 0; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { Error_Handler(); @@ -277,13 +274,13 @@ void SystemClock_Config(void) |RCC_CLOCKTYPE_D3PCLK1|RCC_CLOCKTYPE_D1PCLK1; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1; - RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV1; - RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV1; + RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2; + RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2; RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2; - RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV1; + RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2; RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2; - if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) { Error_Handler(); } @@ -299,8 +296,27 @@ void PeriphCommonClock_Config(void) /** Initializes the peripherals clock */ - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_CKPER; - PeriphClkInitStruct.CkperClockSelection = RCC_CLKPSOURCE_HSI; + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_ADC|RCC_PERIPHCLK_SAI1 + |RCC_PERIPHCLK_SPI3|RCC_PERIPHCLK_SPI2; + PeriphClkInitStruct.PLL2.PLL2M = 1; + PeriphClkInitStruct.PLL2.PLL2N = 18; + PeriphClkInitStruct.PLL2.PLL2P = 6; + PeriphClkInitStruct.PLL2.PLL2Q = 2; + PeriphClkInitStruct.PLL2.PLL2R = 2; + PeriphClkInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_3; + PeriphClkInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOMEDIUM; + PeriphClkInitStruct.PLL2.PLL2FRACN = 6144; + PeriphClkInitStruct.PLL3.PLL3M = 7; + PeriphClkInitStruct.PLL3.PLL3N = 172; + PeriphClkInitStruct.PLL3.PLL3P = 2; + PeriphClkInitStruct.PLL3.PLL3Q = 2; + PeriphClkInitStruct.PLL3.PLL3R = 2; + PeriphClkInitStruct.PLL3.PLL3RGE = RCC_PLL3VCIRANGE_0; + PeriphClkInitStruct.PLL3.PLL3VCOSEL = RCC_PLL3VCOWIDE; + PeriphClkInitStruct.PLL3.PLL3FRACN = 0; + PeriphClkInitStruct.Sai1ClockSelection = RCC_SAI1CLKSOURCE_PLL3; + PeriphClkInitStruct.Spi123ClockSelection = RCC_SPI123CLKSOURCE_PLL2; + PeriphClkInitStruct.AdcClockSelection = RCC_ADCCLKSOURCE_PLL2; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) { Error_Handler(); @@ -435,7 +451,7 @@ static void MX_I2C1_Init(void) /* USER CODE END I2C1_Init 1 */ hi2c1.Instance = I2C1; - hi2c1.Init.Timing = 0x00909FCE; + hi2c1.Init.Timing = 0x307075B1; hi2c1.Init.OwnAddress1 = 0; hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; @@ -556,9 +572,9 @@ static void MX_SAI1_Init(void) hsai_BlockA1.Init.AudioMode = SAI_MODEMASTER_RX; hsai_BlockA1.Init.DataSize = SAI_DATASIZE_24; hsai_BlockA1.Init.FirstBit = SAI_FIRSTBIT_MSB; - hsai_BlockA1.Init.ClockStrobing = SAI_CLOCKSTROBING_FALLINGEDGE; + hsai_BlockA1.Init.ClockStrobing = SAI_CLOCKSTROBING_RISINGEDGE; hsai_BlockA1.Init.Synchro = SAI_ASYNCHRONOUS; - hsai_BlockA1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; + hsai_BlockA1.Init.OutputDrive = SAI_OUTPUTDRIVE_ENABLE; hsai_BlockA1.Init.NoDivider = SAI_MASTERDIVIDER_ENABLE; hsai_BlockA1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; hsai_BlockA1.Init.AudioFrequency = SAI_AUDIO_FREQUENCY_48K; @@ -571,12 +587,12 @@ static void MX_SAI1_Init(void) hsai_BlockA1.FrameInit.FrameLength = 256; hsai_BlockA1.FrameInit.ActiveFrameLength = 1; hsai_BlockA1.FrameInit.FSDefinition = SAI_FS_STARTFRAME; - hsai_BlockA1.FrameInit.FSPolarity = SAI_FS_ACTIVE_LOW; - hsai_BlockA1.FrameInit.FSOffset = SAI_FS_FIRSTBIT; + hsai_BlockA1.FrameInit.FSPolarity = SAI_FS_ACTIVE_HIGH; + hsai_BlockA1.FrameInit.FSOffset = SAI_FS_BEFOREFIRSTBIT; hsai_BlockA1.SlotInit.FirstBitOffset = 0; hsai_BlockA1.SlotInit.SlotSize = SAI_SLOTSIZE_32B; hsai_BlockA1.SlotInit.SlotNumber = 8; - hsai_BlockA1.SlotInit.SlotActive = 0x00000000; + hsai_BlockA1.SlotInit.SlotActive = 0x0000FFFF; if (HAL_SAI_Init(&hsai_BlockA1) != HAL_OK) { Error_Handler(); @@ -588,7 +604,7 @@ static void MX_SAI1_Init(void) hsai_BlockB1.Init.FirstBit = SAI_FIRSTBIT_MSB; hsai_BlockB1.Init.ClockStrobing = SAI_CLOCKSTROBING_FALLINGEDGE; hsai_BlockB1.Init.Synchro = SAI_SYNCHRONOUS; - hsai_BlockB1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; + hsai_BlockB1.Init.OutputDrive = SAI_OUTPUTDRIVE_ENABLE; hsai_BlockB1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; hsai_BlockB1.Init.SynchroExt = SAI_SYNCEXT_DISABLE; hsai_BlockB1.Init.MonoStereoMode = SAI_STEREOMODE; @@ -600,12 +616,12 @@ static void MX_SAI1_Init(void) hsai_BlockB1.FrameInit.FrameLength = 256; hsai_BlockB1.FrameInit.ActiveFrameLength = 1; hsai_BlockB1.FrameInit.FSDefinition = SAI_FS_STARTFRAME; - hsai_BlockB1.FrameInit.FSPolarity = SAI_FS_ACTIVE_LOW; - hsai_BlockB1.FrameInit.FSOffset = SAI_FS_FIRSTBIT; + hsai_BlockB1.FrameInit.FSPolarity = SAI_FS_ACTIVE_HIGH; + hsai_BlockB1.FrameInit.FSOffset = SAI_FS_BEFOREFIRSTBIT; hsai_BlockB1.SlotInit.FirstBitOffset = 0; hsai_BlockB1.SlotInit.SlotSize = SAI_SLOTSIZE_32B; hsai_BlockB1.SlotInit.SlotNumber = 8; - hsai_BlockB1.SlotInit.SlotActive = 0x00000000; + hsai_BlockB1.SlotInit.SlotActive = 0x0000FFFF; if (HAL_SAI_Init(&hsai_BlockB1) != HAL_OK) { Error_Handler(); @@ -636,10 +652,10 @@ static void MX_SPI2_Init(void) hspi2.Init.Mode = SPI_MODE_MASTER; hspi2.Init.Direction = SPI_DIRECTION_2LINES; hspi2.Init.DataSize = SPI_DATASIZE_8BIT; - hspi2.Init.CLKPolarity = SPI_POLARITY_LOW; - hspi2.Init.CLKPhase = SPI_PHASE_1EDGE; + hspi2.Init.CLKPolarity = SPI_POLARITY_HIGH; + hspi2.Init.CLKPhase = SPI_PHASE_2EDGE; hspi2.Init.NSS = SPI_NSS_SOFT; - hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64; + hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_256; hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB; hspi2.Init.TIMode = SPI_TIMODE_DISABLE; hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; diff --git a/Xibeca/Core/Src/stm32h7xx_hal_msp.c b/Xibeca/Core/Src/stm32h7xx_hal_msp.c index cff62946..fc11bcba 100644 --- a/Xibeca/Core/Src/stm32h7xx_hal_msp.c +++ b/Xibeca/Core/Src/stm32h7xx_hal_msp.c @@ -87,29 +87,11 @@ void HAL_MspInit(void) void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) { GPIO_InitTypeDef GPIO_InitStruct = {0}; - RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; if(hadc->Instance==ADC1) { /* USER CODE BEGIN ADC1_MspInit 0 */ /* USER CODE END ADC1_MspInit 0 */ - /** Initializes the peripherals clock - */ - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_ADC; - PeriphClkInitStruct.PLL2.PLL2M = 1; - PeriphClkInitStruct.PLL2.PLL2N = 18; - PeriphClkInitStruct.PLL2.PLL2P = 4; - PeriphClkInitStruct.PLL2.PLL2Q = 2; - PeriphClkInitStruct.PLL2.PLL2R = 2; - PeriphClkInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_3; - PeriphClkInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOMEDIUM; - PeriphClkInitStruct.PLL2.PLL2FRACN = 6144.0; - PeriphClkInitStruct.AdcClockSelection = RCC_ADCCLKSOURCE_PLL2; - if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) - { - Error_Handler(); - } - /* Peripheral clock enable */ __HAL_RCC_ADC12_CLK_ENABLE(); @@ -526,14 +508,6 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) /* USER CODE BEGIN SPI2_MspInit 0 */ /* USER CODE END SPI2_MspInit 0 */ - /** Initializes the peripherals clock - */ - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SPI2; - PeriphClkInitStruct.Spi123ClockSelection = RCC_SPI123CLKSOURCE_PLL; - if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) - { - Error_Handler(); - } /* Peripheral clock enable */ __HAL_RCC_SPI2_CLK_ENABLE(); @@ -569,15 +543,6 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) /* USER CODE END SPI3_MspInit 0 */ - /** Initializes the peripherals clock - */ - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SPI3; - PeriphClkInitStruct.Spi123ClockSelection = RCC_SPI123CLKSOURCE_PLL; - if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) - { - Error_Handler(); - } - /* Peripheral clock enable */ __HAL_RCC_SPI3_CLK_ENABLE(); @@ -603,7 +568,6 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) /* USER CODE BEGIN SPI6_MspInit 0 */ /* USER CODE END SPI6_MspInit 0 */ - /** Initializes the peripherals clock */ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SPI6; @@ -1272,23 +1236,17 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) { GPIO_InitTypeDef GPIO_InitStruct; - RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; /* SAI1 */ if(hsai->Instance==SAI1_Block_A) { /* Peripheral clock enable */ - /** Initializes the peripherals clock - */ - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SAI1; - PeriphClkInitStruct.Sai1ClockSelection = RCC_SAI1CLKSOURCE_CLKP; - if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) - { - Error_Handler(); - } - if (SAI1_client == 0) { __HAL_RCC_SAI1_CLK_ENABLE(); + + /* Peripheral interrupt init*/ + HAL_NVIC_SetPriority(SAI1_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(SAI1_IRQn); } SAI1_client ++; @@ -1301,14 +1259,14 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_7; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); @@ -1339,18 +1297,13 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) if(hsai->Instance==SAI1_Block_B) { /* Peripheral clock enable */ - /** Initializes the peripherals clock - */ - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SAI1; - PeriphClkInitStruct.Sai1ClockSelection = RCC_SAI1CLKSOURCE_CLKP; - if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) - { - Error_Handler(); - } - if (SAI1_client == 0) { __HAL_RCC_SAI1_CLK_ENABLE(); + + /* Peripheral interrupt init*/ + HAL_NVIC_SetPriority(SAI1_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(SAI1_IRQn); } SAI1_client ++; @@ -1360,7 +1313,7 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) GPIO_InitStruct.Pin = GPIO_PIN_3; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); @@ -1398,6 +1351,7 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) { /* Peripheral clock disable */ __HAL_RCC_SAI1_CLK_DISABLE(); + HAL_NVIC_DisableIRQ(SAI1_IRQn); } /**SAI1_A_Block_A GPIO Configuration @@ -1420,6 +1374,7 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) { /* Peripheral clock disable */ __HAL_RCC_SAI1_CLK_DISABLE(); + HAL_NVIC_DisableIRQ(SAI1_IRQn); } /**SAI1_B_Block_B GPIO Configuration diff --git a/Xibeca/Core/Src/stm32h7xx_it.c b/Xibeca/Core/Src/stm32h7xx_it.c index f4c77e77..6d496dbf 100644 --- a/Xibeca/Core/Src/stm32h7xx_it.c +++ b/Xibeca/Core/Src/stm32h7xx_it.c @@ -62,6 +62,8 @@ extern PCD_HandleTypeDef hpcd_USB_OTG_FS; extern HCD_HandleTypeDef hhcd_USB_OTG_HS; extern DMA_HandleTypeDef hdma_sai1_a; extern DMA_HandleTypeDef hdma_sai1_b; +extern SAI_HandleTypeDef hsai_BlockA1; +extern SAI_HandleTypeDef hsai_BlockB1; /* USER CODE BEGIN EV */ /* USER CODE END EV */ @@ -140,6 +142,21 @@ void OTG_HS_IRQHandler(void) /* USER CODE END OTG_HS_IRQn 1 */ } +/** + * @brief This function handles SAI1 global interrupt. + */ +void SAI1_IRQHandler(void) +{ + /* USER CODE BEGIN SAI1_IRQn 0 */ + + /* USER CODE END SAI1_IRQn 0 */ + HAL_SAI_IRQHandler(&hsai_BlockA1); + HAL_SAI_IRQHandler(&hsai_BlockB1); + /* USER CODE BEGIN SAI1_IRQn 1 */ + + /* USER CODE END SAI1_IRQn 1 */ +} + /** * @brief This function handles USB On The Go FS global interrupt. */ From 6d6ff17d733975ef8a7332b05e9b2244dd6adbca Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 16 Jun 2021 17:17:18 +0200 Subject: [PATCH 034/286] config changes --- Xibeca/Core/Inc/hardware.h | 22 +++++++++++++--------- Xibeca/Core/Src/main.c | 2 ++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Xibeca/Core/Inc/hardware.h b/Xibeca/Core/Inc/hardware.h index 83a6e42b..40c27a85 100644 --- a/Xibeca/Core/Inc/hardware.h +++ b/Xibeca/Core/Inc/hardware.h @@ -1,14 +1,20 @@ #include "main.h" #include "stm32h7xx_hal.h" -#define OWL_NOCTUA +#define OWL_XIBECA #define HARDWARE_ID XIBECA_HARDWARE #define HARDWARE_VERSION "Xibeca" -/* #define NO_EXTERNAL_RAM */ +#define NO_EXTERNAL_RAM +#define DMA_RAM __attribute__ ((section (".dmadata"))) +#define USE_PLUS_RAM +/* #define USE_ICACHE */ +/* #define USE_DCACHE */ -/* #define USE_BKPSRAM enable to prevent reset loops */ +/* #define USE_SCREEN */ +/* #define SSD1309 */ +/* #define OLED_SOFT_CS */ +/* #define OLED_SPI hspi6 */ -/* #define USE_RGB_LED */ /* #define USE_ADC */ #define ADC_PERIPH hadc1 #define ADC_A 0 @@ -19,9 +25,11 @@ #define ADC_F 5 #define ADC_G 6 #define ADC_H 7 + #define USE_CODEC -/* #define USE_IIS3DWB */ #define USE_PCM3168A +/* #define CODEC_HP_FILTER */ +#define CODEC_SPI hspi2 /* USB audio settings */ #define AUDIO_BITS_PER_SAMPLE 16 @@ -53,10 +61,6 @@ #define AUDIO_SAMPLINGRATE 48000 #define TIM8_PERIOD (871*48000/AUDIO_SAMPLINGRATE) /* experimentally determined */ -/* #define USE_PCM3168A */ -/* #define CODEC_HP_FILTER */ -#define CODEC_SPI hspi2 - #define USB_HOST_PWR_EN_GPIO_Port GPIOB #define USB_HOST_PWR_EN_Pin GPIO_PIN_0 // PB0 is unused #define USB_HOST_PWR_FAULT_GPIO_Port GPIOB diff --git a/Xibeca/Core/Src/main.c b/Xibeca/Core/Src/main.c index 5cdd2e5a..fff619ec 100644 --- a/Xibeca/Core/Src/main.c +++ b/Xibeca/Core/Src/main.c @@ -183,7 +183,9 @@ int main(void) MX_LPTIM1_Init(); /* USER CODE BEGIN 2 */ +#ifdef USE_EXTERNAL_RAM SDRAM_Initialization_Sequence(&hsdram1); +#endif /* USER CODE END 2 */ From bfacd8c6545dd1202ba87b593d6d8eda1a9a0980 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 16 Jun 2021 17:55:00 +0200 Subject: [PATCH 035/286] freertos updates --- Xibeca/Core/Inc/FreeRTOSConfig.h | 6 +++--- Xibeca/Core/Inc/hardware.h | 2 +- Xibeca/Core/Src/freertos.c | 32 +++++++------------------------- Xibeca/Core/Src/main.c | 2 +- Xibeca/Xibeca.ioc | 8 +++++--- 5 files changed, 17 insertions(+), 33 deletions(-) diff --git a/Xibeca/Core/Inc/FreeRTOSConfig.h b/Xibeca/Core/Inc/FreeRTOSConfig.h index ff70ac0e..36d0599c 100644 --- a/Xibeca/Core/Inc/FreeRTOSConfig.h +++ b/Xibeca/Core/Inc/FreeRTOSConfig.h @@ -63,8 +63,8 @@ #define configUSE_PREEMPTION 0 #define configSUPPORT_STATIC_ALLOCATION 1 #define configSUPPORT_DYNAMIC_ALLOCATION 1 -#define configUSE_IDLE_HOOK 1 -#define configUSE_TICK_HOOK 1 +#define configUSE_IDLE_HOOK 0 +#define configUSE_TICK_HOOK 0 #define configCPU_CLOCK_HZ ( SystemCoreClock ) #define configTICK_RATE_HZ ((TickType_t)1000) #define configMAX_PRIORITIES ( 7 ) @@ -72,8 +72,8 @@ #define configTOTAL_HEAP_SIZE ((size_t)15360) #define configMAX_TASK_NAME_LEN ( 16 ) #define configUSE_16_BIT_TICKS 0 -#define configUSE_MUTEXES 1 #define configQUEUE_REGISTRY_SIZE 8 +#define configCHECK_FOR_STACK_OVERFLOW 2 #define configUSE_MALLOC_FAILED_HOOK 1 #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 /* USER CODE BEGIN MESSAGE_BUFFER_LENGTH_TYPE */ diff --git a/Xibeca/Core/Inc/hardware.h b/Xibeca/Core/Inc/hardware.h index 40c27a85..6515df35 100644 --- a/Xibeca/Core/Inc/hardware.h +++ b/Xibeca/Core/Inc/hardware.h @@ -4,7 +4,7 @@ #define OWL_XIBECA #define HARDWARE_ID XIBECA_HARDWARE #define HARDWARE_VERSION "Xibeca" -#define NO_EXTERNAL_RAM +/* #define NO_EXTERNAL_RAM */ #define DMA_RAM __attribute__ ((section (".dmadata"))) #define USE_PLUS_RAM /* #define USE_ICACHE */ diff --git a/Xibeca/Core/Src/freertos.c b/Xibeca/Core/Src/freertos.c index 5fab4756..4a5debed 100644 --- a/Xibeca/Core/Src/freertos.c +++ b/Xibeca/Core/Src/freertos.c @@ -57,35 +57,17 @@ void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ); /* Hook prototypes */ -void vApplicationIdleHook(void); -void vApplicationTickHook(void); +void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName); void vApplicationMallocFailedHook(void); -/* USER CODE BEGIN 2 */ -__weak void vApplicationIdleHook( void ) +/* USER CODE BEGIN 4 */ +__weak void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName) { - /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set - to 1 in FreeRTOSConfig.h. It will be called on each iteration of the idle - task. It is essential that code added to this hook function never attempts - to block in any way (for example, call xQueueReceive() with a block time - specified, or call vTaskDelay()). If the application makes use of the - vTaskDelete() API function (as this demo application does) then it is also - important that vApplicationIdleHook() is permitted to return to its calling - function, because it is the responsibility of the idle task to clean up - memory allocated by the kernel to any task that has since been deleted. */ + /* Run time stack overflow checking is performed if + configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is + called if a stack overflow is detected. */ } -/* USER CODE END 2 */ - -/* USER CODE BEGIN 3 */ -__weak void vApplicationTickHook( void ) -{ - /* This function will be called by each tick interrupt if - configUSE_TICK_HOOK is set to 1 in FreeRTOSConfig.h. User code can be - added here, but the tick hook is called from an interrupt context, so - code must not attempt to block, and only the interrupt safe FreeRTOS API - functions can be used (those that end in FromISR()). */ -} -/* USER CODE END 3 */ +/* USER CODE END 4 */ /* USER CODE BEGIN 5 */ __weak void vApplicationMallocFailedHook(void) diff --git a/Xibeca/Core/Src/main.c b/Xibeca/Core/Src/main.c index fff619ec..2a1490ed 100644 --- a/Xibeca/Core/Src/main.c +++ b/Xibeca/Core/Src/main.c @@ -207,7 +207,7 @@ int main(void) /* Create the thread(s) */ /* definition and creation of defaultTask */ - osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128); + osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 1024); defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL); /* USER CODE BEGIN RTOS_THREADS */ diff --git a/Xibeca/Xibeca.ioc b/Xibeca/Xibeca.ioc index 731e88ca..344bfda4 100644 --- a/Xibeca/Xibeca.ioc +++ b/Xibeca/Xibeca.ioc @@ -194,6 +194,7 @@ Mcu.Pin31=PI3 Mcu.Pin32=PI2 Dma.SAI1_A.0.SyncRequestNumber=1 NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false +FREERTOS.configUSE_MUTEXES=0 PF13.Signal=FMC_A7 SH.SharedStack_PC8.0=SDMMC1_D0 SH.SharedStack_PC8.1=GPIO_EXTI8 @@ -285,7 +286,7 @@ RCC.SDMMCFreq_Value=192000000 ProjectManager.PreviousToolchain= SH.COMP_DAC12_group.ConfNb=1 SH.FMC_NBL1.0=FMC_NBL1,Sd4ByteEnable1 -FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configUSE_IDLE_HOOK,configUSE_TICK_HOOK,configUSE_MALLOC_FAILED_HOOK,INCLUDE_vTaskDelayUntil +FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configUSE_IDLE_HOOK,configUSE_TICK_HOOK,configUSE_MALLOC_FAILED_HOOK,INCLUDE_vTaskDelayUntil,configUSE_MUTEXES,configCHECK_FOR_STACK_OVERFLOW Dma.SAI1_B.1.Instance=DMA1_Stream1 Dma.SAI1_B.1.FIFOMode=DMA_FIFOMODE_DISABLE FREERTOS.configUSE_PREEMPTION=0 @@ -345,7 +346,7 @@ Mcu.Pin97=PD12 Mcu.Pin98=PD10 Dma.Request1=SAI1_B Dma.SAI1_B.1.PeriphInc=DMA_PINC_DISABLE -FREERTOS.configUSE_TICK_HOOK=1 +FREERTOS.configUSE_TICK_HOOK=0 Mcu.Pin91=PA0 Mcu.Pin92=PA4 NVIC.DMA1_Stream0_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true @@ -392,7 +393,7 @@ USB_DEVICE.IPParameters=VirtualMode-AUDIO_FS,VirtualModeFS,CLASS_NAME_FS,VID-AUD PinOutPanel.CurrentBGAView=Top RCC.FamilyName=M PH1-OSC_OUT\ (PH1).Signal=RCC_OSC_OUT -FREERTOS.configUSE_IDLE_HOOK=1 +FREERTOS.configUSE_IDLE_HOOK=0 VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 SAI1.RealAudioFreq-SAI_A_MasterWithClock=47.991 KHz PA9.Mode=Activate_VBUS @@ -571,6 +572,7 @@ SH.FMC_D28.0=FMC_D28,sd-32b-d1 DAC1.DAC_Channel-DAC_OUT1=DAC_CHANNEL_1 ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,master RCC.SWPMI1Freq_Value=120000000 +FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 PC6.Signal=S_TIM3_CH1 PB11.GPIO_Label=ADC_SPI_NCS PD1.Signal=FMC_D3_DA3 From 5713cb176f5ff9ea38d576a183d5d4da95fd22fc Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 17 Jun 2021 19:20:45 +0200 Subject: [PATCH 036/286] enabled screen (not working) --- Xibeca/Core/Inc/hardware.h | 10 +- Xibeca/Core/Inc/main.h | 11 +- Xibeca/Core/Inc/stm32h7xx_hal_conf.h | 2 +- Xibeca/Core/Inc/stm32h7xx_it.h | 2 + Xibeca/Core/Src/main.c | 213 ++++----------- Xibeca/Core/Src/stm32h7xx_hal_msp.c | 233 ++-------------- Xibeca/Core/Src/stm32h7xx_it.c | 30 +++ Xibeca/Makefile | 8 +- Xibeca/Xibeca.ioc | 390 +++++++++++++-------------- 9 files changed, 317 insertions(+), 582 deletions(-) diff --git a/Xibeca/Core/Inc/hardware.h b/Xibeca/Core/Inc/hardware.h index 6515df35..d0f84718 100644 --- a/Xibeca/Core/Inc/hardware.h +++ b/Xibeca/Core/Inc/hardware.h @@ -4,16 +4,16 @@ #define OWL_XIBECA #define HARDWARE_ID XIBECA_HARDWARE #define HARDWARE_VERSION "Xibeca" -/* #define NO_EXTERNAL_RAM */ +#define NO_EXTERNAL_RAM #define DMA_RAM __attribute__ ((section (".dmadata"))) #define USE_PLUS_RAM /* #define USE_ICACHE */ /* #define USE_DCACHE */ -/* #define USE_SCREEN */ -/* #define SSD1309 */ -/* #define OLED_SOFT_CS */ -/* #define OLED_SPI hspi6 */ +#define USE_SCREEN +#define SSD1309 +#define OLED_SOFT_CS +#define OLED_SPI hspi3 /* #define USE_ADC */ #define ADC_PERIPH hadc1 diff --git a/Xibeca/Core/Inc/main.h b/Xibeca/Core/Inc/main.h index 04b13c5f..7508cd60 100644 --- a/Xibeca/Core/Inc/main.h +++ b/Xibeca/Core/Inc/main.h @@ -60,6 +60,8 @@ void Error_Handler(void); /* Private defines -----------------------------------------------------------*/ #define FLASH_DQ2_Pin GPIO_PIN_2 #define FLASH_DQ2_GPIO_Port GPIOE +#define OLED_CS_Pin GPIO_PIN_14 +#define OLED_CS_GPIO_Port GPIOG #define EXTI10_Pin GPIO_PIN_10 #define EXTI10_GPIO_Port GPIOG #define EXTI13_Pin GPIO_PIN_13 @@ -90,10 +92,8 @@ void Error_Handler(void); #define ADC_SPI_MOSI_GPIO_Port GPIOC #define EXTI0_Pin GPIO_PIN_0 #define EXTI0_GPIO_Port GPIOA -#define DAC1_Pin GPIO_PIN_4 -#define DAC1_GPIO_Port GPIOA -#define DAC2_Pin GPIO_PIN_5 -#define DAC2_GPIO_Port GPIOA +#define OLED_RST_Pin GPIO_PIN_4 +#define OLED_RST_GPIO_Port GPIOA #define EXTI3_Pin GPIO_PIN_3 #define EXTI3_GPIO_Port GPIOA #define EXTI7_Pin GPIO_PIN_7 @@ -104,6 +104,9 @@ void Error_Handler(void); #define ADC_SPI_NCS_GPIO_Port GPIOB /* USER CODE BEGIN Private defines */ +#define OLED_DC_Pin GPIO_PIN_11 +#define OLED_DC_GPIO_Port GPIOC + #define ADC_NCS_Pin ADC_SPI_NCS_Pin #define ADC_NCS_GPIO_Port ADC_SPI_NCS_GPIO_Port diff --git a/Xibeca/Core/Inc/stm32h7xx_hal_conf.h b/Xibeca/Core/Inc/stm32h7xx_hal_conf.h index e70868d7..1a5f3485 100644 --- a/Xibeca/Core/Inc/stm32h7xx_hal_conf.h +++ b/Xibeca/Core/Inc/stm32h7xx_hal_conf.h @@ -42,7 +42,7 @@ /* #define HAL_CORDIC_MODULE_ENABLED */ /* #define HAL_CRC_MODULE_ENABLED */ /* #define HAL_CRYP_MODULE_ENABLED */ -#define HAL_DAC_MODULE_ENABLED +/* #define HAL_DAC_MODULE_ENABLED */ /* #define HAL_DCMI_MODULE_ENABLED */ /* #define HAL_DMA2D_MODULE_ENABLED */ /* #define HAL_ETH_MODULE_ENABLED */ diff --git a/Xibeca/Core/Inc/stm32h7xx_it.h b/Xibeca/Core/Inc/stm32h7xx_it.h index 56211af7..6f031eb9 100644 --- a/Xibeca/Core/Inc/stm32h7xx_it.h +++ b/Xibeca/Core/Inc/stm32h7xx_it.h @@ -50,6 +50,8 @@ void SysTick_Handler(void); void DMA1_Stream0_IRQHandler(void); void DMA1_Stream1_IRQHandler(void); +void DMA1_Stream2_IRQHandler(void); +void SPI3_IRQHandler(void); void OTG_HS_IRQHandler(void); void SAI1_IRQHandler(void); void OTG_FS_IRQHandler(void); diff --git a/Xibeca/Core/Src/main.c b/Xibeca/Core/Src/main.c index 2a1490ed..3c96f786 100644 --- a/Xibeca/Core/Src/main.c +++ b/Xibeca/Core/Src/main.c @@ -46,10 +46,6 @@ /* Private variables ---------------------------------------------------------*/ ADC_HandleTypeDef hadc1; -DAC_HandleTypeDef hdac1; - -I2C_HandleTypeDef hi2c1; - LPTIM_HandleTypeDef hlptim1; QSPI_HandleTypeDef hqspi; @@ -61,7 +57,7 @@ DMA_HandleTypeDef hdma_sai1_b; SPI_HandleTypeDef hspi2; SPI_HandleTypeDef hspi3; -SPI_HandleTypeDef hspi6; +DMA_HandleTypeDef hdma_spi3_tx; TIM_HandleTypeDef htim2; TIM_HandleTypeDef htim3; @@ -83,14 +79,11 @@ void PeriphCommonClock_Config(void); static void MX_GPIO_Init(void); static void MX_DMA_Init(void); static void MX_QUADSPI_Init(void); -static void MX_DAC1_Init(void); static void MX_FMC_Init(void); static void MX_SAI1_Init(void); static void MX_ADC1_Init(void); -static void MX_I2C1_Init(void); static void MX_SPI2_Init(void); static void MX_SPI3_Init(void); -static void MX_SPI6_Init(void); static void MX_TIM2_Init(void); static void MX_TIM3_Init(void); static void MX_TIM4_Init(void); @@ -167,14 +160,11 @@ int main(void) MX_GPIO_Init(); MX_DMA_Init(); MX_QUADSPI_Init(); - MX_DAC1_Init(); MX_FMC_Init(); MX_SAI1_Init(); MX_ADC1_Init(); - MX_I2C1_Init(); MX_SPI2_Init(); MX_SPI3_Init(); - MX_SPI6_Init(); MX_TIM2_Init(); MX_TIM3_Init(); MX_TIM4_Init(); @@ -390,99 +380,6 @@ static void MX_ADC1_Init(void) } -/** - * @brief DAC1 Initialization Function - * @param None - * @retval None - */ -static void MX_DAC1_Init(void) -{ - - /* USER CODE BEGIN DAC1_Init 0 */ - - /* USER CODE END DAC1_Init 0 */ - - DAC_ChannelConfTypeDef sConfig = {0}; - - /* USER CODE BEGIN DAC1_Init 1 */ - - /* USER CODE END DAC1_Init 1 */ - /** DAC Initialization - */ - hdac1.Instance = DAC1; - if (HAL_DAC_Init(&hdac1) != HAL_OK) - { - Error_Handler(); - } - /** DAC channel OUT1 config - */ - sConfig.DAC_SampleAndHold = DAC_SAMPLEANDHOLD_DISABLE; - sConfig.DAC_Trigger = DAC_TRIGGER_NONE; - sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE; - sConfig.DAC_ConnectOnChipPeripheral = DAC_CHIPCONNECT_DISABLE; - sConfig.DAC_UserTrimming = DAC_TRIMMING_FACTORY; - if (HAL_DAC_ConfigChannel(&hdac1, &sConfig, DAC_CHANNEL_1) != HAL_OK) - { - Error_Handler(); - } - /** DAC channel OUT2 config - */ - if (HAL_DAC_ConfigChannel(&hdac1, &sConfig, DAC_CHANNEL_2) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN DAC1_Init 2 */ - - /* USER CODE END DAC1_Init 2 */ - -} - -/** - * @brief I2C1 Initialization Function - * @param None - * @retval None - */ -static void MX_I2C1_Init(void) -{ - - /* USER CODE BEGIN I2C1_Init 0 */ - - /* USER CODE END I2C1_Init 0 */ - - /* USER CODE BEGIN I2C1_Init 1 */ - - /* USER CODE END I2C1_Init 1 */ - hi2c1.Instance = I2C1; - hi2c1.Init.Timing = 0x307075B1; - hi2c1.Init.OwnAddress1 = 0; - hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; - hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; - hi2c1.Init.OwnAddress2 = 0; - hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK; - hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; - hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; - if (HAL_I2C_Init(&hi2c1) != HAL_OK) - { - Error_Handler(); - } - /** Configure Analogue filter - */ - if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK) - { - Error_Handler(); - } - /** Configure Digital filter - */ - if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN I2C1_Init 2 */ - - /* USER CODE END I2C1_Init 2 */ - -} - /** * @brief LPTIM1 Initialization Function * @param None @@ -700,17 +597,17 @@ static void MX_SPI3_Init(void) /* SPI3 parameter configuration*/ hspi3.Instance = SPI3; hspi3.Init.Mode = SPI_MODE_MASTER; - hspi3.Init.Direction = SPI_DIRECTION_2LINES; + hspi3.Init.Direction = SPI_DIRECTION_2LINES_TXONLY; hspi3.Init.DataSize = SPI_DATASIZE_8BIT; hspi3.Init.CLKPolarity = SPI_POLARITY_LOW; hspi3.Init.CLKPhase = SPI_PHASE_1EDGE; hspi3.Init.NSS = SPI_NSS_SOFT; - hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64; + hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8; hspi3.Init.FirstBit = SPI_FIRSTBIT_MSB; hspi3.Init.TIMode = SPI_TIMODE_DISABLE; hspi3.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; hspi3.Init.CRCPolynomial = 0x0; - hspi3.Init.NSSPMode = SPI_NSS_PULSE_ENABLE; + hspi3.Init.NSSPMode = SPI_NSS_PULSE_DISABLE; hspi3.Init.NSSPolarity = SPI_NSS_POLARITY_LOW; hspi3.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA; hspi3.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; @@ -730,54 +627,6 @@ static void MX_SPI3_Init(void) } -/** - * @brief SPI6 Initialization Function - * @param None - * @retval None - */ -static void MX_SPI6_Init(void) -{ - - /* USER CODE BEGIN SPI6_Init 0 */ - - /* USER CODE END SPI6_Init 0 */ - - /* USER CODE BEGIN SPI6_Init 1 */ - - /* USER CODE END SPI6_Init 1 */ - /* SPI6 parameter configuration*/ - hspi6.Instance = SPI6; - hspi6.Init.Mode = SPI_MODE_MASTER; - hspi6.Init.Direction = SPI_DIRECTION_2LINES; - hspi6.Init.DataSize = SPI_DATASIZE_4BIT; - hspi6.Init.CLKPolarity = SPI_POLARITY_LOW; - hspi6.Init.CLKPhase = SPI_PHASE_1EDGE; - hspi6.Init.NSS = SPI_NSS_SOFT; - hspi6.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2; - hspi6.Init.FirstBit = SPI_FIRSTBIT_MSB; - hspi6.Init.TIMode = SPI_TIMODE_DISABLE; - hspi6.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; - hspi6.Init.CRCPolynomial = 0x0; - hspi6.Init.NSSPMode = SPI_NSS_PULSE_ENABLE; - hspi6.Init.NSSPolarity = SPI_NSS_POLARITY_LOW; - hspi6.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA; - hspi6.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; - hspi6.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; - hspi6.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE; - hspi6.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE; - hspi6.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE; - hspi6.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE; - hspi6.Init.IOSwap = SPI_IO_SWAP_DISABLE; - if (HAL_SPI_Init(&hspi6) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN SPI6_Init 2 */ - - /* USER CODE END SPI6_Init 2 */ - -} - /** * @brief TIM2 Initialization Function * @param None @@ -1037,6 +886,9 @@ static void MX_DMA_Init(void) /* DMA1_Stream1_IRQn interrupt configuration */ HAL_NVIC_SetPriority(DMA1_Stream1_IRQn, 5, 0); HAL_NVIC_EnableIRQ(DMA1_Stream1_IRQn); + /* DMA1_Stream2_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA1_Stream2_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA1_Stream2_IRQn); } @@ -1108,11 +960,35 @@ static void MX_GPIO_Init(void) __HAL_RCC_GPIOF_CLK_ENABLE(); /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(ADC_RST_GPIO_Port, ADC_RST_Pin, GPIO_PIN_RESET); + HAL_GPIO_WritePin(GPIOG, OLED_CS_Pin|ADC_RST_Pin, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(OLED_RST_GPIO_Port, OLED_RST_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(ADC_SPI_NCS_GPIO_Port, ADC_SPI_NCS_Pin, GPIO_PIN_RESET); + /*Configure GPIO pins : PB8 PB4 PB9 PB2 + PB12 */ + GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_4|GPIO_PIN_9|GPIO_PIN_2 + |GPIO_PIN_12; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /*Configure GPIO pin : OLED_CS_Pin */ + GPIO_InitStruct.Pin = OLED_CS_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; + HAL_GPIO_Init(OLED_CS_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pins : PG13 PG9 */ + GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + /*Configure GPIO pins : PD7 PD6 PD5 PD4 PD3 PD11 */ GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_6|GPIO_PIN_5|GPIO_PIN_4 @@ -1121,10 +997,12 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); - /*Configure GPIO pins : PB9 PB2 PB12 */ - GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_2|GPIO_PIN_12; - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + /*Configure GPIO pin : PB7 */ + GPIO_InitStruct.Pin = GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF4_I2C1; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /*Configure GPIO pin : EXTI10_Pin */ @@ -1133,12 +1011,6 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(EXTI10_GPIO_Port, &GPIO_InitStruct); - /*Configure GPIO pin : PG9 */ - GPIO_InitStruct.Pin = GPIO_PIN_9; - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); - /*Configure GPIO pins : EXTI13_Pin EXTI14_Pin EXTI15_Pin PC9 PC8 */ GPIO_InitStruct.Pin = EXTI13_Pin|EXTI14_Pin|EXTI15_Pin|GPIO_PIN_9 @@ -1159,8 +1031,8 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); - /*Configure GPIO pin : PA10 */ - GPIO_InitStruct.Pin = GPIO_PIN_10; + /*Configure GPIO pins : PA10 PA5 */ + GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_5; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); @@ -1196,6 +1068,13 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + /*Configure GPIO pin : OLED_RST_Pin */ + GPIO_InitStruct.Pin = OLED_RST_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; + HAL_GPIO_Init(OLED_RST_GPIO_Port, &GPIO_InitStruct); + /*Configure GPIO pin : ADC_SPI_NCS_Pin */ GPIO_InitStruct.Pin = ADC_SPI_NCS_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; diff --git a/Xibeca/Core/Src/stm32h7xx_hal_msp.c b/Xibeca/Core/Src/stm32h7xx_hal_msp.c index fc11bcba..34efac08 100644 --- a/Xibeca/Core/Src/stm32h7xx_hal_msp.c +++ b/Xibeca/Core/Src/stm32h7xx_hal_msp.c @@ -24,6 +24,7 @@ /* USER CODE BEGIN Includes */ /* USER CODE END Includes */ +extern DMA_HandleTypeDef hdma_spi3_tx; /* Private typedef -----------------------------------------------------------*/ /* USER CODE BEGIN TD */ @@ -169,145 +170,6 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) } -/** -* @brief DAC MSP Initialization -* This function configures the hardware resources used in this example -* @param hdac: DAC handle pointer -* @retval None -*/ -void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - if(hdac->Instance==DAC1) - { - /* USER CODE BEGIN DAC1_MspInit 0 */ - - /* USER CODE END DAC1_MspInit 0 */ - /* Peripheral clock enable */ - __HAL_RCC_DAC12_CLK_ENABLE(); - - __HAL_RCC_GPIOA_CLK_ENABLE(); - /**DAC1 GPIO Configuration - PA4 ------> DAC1_OUT1 - PA5 ------> DAC1_OUT2 - */ - GPIO_InitStruct.Pin = DAC1_Pin|DAC2_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* USER CODE BEGIN DAC1_MspInit 1 */ - - /* USER CODE END DAC1_MspInit 1 */ - } - -} - -/** -* @brief DAC MSP De-Initialization -* This function freeze the hardware resources used in this example -* @param hdac: DAC handle pointer -* @retval None -*/ -void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac) -{ - if(hdac->Instance==DAC1) - { - /* USER CODE BEGIN DAC1_MspDeInit 0 */ - - /* USER CODE END DAC1_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_DAC12_CLK_DISABLE(); - - /**DAC1 GPIO Configuration - PA4 ------> DAC1_OUT1 - PA5 ------> DAC1_OUT2 - */ - HAL_GPIO_DeInit(GPIOA, DAC1_Pin|DAC2_Pin); - - /* USER CODE BEGIN DAC1_MspDeInit 1 */ - - /* USER CODE END DAC1_MspDeInit 1 */ - } - -} - -/** -* @brief I2C MSP Initialization -* This function configures the hardware resources used in this example -* @param hi2c: I2C handle pointer -* @retval None -*/ -void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; - if(hi2c->Instance==I2C1) - { - /* USER CODE BEGIN I2C1_MspInit 0 */ - - /* USER CODE END I2C1_MspInit 0 */ - /** Initializes the peripherals clock - */ - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2C1; - PeriphClkInitStruct.I2c123ClockSelection = RCC_I2C123CLKSOURCE_D2PCLK1; - if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) - { - Error_Handler(); - } - - __HAL_RCC_GPIOB_CLK_ENABLE(); - /**I2C1 GPIO Configuration - PB8 ------> I2C1_SCL - PB7 ------> I2C1_SDA - */ - GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_7; - GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF4_I2C1; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /* Peripheral clock enable */ - __HAL_RCC_I2C1_CLK_ENABLE(); - /* USER CODE BEGIN I2C1_MspInit 1 */ - - /* USER CODE END I2C1_MspInit 1 */ - } - -} - -/** -* @brief I2C MSP De-Initialization -* This function freeze the hardware resources used in this example -* @param hi2c: I2C handle pointer -* @retval None -*/ -void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c) -{ - if(hi2c->Instance==I2C1) - { - /* USER CODE BEGIN I2C1_MspDeInit 0 */ - - /* USER CODE END I2C1_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_I2C1_CLK_DISABLE(); - - /**I2C1 GPIO Configuration - PB8 ------> I2C1_SCL - PB7 ------> I2C1_SDA - */ - HAL_GPIO_DeInit(GPIOB, GPIO_PIN_8); - - HAL_GPIO_DeInit(GPIOB, GPIO_PIN_7); - - /* USER CODE BEGIN I2C1_MspDeInit 1 */ - - /* USER CODE END I2C1_MspDeInit 1 */ - } - -} - /** * @brief LPTIM MSP Initialization * This function configures the hardware resources used in this example @@ -502,13 +364,11 @@ void HAL_QSPI_MspDeInit(QSPI_HandleTypeDef* hqspi) void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) { GPIO_InitTypeDef GPIO_InitStruct = {0}; - RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; if(hspi->Instance==SPI2) { /* USER CODE BEGIN SPI2_MspInit 0 */ /* USER CODE END SPI2_MspInit 0 */ - /* Peripheral clock enable */ __HAL_RCC_SPI2_CLK_ENABLE(); @@ -542,68 +402,46 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) /* USER CODE BEGIN SPI3_MspInit 0 */ /* USER CODE END SPI3_MspInit 0 */ - /* Peripheral clock enable */ __HAL_RCC_SPI3_CLK_ENABLE(); __HAL_RCC_GPIOC_CLK_ENABLE(); /**SPI3 GPIO Configuration PC12 ------> SPI3_MOSI - PC11 ------> SPI3_MISO PC10 ------> SPI3_SCK */ - GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_11|GPIO_PIN_10; + GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_10; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF6_SPI3; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - /* USER CODE BEGIN SPI3_MspInit 1 */ - - /* USER CODE END SPI3_MspInit 1 */ - } - else if(hspi->Instance==SPI6) - { - /* USER CODE BEGIN SPI6_MspInit 0 */ - - /* USER CODE END SPI6_MspInit 0 */ - /** Initializes the peripherals clock - */ - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SPI6; - PeriphClkInitStruct.Spi6ClockSelection = RCC_SPI6CLKSOURCE_D3PCLK1; - if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + /* SPI3 DMA Init */ + /* SPI3_TX Init */ + hdma_spi3_tx.Instance = DMA1_Stream2; + hdma_spi3_tx.Init.Request = DMA_REQUEST_SPI3_TX; + hdma_spi3_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; + hdma_spi3_tx.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_spi3_tx.Init.MemInc = DMA_MINC_ENABLE; + hdma_spi3_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; + hdma_spi3_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; + hdma_spi3_tx.Init.Mode = DMA_NORMAL; + hdma_spi3_tx.Init.Priority = DMA_PRIORITY_LOW; + hdma_spi3_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + if (HAL_DMA_Init(&hdma_spi3_tx) != HAL_OK) { Error_Handler(); } - /* Peripheral clock enable */ - __HAL_RCC_SPI6_CLK_ENABLE(); - - __HAL_RCC_GPIOG_CLK_ENABLE(); - __HAL_RCC_GPIOB_CLK_ENABLE(); - /**SPI6 GPIO Configuration - PG14 ------> SPI6_MOSI - PG13 ------> SPI6_SCK - PB4 (NJTRST) ------> SPI6_MISO - */ - GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_13; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF5_SPI6; - HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = GPIO_PIN_4; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF8_SPI6; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + __HAL_LINKDMA(hspi,hdmatx,hdma_spi3_tx); - /* USER CODE BEGIN SPI6_MspInit 1 */ + /* SPI3 interrupt Init */ + HAL_NVIC_SetPriority(SPI3_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(SPI3_IRQn); + /* USER CODE BEGIN SPI3_MspInit 1 */ - /* USER CODE END SPI6_MspInit 1 */ + /* USER CODE END SPI3_MspInit 1 */ } } @@ -647,36 +485,19 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) /**SPI3 GPIO Configuration PC12 ------> SPI3_MOSI - PC11 ------> SPI3_MISO PC10 ------> SPI3_SCK */ - HAL_GPIO_DeInit(GPIOC, GPIO_PIN_12|GPIO_PIN_11|GPIO_PIN_10); + HAL_GPIO_DeInit(GPIOC, GPIO_PIN_12|GPIO_PIN_10); + + /* SPI3 DMA DeInit */ + HAL_DMA_DeInit(hspi->hdmatx); + /* SPI3 interrupt DeInit */ + HAL_NVIC_DisableIRQ(SPI3_IRQn); /* USER CODE BEGIN SPI3_MspDeInit 1 */ /* USER CODE END SPI3_MspDeInit 1 */ } - else if(hspi->Instance==SPI6) - { - /* USER CODE BEGIN SPI6_MspDeInit 0 */ - - /* USER CODE END SPI6_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_SPI6_CLK_DISABLE(); - - /**SPI6 GPIO Configuration - PG14 ------> SPI6_MOSI - PG13 ------> SPI6_SCK - PB4 (NJTRST) ------> SPI6_MISO - */ - HAL_GPIO_DeInit(GPIOG, GPIO_PIN_14|GPIO_PIN_13); - - HAL_GPIO_DeInit(GPIOB, GPIO_PIN_4); - - /* USER CODE BEGIN SPI6_MspDeInit 1 */ - - /* USER CODE END SPI6_MspDeInit 1 */ - } } diff --git a/Xibeca/Core/Src/stm32h7xx_it.c b/Xibeca/Core/Src/stm32h7xx_it.c index 6d496dbf..88326fe6 100644 --- a/Xibeca/Core/Src/stm32h7xx_it.c +++ b/Xibeca/Core/Src/stm32h7xx_it.c @@ -64,6 +64,8 @@ extern DMA_HandleTypeDef hdma_sai1_a; extern DMA_HandleTypeDef hdma_sai1_b; extern SAI_HandleTypeDef hsai_BlockA1; extern SAI_HandleTypeDef hsai_BlockB1; +extern DMA_HandleTypeDef hdma_spi3_tx; +extern SPI_HandleTypeDef hspi3; /* USER CODE BEGIN EV */ /* USER CODE END EV */ @@ -128,6 +130,34 @@ void DMA1_Stream1_IRQHandler(void) /* USER CODE END DMA1_Stream1_IRQn 1 */ } +/** + * @brief This function handles DMA1 stream2 global interrupt. + */ +void DMA1_Stream2_IRQHandler(void) +{ + /* USER CODE BEGIN DMA1_Stream2_IRQn 0 */ + + /* USER CODE END DMA1_Stream2_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_spi3_tx); + /* USER CODE BEGIN DMA1_Stream2_IRQn 1 */ + + /* USER CODE END DMA1_Stream2_IRQn 1 */ +} + +/** + * @brief This function handles SPI3 global interrupt. + */ +void SPI3_IRQHandler(void) +{ + /* USER CODE BEGIN SPI3_IRQn 0 */ + + /* USER CODE END SPI3_IRQn 0 */ + HAL_SPI_IRQHandler(&hspi3); + /* USER CODE BEGIN SPI3_IRQn 1 */ + + /* USER CODE END SPI3_IRQn 1 */ +} + /** * @brief This function handles USB On The Go HS global interrupt. */ diff --git a/Xibeca/Makefile b/Xibeca/Makefile index 010d0175..b77db209 100644 --- a/Xibeca/Makefile +++ b/Xibeca/Makefile @@ -11,10 +11,10 @@ C_SRC += $(OPENWARE)/Source/pcm3168a.c C_SRC += $(OPENWARE)/Source/usbd_audio.c CPP_SRC += $(OPENWARE)/Source/usbh_midi.cpp -# C_SRC += $(OPENWARE)/Source/ssd1309.c -# CPP_SRC += $(OPENWARE)/Source/ScreenBuffer.cpp -# CPP_SRC += $(OPENWARE)/Source/ScreenBufferMono.cpp -# CPP_SRC += $(OPENWARE)/Source/Graphics.cpp +C_SRC += $(OPENWARE)/Source/ssd1309.c +CPP_SRC += $(OPENWARE)/Source/ScreenBuffer.cpp +CPP_SRC += $(OPENWARE)/Source/ScreenBufferMono.cpp +CPP_SRC += $(OPENWARE)/Source/Graphics.cpp # CPP_SRC += $(OPENWARE)/Source/uart.cpp # CPP_SRC += $(OPENWARE)/Source/MidiStreamReader.cpp diff --git a/Xibeca/Xibeca.ioc b/Xibeca/Xibeca.ioc index 344bfda4..076698cd 100644 --- a/Xibeca/Xibeca.ioc +++ b/Xibeca/Xibeca.ioc @@ -1,4 +1,5 @@ #MicroXplorer Configuration settings - do not modify +Dma.SPI3_TX.2.MemInc=DMA_MINC_ENABLE SH.FMC_D0_DA0.ConfNb=1 SH.FMC_A8.ConfNb=1 SH.FMC_A0.ConfNb=1 @@ -10,13 +11,13 @@ SH.GPXTI14.0=GPIO_EXTI14 PG0.Signal=FMC_A10 RCC.PLLFRACN=0 PC3_C.Mode=Full_Duplex_Master -DAC1.IPParameters=DAC_Channel-DAC_OUT2,DAC_Channel-DAC_OUT1 SAI1.Instance-SAI_A_MasterWithClock=SAI$Index_Block_A RCC.RTCFreq_Value=32000 PA15\ (JTDI).Signal=S_TIM2_CH1 RCC.CpuClockFreq_Value=480000000 PD2.GPIOParameters=GPIO_Label SH.FMC_SDNWE.ConfNb=1 +PG14.GPIOParameters=GPIO_Speed,GPIO_Label SH.ADCx_INP5.0=ADC1_INP5,IN5-Single-Ended SH.FMC_D5_DA5.0=FMC_D5,sd-32b-d1 SH.FMC_D9_DA9.0=FMC_D9,sd-32b-d1 @@ -30,9 +31,9 @@ SH.S_TIM3_CH2.ConfNb=1 PF7.Signal=UART7_TX SH.FMC_SDNWE.0=FMC_SDNWE,13b-sda1 PH9.Signal=FMC_D17 -SPI3.VirtualNSS=VM_NSSHARD SH.FMC_D11_DA11.0=FMC_D11,sd-32b-d1 RCC.I2C4Freq_Value=120000000 +Dma.SPI3_TX.2.PeriphDataAlignment=DMA_PDATAALIGN_BYTE PB6.Signal=UART5_TX PC7.Signal=S_TIM3_CH2 PD0.Signal=FMC_D2_DA2 @@ -43,7 +44,6 @@ ProjectManager.ProjectBuild=false NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false PA0.Locked=true VP_USB_HOST_VS_USB_HOST_AUDIO_HS.Mode=AUDIO_HS -PG14.Mode=Full_Duplex_Master ProjectManager.FirmwarePackage=STM32Cube FW_H7 V1.9.0 USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology ProjectManager.BackupPrevious=false @@ -58,6 +58,7 @@ VP_USB_HOST_VS_USB_HOST_AUDIO_HS.Signal=USB_HOST_VS_USB_HOST_AUDIO_HS PA8.Signal=UART7_RX SH.FMC_D1_DA1.0=FMC_D1,sd-32b-d1 USB_OTG_HS.IPParameters=VirtualMode-Host_FS +Dma.SPI3_TX.2.Direction=DMA_MEMORY_TO_PERIPH VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 ProjectManager.HalAssertFull=true RCC.DIVP2Freq_Value=25000000 @@ -79,13 +80,14 @@ SAI1.FSPolarity-SAI_B_SyncSlave=SAI_FS_ACTIVE_HIGH PC3_C.GPIO_Label=ADC_SPI_MOSI SH.FMC_A11.ConfNb=1 SH.FMC_D27.0=FMC_D27,sd-32b-d1 +FREERTOS.FootprintOK=true Dma.SAI1_A.0.SyncSignalID=NONE SH.S_TIM4_CH1.0=TIM4_CH1,Encoder_Interface RCC.LPUART1Freq_Value=120000000 PF10.Mode=Single Bank 1 USB_OTG_FS.IPParameters=VirtualMode PB13.Mode=Activate_VBUS_FS -PA4.GPIO_Label=DAC1 +PA4.GPIO_Label=OLED_RST PD15.Signal=FMC_D1_DA1 SH.ADCx_INP10.ConfNb=1 RCC.VCO3OutputFreq_Value=196571428.5714286 @@ -95,103 +97,102 @@ SAI1.NoDivider-SAI_A_MasterWithClock=SAI_MASTERDIVIDER_ENABLE Dma.SAI1_B.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber SH.GPXTI10.0=GPIO_EXTI10 USB_DEVICE.VID-AUDIO_FS=0x1209 -Mcu.Pin80=PG2 -Mcu.Pin81=PC0 +Mcu.Pin80=PC2_C +Mcu.Pin81=PC3_C SH.S_TIM4_CH1.ConfNb=1 SH.FMC_A4.0=FMC_A4,13b-sda1 ProjectManager.ProjectFileName=Xibeca.ioc SH.FMC_A5.ConfNb=1 -FREERTOS.Tasks01=defaultTask,0,128,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL +FREERTOS.Tasks01=defaultTask,0,1024,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL PH13.Signal=FMC_D21 -Mcu.Pin79=PD15 +Mcu.Pin79=PC1 USB_DEVICE.VirtualMode-AUDIO_FS=Audio -Mcu.PinsNb=130 +Mcu.PinsNb=126 PC14-OSC32_IN\ (OSC32_IN).GPIOParameters=GPIO_Label PC11.Locked=true -Mcu.Pin73=PG3 -Mcu.Pin74=PF10 +Mcu.Pin73=PF8 +Mcu.Pin74=PH11 Dma.SAI1_B.1.MemInc=DMA_MINC_ENABLE -Mcu.Pin71=PG5 -Mcu.Pin72=PG4 -Mcu.Pin77=PH11 +Mcu.Pin71=PF10 +Mcu.Pin72=PF9 +Mcu.Pin77=PG2 PC13.Locked=true SAI1.MClockEnable-SAI_A_MasterWithClock=SAI_MASTERCLOCK_ENABLE PG5.Signal=FMC_A15_BA1 -Mcu.Pin78=PH10 +Mcu.Pin78=PC0 ADC1.OffsetNumber-0\#ChannelRegularConversion=ADC_OFFSET_NONE -Mcu.Pin75=PF9 +Mcu.Pin75=PH10 PC13.Signal=GPXTI13 PG3.Locked=true -Mcu.Pin76=PF8 +Mcu.Pin76=PD15 SH.FMC_D10_DA10.0=FMC_D10,sd-32b-d1 FREERTOS.INCLUDE_vTaskDelayUntil=1 -Mcu.Pin70=PH12 +Mcu.Pin70=PG3 SAI1.ErrorAudioFreq-SAI_A_MasterWithClock=-0.01 % SH.FMC_D16.0=FMC_D16,sd-32b-d1 -Mcu.Pin68=PF6 -Mcu.Pin69=PF5 +Mcu.Pin68=PG5 +Mcu.Pin69=PG4 SH.ADCx_INP9.0=ADC1_INP9,IN9-Single-Ended -Mcu.Pin62=PF3 -Mcu.Pin63=PF4 -Mcu.Pin60=PG8 -Mcu.Pin61=PC6 -Mcu.Pin66=PG6 +PG14.Locked=true +Mcu.Pin62=PG7 +Mcu.Pin63=PG6 +Mcu.Pin60=PF4 +Mcu.Pin61=PH5 +Mcu.Pin66=PF5 RCC.PWR_Regulator_Voltage_Scale=PWR_REGULATOR_VOLTAGE_SCALE0 -Mcu.Pin67=PF7 -Mcu.Pin64=PH5 -Mcu.Pin65=PG7 +Mcu.Pin67=PH12 +Mcu.Pin64=PF7 +Mcu.Pin65=PF6 PF8.GPIO_Label=FLASH_DQ0 PD10.Signal=FMC_D15_DA15 RCC.D1CPREFreq_Value=480000000 RCC.Tim1OutputFreq_Value=240000000 SH.FMC_D29.0=FMC_D29,sd-32b-d1 -Mcu.Pin59=PH4 -Mcu.Pin57=PF2 +Mcu.Pin59=PF3 +Mcu.Pin57=PG8 PC15-OSC32_OUT\ (OSC32_OUT).Locked=true -Mcu.Pin58=PF1 +Mcu.Pin58=PC6 PH4.Locked=true -Mcu.Pin51=PA8 -Mcu.Pin52=PH0-OSC_IN (PH0) -Mcu.Pin50=PC9 -SH.COMP_DAC11_group.0=DAC1_OUT1,DAC_OUT1 -Mcu.Pin55=PC7 -Mcu.Pin56=PH1-OSC_OUT (PH1) -Mcu.Pin53=PH3 -Mcu.Pin54=PC8 +Mcu.Pin51=PC8 +Mcu.Pin52=PC7 +Mcu.Pin50=PH3 +Mcu.Pin55=PF1 +Mcu.Pin56=PH4 +Mcu.Pin53=PH1-OSC_OUT (PH1) +Mcu.Pin54=PF2 PB11.GPIOParameters=GPIO_Label -Mcu.Pin48=PC15-OSC32_OUT (OSC32_OUT) -Mcu.Pin49=PH2 -Mcu.Pin46=PI0 -Mcu.Pin47=PA9 +Mcu.Pin48=PA8 +Mcu.Pin49=PH0-OSC_IN (PH0) +Mcu.Pin46=PH2 +Mcu.Pin47=PC9 SAI1.VirtualMode-SAI_A_MasterWithClock=VM_MASTER PB14.Signal=USB_OTG_HS_DM PG6.GPIOParameters=GPIO_Label -Mcu.Pin40=PC14-OSC32_IN (OSC32_IN) -PA5.Signal=COMP_DAC12_group -Mcu.Pin41=PF0 -Mcu.Pin44=PH13 -Mcu.Pin45=PH14 -Mcu.Pin42=PI10 -Mcu.Pin43=PI11 +Mcu.Pin40=PI11 +Mcu.Pin41=PH13 +Mcu.Pin44=PA9 +Mcu.Pin45=PC15-OSC32_OUT (OSC32_OUT) +Mcu.Pin42=PH14 +Mcu.Pin43=PI0 PI7.Signal=FMC_D29 PC2_C.GPIO_Label=ADC_SPI_MISO SH.FMC_A6.0=FMC_A6,13b-sda1 RCC.AHB12Freq_Value=240000000 PE14.Signal=FMC_D11_DA11 PE6.Mode=SAI_A_MasterWithClock -Mcu.Pin37=PD2 -Mcu.Pin38=PH15 +Mcu.Pin37=PC14-OSC32_IN (OSC32_IN) +Mcu.Pin38=PF0 SAI1.SlotNumber-SAI_B_SyncSlave=8 -Mcu.Pin35=PI9 -Mcu.Pin36=PI4 +Mcu.Pin35=PH15 +Mcu.Pin36=PI1 SH.FMC_D14_DA14.ConfNb=1 -Mcu.Pin39=PI1 +Mcu.Pin39=PI10 PI2.Signal=FMC_D26 -Mcu.Pin30=PD1 -Mcu.Pin33=PA11 -Mcu.Pin34=PC13 -Mcu.Pin31=PI3 -Mcu.Pin32=PI2 +Mcu.Pin30=PA11 +Mcu.Pin33=PI4 +Mcu.Pin34=PD2 +Mcu.Pin31=PC13 +Mcu.Pin32=PI9 Dma.SAI1_A.0.SyncRequestNumber=1 NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false FREERTOS.configUSE_MUTEXES=0 @@ -201,41 +202,41 @@ SH.SharedStack_PC8.1=GPIO_EXTI8 SH.FMC_NBL2.0=FMC_NBL2,Sd4ByteEnable1 PC9.GPIOParameters=GPIO_Label PF9.GPIOParameters=GPIO_Label -Mcu.Pin26=PA12 +Mcu.Pin26=PI5 SH.FMC_D18.0=FMC_D18,sd-32b-d1 -Mcu.Pin27=PI7 -Mcu.Pin24=PC11 +Mcu.Pin27=PD1 +Mcu.Pin24=PI7 SH.FMC_D21.ConfNb=1 -Mcu.Pin25=PC10 -Mcu.Pin28=PI6 -Mcu.Pin29=PI5 -Mcu.Pin22=PG10 -Mcu.Pin23=PD0 -Mcu.Pin20=PG12 +Mcu.Pin25=PI6 +Dma.SPI3_TX.2.SyncEnable=DISABLE +Mcu.Pin28=PI3 +Mcu.Pin29=PI2 +Mcu.Pin22=PC10 +Mcu.Pin23=PA12 +Mcu.Pin20=PD0 ADC1.master=1 PA3.Locked=true -Mcu.Pin21=PG11 +Mcu.Pin21=PC11 PC14-OSC32_IN\ (OSC32_IN).GPIO_Label=EXTI14 -PA5.GPIO_Label=DAC2 NVIC.ForceEnableDMAVector=true NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false SH.FMC_SDNRAS.ConfNb=1 ProjectManager.HeapSize=0x200 -Mcu.Pin15=PE5 +Mcu.Pin15=PB6 PA0.GPIOParameters=GPIO_Label NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false -Mcu.Pin16=PE6 -Mcu.Pin13=PA13 (JTMS/SWDIO) -Mcu.Pin14=PE4 -Mcu.Pin19=PG15 +Mcu.Pin16=PG15 +Mcu.Pin13=PE6 +Mcu.Pin14=PB7 +Mcu.Pin19=PG10 PF10.GPIOParameters=GPIO_Label SH.GPXTI15.ConfNb=1 -Mcu.Pin17=PB7 -Mcu.Pin18=PB6 +Mcu.Pin17=PG12 +Mcu.Pin18=PG11 NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 -Mcu.Pin11=PA15 (JTDI) -Mcu.Pin12=PA14 (JTCK/SWCLK) -Mcu.Pin10=PC12 +Mcu.Pin11=PE4 +Mcu.Pin12=PE5 +Mcu.Pin10=PA13 (JTMS/SWDIO) SH.GPXTI10.ConfNb=1 PI11.GPIO_Label=EXTI11 PE3.Signal=SAI1_SD_B @@ -243,7 +244,7 @@ PF4.Signal=FMC_A4 SH.FMC_D26.ConfNb=1 PD2.Signal=SharedStack_PD2 Mcu.Family=STM32H7 -SH.SharedStack_PC12.1=SPI3_MOSI,Full_Duplex_Master +SH.SharedStack_PC12.1=SPI3_MOSI,TX_Only_Simplex_Unidirect_Master NVIC.OTG_HS_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true ProjectManager.MainLocation=Core/Src SH.SharedStack_PC12.0=SDMMC1_CK @@ -256,7 +257,6 @@ PH10.Signal=FMC_D18 SH.FMC_D14_DA14.0=FMC_D14,sd-32b-d1 PH0-OSC_IN\ (PH0).Signal=RCC_OSC_IN PG2.Signal=FMC_A12 -SH.COMP_DAC12_group.0=DAC1_OUT2,DAC_OUT2 SAI1.FrameLength-SAI_B_SyncSlave=256 PA0.GPIO_Label=EXTI0 PA11.Mode=Device_Only @@ -267,15 +267,16 @@ SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 RCC.VCO2OutputFreq_Value=150000000 SH.FMC_A11.0=FMC_A11,13b-sda1 SH.ADCx_INP11.ConfNb=1 +Dma.SPI3_TX.2.Mode=DMA_NORMAL PB15.Signal=USB_OTG_HS_DP PG15.Signal=FMC_SDNCAS PG11.Signal=LPTIM1_IN2 PD13.Signal=S_TIM4_CH2 -Mcu.IP4=DMA -Mcu.IP5=FMC -Mcu.IP2=DAC1 -I2C1.IPParameters=Timing -Mcu.IP3=DEBUG +Mcu.IP4=FMC +Mcu.IP5=FREERTOS +Mcu.IP2=DEBUG +Dma.SPI3_TX.2.SignalID=NONE +Mcu.IP3=DMA Mcu.IP0=ADC1 Mcu.IP1=CORTEX_M7 PE4.GPIOParameters=GPIO_Speed @@ -284,9 +285,8 @@ Dma.SAI1_B.1.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT RCC.DIVP3Freq_Value=98285714.2857143 RCC.SDMMCFreq_Value=192000000 ProjectManager.PreviousToolchain= -SH.COMP_DAC12_group.ConfNb=1 SH.FMC_NBL1.0=FMC_NBL1,Sd4ByteEnable1 -FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configUSE_IDLE_HOOK,configUSE_TICK_HOOK,configUSE_MALLOC_FAILED_HOOK,INCLUDE_vTaskDelayUntil,configUSE_MUTEXES,configCHECK_FOR_STACK_OVERFLOW +FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configUSE_IDLE_HOOK,configUSE_TICK_HOOK,configUSE_MALLOC_FAILED_HOOK,INCLUDE_vTaskDelayUntil,configUSE_MUTEXES,configCHECK_FOR_STACK_OVERFLOW,FootprintOK Dma.SAI1_B.1.Instance=DMA1_Stream1 Dma.SAI1_B.1.FIFOMode=DMA_FIFOMODE_DISABLE FREERTOS.configUSE_PREEMPTION=0 @@ -297,33 +297,32 @@ RCC.DIVR3Freq_Value=98285714.2857143 RCC.HSE_VALUE=8000000 NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false SH.FMC_A14_BA0.ConfNb=1 -Mcu.IP10=QUADSPI +Mcu.IP10=SAI1 NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:false\:true -Mcu.IP12=SAI1 -Mcu.IP11=RCC -SH.SharedStack_PC10.1=SPI3_SCK,Full_Duplex_Master +Mcu.IP12=SPI3 +Mcu.IP11=SPI2 +SH.SharedStack_PC10.1=SPI3_SCK,TX_Only_Simplex_Unidirect_Master +PA4.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM SH.SharedStack_PC10.0=SDMMC1_D2 -Mcu.IP18=TIM3 -Mcu.IP17=TIM2 -Mcu.IP19=TIM4 +Mcu.IP18=UART7 +Mcu.IP17=UART5 +Mcu.IP19=USB_DEVICE RCC.DIVP1Freq_Value=480000000 -Mcu.IP14=SPI3 +Mcu.IP14=TIM2 PF9.Mode=Single Bank 1 -Mcu.IP13=SPI2 -Mcu.IP16=SYS -Mcu.IP15=SPI6 +Mcu.IP13=SYS +Mcu.IP16=TIM4 +Mcu.IP15=TIM3 PF11.Signal=FMC_SDNRAS +PC11.GPIO_Label=OLED_DC PB5.Mode=Asynchronous PE3.GPIOParameters=GPIO_Speed PB7.Signal=I2C1_SDA -Mcu.IP21=UART7 -Mcu.IP20=UART5 -Mcu.IP23=USB_HOST -Mcu.IP22=USB_DEVICE +Mcu.IP21=USB_OTG_FS +Mcu.IP20=USB_HOST +Mcu.IP22=USB_OTG_HS SH.S_TIM3_CH1.0=TIM3_CH1,Encoder_Interface -Mcu.IP25=USB_OTG_HS SH.FMC_D27.ConfNb=1 -Mcu.IP24=USB_OTG_FS SH.FMC_D16.ConfNb=1 SAI1.OutputDrive-SAI_A_MasterWithClock=SAI_OUTPUTDRIVE_ENABLE USB_DEVICE.PRODUCT_STRING_AUDIO_FS=OWL-XIBECA @@ -337,20 +336,22 @@ SAI1.FSOffset-SAI_A_MasterWithClock=SAI_FS_BEFOREFIRSTBIT PF8.Signal=QUADSPI_BK1_IO0 SH.FMC_D30.ConfNb=1 RCC.DIVR1Freq_Value=480000000 -Mcu.Pin95=PG0 -Mcu.Pin96=PE13 -Mcu.Pin93=PC4 -Mcu.Pin94=PF13 -Mcu.Pin99=PA2 -Mcu.Pin97=PD12 -Mcu.Pin98=PD10 +NVIC.SPI3_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +Mcu.Pin95=PD10 +Mcu.Pin96=PA2 +Mcu.Pin93=PE13 +Mcu.Pin94=PD12 +Mcu.Pin99=PF12 +Mcu.Pin97=PA6 +Mcu.Pin98=PC5 +Dma.Request2=SPI3_TX Dma.Request1=SAI1_B Dma.SAI1_B.1.PeriphInc=DMA_PINC_DISABLE FREERTOS.configUSE_TICK_HOOK=0 -Mcu.Pin91=PA0 -Mcu.Pin92=PA4 +Mcu.Pin91=PF13 +Mcu.Pin92=PG0 NVIC.DMA1_Stream0_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true -Mcu.Pin90=PA1 +Mcu.Pin90=PC4 PC5.Signal=ADCx_INP8 PH2.Mode=SdramChipSelect1_1 PE7.Signal=FMC_D4_DA4 @@ -358,15 +359,15 @@ Dma.Request0=SAI1_A SH.FMC_D22.ConfNb=1 Dma.SAI1_B.1.Priority=DMA_PRIORITY_VERY_HIGH PE2.GPIO_Label=FLASH_DQ2 -Mcu.Pin84=PC3_C -Mcu.Pin85=PG1 -Mcu.Pin82=PC1 -Mcu.Pin83=PC2_C -Mcu.Pin88=PD14 +Mcu.Pin84=PH9 +Mcu.Pin85=PD14 +Mcu.Pin82=PG1 +Mcu.Pin83=PH8 +Mcu.Pin88=PA0 PA3.Signal=GPXTI3 -Mcu.Pin89=PD13 -Mcu.Pin86=PH8 -Mcu.Pin87=PH9 +Mcu.Pin89=PA4 +Mcu.Pin86=PD13 +Mcu.Pin87=PA1 SH.FMC_A3.ConfNb=1 SAI1.VirtualSlotActive-SAI_A_MasterWithClock=SAI_SLOTACTIVE_ALL USB_HOST.IPParameters=USBH_HandleTypeDef-AUDIO_HS,VirtualModeHS @@ -376,6 +377,7 @@ Dma.SAI1_B.1.Mode=DMA_CIRCULAR PG7.Signal=SAI1_MCLK_A PC9.GPIO_Label=EXTI9 Dma.SAI1_B.1.RequestNumber=1 +Dma.SPI3_TX.2.Polarity=HAL_DMAMUX_REQ_GEN_RISING NVIC.SavedSvcallIrqHandlerGenerated=true Dma.SAI1_A.0.Direction=DMA_PERIPH_TO_MEMORY PC11.Signal=SharedStack_PC11 @@ -400,8 +402,8 @@ PA9.Mode=Activate_VBUS SH.FMC_A15_BA1.ConfNb=1 SH.SharedStack_PD2.0=SDMMC1_CMD PF6.Signal=QUADSPI_BK1_IO3 -PC15-OSC32_OUT\ (OSC32_OUT).Signal=GPXTI15 SH.SharedStack_PD2.1=GPIO_EXTI2 +PC15-OSC32_OUT\ (OSC32_OUT).Signal=GPXTI15 PB10.GPIO_Label=ADC_SPI_CLK Dma.SAI1_A.0.Mode=DMA_CIRCULAR RCC.VCO1OutputFreq_Value=960000000 @@ -431,7 +433,7 @@ RCC.ADCFreq_Value=25000000 VP_SYS_VS_Systick.Mode=SysTick SH.FMC_D12_DA12.0=FMC_D12,sd-32b-d1 SAI1.SlotNumber-SAI_A_MasterWithClock=8 -SH.SharedStack_PC11.ConfNb=2 +SH.SharedStack_PC11.ConfNb=3 SH.FMC_D29.ConfNb=1 SH.FMC_D18.ConfNb=1 PF1.Signal=FMC_A1 @@ -444,11 +446,11 @@ PE0.Signal=FMC_NBL0 Dma.SAI1_B.1.SyncSignalID=NONE PE12.Signal=FMC_D9_DA9 NVIC.SavedPendsvIrqHandlerGenerated=true -Mcu.IP8=LPTIM1 +Mcu.IP8=QUADSPI SH.ADCx_INP8.ConfNb=1 -Mcu.IP9=NVIC -Mcu.IP6=FREERTOS -Mcu.IP7=I2C1 +Mcu.IP9=RCC +Mcu.IP6=LPTIM1 +Mcu.IP7=NVIC ProjectManager.CoupleFile=false RCC.SYSCLKFreq_VALUE=480000000 RCC.I2C123Freq_Value=120000000 @@ -466,16 +468,15 @@ PB7.Locked=true PC8.Locked=true SH.ADCx_INP3.ConfNb=1 SH.FMC_D8_DA8.ConfNb=1 +PG14.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM Dma.SAI1_A.0.SyncEnable=DISABLE PA3.GPIO_Label=EXTI3 -PB4\ (NJTRST).Signal=SPI6_MISO -SPI6.Mode=SPI_MODE_MASTER SAI1.SlotActive-SAI_A_MasterWithClock=0x0000FFFF USB_OTG_HS.VirtualMode-Host_FS=Host_FS SH.FMC_D7_DA7.0=FMC_D7,sd-32b-d1 SH.FMC_D24.0=FMC_D24,sd-32b-d1 SH.FMC_A4.ConfNb=1 -SPI3.Direction=SPI_DIRECTION_2LINES +SPI3.Direction=SPI_DIRECTION_2LINES_TXONLY SPI3.VirtualType=VM_MASTER PH12.Signal=FMC_D20 SPI2.VirtualType=VM_MASTER @@ -483,13 +484,13 @@ PB10.Mode=Full_Duplex_Master PC12.Locked=true SH.ADCx_INP10.0=ADC1_INP10,IN10-Single-Ended PG4.Signal=FMC_A14_BA0 +NVIC.DMA1_Stream2_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true PC12.Signal=SharedStack_PC12 PG6.GPIO_Label=FLASH_NCS PG3.GPIOParameters=GPIO_Label PI11.Locked=true PA3.GPIOParameters=GPIO_Label PB13.Signal=USB_OTG_HS_VBUS -PG13.Signal=SPI6_SCK PG6.Mode=Single Bank 1 PinOutPanel.RotationAngle=0 PF6.GPIO_Label=FLASH_DQ3 @@ -503,6 +504,7 @@ PA14\ (JTCK/SWCLK).Signal=DEBUG_JTCK-SWCLK SH.FMC_A12.ConfNb=1 PH5.Signal=FMC_SDNWE SH.GPXTI3.ConfNb=1 +Dma.SPI3_TX.2.SyncRequestNumber=1 PE2.Mode=Single Bank 1 SH.FMC_D10_DA10.ConfNb=1 PB6.Mode=Asynchronous @@ -512,6 +514,7 @@ PE5.Signal=SAI1_SCK_A PF10.GPIO_Label=FLASH_CLK SH.ADCx_INP4.0=ADC1_INP4,IN4-Single-Ended Dma.SAI1_B.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD +PA4.Locked=true RCC.DIVM3=7 RCC.DIVM2=1 RCC.DIVM1=1 @@ -522,6 +525,7 @@ PI6.Signal=FMC_D28 PI3.Signal=FMC_D27 SH.FMC_D15_DA15.ConfNb=1 SPI2.CalculateBaudRate=97.656 KBits/s +PC11.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM SH.S_TIM4_CH2.0=TIM4_CH2,Encoder_Interface SH.SharedStack_PC12.ConfNb=2 PE2.Signal=QUADSPI_BK1_IO2 @@ -540,7 +544,6 @@ PC8.GPIOParameters=GPIO_Label PF8.GPIOParameters=GPIO_Label SH.GPXTI11.0=GPIO_EXTI11 RCC.DFSDMFreq_Value=120000000 -PA5.GPIOParameters=GPIO_Label SH.FMC_A1.0=FMC_A1,13b-sda1 SH.GPXTI14.ConfNb=1 PH2.Signal=FMC_SDCKE0 @@ -567,18 +570,18 @@ SH.FMC_A1.ConfNb=1 SAI1.DataSize-SAI_B_SyncSlave=SAI_DATASIZE_24 RCC.DIVQ1=5 ADC1.Rank-0\#ChannelRegularConversion=1 -DAC1.DAC_Channel-DAC_OUT2=DAC_CHANNEL_2 SH.FMC_D28.0=FMC_D28,sd-32b-d1 -DAC1.DAC_Channel-DAC_OUT1=DAC_CHANNEL_1 ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,master RCC.SWPMI1Freq_Value=120000000 FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 +Dma.SPI3_TX.2.EventEnable=DISABLE PC6.Signal=S_TIM3_CH1 PB11.GPIO_Label=ADC_SPI_NCS PD1.Signal=FMC_D3_DA3 SH.GPXTI0.ConfNb=1 RCC.DIVP2=6 PC0.Signal=ADCx_INP10 +PC11.GPIOParameters=GPIO_Speed,GPIO_Label RCC.QSPIFreq_Value=240000000 PC9.Stacked=true PG10.Signal=GPXTI10 @@ -586,7 +589,6 @@ PG10.Locked=true SH.FMC_A3.0=FMC_A3,13b-sda1 RCC.USART234578Freq_Value=120000000 SH.FMC_D31.ConfNb=1 -SPI6.CalculateBaudRate=60.0 MBits/s RCC.SPI123Freq_Value=25000000 Dma.SAI1_A.0.RequestNumber=1 SH.FMC_D15_DA15.0=FMC_D15,sd-32b-d1 @@ -596,7 +598,6 @@ PA9.Signal=USB_OTG_FS_VBUS RCC.DIVN3=172 SH.S_TIM2_CH2.ConfNb=1 RCC.DIVN2=18 -I2C1.Timing=0x307075B1 RCC.DIVN1=120 PC2_C.Mode=Full_Duplex_Master SH.SharedStack_PC9.0=SDMMC1_D1 @@ -608,48 +609,46 @@ SH.ADCx_INP8.0=ADC1_INP8,IN8-Single-Ended SH.ADCx_INP5.ConfNb=1 RCC.USBCLockSelection=RCC_USBCLKSOURCE_HSI48 ProjectManager.LastFirmware=true -Mcu.Pin116=PF11 -Mcu.Pin117=PF14 -Mcu.Pin118=PE7 -Mcu.Pin119=PE10 +Mcu.Pin116=PE12 +Mcu.Pin117=PE15 +Mcu.Pin118=PB10 +Mcu.Pin119=PB11 Dma.SAI1_A.0.PeriphInc=DMA_PINC_DISABLE SH.FMC_D20.ConfNb=1 PE15.Signal=FMC_D12_DA12 PE8.Signal=FMC_D5_DA5 PI1.Signal=FMC_D25 RCC.RNGFreq_Value=48000000 -Mcu.Pin112=PA3 -Mcu.Pin113=PA7 -Mcu.Pin114=PB1 -Mcu.Pin115=PB0 -Mcu.Pin110=PD9 -Mcu.Pin111=PD8 -Mcu.Pin127=VP_SYS_VS_Systick -Mcu.Pin128=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS -Mcu.Pin129=VP_USB_HOST_VS_USB_HOST_AUDIO_HS -PB4\ (NJTRST).Mode=Full_Duplex_Master +Mcu.Pin112=PF11 +Mcu.Pin113=PF14 +Mcu.Pin114=PE7 +Mcu.Pin115=PE10 +Mcu.Pin110=PB1 +Mcu.Pin111=PB0 SH.FMC_SDNCAS.0=FMC_SDNCAS,13b-sda1 +PG14.GPIO_Label=OLED_CS ProjectManager.FreePins=true RCC.LPTIM2Freq_Value=120000000 SH.FMC_NBL1.ConfNb=1 ProjectManager.UnderRoot=false SH.FMC_D7_DA7.ConfNb=1 -Mcu.Pin123=PB11 +Mcu.Pin123=VP_SYS_VS_Systick Dma.SAI1_B.1.MemDataAlignment=DMA_MDATAALIGN_WORD -Mcu.Pin124=PB14 -PA4.Signal=COMP_DAC11_group -Mcu.Pin125=PB15 -Mcu.Pin126=VP_FREERTOS_VS_CMSIS_V1 +Mcu.Pin124=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS +PA4.Signal=GPIO_Output +Mcu.Pin125=VP_USB_HOST_VS_USB_HOST_AUDIO_HS PB5.Signal=UART5_RX -Mcu.Pin120=PE12 -Mcu.Pin121=PE15 -Mcu.Pin122=PB10 +Mcu.Pin120=PB14 +Mcu.Pin121=PB15 +Mcu.Pin122=VP_FREERTOS_VS_CMSIS_V1 PE3.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH SH.FMC_A10.ConfNb=1 +Dma.SPI3_TX.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber ProjectManager.CompilerOptimize=6 PG11.Mode=Encoder_mode_occur1 SH.FMC_A5.0=FMC_A5,13b-sda1 PA11.Signal=USB_OTG_FS_DM +Dma.SPI3_TX.2.PeriphInc=DMA_PINC_DISABLE SH.S_TIM3_CH1.ConfNb=1 PF6.Mode=Single Bank 1 RCC.LPTIM345Freq_Value=120000000 @@ -657,14 +656,13 @@ ProjectManager.ComputerToolchain=false PF9.Signal=QUADSPI_BK1_IO1 RCC.LTDCFreq_Value=98285714.2857143 PB3\ (JTDO/TRACESWO).Mode=Trace_Asynchronous_SW -PB8.Mode=I2C -Mcu.Pin109=PB13 -Mcu.Pin105=PE8 +Mcu.Pin109=PA7 +Mcu.Pin105=PB13 PA8.Mode=Asynchronous -Mcu.Pin106=PE9 +Mcu.Pin106=PD9 SPI2.DataSize=SPI_DATASIZE_8BIT -Mcu.Pin107=PE11 -Mcu.Pin108=PE14 +Mcu.Pin107=PD8 +Mcu.Pin108=PA3 SH.FMC_NBL3.0=FMC_NBL3,Sd4ByteEnable1 PG3.GPIO_Label=ADC_RST SH.FMC_D12_DA12.ConfNb=1 @@ -680,13 +678,12 @@ PG10.GPIO_Label=EXTI10 PD2.GPIO_Label=EXTI2 PG7.GPIOParameters=GPIO_Speed Dma.SAI1_A.0.PeriphDataAlignment=DMA_PDATAALIGN_WORD -Mcu.Pin101=PA5 +Mcu.Pin101=PE8 PA13\ (JTMS/SWDIO).Signal=DEBUG_JTMS-SWDIO -Mcu.Pin102=PC5 -SPI6.VirtualType=VM_MASTER -Mcu.Pin103=PF12 -Mcu.Pin104=PF15 -Mcu.Pin100=PA6 +Mcu.Pin102=PE9 +Mcu.Pin103=PE11 +Mcu.Pin104=PE14 +Mcu.Pin100=PF15 Dma.SAI1_A.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber RCC.DIVQ2Freq_Value=75000000 SH.S_TIM4_CH2.ConfNb=1 @@ -695,22 +692,26 @@ RCC.CortexFreq_Value=480000000 SH.FMC_A2.ConfNb=1 PG6.Signal=QUADSPI_BK1_NCS Mcu.UserName=STM32H743IIKx +Dma.SPI3_TX.2.Instance=DMA1_Stream2 RCC.HPRE=RCC_HCLK_DIV2 PC10.Locked=true +SPI3.NSSPMode=SPI_NSS_PULSE_DISABLE PC10.Signal=SharedStack_PC10 SH.FMC_NBL0.0=FMC_NBL0,Sd4ByteEnable1 -ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_QUADSPI_Init-QUADSPI-false-HAL-true,5-MX_DAC1_Init-DAC1-false-HAL-true,6-MX_FMC_Init-FMC-false-HAL-true,7-MX_SAI1_Init-SAI1-false-HAL-true,8-MX_ADC1_Init-ADC1-false-HAL-true,9-MX_I2C1_Init-I2C1-false-HAL-true,10-MX_SPI2_Init-SPI2-false-HAL-true,11-MX_SPI3_Init-SPI3-false-HAL-true,12-MX_SPI6_Init-SPI6-false-HAL-true,13-MX_TIM2_Init-TIM2-false-HAL-true,14-MX_TIM3_Init-TIM3-false-HAL-true,15-MX_TIM4_Init-TIM4-false-HAL-true,16-MX_UART5_Init-UART5-false-HAL-true,17-MX_UART7_Init-UART7-false-HAL-true,18-MX_LPTIM1_Init-LPTIM1-false-HAL-true,19-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,20-MX_USB_HOST_Init-USB_HOST-false-HAL-false,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_QUADSPI_Init-QUADSPI-false-HAL-true,5-MX_FMC_Init-FMC-false-HAL-true,6-MX_SAI1_Init-SAI1-false-HAL-true,7-MX_ADC1_Init-ADC1-false-HAL-true,8-MX_SPI2_Init-SPI2-false-HAL-true,9-MX_SPI3_Init-SPI3-false-HAL-true,10-MX_TIM2_Init-TIM2-false-HAL-true,11-MX_TIM3_Init-TIM3-false-HAL-true,12-MX_TIM4_Init-TIM4-false-HAL-true,13-MX_UART5_Init-UART5-false-HAL-true,14-MX_UART7_Init-UART7-false-HAL-true,15-MX_LPTIM1_Init-LPTIM1-false-HAL-true,16-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,17-MX_USB_HOST_Init-USB_HOST-false-HAL-false,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true SH.FMC_D6_DA6.0=FMC_D6,sd-32b-d1 PC9.Locked=true PC13.GPIO_Label=EXTI13 PB11.Signal=GPIO_Output +Dma.SPI3_TX.2.SyncSignalID=NONE PE5.GPIOParameters=GPIO_Speed ProjectManager.StackSize=0x400 +SH.SharedStack_PC11.2=GPIO_Output PI11.GPIOParameters=GPIO_Label RCC.VCOInput3Freq_Value=1142857.142857143 PH3.Mode=SdramChipSelect1_1 SH.SharedStack_PC11.0=SDMMC1_D3 -SH.SharedStack_PC11.1=SPI3_MISO,Full_Duplex_Master +SH.SharedStack_PC11.1=SPI3_MISO USB_HOST.USBH_HandleTypeDef-AUDIO_HS=hUsbHostHS SH.FMC_A7.0=FMC_A7,13b-sda1 PA12.Signal=USB_OTG_FS_DP @@ -720,15 +721,14 @@ Mcu.UserConstants= SH.GPXTI13.ConfNb=1 Mcu.ThirdPartyNb=0 RCC.HCLKFreq_Value=240000000 -Mcu.IPNb=26 +Mcu.IPNb=23 RCC.SPDIFRXFreq_Value=192000000 -SPI6.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate PF12.Signal=FMC_A6 FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 -Mcu.Pin6=PG14 -Mcu.Pin7=PG13 -Mcu.Pin8=PB4 (NJTRST) -Mcu.Pin9=PB3 (JTDO/TRACESWO) +Mcu.Pin6=PB3 (JTDO/TRACESWO) +Mcu.Pin7=PC12 +Mcu.Pin8=PA15 (JTDI) +Mcu.Pin9=PA14 (JTCK/SWCLK) Dma.SAI1_A.0.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT PC2_C.Signal=SPI2_MISO SH.FMC_A10.0=FMC_A10,13b-sda1 @@ -740,8 +740,8 @@ GPIO.groupedBy=Group By Peripherals Mcu.Pin2=PE1 Mcu.Pin3=PE0 PC11.Stacked=true -Mcu.Pin4=PB8 -Mcu.Pin5=PB5 +Mcu.Pin4=PB5 +Mcu.Pin5=PG14 SH.FMC_D8_DA8.0=FMC_D8,sd-32b-d1 PC8.Stacked=true SH.FMC_D2_DA2.0=FMC_D2,sd-32b-d1 @@ -755,15 +755,16 @@ SH.FMC_D5_DA5.ConfNb=1 SH.SharedStack_PC10.ConfNb=2 SH.S_TIM2_CH1.ConfNb=1 SH.FMC_D2_DA2.ConfNb=1 -PG13.Mode=Full_Duplex_Master PE4.Mode=SAI_A_MasterWithClock +Dma.SPI3_TX.2.Priority=DMA_PRIORITY_LOW SH.FMC_SDNRAS.0=FMC_SDNRAS,13b-sda1 PE4.Signal=SAI1_FS_A PE6.GPIOParameters=GPIO_Speed -Dma.RequestsNb=2 +Dma.RequestsNb=3 ProjectManager.ProjectName=Xibeca RCC.APB3Freq_Value=120000000 SAI1.VirtualSlotActive-SAI_B_SyncSlave=SAI_SLOTACTIVE_ALL +Dma.SPI3_TX.2.FIFOMode=DMA_FIFOMODE_DISABLE PA7.Locked=true SH.FMC_D0_DA0.0=FMC_D0,sd-32b-d1 RCC.D1PPRE=RCC_APB3_DIV2 @@ -774,12 +775,12 @@ SPI2.CLKPhase=SPI_PHASE_2EDGE PF5.Signal=FMC_A5 Dma.SAI1_B.1.SignalID=NONE SH.FMC_D19.ConfNb=1 +Dma.SPI3_TX.2.RequestNumber=1 SH.FMC_D30.0=FMC_D30,sd-32b-d1 -SPI3.IPParameters=VirtualType,Mode,Direction,BaudRatePrescaler,CalculateBaudRate,DataSize,VirtualNSS +SPI3.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,DataSize,BaudRatePrescaler,NSSPMode SPI2.Direction=SPI_DIRECTION_2LINES PF0.Signal=FMC_A0 SH.FMC_NBL0.ConfNb=1 -SH.COMP_DAC11_group.ConfNb=1 PE3.Mode=SAI_B_SyncSlave RCC.Tim2OutputFreq_Value=240000000 RCC.DFSDMACLkFreq_Value=98285714.2857143 @@ -802,6 +803,7 @@ RCC.D2PPRE1=RCC_APB1_DIV2 PI10.Signal=FMC_D31 NVIC.DMA1_Stream1_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true Dma.SAI1_A.0.MemInc=DMA_MINC_ENABLE +Dma.SPI3_TX.2.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT PD2.Stacked=true PC14-OSC32_IN\ (OSC32_IN).Locked=true RCC.SPI6Freq_Value=120000000 @@ -826,7 +828,7 @@ PG7.Mode=SAI_A_MasterWithClock PE11.Signal=FMC_D8_DA8 SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_TX Dma.SAI1_A.0.Priority=DMA_PRIORITY_VERY_HIGH -PG14.Signal=SPI6_MOSI +PG14.Signal=GPIO_Output SH.S_TIM3_CH2.0=TIM3_CH2,Encoder_Interface SAI1.IPParameters=Instance-SAI_A_MasterWithClock,VirtualMode-SAI_A_MasterWithClock,MClockEnable-SAI_A_MasterWithClock,RealAudioFreq-SAI_A_MasterWithClock,ErrorAudioFreq-SAI_A_MasterWithClock,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,FrameLength-SAI_A_MasterWithClock,FrameLength-SAI_B_SyncSlave,DataSize-SAI_A_MasterWithClock,SlotSize-SAI_A_MasterWithClock,SlotSize-SAI_B_SyncSlave,SlotNumber-SAI_A_MasterWithClock,AudioFrequency-SAI_A_MasterWithClock,DataSize-SAI_B_SyncSlave,SlotNumber-SAI_B_SyncSlave,AudioMode-SAI_A_MasterWithClock,AudioMode-SAI_B_SyncSlave,FSOffset-SAI_A_MasterWithClock,FSOffset-SAI_B_SyncSlave,FSPolarity-SAI_A_MasterWithClock,FSPolarity-SAI_B_SyncSlave,VirtualSlotActive-SAI_A_MasterWithClock,SlotActive-SAI_A_MasterWithClock,NoDivider-SAI_A_MasterWithClock,ClockStrobing-SAI_A_MasterWithClock,OutputDrive-SAI_A_MasterWithClock,VirtualSlotActive-SAI_B_SyncSlave,SlotActive-SAI_B_SyncSlave,OutputDrive-SAI_B_SyncSlave SH.GPXTI3.0=GPIO_EXTI3 @@ -834,14 +836,14 @@ RCC.VCOInput1Freq_Value=8000000 PG7.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH NVIC.SavedSystickIrqHandlerGenerated=true RCC.APB2Freq_Value=120000000 -SPI3.CalculateBaudRate=390.625 KBits/s +SPI3.CalculateBaudRate=3.125 MBits/s SH.FMC_D13_DA13.ConfNb=1 PC13.GPIOParameters=GPIO_Label PF10.Signal=QUADSPI_CLK -SPI3.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_64 -SPI6.Direction=SPI_DIRECTION_2LINES +Dma.SPI3_TX.2.MemDataAlignment=DMA_MDATAALIGN_BYTE +SPI3.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_8 PF15.Signal=FMC_A9 -PA4.GPIOParameters=GPIO_Label +PA4.GPIOParameters=GPIO_Speed,GPIO_Label PE6.Signal=SAI1_SD_A Mcu.Name=STM32H743IIKx SH.FMC_D23.ConfNb=1 @@ -853,14 +855,12 @@ Dma.SAI1_B.1.Direction=DMA_MEMORY_TO_PERIPH PC14-OSC32_IN\ (OSC32_IN).Signal=GPXTI14 SH.FMC_D23.0=FMC_D23,sd-32b-d1 SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B -PB7.Mode=I2C PF6.GPIOParameters=GPIO_Label RCC.SAI4AFreq_Value=192000000 SH.ADCx_INP11.0=ADC1_INP11,IN11-Single-Ended ADC1.NbrOfConversionFlag=1 SAI1.FSOffset-SAI_B_SyncSlave=SAI_FS_BEFOREFIRSTBIT RCC.DIVQ1Freq_Value=192000000 -PB8.Signal=I2C1_SCL PC2_C.GPIOParameters=GPIO_Label Dma.SAI1_B.1.SyncRequestNumber=1 RCC.D3PPRE=RCC_APB4_DIV2 From 7938b6eef5bc10402c6e4e99ed0a345af8351ce2 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 17 Jun 2021 19:20:58 +0200 Subject: [PATCH 037/286] enabled cache --- Magus3/Inc/hardware.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Magus3/Inc/hardware.h b/Magus3/Inc/hardware.h index 5c89de1b..cbc24915 100644 --- a/Magus3/Inc/hardware.h +++ b/Magus3/Inc/hardware.h @@ -3,14 +3,14 @@ #define OWL_MAGUS #define HARDWARE_ID MAGUS_HARDWARE -#define HARDWARE_VERSION "Magus" +#define HARDWARE_VERSION "Magus3" /* #define NO_EXTERNAL_RAM */ /* #define NO_CCM_RAM */ #define DMA_RAM __attribute__ ((section (".dmadata"))) #define USE_PLUS_RAM -/* #define USE_ICACHE */ -/* #define USE_DCACHE */ +#define USE_ICACHE +#define USE_DCACHE #define USE_SCREEN #define SSD1309 From d3a9d8c5499aae34606fe65ccf332d9389f38425 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 17 Jun 2021 19:22:11 +0200 Subject: [PATCH 038/286] don't delete task from stack overflow hook --- Source/ProgramManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ProgramManager.cpp b/Source/ProgramManager.cpp index 898be39c..45cb2b77 100644 --- a/Source/ProgramManager.cpp +++ b/Source/ProgramManager.cpp @@ -711,7 +711,7 @@ extern "C" { /* Run time stack overflow checking is performed if configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is called from PendSV ISR if a stack overflow is detected. */ - vTaskDelete(pxTask); + // vTaskDelete(pxTask); // seems to just get stuck if(pxTask == utilityTask) utilityTask = NULL; if(pxTask == audioTask) From b1e054c75523e9f9d9a22e0cb58809caa86b68a8 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 21 Jun 2021 13:02:23 +0200 Subject: [PATCH 039/286] config changes --- Magus3/Inc/hardware.h | 2 ++ Magus3/Src/main.c | 51 +++++++++++++++++++++++-------------------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/Magus3/Inc/hardware.h b/Magus3/Inc/hardware.h index cbc24915..7ee133e1 100644 --- a/Magus3/Inc/hardware.h +++ b/Magus3/Inc/hardware.h @@ -12,6 +12,8 @@ #define USE_ICACHE #define USE_DCACHE +#define MAX_SYSEX_PROGRAM_SIZE (512*1024) + #define USE_SCREEN #define SSD1309 /* #define OLED_DMA */ diff --git a/Magus3/Src/main.c b/Magus3/Src/main.c index 9ffde582..009bb069 100644 --- a/Magus3/Src/main.c +++ b/Magus3/Src/main.c @@ -199,30 +199,33 @@ int main(void) MX_SPI6_Init(); MX_TIM2_Init(); /* USER CODE BEGIN 2 */ - HAL_SAI_DeInit(&hsai_BlockA1); - HAL_SAI_DeInit(&hsai_BlockB1); - hsai_BlockA1.Instance = SAI1_Block_A; - hsai_BlockA1.Init.AudioMode = SAI_MODESLAVE_TX; - hsai_BlockA1.Init.Synchro = SAI_ASYNCHRONOUS; - hsai_BlockA1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; - hsai_BlockA1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; - hsai_BlockA1.Init.SynchroExt = SAI_SYNCEXT_DISABLE; - hsai_BlockA1.Init.MonoStereoMode = SAI_STEREOMODE; - hsai_BlockA1.Init.CompandingMode = SAI_NOCOMPANDING; - hsai_BlockA1.Init.TriState = SAI_OUTPUT_NOTRELEASED; - if (HAL_SAI_InitProtocol(&hsai_BlockA1, SAI_I2S_STANDARD, SAI_PROTOCOL_DATASIZE_24BIT, 2) != HAL_OK) - Error_Handler(); - hsai_BlockB1.Instance = SAI1_Block_B; - hsai_BlockB1.Init.AudioMode = SAI_MODESLAVE_RX; - hsai_BlockB1.Init.Synchro = SAI_SYNCHRONOUS; - hsai_BlockB1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; - hsai_BlockB1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; - hsai_BlockB1.Init.SynchroExt = SAI_SYNCEXT_DISABLE; - hsai_BlockB1.Init.MonoStereoMode = SAI_STEREOMODE; - hsai_BlockB1.Init.CompandingMode = SAI_NOCOMPANDING; - hsai_BlockB1.Init.TriState = SAI_OUTPUT_NOTRELEASED; - if (HAL_SAI_InitProtocol(&hsai_BlockB1, SAI_I2S_STANDARD, SAI_PROTOCOL_DATASIZE_24BIT, 2) != HAL_OK) - Error_Handler(); + /* HAL_SAI_DeInit(&hsai_BlockA1); */ + /* HAL_SAI_DeInit(&hsai_BlockB1); */ + /* hsai_BlockA1.Instance = SAI1_Block_A; */ + /* hsai_BlockA1.Init.AudioMode = SAI_MODESLAVE_TX; */ + /* hsai_BlockA1.Init.Synchro = SAI_ASYNCHRONOUS; */ + /* hsai_BlockA1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; */ + /* hsai_BlockA1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; */ + /* hsai_BlockA1.Init.SynchroExt = SAI_SYNCEXT_DISABLE; */ + /* hsai_BlockA1.Init.MonoStereoMode = SAI_STEREOMODE; */ + /* hsai_BlockA1.Init.CompandingMode = SAI_NOCOMPANDING; */ + /* hsai_BlockA1.Init.TriState = SAI_OUTPUT_NOTRELEASED; */ + /* if (HAL_SAI_InitProtocol(&hsai_BlockA1, SAI_I2S_STANDARD, SAI_PROTOCOL_DATASIZE_24BIT, 2) != HAL_OK) */ + /* Error_Handler(); */ + /* hsai_BlockB1.Instance = SAI1_Block_B; */ + /* hsai_BlockB1.Init.AudioMode = SAI_MODESLAVE_RX; */ + /* hsai_BlockB1.Init.Synchro = SAI_SYNCHRONOUS; */ + /* hsai_BlockB1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; */ + /* hsai_BlockB1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; */ + /* hsai_BlockB1.Init.SynchroExt = SAI_SYNCEXT_DISABLE; */ + /* hsai_BlockB1.Init.MonoStereoMode = SAI_STEREOMODE; */ + /* hsai_BlockB1.Init.CompandingMode = SAI_NOCOMPANDING; */ + /* hsai_BlockB1.Init.TriState = SAI_OUTPUT_NOTRELEASED; */ + /* if (HAL_SAI_InitProtocol(&hsai_BlockB1, SAI_I2S_STANDARD, SAI_PROTOCOL_DATASIZE_24BIT, 2) != HAL_OK) */ + /* Error_Handler(); */ + + /* HAL_NVIC_SetPriority(EXTI2_IRQn, 3, 0); */ + /* HAL_NVIC_EnableIRQ(EXTI2_IRQn); */ SDRAM_Initialization_Sequence(&hsdram1); From 0a4ae5714342d7735f3fa021422fe510e532abff Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 7 Jul 2021 14:23:01 +0200 Subject: [PATCH 040/286] updated codec SPI and SAI --- Xibeca/Core/Inc/hardware.h | 5 ++- Xibeca/Core/Src/Xibeca.cpp | 51 +++++++++++++++++++++++++++++ Xibeca/Core/Src/main.c | 27 ++++++++------- Xibeca/Core/Src/stm32h7xx_hal_msp.c | 4 +-- Xibeca/Xibeca.ioc | 15 ++++++--- 5 files changed, 81 insertions(+), 21 deletions(-) create mode 100644 Xibeca/Core/Src/Xibeca.cpp diff --git a/Xibeca/Core/Inc/hardware.h b/Xibeca/Core/Inc/hardware.h index d0f84718..145047bd 100644 --- a/Xibeca/Core/Inc/hardware.h +++ b/Xibeca/Core/Inc/hardware.h @@ -43,8 +43,8 @@ #define USBD_AUDIO_TX_CHANNELS 4 #define USE_USBD_AUDIO -#define USE_USBD_AUDIO_TX // microphone -#define USE_USBD_AUDIO_RX // speaker +/* #define USE_USBD_AUDIO_TX // microphone */ +/* #define USE_USBD_AUDIO_RX // speaker */ #define USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS /* #define USBD_MAX_POWER 100 // 200mA for iPad compatibility */ @@ -59,7 +59,6 @@ /* #define UART_MIDI_RX_BUFFER_SIZE 256 */ #define AUDIO_SAMPLINGRATE 48000 -#define TIM8_PERIOD (871*48000/AUDIO_SAMPLINGRATE) /* experimentally determined */ #define USB_HOST_PWR_EN_GPIO_Port GPIOB #define USB_HOST_PWR_EN_Pin GPIO_PIN_0 // PB0 is unused diff --git a/Xibeca/Core/Src/Xibeca.cpp b/Xibeca/Core/Src/Xibeca.cpp new file mode 100644 index 00000000..ef1160f4 --- /dev/null +++ b/Xibeca/Core/Src/Xibeca.cpp @@ -0,0 +1,51 @@ +#include "Owl.h" +#include "device.h" +#include "errorhandlers.h" +#include "Graphics.h" +#include "Pin.h" +#include "ApplicationSettings.h" + +Graphics graphics; + +extern "C" void onResourceUpdate(void); + +void setLed(uint8_t led, uint32_t rgb){ +} + +void onResourceUpdate(void){ +} + +void setup(){ + + HAL_GPIO_WritePin(OLED_RST_GPIO_Port, OLED_RST_Pin, GPIO_PIN_RESET); // OLED off + extern SPI_HandleTypeDef OLED_SPI; + graphics.begin(&OLED_SPI); + +// #ifdef USE_USB_HOST +// // enable USB Host power +// HAL_GPIO_WritePin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin, GPIO_PIN_SET); +// #endif + + owl.setup(); +} + +void loop(void){ + +// #ifdef USE_USB_HOST +// if(HAL_GPIO_ReadPin(USB_HOST_PWR_FAULT_GPIO_Port, USB_HOST_PWR_FAULT_Pin) == GPIO_PIN_RESET){ +// if(HAL_GPIO_ReadPin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin) == GPIO_PIN_SET){ +// HAL_GPIO_WritePin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin, GPIO_PIN_RESET); +// error(USB_ERROR, "USBH PWR Fault"); +// } +// }else{ +// MX_USB_HOST_Process(); +// } +// #endif + +#ifdef USE_SCREEN + graphics.draw(); + graphics.display(); +#endif /* USE_SCREEN */ + + owl.loop(); +} diff --git a/Xibeca/Core/Src/main.c b/Xibeca/Core/Src/main.c index 3c96f786..e0ddd9df 100644 --- a/Xibeca/Core/Src/main.c +++ b/Xibeca/Core/Src/main.c @@ -484,8 +484,8 @@ static void MX_SAI1_Init(void) hsai_BlockA1.Init.PdmInit.MicPairsNbr = 1; hsai_BlockA1.Init.PdmInit.ClockEnable = SAI_PDM_CLOCK1_ENABLE; hsai_BlockA1.FrameInit.FrameLength = 256; - hsai_BlockA1.FrameInit.ActiveFrameLength = 1; - hsai_BlockA1.FrameInit.FSDefinition = SAI_FS_STARTFRAME; + hsai_BlockA1.FrameInit.ActiveFrameLength = 128; + hsai_BlockA1.FrameInit.FSDefinition = SAI_FS_CHANNEL_IDENTIFICATION; hsai_BlockA1.FrameInit.FSPolarity = SAI_FS_ACTIVE_HIGH; hsai_BlockA1.FrameInit.FSOffset = SAI_FS_BEFOREFIRSTBIT; hsai_BlockA1.SlotInit.FirstBitOffset = 0; @@ -513,8 +513,8 @@ static void MX_SAI1_Init(void) hsai_BlockB1.Init.PdmInit.MicPairsNbr = 1; hsai_BlockB1.Init.PdmInit.ClockEnable = SAI_PDM_CLOCK1_ENABLE; hsai_BlockB1.FrameInit.FrameLength = 256; - hsai_BlockB1.FrameInit.ActiveFrameLength = 1; - hsai_BlockB1.FrameInit.FSDefinition = SAI_FS_STARTFRAME; + hsai_BlockB1.FrameInit.ActiveFrameLength = 128; + hsai_BlockB1.FrameInit.FSDefinition = SAI_FS_CHANNEL_IDENTIFICATION; hsai_BlockB1.FrameInit.FSPolarity = SAI_FS_ACTIVE_HIGH; hsai_BlockB1.FrameInit.FSOffset = SAI_FS_BEFOREFIRSTBIT; hsai_BlockB1.SlotInit.FirstBitOffset = 0; @@ -1121,11 +1121,11 @@ void StartDefaultTask(void const * argument) void Error_Handler(void) { /* USER CODE BEGIN Error_Handler_Debug */ - /* User can add his own implementation to report the HAL error return state */ - __disable_irq(); - while (1) - { - } +#ifdef DEBUG + __asm__("BKPT"); +#else + NVIC_SystemReset(); +#endif /* USER CODE END Error_Handler_Debug */ } @@ -1138,10 +1138,13 @@ void Error_Handler(void) * @retval None */ void assert_failed(uint8_t *file, uint32_t line) -{ +{ /* USER CODE BEGIN 6 */ - /* User can add his own implementation to report the file name and line number, - ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ +#ifdef DEBUG + __asm__("BKPT"); +#else + NVIC_SystemReset(); +#endif /* USER CODE END 6 */ } #endif /* USE_FULL_ASSERT */ diff --git a/Xibeca/Core/Src/stm32h7xx_hal_msp.c b/Xibeca/Core/Src/stm32h7xx_hal_msp.c index 34efac08..5fd56007 100644 --- a/Xibeca/Core/Src/stm32h7xx_hal_msp.c +++ b/Xibeca/Core/Src/stm32h7xx_hal_msp.c @@ -382,14 +382,14 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) GPIO_InitStruct.Pin = ADC_SPI_MISO_Pin|ADC_SPI_MOSI_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF5_SPI2; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); GPIO_InitStruct.Pin = ADC_SPI_CLK_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF5_SPI2; HAL_GPIO_Init(ADC_SPI_CLK_GPIO_Port, &GPIO_InitStruct); diff --git a/Xibeca/Xibeca.ioc b/Xibeca/Xibeca.ioc index 076698cd..920e3469 100644 --- a/Xibeca/Xibeca.ioc +++ b/Xibeca/Xibeca.ioc @@ -26,6 +26,7 @@ USB_DEVICE.PID_AUDIO_FS=0xDADA SH.GPXTI7.ConfNb=1 NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false SH.FMC_D25.0=FMC_D25,sd-32b-d1 +SAI1.FSDefinition-SAI_B_SyncSlave=SAI_FS_CHANNEL_IDENTIFICATION SH.FMC_NBL2.ConfNb=1 SH.S_TIM3_CH2.ConfNb=1 PF7.Signal=UART7_TX @@ -46,6 +47,7 @@ PA0.Locked=true VP_USB_HOST_VS_USB_HOST_AUDIO_HS.Mode=AUDIO_HS ProjectManager.FirmwarePackage=STM32Cube FW_H7 V1.9.0 USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology +PC2_C.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH ProjectManager.BackupPrevious=false RCC.FMCFreq_Value=240000000 RCC.SAI1CLockSelection=RCC_SAI1CLKSOURCE_PLL3 @@ -77,6 +79,7 @@ PD12.Signal=S_TIM4_CH1 SH.FMC_SDNCAS.ConfNb=1 VP_SYS_VS_Systick.Signal=SYS_VS_Systick SAI1.FSPolarity-SAI_B_SyncSlave=SAI_FS_ACTIVE_HIGH +PC3_C.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH PC3_C.GPIO_Label=ADC_SPI_MOSI SH.FMC_A11.ConfNb=1 SH.FMC_D27.0=FMC_D27,sd-32b-d1 @@ -258,6 +261,7 @@ SH.FMC_D14_DA14.0=FMC_D14,sd-32b-d1 PH0-OSC_IN\ (PH0).Signal=RCC_OSC_IN PG2.Signal=FMC_A12 SAI1.FrameLength-SAI_B_SyncSlave=256 +SAI1.FSDefinition-SAI_A_MasterWithClock=SAI_FS_CHANNEL_IDENTIFICATION PA0.GPIO_Label=EXTI0 PA11.Mode=Device_Only RCC.PLL2FRACN=6144 @@ -284,6 +288,7 @@ SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE Dma.SAI1_B.1.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT RCC.DIVP3Freq_Value=98285714.2857143 RCC.SDMMCFreq_Value=192000000 +SAI1.ActiveFrameLength-SAI_B_SyncSlave=128 ProjectManager.PreviousToolchain= SH.FMC_NBL1.0=FMC_NBL1,Sd4ByteEnable1 FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configUSE_IDLE_HOOK,configUSE_TICK_HOOK,configUSE_MALLOC_FAILED_HOOK,INCLUDE_vTaskDelayUntil,configUSE_MUTEXES,configCHECK_FOR_STACK_OVERFLOW,FootprintOK @@ -555,7 +560,7 @@ RCC.SAI23Freq_Value=192000000 PF14.Signal=FMC_A8 NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false SAI1.FrameLength-SAI_A_MasterWithClock=256 -PB10.GPIOParameters=GPIO_Label +PB10.GPIOParameters=GPIO_Speed,GPIO_Label PI11.Signal=GPXTI11 PH0-OSC_IN\ (PH0).Mode=HSE-External-Oscillator PE6.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH @@ -592,7 +597,7 @@ SH.FMC_D31.ConfNb=1 RCC.SPI123Freq_Value=25000000 Dma.SAI1_A.0.RequestNumber=1 SH.FMC_D15_DA15.0=FMC_D15,sd-32b-d1 -PC3_C.GPIOParameters=GPIO_Label +PC3_C.GPIOParameters=GPIO_Speed,GPIO_Label USB_HOST.VirtualModeHS=Audio PA9.Signal=USB_OTG_FS_VBUS RCC.DIVN3=172 @@ -692,6 +697,7 @@ RCC.CortexFreq_Value=480000000 SH.FMC_A2.ConfNb=1 PG6.Signal=QUADSPI_BK1_NCS Mcu.UserName=STM32H743IIKx +PB10.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH Dma.SPI3_TX.2.Instance=DMA1_Stream2 RCC.HPRE=RCC_HCLK_DIV2 PC10.Locked=true @@ -703,6 +709,7 @@ SH.FMC_D6_DA6.0=FMC_D6,sd-32b-d1 PC9.Locked=true PC13.GPIO_Label=EXTI13 PB11.Signal=GPIO_Output +SAI1.ActiveFrameLength-SAI_A_MasterWithClock=128 Dma.SPI3_TX.2.SyncSignalID=NONE PE5.GPIOParameters=GPIO_Speed ProjectManager.StackSize=0x400 @@ -830,7 +837,7 @@ SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_TX Dma.SAI1_A.0.Priority=DMA_PRIORITY_VERY_HIGH PG14.Signal=GPIO_Output SH.S_TIM3_CH2.0=TIM3_CH2,Encoder_Interface -SAI1.IPParameters=Instance-SAI_A_MasterWithClock,VirtualMode-SAI_A_MasterWithClock,MClockEnable-SAI_A_MasterWithClock,RealAudioFreq-SAI_A_MasterWithClock,ErrorAudioFreq-SAI_A_MasterWithClock,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,FrameLength-SAI_A_MasterWithClock,FrameLength-SAI_B_SyncSlave,DataSize-SAI_A_MasterWithClock,SlotSize-SAI_A_MasterWithClock,SlotSize-SAI_B_SyncSlave,SlotNumber-SAI_A_MasterWithClock,AudioFrequency-SAI_A_MasterWithClock,DataSize-SAI_B_SyncSlave,SlotNumber-SAI_B_SyncSlave,AudioMode-SAI_A_MasterWithClock,AudioMode-SAI_B_SyncSlave,FSOffset-SAI_A_MasterWithClock,FSOffset-SAI_B_SyncSlave,FSPolarity-SAI_A_MasterWithClock,FSPolarity-SAI_B_SyncSlave,VirtualSlotActive-SAI_A_MasterWithClock,SlotActive-SAI_A_MasterWithClock,NoDivider-SAI_A_MasterWithClock,ClockStrobing-SAI_A_MasterWithClock,OutputDrive-SAI_A_MasterWithClock,VirtualSlotActive-SAI_B_SyncSlave,SlotActive-SAI_B_SyncSlave,OutputDrive-SAI_B_SyncSlave +SAI1.IPParameters=Instance-SAI_A_MasterWithClock,VirtualMode-SAI_A_MasterWithClock,MClockEnable-SAI_A_MasterWithClock,RealAudioFreq-SAI_A_MasterWithClock,ErrorAudioFreq-SAI_A_MasterWithClock,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,FrameLength-SAI_A_MasterWithClock,FrameLength-SAI_B_SyncSlave,DataSize-SAI_A_MasterWithClock,SlotSize-SAI_A_MasterWithClock,SlotSize-SAI_B_SyncSlave,SlotNumber-SAI_A_MasterWithClock,AudioFrequency-SAI_A_MasterWithClock,DataSize-SAI_B_SyncSlave,SlotNumber-SAI_B_SyncSlave,AudioMode-SAI_A_MasterWithClock,AudioMode-SAI_B_SyncSlave,FSOffset-SAI_A_MasterWithClock,FSOffset-SAI_B_SyncSlave,FSPolarity-SAI_A_MasterWithClock,FSPolarity-SAI_B_SyncSlave,VirtualSlotActive-SAI_A_MasterWithClock,SlotActive-SAI_A_MasterWithClock,NoDivider-SAI_A_MasterWithClock,ClockStrobing-SAI_A_MasterWithClock,OutputDrive-SAI_A_MasterWithClock,VirtualSlotActive-SAI_B_SyncSlave,SlotActive-SAI_B_SyncSlave,OutputDrive-SAI_B_SyncSlave,FSDefinition-SAI_A_MasterWithClock,FSDefinition-SAI_B_SyncSlave,ActiveFrameLength-SAI_A_MasterWithClock,ActiveFrameLength-SAI_B_SyncSlave SH.GPXTI3.0=GPIO_EXTI3 RCC.VCOInput1Freq_Value=8000000 PG7.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH @@ -861,7 +868,7 @@ SH.ADCx_INP11.0=ADC1_INP11,IN11-Single-Ended ADC1.NbrOfConversionFlag=1 SAI1.FSOffset-SAI_B_SyncSlave=SAI_FS_BEFOREFIRSTBIT RCC.DIVQ1Freq_Value=192000000 -PC2_C.GPIOParameters=GPIO_Label +PC2_C.GPIOParameters=GPIO_Speed,GPIO_Label Dma.SAI1_B.1.SyncRequestNumber=1 RCC.D3PPRE=RCC_APB4_DIV2 PC9.Signal=SharedStack_PC9 From 55ac3fc627f5e0515edab0556e3c526a938ae022 Mon Sep 17 00:00:00 2001 From: antisvin Date: Thu, 5 Aug 2021 22:53:41 +0300 Subject: [PATCH 041/286] Let's be twice as generous with parameters for Magus --- Magus/Inc/hardware.h | 2 +- Magus/Src/Magus.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Magus/Inc/hardware.h b/Magus/Inc/hardware.h index 76f7ded3..71002559 100644 --- a/Magus/Inc/hardware.h +++ b/Magus/Inc/hardware.h @@ -50,7 +50,7 @@ #undef USE_ADC #define NOF_ADC_VALUES 0 -#define NOF_PARAMETERS 20 +#define NOF_PARAMETERS 40 #define NOF_BUTTONS 0 #undef USE_DAC diff --git a/Magus/Src/Magus.cpp b/Magus/Src/Magus.cpp index e3aac9c2..d360e361 100644 --- a/Magus/Src/Magus.cpp +++ b/Magus/Src/Magus.cpp @@ -195,5 +195,8 @@ void loop(void){ MAX11300_setDAC(i+1, graphics.params.parameters[i]); } } + for(int i=20; i < 40; i++) { + graphics.params.updateValue(i, 0); + } // MAX11300_bulkwriteDAC(); } From 2c45445156b3c4fd1253ecaf666f910002490b3d Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Sat, 28 Aug 2021 11:56:11 +0200 Subject: [PATCH 042/286] enable/disable hpf on CS4271 --- Source/Codec.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/Codec.cpp b/Source/Codec.cpp index 8bd17b6c..33c3f847 100644 --- a/Source/Codec.cpp +++ b/Source/Codec.cpp @@ -290,6 +290,12 @@ void Codec::setHighPass(bool hpf){ else codec_write(82, 0b00000111); // disable HPF for all ADC channels #endif +#ifdef USE_CS4271 + if(hpf) + codec_write(0x06, 0x10); // hp filters enabled + else + codec_write(0x06, 0x10 | 0x03 ); // hp filters disabled +#endif } #ifdef USE_IIS3DWB From e79a5135e07615a90222ad9b88db3011124581df Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Sat, 28 Aug 2021 11:56:48 +0200 Subject: [PATCH 043/286] use modulus instead of conditional --- Source/SerialBuffer.hpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/Source/SerialBuffer.hpp b/Source/SerialBuffer.hpp index 3a773fc4..18deda2f 100644 --- a/Source/SerialBuffer.hpp +++ b/Source/SerialBuffer.hpp @@ -42,14 +42,12 @@ class SerialBuffer { } void push(T c){ - buffer[writepos++] = c; - if(writepos >= size) - writepos = 0; + buffer[writepos] = c; + writepos = (writepos + 1) % size; } T pull(){ - T c = buffer[readpos++]; - if(readpos >= size) - readpos = 0; + T c = buffer[readpos]; + readpos = (readpos + 1) % size; return c; } @@ -99,9 +97,7 @@ class SerialBuffer { void incrementReadHead(size_t len){ // ASSERT((readpos >= writepos && readpos+len <= size) || // (readpos < writepos && readpos+len <= writepos), "uart rx underflow"); - readpos += len; - if(readpos >= size) - readpos -= size; + readpos = (readpos + len) % size; } bool notEmpty(){ return writepos != readpos; From eeee5ff2102391c584cf970a32fe35e38710ef1f Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Sat, 28 Aug 2021 11:57:35 +0200 Subject: [PATCH 044/286] remove disused AUDIO_MAX_BLOCK_SIZE --- Source/device.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Source/device.h b/Source/device.h index a817c6d7..fda8729b 100644 --- a/Source/device.h +++ b/Source/device.h @@ -134,7 +134,6 @@ #define AUDIO_SAMPLINGRATE 48000 #endif #define AUDIO_BLOCK_SIZE CODEC_BLOCKSIZE /* size in samples of a single channel audio block */ -#define AUDIO_MAX_BLOCK_SIZE (CODEC_BUFFER_SIZE/4) #define USBD_AUDIO_RX_FREQ AUDIO_SAMPLINGRATE #define USBD_AUDIO_TX_FREQ AUDIO_SAMPLINGRATE @@ -170,11 +169,11 @@ #define USE_EXTERNAL_RAM #endif -#ifndef NO_CCM_RAM -#define USE_CCM_RAM -#define CCM_RAM __attribute__ ((section (".ccmdata"))) -#else +#ifdef NO_CCM_RAM #define CCM_RAM +#else +#define USE_CCM_RAM +#define CCM_RAM __attribute__ ((section (".ccmdata"))) #endif #ifndef DMA_RAM From 363943800104d0aeaf8d6d7f4cf706adfab7806c Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Sat, 28 Aug 2021 11:58:09 +0200 Subject: [PATCH 045/286] changed preprocessing conditional --- Source/ScreenBuffer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/ScreenBuffer.h b/Source/ScreenBuffer.h index 2f400661..d8599470 100644 --- a/Source/ScreenBuffer.h +++ b/Source/ScreenBuffer.h @@ -29,8 +29,8 @@ typedef uint16_t Colour; #define CYAN 0x07FF #define MAGENTA 0xFFE0 #define WHITE 0xFFFF -#else -#error "Invalid configuration" +#elif defined USE_SCREEN +#error "Invalid screen configuration" #endif class ScreenBuffer { From e7ee1880450d6297270e8258ac30204a580f0792 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Sat, 28 Aug 2021 12:00:14 +0200 Subject: [PATCH 046/286] Moved midi rx/tx from onProgramReady to Owl::loop in case patch is not running. Changed audio_format setting to always include channel count --- Source/Owl.cpp | 2 ++ Source/ProgramManager.cpp | 7 +------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Source/Owl.cpp b/Source/Owl.cpp index 929ecfc3..323974d3 100644 --- a/Source/Owl.cpp +++ b/Source/Owl.cpp @@ -215,6 +215,8 @@ void Owl::setOperationMode(OperationMode mode){ } void Owl::loop(){ + midi_tx.transmit(); + midi_rx.receive(); // push queued up MIDI messages through to patch #ifdef USE_DIGITALBUS busstatus = bus_status(); #endif diff --git a/Source/ProgramManager.cpp b/Source/ProgramManager.cpp index dec09b11..1f63039b 100644 --- a/Source/ProgramManager.cpp +++ b/Source/ProgramManager.cpp @@ -140,7 +140,6 @@ void setButtonValue(uint8_t ch, uint8_t value){ /* called by the program when a block has been processed */ void onProgramReady(){ - midi_tx.transmit(); ProgramVector* pv = getProgramVector(); #ifdef DEBUG_DWT pv->cycles_per_block = DWT->CYCCNT; @@ -151,7 +150,6 @@ void onProgramReady(){ #ifdef DEBUG_DWT DWT->CYCCNT = 0; #endif - midi_rx.receive(); // push queued up MIDI messages through to patch #ifdef USE_ADC #ifdef USE_SCREEN updateParameters(graphics.params.parameters, NOF_PARAMETERS, adc_values, NOF_ADC_VALUES); @@ -281,11 +279,8 @@ void updateProgramVector(ProgramVector* pv, PatchDefinition* def){ pv->heapSegments = (MemorySegment*)heapSegments; #ifdef USE_WM8731 pv->audio_format = AUDIO_FORMAT_24B16_2X; -#elif defined OWL_BIOSIGNALS || defined OWL_NOCTUA - pv->audio_format = AUDIO_FORMAT_24B32 | AUDIO_CHANNELS; #else - pv->audio_format = AUDIO_FORMAT_24B32; - // pv->audio_format = AUDIO_FORMAT_24B32_2X; + pv->audio_format = AUDIO_FORMAT_24B32 | AUDIO_CHANNELS; #endif #endif /* PROGRAM_VECTOR_V13 */ pv->message = NULL; From 94b09e526713032addb894eb29b1ca9e576f0a7c Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Sat, 28 Aug 2021 12:21:16 +0200 Subject: [PATCH 047/286] moved fw stack to ITCM, partitioned for CCMRAM, disable bootloader --- Hardware/owl3.ld | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/Hardware/owl3.ld b/Hardware/owl3.ld index 881f2032..f86ed448 100644 --- a/Hardware/owl3.ld +++ b/Hardware/owl3.ld @@ -2,24 +2,31 @@ ENTRY(Reset_Handler) /* Generate a link error if heap and stack don't fit into RAM */ -_Min_Heap_Size = 0x000; /* required amount of heap */ +_Min_Heap_Size = 0x200; /* required amount of heap */ _Min_Stack_Size = 0x200; /* required amount of stack */ /* Specify the memory areas */ MEMORY { -DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 48K + /* DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K */ + /* RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 512K */ + /* RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K */ + /* RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K */ + /* ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K */ + /* FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 2048K */ +DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 48K PATCHRAM (rwx) : ORIGIN = 0x2000c000, LENGTH = 80K PLUSRAM (xrw) : ORIGIN = 0x24000000, LENGTH = 512K /* D1 RAM */ HEAP_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 256K -DMA_D2 (xrw) : ORIGIN = 0x30040000, LENGTH = 32K -RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K -ITCMRAM (xrw) : ORIGIN = 0x00000008, LENGTH = 65528 /* 64K - 8 to avoid starting at 0x0 - FreeRTOS fails if stack address is NULL */ +DMA_D2 (xrw) : ORIGIN = 0x30040000, LENGTH = 32K +RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K +ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 2K +CCMRAM (xrw) : ORIGIN = 0x00000800, LENGTH = 62K EXTRAM (rwx) : ORIGIN = 0xD0000000, LENGTH = 8M -/* BOOTLOADER (rx) : ORIGIN = 0x08000000, LENGTH = 0K */ -/* FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K */ -BOOTLOADER (rx) : ORIGIN = 0x08000000, LENGTH = 128K -FLASH (rx) : ORIGIN = 0x08020000, LENGTH = 384K +BOOTLOADER (rx) : ORIGIN = 0x08000000, LENGTH = 0K +FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K +/* BOOTLOADER (rx) : ORIGIN = 0x08000000, LENGTH = 128K */ +/* FLASH (rx) : ORIGIN = 0x08020000, LENGTH = 384K */ STORAGE (rx) : ORIGIN = 0x08080000, LENGTH = 512K /* Assuming 1Mb FLASH */ /* STORAGE (rx) : ORIGIN = 0x08080000, LENGTH = 1536K /\* Assuming 2Mb FLASH *\/ */ } @@ -122,19 +129,18 @@ SECTIONS . = ALIGN(4); _ebss = .; /* define a global symbol at bss end */ __bss_end__ = _ebss; + + end = .; /* system heap, used e.g. by printf in DEBUG builds */ + . = . + _Min_Heap_Size; } >DTCMRAM /* User_heap_stack section, used to check that there is enough RAM left */ ._user_heap_stack : { - . = ALIGN(8); - PROVIDE ( end = . ); - PROVIDE ( _end = . ); - . = . + _Min_Heap_Size; . = . + _Min_Stack_Size; . = ALIGN(8); - } >DTCMRAM - _estack = ORIGIN(DTCMRAM)+LENGTH(DTCMRAM); + } >ITCMRAM + _estack = ORIGIN(ITCMRAM)+LENGTH(ITCMRAM); /* CCM section, vars must be located here explicitly */ /* Example: int foo __attribute__ ((section (".ccmdata"))); */ @@ -143,8 +149,8 @@ SECTIONS *(.ccmdata) . = ALIGN(8); PROVIDE (_CCMRAM = .); - } >ITCMRAM - _CCMRAM_END = ORIGIN(ITCMRAM) + LENGTH(ITCMRAM); + } >CCMRAM + _CCMRAM_END = ORIGIN(CCMRAM) + LENGTH(CCMRAM); _CCMRAM_SIZE = _CCMRAM_END - _CCMRAM; /* Bootloader end will be used for finding bootloader token */ From 3e50f9ce06cc121f473d2ee5009e0d877e80b00c Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Sat, 28 Aug 2021 12:22:19 +0200 Subject: [PATCH 048/286] mostly working on Xibeca/PolyVCO w/o screen and extram --- Xibeca/Core/Inc/hardware.h | 14 +++++++++----- Xibeca/Core/Src/Xibeca.cpp | 8 ++++++-- Xibeca/Core/Src/main.c | 8 +++++--- Xibeca/Core/Src/system_stm32h7xx.c | 26 +++----------------------- Xibeca/Makefile | 8 ++++---- 5 files changed, 27 insertions(+), 37 deletions(-) diff --git a/Xibeca/Core/Inc/hardware.h b/Xibeca/Core/Inc/hardware.h index 145047bd..232a9aa6 100644 --- a/Xibeca/Core/Inc/hardware.h +++ b/Xibeca/Core/Inc/hardware.h @@ -5,15 +5,19 @@ #define HARDWARE_ID XIBECA_HARDWARE #define HARDWARE_VERSION "Xibeca" #define NO_EXTERNAL_RAM +/* #define NO_CCM_RAM */ #define DMA_RAM __attribute__ ((section (".dmadata"))) #define USE_PLUS_RAM /* #define USE_ICACHE */ /* #define USE_DCACHE */ -#define USE_SCREEN -#define SSD1309 -#define OLED_SOFT_CS -#define OLED_SPI hspi3 +/* #define USE_SCREEN */ +/* #define SSD1309 */ +/* #define OLED_SOFT_CS */ +/* #define OLED_SPI hspi3 */ + +// todo: quad SPI +/* #define USE_SPI_FLASH */ /* #define USE_ADC */ #define ADC_PERIPH hadc1 @@ -43,7 +47,7 @@ #define USBD_AUDIO_TX_CHANNELS 4 #define USE_USBD_AUDIO -/* #define USE_USBD_AUDIO_TX // microphone */ +#define USE_USBD_AUDIO_TX // microphone /* #define USE_USBD_AUDIO_RX // speaker */ #define USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS diff --git a/Xibeca/Core/Src/Xibeca.cpp b/Xibeca/Core/Src/Xibeca.cpp index ef1160f4..30a68d4e 100644 --- a/Xibeca/Core/Src/Xibeca.cpp +++ b/Xibeca/Core/Src/Xibeca.cpp @@ -1,11 +1,13 @@ #include "Owl.h" #include "device.h" #include "errorhandlers.h" -#include "Graphics.h" #include "Pin.h" #include "ApplicationSettings.h" +#ifdef USE_SCREEN +#include "Graphics.h" Graphics graphics; +#endif extern "C" void onResourceUpdate(void); @@ -17,10 +19,12 @@ void onResourceUpdate(void){ void setup(){ +#ifdef USE_SCREEN HAL_GPIO_WritePin(OLED_RST_GPIO_Port, OLED_RST_Pin, GPIO_PIN_RESET); // OLED off extern SPI_HandleTypeDef OLED_SPI; graphics.begin(&OLED_SPI); - +#endif + // #ifdef USE_USB_HOST // // enable USB Host power // HAL_GPIO_WritePin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin, GPIO_PIN_SET); diff --git a/Xibeca/Core/Src/main.c b/Xibeca/Core/Src/main.c index e0ddd9df..27695376 100644 --- a/Xibeca/Core/Src/main.c +++ b/Xibeca/Core/Src/main.c @@ -131,9 +131,11 @@ int main(void) #endif /* Enable D2 domain SRAM Clocks */ - __HAL_RCC_D2SRAM1_CLK_ENABLE(); - __HAL_RCC_D2SRAM2_CLK_ENABLE(); - __HAL_RCC_D2SRAM3_CLK_ENABLE(); + /* presumably done in SystemInit by setting DATA_IN_D2_SRAM ? */ + /* should be started before libc_init_array and LoopCopyData in startup.s */ + /* __HAL_RCC_D2SRAM1_CLK_ENABLE(); */ + /* __HAL_RCC_D2SRAM2_CLK_ENABLE(); */ + /* __HAL_RCC_D2SRAM3_CLK_ENABLE(); */ /* USER CODE END 1 */ diff --git a/Xibeca/Core/Src/system_stm32h7xx.c b/Xibeca/Core/Src/system_stm32h7xx.c index 8dccfb9b..9ae8b842 100644 --- a/Xibeca/Core/Src/system_stm32h7xx.c +++ b/Xibeca/Core/Src/system_stm32h7xx.c @@ -78,13 +78,8 @@ /************************* Miscellaneous Configuration ************************/ /*!< Uncomment the following line if you need to use initialized data in D2 domain SRAM (AHB SRAM) */ -/* #define DATA_IN_D2_SRAM */ +#define DATA_IN_D2_SRAM -/*!< Uncomment the following line if you need to relocate your vector Table in - Internal SRAM. */ -/* #define VECT_TAB_SRAM */ -#define VECT_TAB_OFFSET 0x00000000UL /*!< Vector Table base offset field. - This value must be a multiple of 0x200. */ /******************************************************************************/ /** @@ -243,16 +238,6 @@ void SystemInit (void) (void) tmpreg; #endif /* DATA_IN_D2_SRAM */ -#if defined(DUAL_CORE) && defined(CORE_CM4) - /* Configure the Vector Table location add offset address for cortex-M4 ------------------*/ -#ifdef VECT_TAB_SRAM - SCB->VTOR = D2_AXISRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ -#else - SCB->VTOR = FLASH_BANK2_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ -#endif /* VECT_TAB_SRAM */ - -#else - /* * Disable the FMC bank1 (enabled after reset). * This, prevents CPU speculation access on this bank which blocks the use of FMC during @@ -261,13 +246,8 @@ void SystemInit (void) FMC_Bank1_R->BTCR[0] = 0x000030D2; /* Configure the Vector Table location add offset address for cortex-M7 ------------------*/ -#ifdef VECT_TAB_SRAM - SCB->VTOR = D1_AXISRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal AXI-RAM */ -#else - SCB->VTOR = FLASH_BANK1_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ -#endif - -#endif /*DUAL_CORE && CORE_CM4*/ + extern char _ISR_VECTOR; + SCB->VTOR = (uint32_t)&_ISR_VECTOR; } diff --git a/Xibeca/Makefile b/Xibeca/Makefile index b77db209..010d0175 100644 --- a/Xibeca/Makefile +++ b/Xibeca/Makefile @@ -11,10 +11,10 @@ C_SRC += $(OPENWARE)/Source/pcm3168a.c C_SRC += $(OPENWARE)/Source/usbd_audio.c CPP_SRC += $(OPENWARE)/Source/usbh_midi.cpp -C_SRC += $(OPENWARE)/Source/ssd1309.c -CPP_SRC += $(OPENWARE)/Source/ScreenBuffer.cpp -CPP_SRC += $(OPENWARE)/Source/ScreenBufferMono.cpp -CPP_SRC += $(OPENWARE)/Source/Graphics.cpp +# C_SRC += $(OPENWARE)/Source/ssd1309.c +# CPP_SRC += $(OPENWARE)/Source/ScreenBuffer.cpp +# CPP_SRC += $(OPENWARE)/Source/ScreenBufferMono.cpp +# CPP_SRC += $(OPENWARE)/Source/Graphics.cpp # CPP_SRC += $(OPENWARE)/Source/uart.cpp # CPP_SRC += $(OPENWARE)/Source/MidiStreamReader.cpp From 94574fe40f31d5d03541a56cd00e955212f0db05 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Sat, 28 Aug 2021 12:23:44 +0200 Subject: [PATCH 049/286] removed OLED_SOFT_CS option --- Source/seps114a.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Source/seps114a.c b/Source/seps114a.c index 0d62360a..842cbba2 100644 --- a/Source/seps114a.c +++ b/Source/seps114a.c @@ -46,13 +46,8 @@ #define SEPS114A_RGB_POL 0xE1 #define SEPS114A_DISPLAY_MODE_CONTROL 0xE5 -#ifdef OLED_SOFT_CS #define setCS() setPin(OLED_CS_GPIO_Port, OLED_CS_Pin) #define clearCS() clearPin(OLED_CS_GPIO_Port, OLED_CS_Pin) -#else -#define setCS() -#define clearCS() -#endif #define setDC() setPin(OLED_DC_GPIO_Port, OLED_DC_Pin) #define clearDC() clearPin(OLED_DC_GPIO_Port, OLED_DC_Pin) #define clearRST() clearPin(OLED_RST_GPIO_Port, OLED_RST_Pin); From abdf6d726d92ce0bd1085849a938f6a0c5b2407c Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Sat, 28 Aug 2021 13:32:48 +0200 Subject: [PATCH 050/286] config changes --- Xibeca/Core/Inc/hardware.h | 37 ++++++++++++++----------------------- Xibeca/Core/Src/Xibeca.cpp | 15 --------------- Xibeca/Core/Src/main.c | 2 +- 3 files changed, 15 insertions(+), 39 deletions(-) diff --git a/Xibeca/Core/Inc/hardware.h b/Xibeca/Core/Inc/hardware.h index 232a9aa6..068d8f0c 100644 --- a/Xibeca/Core/Inc/hardware.h +++ b/Xibeca/Core/Inc/hardware.h @@ -11,25 +11,14 @@ /* #define USE_ICACHE */ /* #define USE_DCACHE */ -/* #define USE_SCREEN */ -/* #define SSD1309 */ -/* #define OLED_SOFT_CS */ -/* #define OLED_SPI hspi3 */ +#define USE_SCREEN +#define SSD1309 +#define SSD1306 +#define OLED_SPI hspi3 // todo: quad SPI /* #define USE_SPI_FLASH */ -/* #define USE_ADC */ -#define ADC_PERIPH hadc1 -#define ADC_A 0 -#define ADC_B 1 -#define ADC_C 2 -#define ADC_D 3 -#define ADC_E 4 -#define ADC_F 5 -#define ADC_G 6 -#define ADC_H 7 - #define USE_CODEC #define USE_PCM3168A /* #define CODEC_HP_FILTER */ @@ -52,10 +41,6 @@ #define USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS /* #define USBD_MAX_POWER 100 // 200mA for iPad compatibility */ -#define USE_USB_HOST -#define USB_HOST_RX_BUFF_SIZE 256 /* Max Received data 64 bytes */ -#define USE_USBH_MIDI -#define USBH_HANDLE hUsbHostHS /* #define USE_UART_MIDI_RX */ /* #define USE_UART_MIDI_TX */ @@ -64,10 +49,16 @@ #define AUDIO_SAMPLINGRATE 48000 -#define USB_HOST_PWR_EN_GPIO_Port GPIOB -#define USB_HOST_PWR_EN_Pin GPIO_PIN_0 // PB0 is unused -#define USB_HOST_PWR_FAULT_GPIO_Port GPIOB -#define USB_HOST_PWR_FAULT_Pin GPIO_PIN_1 // PB1 is unused +#define USE_ADC +#define ADC_PERIPH hadc1 +#define ADC_A 0 +#define ADC_B 1 +#define ADC_C 2 +#define ADC_D 3 +#define ADC_E 4 +#define ADC_F 5 +#define ADC_G 6 +#define ADC_H 7 #define NOF_ADC_VALUES 8 #define NOF_PARAMETERS 40 diff --git a/Xibeca/Core/Src/Xibeca.cpp b/Xibeca/Core/Src/Xibeca.cpp index 30a68d4e..357be92f 100644 --- a/Xibeca/Core/Src/Xibeca.cpp +++ b/Xibeca/Core/Src/Xibeca.cpp @@ -25,27 +25,12 @@ void setup(){ graphics.begin(&OLED_SPI); #endif -// #ifdef USE_USB_HOST -// // enable USB Host power -// HAL_GPIO_WritePin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin, GPIO_PIN_SET); -// #endif owl.setup(); } void loop(void){ -// #ifdef USE_USB_HOST -// if(HAL_GPIO_ReadPin(USB_HOST_PWR_FAULT_GPIO_Port, USB_HOST_PWR_FAULT_Pin) == GPIO_PIN_RESET){ -// if(HAL_GPIO_ReadPin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin) == GPIO_PIN_SET){ -// HAL_GPIO_WritePin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin, GPIO_PIN_RESET); -// error(USB_ERROR, "USBH PWR Fault"); -// } -// }else{ -// MX_USB_HOST_Process(); -// } -// #endif - #ifdef USE_SCREEN graphics.draw(); graphics.display(); diff --git a/Xibeca/Core/Src/main.c b/Xibeca/Core/Src/main.c index 27695376..a0323d91 100644 --- a/Xibeca/Core/Src/main.c +++ b/Xibeca/Core/Src/main.c @@ -604,7 +604,7 @@ static void MX_SPI3_Init(void) hspi3.Init.CLKPolarity = SPI_POLARITY_LOW; hspi3.Init.CLKPhase = SPI_PHASE_1EDGE; hspi3.Init.NSS = SPI_NSS_SOFT; - hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8; + hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16; hspi3.Init.FirstBit = SPI_FIRSTBIT_MSB; hspi3.Init.TIMode = SPI_TIMODE_DISABLE; hspi3.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; From dd7a34e651cee92782402f8af18fb40a2d06045f Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Sat, 28 Aug 2021 13:34:28 +0200 Subject: [PATCH 051/286] adc config --- Xibeca/Core/Src/main.c | 34 ++++++++++++++++++++++---- Xibeca/Core/Src/stm32h7xx_hal_msp.c | 2 +- Xibeca/Makefile | 8 +++---- Xibeca/USB_HOST/App/usb_host.c | 4 ++-- Xibeca/Xibeca.ioc | 37 ++++++++++++++++++++++------- 5 files changed, 65 insertions(+), 20 deletions(-) diff --git a/Xibeca/Core/Src/main.c b/Xibeca/Core/Src/main.c index a0323d91..4458e814 100644 --- a/Xibeca/Core/Src/main.c +++ b/Xibeca/Core/Src/main.c @@ -340,11 +340,11 @@ static void MX_ADC1_Init(void) hadc1.Instance = ADC1; hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1; hadc1.Init.Resolution = ADC_RESOLUTION_16B; - hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE; + hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE; hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV; hadc1.Init.LowPowerAutoWait = DISABLE; hadc1.Init.ContinuousConvMode = DISABLE; - hadc1.Init.NbrOfConversion = 1; + hadc1.Init.NbrOfConversion = 4; hadc1.Init.DiscontinuousConvMode = DISABLE; hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START; hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; @@ -365,9 +365,9 @@ static void MX_ADC1_Init(void) } /** Configure Regular Channel */ - sConfig.Channel = ADC_CHANNEL_4; + sConfig.Channel = ADC_CHANNEL_10; sConfig.Rank = ADC_REGULAR_RANK_1; - sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5; + sConfig.SamplingTime = ADC_SAMPLETIME_64CYCLES_5; sConfig.SingleDiff = ADC_SINGLE_ENDED; sConfig.OffsetNumber = ADC_OFFSET_NONE; sConfig.Offset = 0; @@ -376,6 +376,30 @@ static void MX_ADC1_Init(void) { Error_Handler(); } + /** Configure Regular Channel + */ + sConfig.Channel = ADC_CHANNEL_14; + sConfig.Rank = ADC_REGULAR_RANK_2; + if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /** Configure Regular Channel + */ + sConfig.Channel = ADC_CHANNEL_5; + sConfig.Rank = ADC_REGULAR_RANK_3; + if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /** Configure Regular Channel + */ + sConfig.Channel = ADC_CHANNEL_8; + sConfig.Rank = ADC_REGULAR_RANK_4; + if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) + { + Error_Handler(); + } /* USER CODE BEGIN ADC1_Init 2 */ /* USER CODE END ADC1_Init 2 */ @@ -1140,7 +1164,7 @@ void Error_Handler(void) * @retval None */ void assert_failed(uint8_t *file, uint32_t line) -{ +{ /* USER CODE BEGIN 6 */ #ifdef DEBUG __asm__("BKPT"); diff --git a/Xibeca/Core/Src/stm32h7xx_hal_msp.c b/Xibeca/Core/Src/stm32h7xx_hal_msp.c index 5fd56007..64c11cb0 100644 --- a/Xibeca/Core/Src/stm32h7xx_hal_msp.c +++ b/Xibeca/Core/Src/stm32h7xx_hal_msp.c @@ -413,7 +413,7 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_10; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.Alternate = GPIO_AF6_SPI3; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); diff --git a/Xibeca/Makefile b/Xibeca/Makefile index 010d0175..b77db209 100644 --- a/Xibeca/Makefile +++ b/Xibeca/Makefile @@ -11,10 +11,10 @@ C_SRC += $(OPENWARE)/Source/pcm3168a.c C_SRC += $(OPENWARE)/Source/usbd_audio.c CPP_SRC += $(OPENWARE)/Source/usbh_midi.cpp -# C_SRC += $(OPENWARE)/Source/ssd1309.c -# CPP_SRC += $(OPENWARE)/Source/ScreenBuffer.cpp -# CPP_SRC += $(OPENWARE)/Source/ScreenBufferMono.cpp -# CPP_SRC += $(OPENWARE)/Source/Graphics.cpp +C_SRC += $(OPENWARE)/Source/ssd1309.c +CPP_SRC += $(OPENWARE)/Source/ScreenBuffer.cpp +CPP_SRC += $(OPENWARE)/Source/ScreenBufferMono.cpp +CPP_SRC += $(OPENWARE)/Source/Graphics.cpp # CPP_SRC += $(OPENWARE)/Source/uart.cpp # CPP_SRC += $(OPENWARE)/Source/MidiStreamReader.cpp diff --git a/Xibeca/USB_HOST/App/usb_host.c b/Xibeca/USB_HOST/App/usb_host.c index 02c1c118..b24a9c71 100644 --- a/Xibeca/USB_HOST/App/usb_host.c +++ b/Xibeca/USB_HOST/App/usb_host.c @@ -23,7 +23,7 @@ #include "usb_host.h" #include "usbh_core.h" -#include "usbh_midi.h" +#include "usbh_audio.h" /* USER CODE BEGIN Includes */ @@ -81,7 +81,7 @@ void MX_USB_HOST_Init(void) { Error_Handler(); } - if (USBH_RegisterClass(&hUsbHostHS, USBH_MIDI_CLASS) != USBH_OK) + if (USBH_RegisterClass(&hUsbHostHS, USBH_AUDIO_CLASS) != USBH_OK) { Error_Handler(); } diff --git a/Xibeca/Xibeca.ioc b/Xibeca/Xibeca.ioc index 920e3469..b05fe954 100644 --- a/Xibeca/Xibeca.ioc +++ b/Xibeca/Xibeca.ioc @@ -44,6 +44,7 @@ PE1.Signal=FMC_NBL1 ProjectManager.ProjectBuild=false NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false PA0.Locked=true +ADC1.OffsetSignedSaturation-3\#ChannelRegularConversion=DISABLE VP_USB_HOST_VS_USB_HOST_AUDIO_HS.Mode=AUDIO_HS ProjectManager.FirmwarePackage=STM32Cube FW_H7 V1.9.0 USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology @@ -73,6 +74,7 @@ PB1.Signal=ADCx_INP5 PC10.Stacked=true SAI1.SlotActive-SAI_B_SyncSlave=0x0000FFFF SPI2.Mode=SPI_MODE_MASTER +ADC1.OversamplingMode=DISABLE RCC.PLL3FRACN=0 SPI3.Mode=SPI_MODE_MASTER PD12.Signal=S_TIM4_CH1 @@ -118,8 +120,8 @@ Mcu.Pin74=PH11 Dma.SAI1_B.1.MemInc=DMA_MINC_ENABLE Mcu.Pin71=PF10 Mcu.Pin72=PF9 -Mcu.Pin77=PG2 PC13.Locked=true +Mcu.Pin77=PG2 SAI1.MClockEnable-SAI_A_MasterWithClock=SAI_MASTERCLOCK_ENABLE PG5.Signal=FMC_A15_BA1 Mcu.Pin78=PC0 @@ -169,8 +171,8 @@ Mcu.Pin49=PH0-OSC_IN (PH0) Mcu.Pin46=PH2 Mcu.Pin47=PC9 SAI1.VirtualMode-SAI_A_MasterWithClock=VM_MASTER -PB14.Signal=USB_OTG_HS_DM PG6.GPIOParameters=GPIO_Label +PB14.Signal=USB_OTG_HS_DM Mcu.Pin40=PI11 Mcu.Pin41=PH13 Mcu.Pin44=PA9 @@ -200,6 +202,7 @@ Dma.SAI1_A.0.SyncRequestNumber=1 NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false FREERTOS.configUSE_MUTEXES=0 PF13.Signal=FMC_A7 +PC10.GPIOParameters=GPIO_Speed SH.SharedStack_PC8.0=SDMMC1_D0 SH.SharedStack_PC8.1=GPIO_EXTI8 SH.FMC_NBL2.0=FMC_NBL2,Sd4ByteEnable1 @@ -253,6 +256,7 @@ ProjectManager.MainLocation=Core/Src SH.SharedStack_PC12.0=SDMMC1_CK SH.FMC_A6.ConfNb=1 USB_DEVICE.CLASS_NAME_FS=AUDIO +ADC1.OffsetSignedSaturation-1\#ChannelRegularConversion=DISABLE SH.FMC_A8.0=FMC_A8,13b-sda1 ProjectManager.KeepUserCode=true PH14.Signal=FMC_D22 @@ -288,6 +292,7 @@ SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE Dma.SAI1_B.1.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT RCC.DIVP3Freq_Value=98285714.2857143 RCC.SDMMCFreq_Value=192000000 +ADC1.Channel-3\#ChannelRegularConversion=ADC_CHANNEL_8 SAI1.ActiveFrameLength-SAI_B_SyncSlave=128 ProjectManager.PreviousToolchain= SH.FMC_NBL1.0=FMC_NBL1,Sd4ByteEnable1 @@ -296,7 +301,7 @@ Dma.SAI1_B.1.Instance=DMA1_Stream1 Dma.SAI1_B.1.FIFOMode=DMA_FIFOMODE_DISABLE FREERTOS.configUSE_PREEMPTION=0 RCC.HRTIMFreq_Value=240000000 -ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_4 +ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_10 PH1-OSC_OUT\ (PH1).Mode=HSE-External-Oscillator RCC.DIVR3Freq_Value=98285714.2857143 RCC.HSE_VALUE=8000000 @@ -445,6 +450,8 @@ PF1.Signal=FMC_A1 VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_FS VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Mode=AUDIO_FS SH.FMC_D11_DA11.ConfNb=1 +ADC1.NbrOfConversion=4 +ADC1.OffsetNumber-2\#ChannelRegularConversion=ADC_OFFSET_NONE RCC.IPParameters=ADCFreq_Value,AHB12Freq_Value,AHB4Freq_Value,APB1Freq_Value,APB2Freq_Value,APB3Freq_Value,APB4Freq_Value,AXIClockFreq_Value,CECFreq_Value,CKPERFreq_Value,CortexFreq_Value,CpuClockFreq_Value,D1CPREFreq_Value,D1PPRE,D2PPRE1,D2PPRE2,D3PPRE,DFSDMACLkFreq_Value,DFSDMFreq_Value,DIVM1,DIVM2,DIVM3,DIVN1,DIVN2,DIVN3,DIVP1Freq_Value,DIVP2,DIVP2Freq_Value,DIVP3Freq_Value,DIVQ1,DIVQ1Freq_Value,DIVQ2Freq_Value,DIVQ3Freq_Value,DIVR1Freq_Value,DIVR2Freq_Value,DIVR3Freq_Value,FDCANFreq_Value,FMCFreq_Value,FamilyName,HCLK3ClockFreq_Value,HCLKFreq_Value,HPRE,HRTIMFreq_Value,HSE_VALUE,I2C123Freq_Value,I2C4Freq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPTIM345Freq_Value,LPUART1Freq_Value,LTDCFreq_Value,MCO1PinFreq_Value,MCO2PinFreq_Value,PLL2FRACN,PLL3FRACN,PLLFRACN,PLLSourceVirtual,PWR_Regulator_Voltage_Scale,QSPIFreq_Value,RNGFreq_Value,RTCFreq_Value,SAI1CLockSelection,SAI1Freq_Value,SAI23Freq_Value,SAI4AFreq_Value,SAI4BFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SPI123CLockSelection,SPI123Freq_Value,SPI45Freq_Value,SPI6Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,Tim1OutputFreq_Value,Tim2OutputFreq_Value,TraceFreq_Value,USART16Freq_Value,USART234578Freq_Value,USBCLockSelection,USBFreq_Value,VCO1OutputFreq_Value,VCO2OutputFreq_Value,VCO3OutputFreq_Value,VCOInput1Freq_Value,VCOInput2Freq_Value,VCOInput3Freq_Value ProjectManager.AskForMigrate=true PE0.Signal=FMC_NBL0 @@ -461,6 +468,8 @@ RCC.SYSCLKFreq_VALUE=480000000 RCC.I2C123Freq_Value=120000000 SH.SharedStack_PC8.ConfNb=2 SH.GPXTI4.0=GPIO_EXTI4 +ADC1.Rank-3\#ChannelRegularConversion=4 +ADC1.SamplingTime-3\#ChannelRegularConversion=ADC_SAMPLETIME_64CYCLES_5 KeepUserPlacement=false PC15-OSC32_OUT\ (OSC32_OUT).GPIO_Label=EXTI15 SH.ADCx_INP14.ConfNb=1 @@ -474,6 +483,7 @@ PC8.Locked=true SH.ADCx_INP3.ConfNb=1 SH.FMC_D8_DA8.ConfNb=1 PG14.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM +PC12.GPIO_Speed=GPIO_SPEED_FREQ_HIGH Dma.SAI1_A.0.SyncEnable=DISABLE PA3.GPIO_Label=EXTI3 SAI1.SlotActive-SAI_A_MasterWithClock=0x0000FFFF @@ -511,6 +521,7 @@ PH5.Signal=FMC_SDNWE SH.GPXTI3.ConfNb=1 Dma.SPI3_TX.2.SyncRequestNumber=1 PE2.Mode=Single Bank 1 +ADC1.Channel-2\#ChannelRegularConversion=ADC_CHANNEL_5 SH.FMC_D10_DA10.ConfNb=1 PB6.Mode=Asynchronous RCC.DIVQ3Freq_Value=98285714.2857143 @@ -543,7 +554,7 @@ SH.FMC_D25.ConfNb=1 NVIC.SAI1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true RCC.DIVR2Freq_Value=75000000 PE10.Signal=FMC_D7_DA7 -ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_1CYCLE_5 +ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_64CYCLES_5 RCC.MCO2PinFreq_Value=480000000 PC8.GPIOParameters=GPIO_Label PF8.GPIOParameters=GPIO_Label @@ -576,7 +587,7 @@ SAI1.DataSize-SAI_B_SyncSlave=SAI_DATASIZE_24 RCC.DIVQ1=5 ADC1.Rank-0\#ChannelRegularConversion=1 SH.FMC_D28.0=FMC_D28,sd-32b-d1 -ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,master +ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,master,NbrOfConversion,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,OffsetNumber-1\#ChannelRegularConversion,OffsetSignedSaturation-1\#ChannelRegularConversion,Rank-2\#ChannelRegularConversion,Channel-2\#ChannelRegularConversion,SamplingTime-2\#ChannelRegularConversion,OffsetNumber-2\#ChannelRegularConversion,OffsetSignedSaturation-2\#ChannelRegularConversion,Rank-3\#ChannelRegularConversion,Channel-3\#ChannelRegularConversion,SamplingTime-3\#ChannelRegularConversion,OffsetNumber-3\#ChannelRegularConversion,OffsetSignedSaturation-3\#ChannelRegularConversion,OversamplingMode RCC.SWPMI1Freq_Value=120000000 FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 Dma.SPI3_TX.2.EventEnable=DISABLE @@ -609,8 +620,8 @@ SH.SharedStack_PC9.0=SDMMC1_D1 SH.SharedStack_PC9.1=GPIO_EXTI9 SH.FMC_D17.0=FMC_D17,sd-32b-d1 ADC1.OffsetSignedSaturation-0\#ChannelRegularConversion=DISABLE -PB10.Signal=SPI2_SCK SH.ADCx_INP8.0=ADC1_INP8,IN8-Single-Ended +PB10.Signal=SPI2_SCK SH.ADCx_INP5.ConfNb=1 RCC.USBCLockSelection=RCC_USBCLKSOURCE_HSI48 ProjectManager.LastFirmware=true @@ -642,6 +653,7 @@ Dma.SAI1_B.1.MemDataAlignment=DMA_MDATAALIGN_WORD Mcu.Pin124=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS PA4.Signal=GPIO_Output Mcu.Pin125=VP_USB_HOST_VS_USB_HOST_AUDIO_HS +ADC1.SamplingTime-1\#ChannelRegularConversion=ADC_SAMPLETIME_64CYCLES_5 PB5.Signal=UART5_RX Mcu.Pin120=PB14 Mcu.Pin121=PB15 @@ -650,6 +662,7 @@ PE3.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH SH.FMC_A10.ConfNb=1 Dma.SPI3_TX.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber ProjectManager.CompilerOptimize=6 +ADC1.Rank-1\#ChannelRegularConversion=2 PG11.Mode=Encoder_mode_occur1 SH.FMC_A5.0=FMC_A5,13b-sda1 PA11.Signal=USB_OTG_FS_DM @@ -707,6 +720,7 @@ SH.FMC_NBL0.0=FMC_NBL0,Sd4ByteEnable1 ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_QUADSPI_Init-QUADSPI-false-HAL-true,5-MX_FMC_Init-FMC-false-HAL-true,6-MX_SAI1_Init-SAI1-false-HAL-true,7-MX_ADC1_Init-ADC1-false-HAL-true,8-MX_SPI2_Init-SPI2-false-HAL-true,9-MX_SPI3_Init-SPI3-false-HAL-true,10-MX_TIM2_Init-TIM2-false-HAL-true,11-MX_TIM3_Init-TIM3-false-HAL-true,12-MX_TIM4_Init-TIM4-false-HAL-true,13-MX_UART5_Init-UART5-false-HAL-true,14-MX_UART7_Init-UART7-false-HAL-true,15-MX_LPTIM1_Init-LPTIM1-false-HAL-true,16-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,17-MX_USB_HOST_Init-USB_HOST-false-HAL-false,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true SH.FMC_D6_DA6.0=FMC_D6,sd-32b-d1 PC9.Locked=true +PC10.GPIO_Speed=GPIO_SPEED_FREQ_HIGH PC13.GPIO_Label=EXTI13 PB11.Signal=GPIO_Output SAI1.ActiveFrameLength-SAI_A_MasterWithClock=128 @@ -752,6 +766,7 @@ Mcu.Pin5=PG14 SH.FMC_D8_DA8.0=FMC_D8,sd-32b-d1 PC8.Stacked=true SH.FMC_D2_DA2.0=FMC_D2,sd-32b-d1 +ADC1.Rank-2\#ChannelRegularConversion=3 PE13.Signal=FMC_D10_DA10 PI5.Signal=FMC_NBL3 PE4.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH @@ -777,6 +792,7 @@ SH.FMC_D0_DA0.0=FMC_D0,sd-32b-d1 RCC.D1PPRE=RCC_APB3_DIV2 USB_OTG_FS.VirtualMode=Device_Only SH.FMC_A9.0=FMC_A9,13b-sda1 +ADC1.OffsetNumber-1\#ChannelRegularConversion=ADC_OFFSET_NONE SH.FMC_D4_DA4.0=FMC_D4,sd-32b-d1 SPI2.CLKPhase=SPI_PHASE_2EDGE PF5.Signal=FMC_A5 @@ -802,6 +818,7 @@ USB_DEVICE.VirtualModeFS=Audio_FS PG3.Signal=GPIO_Output PG1.Signal=FMC_A11 SAI1.FSPolarity-SAI_A_MasterWithClock=SAI_FS_ACTIVE_HIGH +ADC1.OffsetNumber-3\#ChannelRegularConversion=ADC_OFFSET_NONE RCC.SAI4BFreq_Value=192000000 SH.FMC_SDCLK.ConfNb=1 PC4.Signal=ADCx_INP4 @@ -811,9 +828,11 @@ PI10.Signal=FMC_D31 NVIC.DMA1_Stream1_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true Dma.SAI1_A.0.MemInc=DMA_MINC_ENABLE Dma.SPI3_TX.2.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +ADC1.SamplingTime-2\#ChannelRegularConversion=ADC_SAMPLETIME_64CYCLES_5 PD2.Stacked=true PC14-OSC32_IN\ (OSC32_IN).Locked=true RCC.SPI6Freq_Value=120000000 +PC12.GPIOParameters=GPIO_Speed PC8.GPIO_Label=EXTI8 SH.FMC_D21.0=FMC_D21,sd-32b-d1 PF7.Mode=Asynchronous @@ -825,7 +844,9 @@ PH4.Signal=GPXTI4 PB3\ (JTDO/TRACESWO).Signal=DEBUG_JTDO-SWO ProjectManager.TargetToolchain=Other Toolchains (GPDSC) SAI1.SlotSize-SAI_A_MasterWithClock=SAI_SLOTSIZE_32B +ADC1.OffsetSignedSaturation-2\#ChannelRegularConversion=DISABLE SH.FMC_D1_DA1.ConfNb=1 +ADC1.Channel-1\#ChannelRegularConversion=ADC_CHANNEL_14 PC15-OSC32_OUT\ (OSC32_OUT).GPIOParameters=GPIO_Label SAI1.DataSize-SAI_A_MasterWithClock=SAI_DATASIZE_24 PF2.Signal=FMC_A2 @@ -843,12 +864,12 @@ RCC.VCOInput1Freq_Value=8000000 PG7.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH NVIC.SavedSystickIrqHandlerGenerated=true RCC.APB2Freq_Value=120000000 -SPI3.CalculateBaudRate=3.125 MBits/s +SPI3.CalculateBaudRate=1.5625 MBits/s SH.FMC_D13_DA13.ConfNb=1 PC13.GPIOParameters=GPIO_Label PF10.Signal=QUADSPI_CLK Dma.SPI3_TX.2.MemDataAlignment=DMA_MDATAALIGN_BYTE -SPI3.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_8 +SPI3.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_16 PF15.Signal=FMC_A9 PA4.GPIOParameters=GPIO_Speed,GPIO_Label PE6.Signal=SAI1_SD_A From ea9fc08cffd27720187659733c55fe27005a223e Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 30 Aug 2021 11:23:56 +0200 Subject: [PATCH 052/286] remove USBH support --- Xibeca/Core/Inc/hardware.h | 6 +- Xibeca/Core/Inc/stm32h7xx_hal_conf.h | 2 +- Xibeca/Core/Inc/stm32h7xx_it.h | 1 - Xibeca/Core/Src/main.c | 12 +- Xibeca/Core/Src/stm32h7xx_it.c | 15 - Xibeca/Makefile | 10 +- Xibeca/USB_HOST/App/usb_host.c | 134 ------- Xibeca/USB_HOST/App/usb_host.h | 92 ----- Xibeca/USB_HOST/Target/usbh_conf.c | 577 --------------------------- Xibeca/USB_HOST/Target/usbh_conf.h | 196 --------- Xibeca/Xibeca.ioc | 95 ++--- 11 files changed, 60 insertions(+), 1080 deletions(-) delete mode 100644 Xibeca/USB_HOST/App/usb_host.c delete mode 100644 Xibeca/USB_HOST/App/usb_host.h delete mode 100644 Xibeca/USB_HOST/Target/usbh_conf.c delete mode 100644 Xibeca/USB_HOST/Target/usbh_conf.h diff --git a/Xibeca/Core/Inc/hardware.h b/Xibeca/Core/Inc/hardware.h index 068d8f0c..208a59cc 100644 --- a/Xibeca/Core/Inc/hardware.h +++ b/Xibeca/Core/Inc/hardware.h @@ -55,11 +55,7 @@ #define ADC_B 1 #define ADC_C 2 #define ADC_D 3 -#define ADC_E 4 -#define ADC_F 5 -#define ADC_G 6 -#define ADC_H 7 -#define NOF_ADC_VALUES 8 +#define NOF_ADC_VALUES 4 #define NOF_PARAMETERS 40 #define NOF_BUTTONS (2+4) diff --git a/Xibeca/Core/Inc/stm32h7xx_hal_conf.h b/Xibeca/Core/Inc/stm32h7xx_hal_conf.h index 1a5f3485..6348633e 100644 --- a/Xibeca/Core/Inc/stm32h7xx_hal_conf.h +++ b/Xibeca/Core/Inc/stm32h7xx_hal_conf.h @@ -80,7 +80,7 @@ /* #define HAL_SMARTCARD_MODULE_ENABLED */ /* #define HAL_WWDG_MODULE_ENABLED */ #define HAL_PCD_MODULE_ENABLED -#define HAL_HCD_MODULE_ENABLED +/* #define HAL_HCD_MODULE_ENABLED */ /* #define HAL_DFSDM_MODULE_ENABLED */ /* #define HAL_DSI_MODULE_ENABLED */ /* #define HAL_JPEG_MODULE_ENABLED */ diff --git a/Xibeca/Core/Inc/stm32h7xx_it.h b/Xibeca/Core/Inc/stm32h7xx_it.h index 6f031eb9..b8915c92 100644 --- a/Xibeca/Core/Inc/stm32h7xx_it.h +++ b/Xibeca/Core/Inc/stm32h7xx_it.h @@ -52,7 +52,6 @@ void DMA1_Stream0_IRQHandler(void); void DMA1_Stream1_IRQHandler(void); void DMA1_Stream2_IRQHandler(void); void SPI3_IRQHandler(void); -void OTG_HS_IRQHandler(void); void SAI1_IRQHandler(void); void OTG_FS_IRQHandler(void); /* USER CODE BEGIN EFP */ diff --git a/Xibeca/Core/Src/main.c b/Xibeca/Core/Src/main.c index 4458e814..b5583ca7 100644 --- a/Xibeca/Core/Src/main.c +++ b/Xibeca/Core/Src/main.c @@ -21,7 +21,6 @@ #include "main.h" #include "cmsis_os.h" #include "usb_device.h" -#include "usb_host.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ @@ -341,9 +340,9 @@ static void MX_ADC1_Init(void) hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1; hadc1.Init.Resolution = ADC_RESOLUTION_16B; hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE; - hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV; + hadc1.Init.EOCSelection = ADC_EOC_SEQ_CONV; hadc1.Init.LowPowerAutoWait = DISABLE; - hadc1.Init.ContinuousConvMode = DISABLE; + hadc1.Init.ContinuousConvMode = ENABLE; hadc1.Init.NbrOfConversion = 4; hadc1.Init.DiscontinuousConvMode = DISABLE; hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START; @@ -995,9 +994,9 @@ static void MX_GPIO_Init(void) HAL_GPIO_WritePin(ADC_SPI_NCS_GPIO_Port, ADC_SPI_NCS_Pin, GPIO_PIN_RESET); /*Configure GPIO pins : PB8 PB4 PB9 PB2 - PB12 */ + PB12 PB13 PB14 PB15 */ GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_4|GPIO_PIN_9|GPIO_PIN_2 - |GPIO_PIN_12; + |GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); @@ -1125,9 +1124,6 @@ void StartDefaultTask(void const * argument) { /* init code for USB_DEVICE */ MX_USB_DEVICE_Init(); - - /* init code for USB_HOST */ - MX_USB_HOST_Init(); /* USER CODE BEGIN 5 */ setup(); diff --git a/Xibeca/Core/Src/stm32h7xx_it.c b/Xibeca/Core/Src/stm32h7xx_it.c index 88326fe6..630160ee 100644 --- a/Xibeca/Core/Src/stm32h7xx_it.c +++ b/Xibeca/Core/Src/stm32h7xx_it.c @@ -59,7 +59,6 @@ /* External variables --------------------------------------------------------*/ extern PCD_HandleTypeDef hpcd_USB_OTG_FS; -extern HCD_HandleTypeDef hhcd_USB_OTG_HS; extern DMA_HandleTypeDef hdma_sai1_a; extern DMA_HandleTypeDef hdma_sai1_b; extern SAI_HandleTypeDef hsai_BlockA1; @@ -158,20 +157,6 @@ void SPI3_IRQHandler(void) /* USER CODE END SPI3_IRQn 1 */ } -/** - * @brief This function handles USB On The Go HS global interrupt. - */ -void OTG_HS_IRQHandler(void) -{ - /* USER CODE BEGIN OTG_HS_IRQn 0 */ - - /* USER CODE END OTG_HS_IRQn 0 */ - HAL_HCD_IRQHandler(&hhcd_USB_OTG_HS); - /* USER CODE BEGIN OTG_HS_IRQn 1 */ - - /* USER CODE END OTG_HS_IRQn 1 */ -} - /** * @brief This function handles SAI1 global interrupt. */ diff --git a/Xibeca/Makefile b/Xibeca/Makefile index b77db209..05f96f85 100644 --- a/Xibeca/Makefile +++ b/Xibeca/Makefile @@ -9,7 +9,6 @@ CPP_SRC = $(wildcard Core/Src/*.cpp) C_SRC += $(OPENWARE)/Source/sdram.c C_SRC += $(OPENWARE)/Source/pcm3168a.c C_SRC += $(OPENWARE)/Source/usbd_audio.c -CPP_SRC += $(OPENWARE)/Source/usbh_midi.cpp C_SRC += $(OPENWARE)/Source/ssd1309.c CPP_SRC += $(OPENWARE)/Source/ScreenBuffer.cpp @@ -25,16 +24,17 @@ C_SRC += $(BUILDROOT)/USB_DEVICE/App/usb_device.c C_SRC += $(BUILDROOT)/USB_DEVICE/App/usbd_desc.c C_SRC += $(BUILDROOT)/USB_DEVICE/Target/usbd_conf.c -C_SRC += $(BUILDROOT)/USB_HOST/Target/usbh_conf.c -C_SRC += $(BUILDROOT)/USB_HOST/App/usb_host.c +# CPP_SRC += $(OPENWARE)/Source/usbh_midi.cpp +# C_SRC += $(BUILDROOT)/USB_HOST/Target/usbh_conf.c +# C_SRC += $(BUILDROOT)/USB_HOST/App/usb_host.c include $(OPENWARE)/Hardware/sources.mk C_SRC += $(C_SRC_SAI) -C_SRC += $(C_SRC_DAC) +# C_SRC += $(C_SRC_DAC) C_SRC += $(C_SRC_SDRAM) C_SRC += $(C_SRC_USBD) -C_SRC += $(C_SRC_USBH) +# C_SRC += $(C_SRC_USBH) C_SRC += $(C_SRC_DSP) C_SRC += $(C_SRC_OS) C_SRC += $(C_SRC_UART) diff --git a/Xibeca/USB_HOST/App/usb_host.c b/Xibeca/USB_HOST/App/usb_host.c deleted file mode 100644 index b24a9c71..00000000 --- a/Xibeca/USB_HOST/App/usb_host.c +++ /dev/null @@ -1,134 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : usb_host.c - * @version : v1.0_Cube - * @brief : This file implements the USB Host - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2020 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under Ultimate Liberty license - * SLA0044, the "License"; You may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * www.st.com/SLA0044 - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Includes ------------------------------------------------------------------*/ - -#include "usb_host.h" -#include "usbh_core.h" -#include "usbh_audio.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN PV */ -/* Private variables ---------------------------------------------------------*/ - -/* USER CODE END PV */ - -/* USER CODE BEGIN PFP */ -/* Private function prototypes -----------------------------------------------*/ - -/* USER CODE END PFP */ - -/* USB Host core handle declaration */ -USBH_HandleTypeDef hUsbHostHS; -ApplicationTypeDef Appli_state = APPLICATION_IDLE; - -/* - * -- Insert your variables declaration here -- - */ -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* - * user callback declaration - */ -static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id); - -/* - * -- Insert your external function declaration here -- - */ -/* USER CODE BEGIN 1 */ -void MX_USB_HOST_Process() -{ - /* USB Host Background task */ - USBH_Process(&hUsbHostHS); -} -/* USER CODE END 1 */ - -/** - * Init USB host library, add supported class and start the library - * @retval None - */ -void MX_USB_HOST_Init(void) -{ - /* USER CODE BEGIN USB_HOST_Init_PreTreatment */ - - /* USER CODE END USB_HOST_Init_PreTreatment */ - - /* Init host Library, add supported class and start the library. */ - if (USBH_Init(&hUsbHostHS, USBH_UserProcess, HOST_HS) != USBH_OK) - { - Error_Handler(); - } - if (USBH_RegisterClass(&hUsbHostHS, USBH_AUDIO_CLASS) != USBH_OK) - { - Error_Handler(); - } - if (USBH_Start(&hUsbHostHS) != USBH_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN USB_HOST_Init_PostTreatment */ - - /* USER CODE END USB_HOST_Init_PostTreatment */ -} - -/* - * user callback definition - */ -static void USBH_UserProcess (USBH_HandleTypeDef *phost, uint8_t id) -{ - /* USER CODE BEGIN CALL_BACK_1 */ - switch(id) - { - case HOST_USER_SELECT_CONFIGURATION: - break; - - case HOST_USER_DISCONNECTION: - Appli_state = APPLICATION_DISCONNECT; - break; - - case HOST_USER_CLASS_ACTIVE: - Appli_state = APPLICATION_READY; - break; - - case HOST_USER_CONNECTION: - Appli_state = APPLICATION_START; - break; - - default: - break; - } - /* USER CODE END CALL_BACK_1 */ -} - -/** - * @} - */ - -/** - * @} - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/USB_HOST/App/usb_host.h b/Xibeca/USB_HOST/App/usb_host.h deleted file mode 100644 index d261dea2..00000000 --- a/Xibeca/USB_HOST/App/usb_host.h +++ /dev/null @@ -1,92 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : usb_host.h - * @version : v1.0_Cube - * @brief : Header for usb_host.c file. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2021 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under Ultimate Liberty license - * SLA0044, the "License"; You may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * www.st.com/SLA0044 - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __USB_HOST__H__ -#define __USB_HOST__H__ - -#ifdef __cplusplus - extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32h7xx.h" -#include "stm32h7xx_hal.h" - -/* USER CODE BEGIN INCLUDE */ - -/* USER CODE END INCLUDE */ - -/** @addtogroup USBH_OTG_DRIVER - * @{ - */ - -/** @defgroup USBH_HOST USBH_HOST - * @brief Host file for Usb otg low level driver. - * @{ - */ - -/** @defgroup USBH_HOST_Exported_Variables USBH_HOST_Exported_Variables - * @brief Public variables. - * @{ - */ - -/** - * @} - */ - -/** Status of the application. */ -typedef enum { - APPLICATION_IDLE = 0, - APPLICATION_START, - APPLICATION_READY, - APPLICATION_DISCONNECT -}ApplicationTypeDef; - -/** @defgroup USBH_HOST_Exported_FunctionsPrototype USBH_HOST_Exported_FunctionsPrototype - * @brief Declaration of public functions for Usb host. - * @{ - */ - -/* Exported functions -------------------------------------------------------*/ - -/** @brief USB Host initialization function. */ -void MX_USB_HOST_Init(void); - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __USB_HOST__H__ */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/USB_HOST/Target/usbh_conf.c b/Xibeca/USB_HOST/Target/usbh_conf.c deleted file mode 100644 index 2b7afd8e..00000000 --- a/Xibeca/USB_HOST/Target/usbh_conf.c +++ /dev/null @@ -1,577 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : Target/usbh_conf.c - * @version : v1.0_Cube - * @brief : This file implements the board support package for the USB host library - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2021 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under Ultimate Liberty license - * SLA0044, the "License"; You may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * www.st.com/SLA0044 - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Includes ------------------------------------------------------------------*/ -#include "usbh_core.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* Private define ------------------------------------------------------------*/ -/* Private macro -------------------------------------------------------------*/ - -/* USER CODE BEGIN PV */ -/* Private variables ---------------------------------------------------------*/ - -/* USER CODE END PV */ - -HCD_HandleTypeDef hhcd_USB_OTG_HS; -void Error_Handler(void); - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* USER CODE BEGIN PFP */ -/* Private function prototypes -----------------------------------------------*/ -USBH_StatusTypeDef USBH_Get_USB_Status(HAL_StatusTypeDef hal_status); - -/* USER CODE END PFP */ - -/* Private functions ---------------------------------------------------------*/ - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ - -/******************************************************************************* - LL Driver Callbacks (HCD -> USB Host Library) -*******************************************************************************/ -/* MSP Init */ - -void HAL_HCD_MspInit(HCD_HandleTypeDef* hcdHandle) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; - if(hcdHandle->Instance==USB_OTG_HS) - { - /* USER CODE BEGIN USB_OTG_HS_MspInit 0 */ - - /* USER CODE END USB_OTG_HS_MspInit 0 */ - /** Initializes the peripherals clock - */ - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB; - PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48; - if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) - { - Error_Handler(); - } - /** Enable USB Voltage detector - */ - HAL_PWREx_EnableUSBVoltageDetector(); - - __HAL_RCC_GPIOB_CLK_ENABLE(); - /**USB_OTG_HS GPIO Configuration - PB13 ------> USB_OTG_HS_VBUS - PB14 ------> USB_OTG_HS_DM - PB15 ------> USB_OTG_HS_DP - */ - GPIO_InitStruct.Pin = GPIO_PIN_13; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF12_OTG2_FS; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /* Peripheral clock enable */ - __HAL_RCC_USB_OTG_HS_CLK_ENABLE(); - - /* Peripheral interrupt init */ - HAL_NVIC_SetPriority(OTG_HS_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(OTG_HS_IRQn); - /* USER CODE BEGIN USB_OTG_HS_MspInit 1 */ - - /* USER CODE END USB_OTG_HS_MspInit 1 */ - } -} - -void HAL_HCD_MspDeInit(HCD_HandleTypeDef* hcdHandle) -{ - if(hcdHandle->Instance==USB_OTG_HS) - { - /* USER CODE BEGIN USB_OTG_HS_MspDeInit 0 */ - - /* USER CODE END USB_OTG_HS_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_USB_OTG_HS_CLK_DISABLE(); - - /**USB_OTG_HS GPIO Configuration - PB13 ------> USB_OTG_HS_VBUS - PB14 ------> USB_OTG_HS_DM - PB15 ------> USB_OTG_HS_DP - */ - HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15); - - /* Peripheral interrupt Deinit*/ - HAL_NVIC_DisableIRQ(OTG_HS_IRQn); - - /* USER CODE BEGIN USB_OTG_HS_MspDeInit 1 */ - - /* USER CODE END USB_OTG_HS_MspDeInit 1 */ - } -} - -/** - * @brief SOF callback. - * @param hhcd: HCD handle - * @retval None - */ -void HAL_HCD_SOF_Callback(HCD_HandleTypeDef *hhcd) -{ - USBH_LL_IncTimer(hhcd->pData); -} - -/** - * @brief SOF callback. - * @param hhcd: HCD handle - * @retval None - */ -void HAL_HCD_Connect_Callback(HCD_HandleTypeDef *hhcd) -{ - USBH_LL_Connect(hhcd->pData); -} - -/** - * @brief SOF callback. - * @param hhcd: HCD handle - * @retval None - */ -void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd) -{ - USBH_LL_Disconnect(hhcd->pData); -} - -/** - * @brief Notify URB state change callback. - * @param hhcd: HCD handle - * @param chnum: channel number - * @param urb_state: state - * @retval None - */ -void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) -{ - /* To be used with OS to sync URB state with the global state machine */ -#if (USBH_USE_OS == 1) - USBH_LL_NotifyURBChange(hhcd->pData); -#endif -} -/** -* @brief Port Port Enabled callback. - * @param hhcd: HCD handle - * @retval None - */ -void HAL_HCD_PortEnabled_Callback(HCD_HandleTypeDef *hhcd) -{ - USBH_LL_PortEnabled(hhcd->pData); -} - -/** - * @brief Port Port Disabled callback. - * @param hhcd: HCD handle - * @retval None - */ -void HAL_HCD_PortDisabled_Callback(HCD_HandleTypeDef *hhcd) -{ - USBH_LL_PortDisabled(hhcd->pData); -} - -/******************************************************************************* - LL Driver Interface (USB Host Library --> HCD) -*******************************************************************************/ - -/** - * @brief Initialize the low level portion of the host driver. - * @param phost: Host handle - * @retval USBH status - */ -USBH_StatusTypeDef USBH_LL_Init(USBH_HandleTypeDef *phost) -{ - /* Init USB_IP */ - if (phost->id == HOST_HS) { - /* Link the driver to the stack. */ - hhcd_USB_OTG_HS.pData = phost; - phost->pData = &hhcd_USB_OTG_HS; - - hhcd_USB_OTG_HS.Instance = USB_OTG_HS; - hhcd_USB_OTG_HS.Init.Host_channels = 16; - hhcd_USB_OTG_HS.Init.speed = HCD_SPEED_FULL; - hhcd_USB_OTG_HS.Init.dma_enable = DISABLE; - hhcd_USB_OTG_HS.Init.phy_itface = USB_OTG_EMBEDDED_PHY; - hhcd_USB_OTG_HS.Init.Sof_enable = DISABLE; - hhcd_USB_OTG_HS.Init.low_power_enable = DISABLE; - hhcd_USB_OTG_HS.Init.use_external_vbus = DISABLE; - if (HAL_HCD_Init(&hhcd_USB_OTG_HS) != HAL_OK) - { - Error_Handler( ); - } - - USBH_LL_SetTimer(phost, HAL_HCD_GetCurrentFrame(&hhcd_USB_OTG_HS)); - } - return USBH_OK; -} - -/** - * @brief De-Initialize the low level portion of the host driver. - * @param phost: Host handle - * @retval USBH status - */ -USBH_StatusTypeDef USBH_LL_DeInit(USBH_HandleTypeDef *phost) -{ - HAL_StatusTypeDef hal_status = HAL_OK; - USBH_StatusTypeDef usb_status = USBH_OK; - - hal_status = HAL_HCD_DeInit(phost->pData); - - usb_status = USBH_Get_USB_Status(hal_status); - - return usb_status; -} - -/** - * @brief Start the low level portion of the host driver. - * @param phost: Host handle - * @retval USBH status - */ -USBH_StatusTypeDef USBH_LL_Start(USBH_HandleTypeDef *phost) -{ - HAL_StatusTypeDef hal_status = HAL_OK; - USBH_StatusTypeDef usb_status = USBH_OK; - - hal_status = HAL_HCD_Start(phost->pData); - - usb_status = USBH_Get_USB_Status(hal_status); - - return usb_status; -} - -/** - * @brief Stop the low level portion of the host driver. - * @param phost: Host handle - * @retval USBH status - */ -USBH_StatusTypeDef USBH_LL_Stop(USBH_HandleTypeDef *phost) -{ - HAL_StatusTypeDef hal_status = HAL_OK; - USBH_StatusTypeDef usb_status = USBH_OK; - - hal_status = HAL_HCD_Stop(phost->pData); - - usb_status = USBH_Get_USB_Status(hal_status); - - return usb_status; -} - -/** - * @brief Return the USB host speed from the low level driver. - * @param phost: Host handle - * @retval USBH speeds - */ -USBH_SpeedTypeDef USBH_LL_GetSpeed(USBH_HandleTypeDef *phost) -{ - USBH_SpeedTypeDef speed = USBH_SPEED_FULL; - - switch (HAL_HCD_GetCurrentSpeed(phost->pData)) - { - case 0 : - speed = USBH_SPEED_HIGH; - break; - - case 1 : - speed = USBH_SPEED_FULL; - break; - - case 2 : - speed = USBH_SPEED_LOW; - break; - - default: - speed = USBH_SPEED_FULL; - break; - } - return speed; -} - -/** - * @brief Reset the Host port of the low level driver. - * @param phost: Host handle - * @retval USBH status - */ -USBH_StatusTypeDef USBH_LL_ResetPort(USBH_HandleTypeDef *phost) -{ - HAL_StatusTypeDef hal_status = HAL_OK; - USBH_StatusTypeDef usb_status = USBH_OK; - - hal_status = HAL_HCD_ResetPort(phost->pData); - - usb_status = USBH_Get_USB_Status(hal_status); - - return usb_status; -} - -/** - * @brief Return the last transfered packet size. - * @param phost: Host handle - * @param pipe: Pipe index - * @retval Packet size - */ -uint32_t USBH_LL_GetLastXferSize(USBH_HandleTypeDef *phost, uint8_t pipe) -{ - return HAL_HCD_HC_GetXferCount(phost->pData, pipe); -} - -/** - * @brief Open a pipe of the low level driver. - * @param phost: Host handle - * @param pipe_num: Pipe index - * @param epnum: Endpoint number - * @param dev_address: Device USB address - * @param speed: Device Speed - * @param ep_type: Endpoint type - * @param mps: Endpoint max packet size - * @retval USBH status - */ -USBH_StatusTypeDef USBH_LL_OpenPipe(USBH_HandleTypeDef *phost, uint8_t pipe_num, uint8_t epnum, - uint8_t dev_address, uint8_t speed, uint8_t ep_type, uint16_t mps) -{ - HAL_StatusTypeDef hal_status = HAL_OK; - USBH_StatusTypeDef usb_status = USBH_OK; - - hal_status = HAL_HCD_HC_Init(phost->pData, pipe_num, epnum, - dev_address, speed, ep_type, mps); - - usb_status = USBH_Get_USB_Status(hal_status); - - return usb_status; -} - -/** - * @brief Close a pipe of the low level driver. - * @param phost: Host handle - * @param pipe: Pipe index - * @retval USBH status - */ -USBH_StatusTypeDef USBH_LL_ClosePipe(USBH_HandleTypeDef *phost, uint8_t pipe) -{ - HAL_StatusTypeDef hal_status = HAL_OK; - USBH_StatusTypeDef usb_status = USBH_OK; - - hal_status = HAL_HCD_HC_Halt(phost->pData, pipe); - - usb_status = USBH_Get_USB_Status(hal_status); - - return usb_status; -} - -/** - * @brief Submit a new URB to the low level driver. - * @param phost: Host handle - * @param pipe: Pipe index - * This parameter can be a value from 1 to 15 - * @param direction : Channel number - * This parameter can be one of the these values: - * 0 : Output - * 1 : Input - * @param ep_type : Endpoint Type - * This parameter can be one of the these values: - * @arg EP_TYPE_CTRL: Control type - * @arg EP_TYPE_ISOC: Isochrounous type - * @arg EP_TYPE_BULK: Bulk type - * @arg EP_TYPE_INTR: Interrupt type - * @param token : Endpoint Type - * This parameter can be one of the these values: - * @arg 0: PID_SETUP - * @arg 1: PID_DATA - * @param pbuff : pointer to URB data - * @param length : Length of URB data - * @param do_ping : activate do ping protocol (for high speed only) - * This parameter can be one of the these values: - * 0 : do ping inactive - * 1 : do ping active - * @retval Status - */ -USBH_StatusTypeDef USBH_LL_SubmitURB(USBH_HandleTypeDef *phost, uint8_t pipe, uint8_t direction, - uint8_t ep_type, uint8_t token, uint8_t *pbuff, uint16_t length, - uint8_t do_ping) -{ - HAL_StatusTypeDef hal_status = HAL_OK; - USBH_StatusTypeDef usb_status = USBH_OK; - - hal_status = HAL_HCD_HC_SubmitRequest(phost->pData, pipe, direction , - ep_type, token, pbuff, length, - do_ping); - usb_status = USBH_Get_USB_Status(hal_status); - - return usb_status; -} - -/** - * @brief Get a URB state from the low level driver. - * @param phost: Host handle - * @param pipe: Pipe index - * This parameter can be a value from 1 to 15 - * @retval URB state - * This parameter can be one of the these values: - * @arg URB_IDLE - * @arg URB_DONE - * @arg URB_NOTREADY - * @arg URB_NYET - * @arg URB_ERROR - * @arg URB_STALL - */ -USBH_URBStateTypeDef USBH_LL_GetURBState(USBH_HandleTypeDef *phost, uint8_t pipe) -{ - return (USBH_URBStateTypeDef)HAL_HCD_HC_GetURBState (phost->pData, pipe); -} - -/** - * @brief Drive VBUS. - * @param phost: Host handle - * @param state : VBUS state - * This parameter can be one of the these values: - * 0 : VBUS Inactive - * 1 : VBUS Active - * @retval Status - */ -USBH_StatusTypeDef USBH_LL_DriverVBUS(USBH_HandleTypeDef *phost, uint8_t state) -{ - - /* USER CODE BEGIN 0 */ - - /* USER CODE END 0*/ - - if (phost->id == HOST_HS) - { - if (state == 0) - { - /* Drive high Charge pump */ - /* ToDo: Add IOE driver control */ - /* USER CODE BEGIN DRIVE_HIGH_CHARGE_FOR_HS */ - - /* USER CODE END DRIVE_HIGH_CHARGE_FOR_HS */ - } - else - { - /* Drive low Charge pump */ - /* ToDo: Add IOE driver control */ - /* USER CODE BEGIN DRIVE_LOW_CHARGE_FOR_HS */ - - /* USER CODE END DRIVE_LOW_CHARGE_FOR_HS */ - } - } - HAL_Delay(200); - return USBH_OK; -} - -/** - * @brief Set toggle for a pipe. - * @param phost: Host handle - * @param pipe: Pipe index - * @param toggle: toggle (0/1) - * @retval Status - */ -USBH_StatusTypeDef USBH_LL_SetToggle(USBH_HandleTypeDef *phost, uint8_t pipe, uint8_t toggle) -{ - HCD_HandleTypeDef *pHandle; - pHandle = phost->pData; - - if(pHandle->hc[pipe].ep_is_in) - { - pHandle->hc[pipe].toggle_in = toggle; - } - else - { - pHandle->hc[pipe].toggle_out = toggle; - } - - return USBH_OK; -} - -/** - * @brief Return the current toggle of a pipe. - * @param phost: Host handle - * @param pipe: Pipe index - * @retval toggle (0/1) - */ -uint8_t USBH_LL_GetToggle(USBH_HandleTypeDef *phost, uint8_t pipe) -{ - uint8_t toggle = 0; - HCD_HandleTypeDef *pHandle; - pHandle = phost->pData; - - if(pHandle->hc[pipe].ep_is_in) - { - toggle = pHandle->hc[pipe].toggle_in; - } - else - { - toggle = pHandle->hc[pipe].toggle_out; - } - return toggle; -} - -/** - * @brief Delay routine for the USB Host Library - * @param Delay: Delay in ms - * @retval None - */ -void USBH_Delay(uint32_t Delay) -{ - HAL_Delay(Delay); -} - -/** - * @brief Retuns the USB status depending on the HAL status: - * @param hal_status: HAL status - * @retval USB status - */ -USBH_StatusTypeDef USBH_Get_USB_Status(HAL_StatusTypeDef hal_status) -{ - USBH_StatusTypeDef usb_status = USBH_OK; - - switch (hal_status) - { - case HAL_OK : - usb_status = USBH_OK; - break; - case HAL_ERROR : - usb_status = USBH_FAIL; - break; - case HAL_BUSY : - usb_status = USBH_BUSY; - break; - case HAL_TIMEOUT : - usb_status = USBH_FAIL; - break; - default : - usb_status = USBH_FAIL; - break; - } - return usb_status; -} - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/USB_HOST/Target/usbh_conf.h b/Xibeca/USB_HOST/Target/usbh_conf.h deleted file mode 100644 index 8857272b..00000000 --- a/Xibeca/USB_HOST/Target/usbh_conf.h +++ /dev/null @@ -1,196 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : Target/usbh_conf.h - * @version : v1.0_Cube - * @brief : Header for usbh_conf.c file. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2021 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under Ultimate Liberty license - * SLA0044, the "License"; You may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * www.st.com/SLA0044 - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __USBH_CONF__H__ -#define __USBH_CONF__H__ -#ifdef __cplusplus - extern "C" { -#endif -/* Includes ------------------------------------------------------------------*/ - -#include -#include -#include -#include "main.h" - -#include "stm32h7xx.h" -#include "stm32h7xx_hal.h" - -/* USER CODE BEGIN INCLUDE */ - -/* USER CODE END INCLUDE */ - -/** @addtogroup STM32_USB_HOST_LIBRARY - * @{ - */ - -/** @defgroup USBH_CONF - * @brief usb host low level driver configuration file - * @{ - */ - -/** @defgroup USBH_CONF_Exported_Variables USBH_CONF_Exported_Variables - * @brief Public variables. - * @{ - */ - -/** - * @} - */ - -/** @defgroup USBH_CONF_Exported_Defines USBH_CONF_Exported_Defines - * @brief Defines for configuration of the Usb host. - * @{ - */ - -/*---------- -----------*/ -#define USBH_MAX_NUM_ENDPOINTS 5U - -/*---------- -----------*/ -#define USBH_MAX_NUM_INTERFACES 10U - -/*---------- -----------*/ -#define USBH_MAX_NUM_CONFIGURATION 1U - -/*---------- -----------*/ -#define USBH_KEEP_CFG_DESCRIPTOR 1U - -/*---------- -----------*/ -#define USBH_MAX_NUM_SUPPORTED_CLASS 1U - -/*---------- -----------*/ -#define USBH_MAX_SIZE_CONFIGURATION 256U - -/*---------- -----------*/ -#define USBH_MAX_DATA_BUFFER 512U - -/*---------- -----------*/ -#define USBH_DEBUG_LEVEL 0U - -/*---------- -----------*/ -#define USBH_USE_OS 1U - -/****************************************/ -/* #define for FS and HS identification */ -#define HOST_HS 0 -#define HOST_FS 1 - -#if (USBH_USE_OS == 1) - #include "cmsis_os.h" - #define USBH_PROCESS_PRIO osPriorityNormal - #define USBH_PROCESS_STACK_SIZE ((uint16_t)128) -#endif /* (USBH_USE_OS == 1) */ - -/** - * @} - */ - -/** @defgroup USBH_CONF_Exported_Macros USBH_CONF_Exported_Macros - * @brief Aliases. - * @{ - */ - -/* Memory management macros */ - -/** Alias for memory allocation. */ -#define USBH_malloc malloc - -/** Alias for memory release. */ -#define USBH_free free - -/** Alias for memory set. */ -#define USBH_memset memset - -/** Alias for memory copy. */ -#define USBH_memcpy memcpy - -/* DEBUG macros */ - -#if (USBH_DEBUG_LEVEL > 0U) -#define USBH_UsrLog(...) do { \ - printf(__VA_ARGS__); \ - printf("\n"); \ -} while (0) -#else -#define USBH_UsrLog(...) do {} while (0) -#endif - -#if (USBH_DEBUG_LEVEL > 1U) - -#define USBH_ErrLog(...) do { \ - printf("ERROR: ") ; \ - printf(__VA_ARGS__); \ - printf("\n"); \ -} while (0) -#else -#define USBH_ErrLog(...) do {} while (0) -#endif - -#if (USBH_DEBUG_LEVEL > 2U) -#define USBH_DbgLog(...) do { \ - printf("DEBUG : ") ; \ - printf(__VA_ARGS__); \ - printf("\n"); \ -} while (0) -#else -#define USBH_DbgLog(...) do {} while (0) -#endif - -/** - * @} - */ - -/** @defgroup USBH_CONF_Exported_Types USBH_CONF_Exported_Types - * @brief Types. - * @{ - */ - -/** - * @} - */ - -/** @defgroup USBH_CONF_Exported_FunctionsPrototype USBH_CONF_Exported_FunctionsPrototype - * @brief Declaration of public functions for Usb host. - * @{ - */ - -/* Exported functions -------------------------------------------------------*/ - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __USBH_CONF__H__ */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Xibeca/Xibeca.ioc b/Xibeca/Xibeca.ioc index b05fe954..f192ebc6 100644 --- a/Xibeca/Xibeca.ioc +++ b/Xibeca/Xibeca.ioc @@ -44,8 +44,8 @@ PE1.Signal=FMC_NBL1 ProjectManager.ProjectBuild=false NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false PA0.Locked=true +Dma.ADC1.3.RequestNumber=1 ADC1.OffsetSignedSaturation-3\#ChannelRegularConversion=DISABLE -VP_USB_HOST_VS_USB_HOST_AUDIO_HS.Mode=AUDIO_HS ProjectManager.FirmwarePackage=STM32Cube FW_H7 V1.9.0 USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology PC2_C.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH @@ -54,13 +54,11 @@ RCC.FMCFreq_Value=240000000 RCC.SAI1CLockSelection=RCC_SAI1CLKSOURCE_PLL3 PE9.Signal=FMC_D6_DA6 Dma.SAI1_A.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.ADC1.3.Mode=DMA_CIRCULAR SH.FMC_A2.0=FMC_A2,13b-sda1 -PB14.Mode=Host_FS RCC.USART16Freq_Value=120000000 -VP_USB_HOST_VS_USB_HOST_AUDIO_HS.Signal=USB_HOST_VS_USB_HOST_AUDIO_HS PA8.Signal=UART7_RX SH.FMC_D1_DA1.0=FMC_D1,sd-32b-d1 -USB_OTG_HS.IPParameters=VirtualMode-Host_FS Dma.SPI3_TX.2.Direction=DMA_MEMORY_TO_PERIPH VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 ProjectManager.HalAssertFull=true @@ -91,8 +89,8 @@ SH.S_TIM4_CH1.0=TIM4_CH1,Encoder_Interface RCC.LPUART1Freq_Value=120000000 PF10.Mode=Single Bank 1 USB_OTG_FS.IPParameters=VirtualMode -PB13.Mode=Activate_VBUS_FS PA4.GPIO_Label=OLED_RST +ADC1.EOCSelection=ADC_EOC_SEQ_CONV PD15.Signal=FMC_D1_DA1 SH.ADCx_INP10.ConfNb=1 RCC.VCO3OutputFreq_Value=196571428.5714286 @@ -112,7 +110,7 @@ FREERTOS.Tasks01=defaultTask,0,1024,StartDefaultTask,Default,NULL,Dynamic,NULL,N PH13.Signal=FMC_D21 Mcu.Pin79=PC1 USB_DEVICE.VirtualMode-AUDIO_FS=Audio -Mcu.PinsNb=126 +Mcu.PinsNb=122 PC14-OSC32_IN\ (OSC32_IN).GPIOParameters=GPIO_Label PC11.Locked=true Mcu.Pin73=PF8 @@ -132,6 +130,7 @@ PG3.Locked=true Mcu.Pin76=PD15 SH.FMC_D10_DA10.0=FMC_D10,sd-32b-d1 FREERTOS.INCLUDE_vTaskDelayUntil=1 +Dma.ADC1.3.Priority=DMA_PRIORITY_LOW Mcu.Pin70=PG3 SAI1.ErrorAudioFreq-SAI_A_MasterWithClock=-0.01 % SH.FMC_D16.0=FMC_D16,sd-32b-d1 @@ -172,7 +171,6 @@ Mcu.Pin46=PH2 Mcu.Pin47=PC9 SAI1.VirtualMode-SAI_A_MasterWithClock=VM_MASTER PG6.GPIOParameters=GPIO_Label -PB14.Signal=USB_OTG_HS_DM Mcu.Pin40=PI11 Mcu.Pin41=PH13 Mcu.Pin44=PA9 @@ -192,11 +190,13 @@ Mcu.Pin35=PH15 Mcu.Pin36=PI1 SH.FMC_D14_DA14.ConfNb=1 Mcu.Pin39=PI10 +Dma.ADC1.3.SyncSignalID=NONE PI2.Signal=FMC_D26 Mcu.Pin30=PA11 Mcu.Pin33=PI4 Mcu.Pin34=PD2 Mcu.Pin31=PC13 +Dma.ADC1.3.Polarity=HAL_DMAMUX_REQ_GEN_RISING Mcu.Pin32=PI9 Dma.SAI1_A.0.SyncRequestNumber=1 NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false @@ -221,11 +221,12 @@ Mcu.Pin22=PC10 Mcu.Pin23=PA12 Mcu.Pin20=PD0 ADC1.master=1 -PA3.Locked=true Mcu.Pin21=PC11 +PA3.Locked=true PC14-OSC32_IN\ (OSC32_IN).GPIO_Label=EXTI14 NVIC.ForceEnableDMAVector=true NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false +Dma.ADC1.3.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber SH.FMC_SDNRAS.ConfNb=1 ProjectManager.HeapSize=0x200 Mcu.Pin15=PB6 @@ -234,8 +235,8 @@ NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false Mcu.Pin16=PG15 Mcu.Pin13=PE6 Mcu.Pin14=PB7 -Mcu.Pin19=PG10 PF10.GPIOParameters=GPIO_Label +Mcu.Pin19=PG10 SH.GPXTI15.ConfNb=1 Mcu.Pin17=PG12 Mcu.Pin18=PG11 @@ -251,7 +252,6 @@ SH.FMC_D26.ConfNb=1 PD2.Signal=SharedStack_PD2 Mcu.Family=STM32H7 SH.SharedStack_PC12.1=SPI3_MOSI,TX_Only_Simplex_Unidirect_Master -NVIC.OTG_HS_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true ProjectManager.MainLocation=Core/Src SH.SharedStack_PC12.0=SDMMC1_CK SH.FMC_A6.ConfNb=1 @@ -261,6 +261,7 @@ SH.FMC_A8.0=FMC_A8,13b-sda1 ProjectManager.KeepUserCode=true PH14.Signal=FMC_D22 PH10.Signal=FMC_D18 +ADC1.ContinuousConvMode=ENABLE SH.FMC_D14_DA14.0=FMC_D14,sd-32b-d1 PH0-OSC_IN\ (PH0).Signal=RCC_OSC_IN PG2.Signal=FMC_A12 @@ -276,7 +277,6 @@ RCC.VCO2OutputFreq_Value=150000000 SH.FMC_A11.0=FMC_A11,13b-sda1 SH.ADCx_INP11.ConfNb=1 Dma.SPI3_TX.2.Mode=DMA_NORMAL -PB15.Signal=USB_OTG_HS_DP PG15.Signal=FMC_SDNCAS PG11.Signal=LPTIM1_IN2 PD13.Signal=S_TIM4_CH2 @@ -294,6 +294,8 @@ RCC.DIVP3Freq_Value=98285714.2857143 RCC.SDMMCFreq_Value=192000000 ADC1.Channel-3\#ChannelRegularConversion=ADC_CHANNEL_8 SAI1.ActiveFrameLength-SAI_B_SyncSlave=128 +Dma.ADC1.3.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +ADC1.Resolution=ADC_RESOLUTION_12B_OPT ProjectManager.PreviousToolchain= SH.FMC_NBL1.0=FMC_NBL1,Sd4ByteEnable1 FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configUSE_IDLE_HOOK,configUSE_TICK_HOOK,configUSE_MALLOC_FAILED_HOOK,INCLUDE_vTaskDelayUntil,configUSE_MUTEXES,configCHECK_FOR_STACK_OVERFLOW,FootprintOK @@ -328,9 +330,7 @@ PC11.GPIO_Label=OLED_DC PB5.Mode=Asynchronous PE3.GPIOParameters=GPIO_Speed PB7.Signal=I2C1_SDA -Mcu.IP21=USB_OTG_FS -Mcu.IP20=USB_HOST -Mcu.IP22=USB_OTG_HS +Mcu.IP20=USB_OTG_FS SH.S_TIM3_CH1.0=TIM3_CH1,Encoder_Interface SH.FMC_D27.ConfNb=1 SH.FMC_D16.ConfNb=1 @@ -357,6 +357,7 @@ Mcu.Pin98=PC5 Dma.Request2=SPI3_TX Dma.Request1=SAI1_B Dma.SAI1_B.1.PeriphInc=DMA_PINC_DISABLE +Dma.Request3=ADC1 FREERTOS.configUSE_TICK_HOOK=0 Mcu.Pin91=PF13 Mcu.Pin92=PG0 @@ -380,7 +381,6 @@ Mcu.Pin86=PD13 Mcu.Pin87=PA1 SH.FMC_A3.ConfNb=1 SAI1.VirtualSlotActive-SAI_A_MasterWithClock=SAI_SLOTACTIVE_ALL -USB_HOST.IPParameters=USBH_HandleTypeDef-AUDIO_HS,VirtualModeHS SH.FMC_D20.0=FMC_D20,sd-32b-d1 SH.S_TIM2_CH1.0=TIM2_CH1,Encoder_Interface Dma.SAI1_B.1.Mode=DMA_CIRCULAR @@ -419,6 +419,7 @@ Dma.SAI1_A.0.Mode=DMA_CIRCULAR RCC.VCO1OutputFreq_Value=960000000 SH.FMC_D13_DA13.0=FMC_D13,sd-32b-d1 PH8.Signal=FMC_D16 +Dma.ADC1.3.SyncRequestNumber=1 RCC.AXIClockFreq_Value=240000000 SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,DataSize,NSSPMode,CLKPolarity,CLKPhase PG10.GPIOParameters=GPIO_Label @@ -429,11 +430,11 @@ SH.FMC_D24.ConfNb=1 Dma.SAI1_B.1.SyncEnable=DISABLE PA1.Signal=S_TIM2_CH2 RCC.CKPERFreq_Value=64000000 +Dma.ADC1.3.Direction=DMA_PERIPH_TO_MEMORY board=custom PG12.Mode=Encoder_mode_occur1 PI9.Signal=FMC_D30 PH4.GPIO_Label=EXTI4 -PB15.Mode=Host_FS SH.FMC_D22.0=FMC_D22,sd-32b-d1 MxCube.Version=6.2.1 RCC.FDCANFreq_Value=192000000 @@ -479,6 +480,7 @@ PH3.Signal=FMC_SDNE0 PC3_C.Signal=SPI2_MOSI PE5.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH PB7.Locked=true +NVIC.DMA1_Stream3_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true PC8.Locked=true SH.ADCx_INP3.ConfNb=1 SH.FMC_D8_DA8.ConfNb=1 @@ -487,7 +489,6 @@ PC12.GPIO_Speed=GPIO_SPEED_FREQ_HIGH Dma.SAI1_A.0.SyncEnable=DISABLE PA3.GPIO_Label=EXTI3 SAI1.SlotActive-SAI_A_MasterWithClock=0x0000FFFF -USB_OTG_HS.VirtualMode-Host_FS=Host_FS SH.FMC_D7_DA7.0=FMC_D7,sd-32b-d1 SH.FMC_D24.0=FMC_D24,sd-32b-d1 SH.FMC_A4.ConfNb=1 @@ -505,7 +506,6 @@ PG6.GPIO_Label=FLASH_NCS PG3.GPIOParameters=GPIO_Label PI11.Locked=true PA3.GPIOParameters=GPIO_Label -PB13.Signal=USB_OTG_HS_VBUS PG6.Mode=Single Bank 1 PinOutPanel.RotationAngle=0 PF6.GPIO_Label=FLASH_DQ3 @@ -515,6 +515,7 @@ RCC.AHB4Freq_Value=240000000 SH.GPXTI13.0=GPIO_EXTI13 SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 RCC.SPI123CLockSelection=RCC_SPI123CLKSOURCE_PLL2 +Dma.ADC1.3.MemInc=DMA_MINC_ENABLE PA14\ (JTCK/SWCLK).Signal=DEBUG_JTCK-SWCLK SH.FMC_A12.ConfNb=1 PH5.Signal=FMC_SDNWE @@ -534,6 +535,7 @@ PA4.Locked=true RCC.DIVM3=7 RCC.DIVM2=1 RCC.DIVM1=1 +Dma.ADC1.3.Instance=DMA1_Stream3 SH.GPXTI7.0=GPIO_EXTI7 MxDb.Version=DB.6.0.21 SH.FMC_D26.0=FMC_D26,sd-32b-d1 @@ -587,7 +589,7 @@ SAI1.DataSize-SAI_B_SyncSlave=SAI_DATASIZE_24 RCC.DIVQ1=5 ADC1.Rank-0\#ChannelRegularConversion=1 SH.FMC_D28.0=FMC_D28,sd-32b-d1 -ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,master,NbrOfConversion,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,OffsetNumber-1\#ChannelRegularConversion,OffsetSignedSaturation-1\#ChannelRegularConversion,Rank-2\#ChannelRegularConversion,Channel-2\#ChannelRegularConversion,SamplingTime-2\#ChannelRegularConversion,OffsetNumber-2\#ChannelRegularConversion,OffsetSignedSaturation-2\#ChannelRegularConversion,Rank-3\#ChannelRegularConversion,Channel-3\#ChannelRegularConversion,SamplingTime-3\#ChannelRegularConversion,OffsetNumber-3\#ChannelRegularConversion,OffsetSignedSaturation-3\#ChannelRegularConversion,OversamplingMode +ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,master,NbrOfConversion,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,OffsetNumber-1\#ChannelRegularConversion,OffsetSignedSaturation-1\#ChannelRegularConversion,Rank-2\#ChannelRegularConversion,Channel-2\#ChannelRegularConversion,SamplingTime-2\#ChannelRegularConversion,OffsetNumber-2\#ChannelRegularConversion,OffsetSignedSaturation-2\#ChannelRegularConversion,Rank-3\#ChannelRegularConversion,Channel-3\#ChannelRegularConversion,SamplingTime-3\#ChannelRegularConversion,OffsetNumber-3\#ChannelRegularConversion,OffsetSignedSaturation-3\#ChannelRegularConversion,OversamplingMode,ContinuousConvMode,EOCSelection,Resolution RCC.SWPMI1Freq_Value=120000000 FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 Dma.SPI3_TX.2.EventEnable=DISABLE @@ -609,7 +611,6 @@ RCC.SPI123Freq_Value=25000000 Dma.SAI1_A.0.RequestNumber=1 SH.FMC_D15_DA15.0=FMC_D15,sd-32b-d1 PC3_C.GPIOParameters=GPIO_Speed,GPIO_Label -USB_HOST.VirtualModeHS=Audio PA9.Signal=USB_OTG_FS_VBUS RCC.DIVN3=172 SH.S_TIM2_CH2.ConfNb=1 @@ -625,22 +626,22 @@ PB10.Signal=SPI2_SCK SH.ADCx_INP5.ConfNb=1 RCC.USBCLockSelection=RCC_USBCLKSOURCE_HSI48 ProjectManager.LastFirmware=true -Mcu.Pin116=PE12 -Mcu.Pin117=PE15 -Mcu.Pin118=PB10 -Mcu.Pin119=PB11 +Mcu.Pin116=PE15 +Mcu.Pin117=PB10 +Mcu.Pin118=PB11 +Mcu.Pin119=VP_FREERTOS_VS_CMSIS_V1 Dma.SAI1_A.0.PeriphInc=DMA_PINC_DISABLE SH.FMC_D20.ConfNb=1 PE15.Signal=FMC_D12_DA12 PE8.Signal=FMC_D5_DA5 PI1.Signal=FMC_D25 RCC.RNGFreq_Value=48000000 -Mcu.Pin112=PF11 -Mcu.Pin113=PF14 -Mcu.Pin114=PE7 -Mcu.Pin115=PE10 -Mcu.Pin110=PB1 -Mcu.Pin111=PB0 +Mcu.Pin112=PF14 +Mcu.Pin113=PE7 +Mcu.Pin114=PE10 +Mcu.Pin115=PE12 +Mcu.Pin110=PB0 +Mcu.Pin111=PF11 SH.FMC_SDNCAS.0=FMC_SDNCAS,13b-sda1 PG14.GPIO_Label=OLED_CS ProjectManager.FreePins=true @@ -648,25 +649,22 @@ RCC.LPTIM2Freq_Value=120000000 SH.FMC_NBL1.ConfNb=1 ProjectManager.UnderRoot=false SH.FMC_D7_DA7.ConfNb=1 -Mcu.Pin123=VP_SYS_VS_Systick Dma.SAI1_B.1.MemDataAlignment=DMA_MDATAALIGN_WORD -Mcu.Pin124=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS PA4.Signal=GPIO_Output -Mcu.Pin125=VP_USB_HOST_VS_USB_HOST_AUDIO_HS ADC1.SamplingTime-1\#ChannelRegularConversion=ADC_SAMPLETIME_64CYCLES_5 PB5.Signal=UART5_RX -Mcu.Pin120=PB14 -Mcu.Pin121=PB15 -Mcu.Pin122=VP_FREERTOS_VS_CMSIS_V1 +Mcu.Pin120=VP_SYS_VS_Systick +Mcu.Pin121=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS PE3.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH SH.FMC_A10.ConfNb=1 Dma.SPI3_TX.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber ProjectManager.CompilerOptimize=6 ADC1.Rank-1\#ChannelRegularConversion=2 -PG11.Mode=Encoder_mode_occur1 SH.FMC_A5.0=FMC_A5,13b-sda1 +PG11.Mode=Encoder_mode_occur1 PA11.Signal=USB_OTG_FS_DM Dma.SPI3_TX.2.PeriphInc=DMA_PINC_DISABLE +Dma.ADC1.3.SignalID=NONE SH.S_TIM3_CH1.ConfNb=1 PF6.Mode=Single Bank 1 RCC.LPTIM345Freq_Value=120000000 @@ -674,13 +672,14 @@ ProjectManager.ComputerToolchain=false PF9.Signal=QUADSPI_BK1_IO1 RCC.LTDCFreq_Value=98285714.2857143 PB3\ (JTDO/TRACESWO).Mode=Trace_Asynchronous_SW -Mcu.Pin109=PA7 -Mcu.Pin105=PB13 +Mcu.Pin109=PB1 +Dma.ADC1.3.EventEnable=DISABLE +Mcu.Pin105=PD9 PA8.Mode=Asynchronous -Mcu.Pin106=PD9 +Mcu.Pin106=PD8 SPI2.DataSize=SPI_DATASIZE_8BIT -Mcu.Pin107=PD8 -Mcu.Pin108=PA3 +Mcu.Pin107=PA3 +Mcu.Pin108=PA7 SH.FMC_NBL3.0=FMC_NBL3,Sd4ByteEnable1 PG3.GPIO_Label=ADC_RST SH.FMC_D12_DA12.ConfNb=1 @@ -717,11 +716,12 @@ PC10.Locked=true SPI3.NSSPMode=SPI_NSS_PULSE_DISABLE PC10.Signal=SharedStack_PC10 SH.FMC_NBL0.0=FMC_NBL0,Sd4ByteEnable1 -ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_QUADSPI_Init-QUADSPI-false-HAL-true,5-MX_FMC_Init-FMC-false-HAL-true,6-MX_SAI1_Init-SAI1-false-HAL-true,7-MX_ADC1_Init-ADC1-false-HAL-true,8-MX_SPI2_Init-SPI2-false-HAL-true,9-MX_SPI3_Init-SPI3-false-HAL-true,10-MX_TIM2_Init-TIM2-false-HAL-true,11-MX_TIM3_Init-TIM3-false-HAL-true,12-MX_TIM4_Init-TIM4-false-HAL-true,13-MX_UART5_Init-UART5-false-HAL-true,14-MX_UART7_Init-UART7-false-HAL-true,15-MX_LPTIM1_Init-LPTIM1-false-HAL-true,16-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,17-MX_USB_HOST_Init-USB_HOST-false-HAL-false,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_QUADSPI_Init-QUADSPI-false-HAL-true,5-MX_FMC_Init-FMC-false-HAL-true,6-MX_SAI1_Init-SAI1-false-HAL-true,7-MX_ADC1_Init-ADC1-false-HAL-true,8-MX_SPI2_Init-SPI2-false-HAL-true,9-MX_SPI3_Init-SPI3-false-HAL-true,10-MX_TIM2_Init-TIM2-false-HAL-true,11-MX_TIM3_Init-TIM3-false-HAL-true,12-MX_TIM4_Init-TIM4-false-HAL-true,13-MX_UART5_Init-UART5-false-HAL-true,14-MX_UART7_Init-UART7-false-HAL-true,15-MX_LPTIM1_Init-LPTIM1-false-HAL-true,16-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true SH.FMC_D6_DA6.0=FMC_D6,sd-32b-d1 PC9.Locked=true PC10.GPIO_Speed=GPIO_SPEED_FREQ_HIGH PC13.GPIO_Label=EXTI13 +Dma.ADC1.3.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD PB11.Signal=GPIO_Output SAI1.ActiveFrameLength-SAI_A_MasterWithClock=128 Dma.SPI3_TX.2.SyncSignalID=NONE @@ -733,7 +733,6 @@ RCC.VCOInput3Freq_Value=1142857.142857143 PH3.Mode=SdramChipSelect1_1 SH.SharedStack_PC11.0=SDMMC1_D3 SH.SharedStack_PC11.1=SPI3_MISO -USB_HOST.USBH_HandleTypeDef-AUDIO_HS=hUsbHostHS SH.FMC_A7.0=FMC_A7,13b-sda1 PA12.Signal=USB_OTG_FS_DP PH4.GPIOParameters=GPIO_Label @@ -742,8 +741,9 @@ Mcu.UserConstants= SH.GPXTI13.ConfNb=1 Mcu.ThirdPartyNb=0 RCC.HCLKFreq_Value=240000000 -Mcu.IPNb=23 +Mcu.IPNb=21 RCC.SPDIFRXFreq_Value=192000000 +Dma.ADC1.3.PeriphInc=DMA_PINC_DISABLE PF12.Signal=FMC_A6 FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 Mcu.Pin6=PB3 (JTDO/TRACESWO) @@ -782,7 +782,7 @@ Dma.SPI3_TX.2.Priority=DMA_PRIORITY_LOW SH.FMC_SDNRAS.0=FMC_SDNRAS,13b-sda1 PE4.Signal=SAI1_FS_A PE6.GPIOParameters=GPIO_Speed -Dma.RequestsNb=3 +Dma.RequestsNb=4 ProjectManager.ProjectName=Xibeca RCC.APB3Freq_Value=120000000 SAI1.VirtualSlotActive-SAI_B_SyncSlave=SAI_SLOTACTIVE_ALL @@ -828,8 +828,10 @@ PI10.Signal=FMC_D31 NVIC.DMA1_Stream1_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true Dma.SAI1_A.0.MemInc=DMA_MINC_ENABLE Dma.SPI3_TX.2.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.ADC1.3.FIFOMode=DMA_FIFOMODE_DISABLE ADC1.SamplingTime-2\#ChannelRegularConversion=ADC_SAMPLETIME_64CYCLES_5 PD2.Stacked=true +Dma.ADC1.3.SyncEnable=DISABLE PC14-OSC32_IN\ (OSC32_IN).Locked=true RCC.SPI6Freq_Value=120000000 PC12.GPIOParameters=GPIO_Speed @@ -858,6 +860,7 @@ SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_TX Dma.SAI1_A.0.Priority=DMA_PRIORITY_VERY_HIGH PG14.Signal=GPIO_Output SH.S_TIM3_CH2.0=TIM3_CH2,Encoder_Interface +Dma.ADC1.3.MemDataAlignment=DMA_MDATAALIGN_HALFWORD SAI1.IPParameters=Instance-SAI_A_MasterWithClock,VirtualMode-SAI_A_MasterWithClock,MClockEnable-SAI_A_MasterWithClock,RealAudioFreq-SAI_A_MasterWithClock,ErrorAudioFreq-SAI_A_MasterWithClock,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,FrameLength-SAI_A_MasterWithClock,FrameLength-SAI_B_SyncSlave,DataSize-SAI_A_MasterWithClock,SlotSize-SAI_A_MasterWithClock,SlotSize-SAI_B_SyncSlave,SlotNumber-SAI_A_MasterWithClock,AudioFrequency-SAI_A_MasterWithClock,DataSize-SAI_B_SyncSlave,SlotNumber-SAI_B_SyncSlave,AudioMode-SAI_A_MasterWithClock,AudioMode-SAI_B_SyncSlave,FSOffset-SAI_A_MasterWithClock,FSOffset-SAI_B_SyncSlave,FSPolarity-SAI_A_MasterWithClock,FSPolarity-SAI_B_SyncSlave,VirtualSlotActive-SAI_A_MasterWithClock,SlotActive-SAI_A_MasterWithClock,NoDivider-SAI_A_MasterWithClock,ClockStrobing-SAI_A_MasterWithClock,OutputDrive-SAI_A_MasterWithClock,VirtualSlotActive-SAI_B_SyncSlave,SlotActive-SAI_B_SyncSlave,OutputDrive-SAI_B_SyncSlave,FSDefinition-SAI_A_MasterWithClock,FSDefinition-SAI_B_SyncSlave,ActiveFrameLength-SAI_A_MasterWithClock,ActiveFrameLength-SAI_B_SyncSlave SH.GPXTI3.0=GPIO_EXTI3 RCC.VCOInput1Freq_Value=8000000 From 8691872e9523a64655a5c993204c630b0fa6e9fe Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 30 Aug 2021 11:49:23 +0200 Subject: [PATCH 053/286] adc changes (not working) --- Xibeca/Core/Inc/hardware.h | 2 ++ Xibeca/Core/Inc/stm32h7xx_it.h | 2 ++ Xibeca/Core/Src/main.c | 15 +++++++++------ Xibeca/Core/Src/stm32h7xx_hal_msp.c | 29 ++++++++++++++++++++++++++++ Xibeca/Core/Src/stm32h7xx_it.c | 30 +++++++++++++++++++++++++++++ Xibeca/Xibeca.ioc | 18 +++++++++-------- 6 files changed, 82 insertions(+), 14 deletions(-) diff --git a/Xibeca/Core/Inc/hardware.h b/Xibeca/Core/Inc/hardware.h index 208a59cc..c4f77637 100644 --- a/Xibeca/Core/Inc/hardware.h +++ b/Xibeca/Core/Inc/hardware.h @@ -11,6 +11,8 @@ /* #define USE_ICACHE */ /* #define USE_DCACHE */ +#define ARM_CYCLES_PER_SAMPLE (480000000/AUDIO_SAMPLINGRATE) /* 480MHz / 48kHz */ + #define USE_SCREEN #define SSD1309 #define SSD1306 diff --git a/Xibeca/Core/Inc/stm32h7xx_it.h b/Xibeca/Core/Inc/stm32h7xx_it.h index b8915c92..3bca4b74 100644 --- a/Xibeca/Core/Inc/stm32h7xx_it.h +++ b/Xibeca/Core/Inc/stm32h7xx_it.h @@ -51,6 +51,8 @@ void SysTick_Handler(void); void DMA1_Stream0_IRQHandler(void); void DMA1_Stream1_IRQHandler(void); void DMA1_Stream2_IRQHandler(void); +void DMA1_Stream3_IRQHandler(void); +void ADC_IRQHandler(void); void SPI3_IRQHandler(void); void SAI1_IRQHandler(void); void OTG_FS_IRQHandler(void); diff --git a/Xibeca/Core/Src/main.c b/Xibeca/Core/Src/main.c index b5583ca7..e4fd43c8 100644 --- a/Xibeca/Core/Src/main.c +++ b/Xibeca/Core/Src/main.c @@ -44,6 +44,7 @@ /* Private variables ---------------------------------------------------------*/ ADC_HandleTypeDef hadc1; +DMA_HandleTypeDef hdma_adc1; LPTIM_HandleTypeDef hlptim1; @@ -289,8 +290,8 @@ void PeriphCommonClock_Config(void) /** Initializes the peripherals clock */ - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_ADC|RCC_PERIPHCLK_SAI1 - |RCC_PERIPHCLK_SPI3|RCC_PERIPHCLK_SPI2; + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SAI1|RCC_PERIPHCLK_SPI3 + |RCC_PERIPHCLK_SPI2; PeriphClkInitStruct.PLL2.PLL2M = 1; PeriphClkInitStruct.PLL2.PLL2N = 18; PeriphClkInitStruct.PLL2.PLL2P = 6; @@ -309,7 +310,6 @@ void PeriphCommonClock_Config(void) PeriphClkInitStruct.PLL3.PLL3FRACN = 0; PeriphClkInitStruct.Sai1ClockSelection = RCC_SAI1CLKSOURCE_PLL3; PeriphClkInitStruct.Spi123ClockSelection = RCC_SPI123CLKSOURCE_PLL2; - PeriphClkInitStruct.AdcClockSelection = RCC_ADCCLKSOURCE_PLL2; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) { Error_Handler(); @@ -337,8 +337,8 @@ static void MX_ADC1_Init(void) /** Common config */ hadc1.Instance = ADC1; - hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1; - hadc1.Init.Resolution = ADC_RESOLUTION_16B; + hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4; + hadc1.Init.Resolution = ADC_RESOLUTION_12B; hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE; hadc1.Init.EOCSelection = ADC_EOC_SEQ_CONV; hadc1.Init.LowPowerAutoWait = DISABLE; @@ -366,7 +366,7 @@ static void MX_ADC1_Init(void) */ sConfig.Channel = ADC_CHANNEL_10; sConfig.Rank = ADC_REGULAR_RANK_1; - sConfig.SamplingTime = ADC_SAMPLETIME_64CYCLES_5; + sConfig.SamplingTime = ADC_SAMPLETIME_387CYCLES_5; sConfig.SingleDiff = ADC_SINGLE_ENDED; sConfig.OffsetNumber = ADC_OFFSET_NONE; sConfig.Offset = 0; @@ -914,6 +914,9 @@ static void MX_DMA_Init(void) /* DMA1_Stream2_IRQn interrupt configuration */ HAL_NVIC_SetPriority(DMA1_Stream2_IRQn, 5, 0); HAL_NVIC_EnableIRQ(DMA1_Stream2_IRQn); + /* DMA1_Stream3_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA1_Stream3_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA1_Stream3_IRQn); } diff --git a/Xibeca/Core/Src/stm32h7xx_hal_msp.c b/Xibeca/Core/Src/stm32h7xx_hal_msp.c index 64c11cb0..80e60765 100644 --- a/Xibeca/Core/Src/stm32h7xx_hal_msp.c +++ b/Xibeca/Core/Src/stm32h7xx_hal_msp.c @@ -24,6 +24,8 @@ /* USER CODE BEGIN Includes */ /* USER CODE END Includes */ +extern DMA_HandleTypeDef hdma_adc1; + extern DMA_HandleTypeDef hdma_spi3_tx; /* Private typedef -----------------------------------------------------------*/ @@ -124,6 +126,28 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + /* ADC1 DMA Init */ + /* ADC1 Init */ + hdma_adc1.Instance = DMA1_Stream3; + hdma_adc1.Init.Request = DMA_REQUEST_ADC1; + hdma_adc1.Init.Direction = DMA_PERIPH_TO_MEMORY; + hdma_adc1.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_adc1.Init.MemInc = DMA_MINC_ENABLE; + hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; + hdma_adc1.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; + hdma_adc1.Init.Mode = DMA_CIRCULAR; + hdma_adc1.Init.Priority = DMA_PRIORITY_LOW; + hdma_adc1.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + if (HAL_DMA_Init(&hdma_adc1) != HAL_OK) + { + Error_Handler(); + } + + __HAL_LINKDMA(hadc,DMA_Handle,hdma_adc1); + + /* ADC1 interrupt Init */ + HAL_NVIC_SetPriority(ADC_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(ADC_IRQn); /* USER CODE BEGIN ADC1_MspInit 1 */ /* USER CODE END ADC1_MspInit 1 */ @@ -163,6 +187,11 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) HAL_GPIO_DeInit(GPIOB, GPIO_PIN_1|GPIO_PIN_0); + /* ADC1 DMA DeInit */ + HAL_DMA_DeInit(hadc->DMA_Handle); + + /* ADC1 interrupt DeInit */ + HAL_NVIC_DisableIRQ(ADC_IRQn); /* USER CODE BEGIN ADC1_MspDeInit 1 */ /* USER CODE END ADC1_MspDeInit 1 */ diff --git a/Xibeca/Core/Src/stm32h7xx_it.c b/Xibeca/Core/Src/stm32h7xx_it.c index 630160ee..9aa592c7 100644 --- a/Xibeca/Core/Src/stm32h7xx_it.c +++ b/Xibeca/Core/Src/stm32h7xx_it.c @@ -59,6 +59,8 @@ /* External variables --------------------------------------------------------*/ extern PCD_HandleTypeDef hpcd_USB_OTG_FS; +extern DMA_HandleTypeDef hdma_adc1; +extern ADC_HandleTypeDef hadc1; extern DMA_HandleTypeDef hdma_sai1_a; extern DMA_HandleTypeDef hdma_sai1_b; extern SAI_HandleTypeDef hsai_BlockA1; @@ -143,6 +145,34 @@ void DMA1_Stream2_IRQHandler(void) /* USER CODE END DMA1_Stream2_IRQn 1 */ } +/** + * @brief This function handles DMA1 stream3 global interrupt. + */ +void DMA1_Stream3_IRQHandler(void) +{ + /* USER CODE BEGIN DMA1_Stream3_IRQn 0 */ + + /* USER CODE END DMA1_Stream3_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_adc1); + /* USER CODE BEGIN DMA1_Stream3_IRQn 1 */ + + /* USER CODE END DMA1_Stream3_IRQn 1 */ +} + +/** + * @brief This function handles ADC1 and ADC2 global interrupts. + */ +void ADC_IRQHandler(void) +{ + /* USER CODE BEGIN ADC_IRQn 0 */ + + /* USER CODE END ADC_IRQn 0 */ + HAL_ADC_IRQHandler(&hadc1); + /* USER CODE BEGIN ADC_IRQn 1 */ + + /* USER CODE END ADC_IRQn 1 */ +} + /** * @brief This function handles SPI3 global interrupt. */ diff --git a/Xibeca/Xibeca.ioc b/Xibeca/Xibeca.ioc index f192ebc6..ef97b424 100644 --- a/Xibeca/Xibeca.ioc +++ b/Xibeca/Xibeca.ioc @@ -256,8 +256,8 @@ ProjectManager.MainLocation=Core/Src SH.SharedStack_PC12.0=SDMMC1_CK SH.FMC_A6.ConfNb=1 USB_DEVICE.CLASS_NAME_FS=AUDIO -ADC1.OffsetSignedSaturation-1\#ChannelRegularConversion=DISABLE SH.FMC_A8.0=FMC_A8,13b-sda1 +ADC1.OffsetSignedSaturation-1\#ChannelRegularConversion=DISABLE ProjectManager.KeepUserCode=true PH14.Signal=FMC_D22 PH10.Signal=FMC_D18 @@ -282,8 +282,8 @@ PG11.Signal=LPTIM1_IN2 PD13.Signal=S_TIM4_CH2 Mcu.IP4=FMC Mcu.IP5=FREERTOS -Mcu.IP2=DEBUG Dma.SPI3_TX.2.SignalID=NONE +Mcu.IP2=DEBUG Mcu.IP3=DMA Mcu.IP0=ADC1 Mcu.IP1=CORTEX_M7 @@ -295,7 +295,7 @@ RCC.SDMMCFreq_Value=192000000 ADC1.Channel-3\#ChannelRegularConversion=ADC_CHANNEL_8 SAI1.ActiveFrameLength-SAI_B_SyncSlave=128 Dma.ADC1.3.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -ADC1.Resolution=ADC_RESOLUTION_12B_OPT +ADC1.Resolution=ADC_RESOLUTION_12B ProjectManager.PreviousToolchain= SH.FMC_NBL1.0=FMC_NBL1,Sd4ByteEnable1 FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configUSE_IDLE_HOOK,configUSE_TICK_HOOK,configUSE_MALLOC_FAILED_HOOK,INCLUDE_vTaskDelayUntil,configUSE_MUTEXES,configCHECK_FOR_STACK_OVERFLOW,FootprintOK @@ -470,7 +470,7 @@ RCC.I2C123Freq_Value=120000000 SH.SharedStack_PC8.ConfNb=2 SH.GPXTI4.0=GPIO_EXTI4 ADC1.Rank-3\#ChannelRegularConversion=4 -ADC1.SamplingTime-3\#ChannelRegularConversion=ADC_SAMPLETIME_64CYCLES_5 +ADC1.SamplingTime-3\#ChannelRegularConversion=ADC_SAMPLETIME_387CYCLES_5 KeepUserPlacement=false PC15-OSC32_OUT\ (OSC32_OUT).GPIO_Label=EXTI15 SH.ADCx_INP14.ConfNb=1 @@ -556,7 +556,7 @@ SH.FMC_D25.ConfNb=1 NVIC.SAI1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true RCC.DIVR2Freq_Value=75000000 PE10.Signal=FMC_D7_DA7 -ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_64CYCLES_5 +ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_387CYCLES_5 RCC.MCO2PinFreq_Value=480000000 PC8.GPIOParameters=GPIO_Label PF8.GPIOParameters=GPIO_Label @@ -589,7 +589,7 @@ SAI1.DataSize-SAI_B_SyncSlave=SAI_DATASIZE_24 RCC.DIVQ1=5 ADC1.Rank-0\#ChannelRegularConversion=1 SH.FMC_D28.0=FMC_D28,sd-32b-d1 -ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,master,NbrOfConversion,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,OffsetNumber-1\#ChannelRegularConversion,OffsetSignedSaturation-1\#ChannelRegularConversion,Rank-2\#ChannelRegularConversion,Channel-2\#ChannelRegularConversion,SamplingTime-2\#ChannelRegularConversion,OffsetNumber-2\#ChannelRegularConversion,OffsetSignedSaturation-2\#ChannelRegularConversion,Rank-3\#ChannelRegularConversion,Channel-3\#ChannelRegularConversion,SamplingTime-3\#ChannelRegularConversion,OffsetNumber-3\#ChannelRegularConversion,OffsetSignedSaturation-3\#ChannelRegularConversion,OversamplingMode,ContinuousConvMode,EOCSelection,Resolution +ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,master,NbrOfConversion,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,OffsetNumber-1\#ChannelRegularConversion,OffsetSignedSaturation-1\#ChannelRegularConversion,Rank-2\#ChannelRegularConversion,Channel-2\#ChannelRegularConversion,SamplingTime-2\#ChannelRegularConversion,OffsetNumber-2\#ChannelRegularConversion,OffsetSignedSaturation-2\#ChannelRegularConversion,Rank-3\#ChannelRegularConversion,Channel-3\#ChannelRegularConversion,SamplingTime-3\#ChannelRegularConversion,OffsetNumber-3\#ChannelRegularConversion,OffsetSignedSaturation-3\#ChannelRegularConversion,OversamplingMode,ContinuousConvMode,EOCSelection,Resolution,ClockPrescaler RCC.SWPMI1Freq_Value=120000000 FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 Dma.SPI3_TX.2.EventEnable=DISABLE @@ -651,7 +651,7 @@ ProjectManager.UnderRoot=false SH.FMC_D7_DA7.ConfNb=1 Dma.SAI1_B.1.MemDataAlignment=DMA_MDATAALIGN_WORD PA4.Signal=GPIO_Output -ADC1.SamplingTime-1\#ChannelRegularConversion=ADC_SAMPLETIME_64CYCLES_5 +ADC1.SamplingTime-1\#ChannelRegularConversion=ADC_SAMPLETIME_387CYCLES_5 PB5.Signal=UART5_RX Mcu.Pin120=VP_SYS_VS_Systick Mcu.Pin121=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS @@ -733,6 +733,7 @@ RCC.VCOInput3Freq_Value=1142857.142857143 PH3.Mode=SdramChipSelect1_1 SH.SharedStack_PC11.0=SDMMC1_D3 SH.SharedStack_PC11.1=SPI3_MISO +NVIC.ADC_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true SH.FMC_A7.0=FMC_A7,13b-sda1 PA12.Signal=USB_OTG_FS_DP PH4.GPIOParameters=GPIO_Label @@ -829,7 +830,7 @@ NVIC.DMA1_Stream1_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true Dma.SAI1_A.0.MemInc=DMA_MINC_ENABLE Dma.SPI3_TX.2.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT Dma.ADC1.3.FIFOMode=DMA_FIFOMODE_DISABLE -ADC1.SamplingTime-2\#ChannelRegularConversion=ADC_SAMPLETIME_64CYCLES_5 +ADC1.SamplingTime-2\#ChannelRegularConversion=ADC_SAMPLETIME_387CYCLES_5 PD2.Stacked=true Dma.ADC1.3.SyncEnable=DISABLE PC14-OSC32_IN\ (OSC32_IN).Locked=true @@ -898,6 +899,7 @@ RCC.D3PPRE=RCC_APB4_DIV2 PC9.Signal=SharedStack_PC9 RCC.VCOInput2Freq_Value=8000000 RCC.APB1Freq_Value=120000000 +ADC1.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV4 PB11.Locked=true ProjectManager.DeviceId=STM32H743IIKx ProjectManager.LibraryCopy=1 From e941fc671387eb2884a8cf362f57726194dfb72e Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 30 Aug 2021 18:55:40 +0200 Subject: [PATCH 054/286] pin mappings for leds and buttons --- Xibeca/Core/Inc/main.h | 17 ++- Xibeca/Core/Src/Xibeca.cpp | 189 +++++++++++++++++++++++++++- Xibeca/Core/Src/main.c | 22 ++-- Xibeca/Core/Src/stm32h7xx_hal_msp.c | 18 ++- Xibeca/Xibeca.ioc | 91 ++++++++------ 5 files changed, 268 insertions(+), 69 deletions(-) diff --git a/Xibeca/Core/Inc/main.h b/Xibeca/Core/Inc/main.h index 7508cd60..f5c38085 100644 --- a/Xibeca/Core/Inc/main.h +++ b/Xibeca/Core/Inc/main.h @@ -72,8 +72,6 @@ void Error_Handler(void); #define EXTI11_GPIO_Port GPIOI #define EXTI15_Pin GPIO_PIN_15 #define EXTI15_GPIO_Port GPIOC -#define EXTI4_Pin GPIO_PIN_4 -#define EXTI4_GPIO_Port GPIOH #define FLASH_NCS_Pin GPIO_PIN_6 #define FLASH_NCS_GPIO_Port GPIOG #define FLASH_DQ3_Pin GPIO_PIN_6 @@ -86,6 +84,10 @@ void Error_Handler(void); #define FLASH_DQ1_GPIO_Port GPIOF #define FLASH_DQ0_Pin GPIO_PIN_8 #define FLASH_DQ0_GPIO_Port GPIOF +#define ADC1_Pin GPIO_PIN_0 +#define ADC1_GPIO_Port GPIOC +#define ADC5_Pin GPIO_PIN_1 +#define ADC5_GPIO_Port GPIOC #define ADC_SPI_MISO_Pin GPIO_PIN_2 #define ADC_SPI_MISO_GPIO_Port GPIOC #define ADC_SPI_MOSI_Pin GPIO_PIN_3 @@ -94,10 +96,18 @@ void Error_Handler(void); #define EXTI0_GPIO_Port GPIOA #define OLED_RST_Pin GPIO_PIN_4 #define OLED_RST_GPIO_Port GPIOA +#define ADC2_Pin GPIO_PIN_2 +#define ADC2_GPIO_Port GPIOA +#define ADC4_Pin GPIO_PIN_5 +#define ADC4_GPIO_Port GPIOC #define EXTI3_Pin GPIO_PIN_3 #define EXTI3_GPIO_Port GPIOA #define EXTI7_Pin GPIO_PIN_7 #define EXTI7_GPIO_Port GPIOA +#define ADC3_Pin GPIO_PIN_1 +#define ADC3_GPIO_Port GPIOB +#define ADC7_Pin GPIO_PIN_0 +#define ADC7_GPIO_Port GPIOB #define ADC_SPI_CLK_Pin GPIO_PIN_10 #define ADC_SPI_CLK_GPIO_Port GPIOB #define ADC_SPI_NCS_Pin GPIO_PIN_11 @@ -113,6 +123,9 @@ void Error_Handler(void); #define ADC_RESET_Pin ADC_RST_Pin #define ADC_RESET_GPIO_Port ADC_RST_GPIO_Port + + + /* USER CODE END Private defines */ #ifdef __cplusplus diff --git a/Xibeca/Core/Src/Xibeca.cpp b/Xibeca/Core/Src/Xibeca.cpp index 357be92f..a8f6d548 100644 --- a/Xibeca/Core/Src/Xibeca.cpp +++ b/Xibeca/Core/Src/Xibeca.cpp @@ -3,6 +3,50 @@ #include "errorhandlers.h" #include "Pin.h" #include "ApplicationSettings.h" +#include "OpenWareMidiControl.h" + +#if 0 +#define XIBECA_PIN3 GPIOD, GPIO_PIN_2 +#define XIBECA_PIN4 GPIOG, GPIO_PIN_10 +#define XIBECA_PIN5 GPIOC, GPIO_PIN_9 +#define XIBECA_PIN6 GPIOC, GPIO_PIN_8 +#define XIBECA_PIN7 GPIOC, GPIO_PIN_13 +#define XIBECA_PIN8 GPIOI, GPIO_PIN_11 +#define XIBECA_PIN9 GPIOC, GPIO_PIN_14 +#define XIBECA_PIN10 GPIOA, GPIO_PIN_0 +#define XIBECA_PIN11 GPIOH, GPIO_PIN_4 +#define XIBECA_PIN12 GPIOC, GPIO_PIN_15 +#define XIBECA_PIN13 GPIOA, GPIO_PIN_7 +#define XIBECA_PIN14 GPIOA, GPIO_PIN_3 + +#endif + +#define PUSH_A_Pin GPIO_PIN_0 +#define PUSH_A_GPIO_Port GPIOA +#define PUSH_B_Pin GPIO_PIN_4 +#define PUSH_B_GPIO_Port GPIOB +#define PUSH_C_Pin GPIO_PIN_6 +#define PUSH_C_GPIO_Port GPIOA +#define PUSH_D_Pin GPIO_PIN_4 +#define PUSH_D_GPIO_Port GPIOC + +#define PUSH_TUNE_Pin GPIO_PIN_10 +#define PUSH_TUNE_GPIO_Port GPIOG +#define PUSH_MOD_Pin GPIO_PIN_15 +#define PUSH_MOD_GPIO_Port GPIOC +#define PUSH_NOTES_Pin GPIO_PIN_13 +#define PUSH_NOTES_GPIO_Port GPIOB +#define PUSH_CV_Pin GPIO_PIN_14 +#define PUSH_CV_GPIO_Port GPIOB + +#define SYNC_OUT_A_Pin GPIO_PIN_2 +#define SYNC_OUT_A_GPIO_Port GPIOD +#define SYNC_OUT_B_Pin GPIO_PIN_9 +#define SYNC_OUT_B_GPIO_Port GPIOC +#define SYNC_OUT_C_Pin GPIO_PIN_13 +#define SYNC_OUT_C_GPIO_Port GPIOC +#define SYNC_OUT_D_Pin GPIO_PIN_14 +#define SYNC_OUT_D_GPIO_Port GPIOC #ifdef USE_SCREEN #include "Graphics.h" @@ -11,14 +55,150 @@ Graphics graphics; extern "C" void onResourceUpdate(void); +void onResourceUpdate(void){ +} + +Pin led_tune(GPIOC, GPIO_PIN_8); +Pin led_mod(GPIOA, GPIO_PIN_3); +Pin led_notes(GPIOA, GPIO_PIN_7); +Pin led_cv(GPIOH, GPIO_PIN_4); +Pin led_a(GPIOI, GPIO_PIN_11); +Pin led_b(GPIOG, GPIO_PIN_13); +Pin led_c(GPIOA, GPIO_PIN_5); +Pin led_d(GPIOB, GPIO_PIN_0); +Pin led_options(GPIOB, GPIO_PIN_6); + +Pin push_tune(GPIOG, GPIO_PIN_10); +Pin push_mod(GPIOC, GPIO_PIN_15); +Pin push_notes(GPIOB, GPIO_PIN_13); +Pin push_cv(GPIOB, GPIO_PIN_14); +Pin push_a(GPIOA, GPIO_PIN_0); +Pin push_b(GPIOB, GPIO_PIN_4); +Pin push_c(GPIOA, GPIO_PIN_6); +Pin push_d(GPIOC, GPIO_PIN_4); +Pin push_options(GPIOB, GPIO_PIN_5); + +// Pin led_d(PIN30_GPIO_Port, PIN30_Pin); +// Pin led_d(XIBECA_PIN30); + +// Pin hard_sync_a(PIN17_GPIO_Port, PIN17_Pin); +// Pin hard_sync_b(PIN19_GPIO_Port, PIN19_Pin); +// Pin hard_sync_c(PIN21_GPIO_Port, PIN21_Pin); +// Pin hard_sync_d(PIN22_GPIO_Port, PIN22_Pin); + + void setLed(uint8_t led, uint32_t rgb){ + bool value = rgb; + switch(led){ + case 1: + led_tune.set(value); + break; + case 2: + led_mod.set(value); + break; + case 3: + led_notes.set(value); + break; + case 4: + led_cv.set(value); + break; + case 5: + led_a.set(value); + break; + case 6: + led_b.set(value); + break; + case 7: + led_c.set(value); + break; + case 8: + led_d.set(value); + break; + case 9: + led_options.set(value); + break; + } } -void onResourceUpdate(void){ +void onChangePin(uint16_t pin){ + switch(pin){ + // case PUSH_TUNE_Pin: + // break; + // case PUSH_MOD_Pin: + // break; + // case PUSH_NOTES_Pin: + // break; + // case PUSH_CV_Pin: + // break; + // case PUSH_A_Pin: + // break; + // case PUSH_B_Pin: + // break; + // case PUSH_C_Pin: + // break; + // case PUSH_D_Pin: + // break; + case SYNC_OUT_A_Pin: + break; + case SYNC_OUT_B_Pin: + break; + case SYNC_OUT_C_Pin: + break; + case SYNC_OUT_D_Pin: + break; + } +} + +void setGateValue(uint8_t ch, int16_t value){ + int idx = 1 + ch - BUTTON_A; + setLed(idx, value ? RED_COLOUR : NO_COLOUR); + // switch(ch){ + // case BUTTON_A: + // setLed(1, value ? RED_COLOUR : NO_COLOUR); + // break; + // case BUTTON_B: + // setLed(2, value ? RED_COLOUR : NO_COLOUR); + // break; + // case BUTTON_C: + // setLed(3, value ? RED_COLOUR : NO_COLOUR); + // break; + // case BUTTON_D: + // setLed(4, value ? RED_COLOUR : NO_COLOUR); + // break; + // } } void setup(){ + led_tune.outputMode(); + led_mod.outputMode(); + led_notes.outputMode(); + led_cv.outputMode(); + led_a.outputMode(); + led_b.outputMode(); + led_c.outputMode(); + led_d.outputMode(); + led_options.outputMode(); + push_tune.inputMode(); + push_mod.inputMode(); + push_notes.inputMode(); + push_cv.inputMode(); + push_a.inputMode(); + push_b.inputMode(); + push_c.inputMode(); + push_d.inputMode(); + push_options.inputMode(); + + push_tune.setPull(PIN_PULL_UP); + push_mod.setPull(PIN_PULL_UP); + push_notes.setPull(PIN_PULL_UP); + push_cv.setPull(PIN_PULL_UP); + push_a.setPull(PIN_PULL_UP); + push_b.setPull(PIN_PULL_UP); + push_c.setPull(PIN_PULL_UP); + push_d.setPull(PIN_PULL_UP); + options.setPull(PIN_PULL_UP); + #ifdef USE_SCREEN HAL_GPIO_WritePin(OLED_RST_GPIO_Port, OLED_RST_Pin, GPIO_PIN_RESET); // OLED off extern SPI_HandleTypeDef OLED_SPI; @@ -30,6 +210,13 @@ void setup(){ } void loop(void){ + if(push_a.get()) + led_a.low(); + else + led_a.high(); + led_b.set(push_b.get()); + led_c.set(push_c.get()); + led_d.set(push_d.get()); #ifdef USE_SCREEN graphics.draw(); diff --git a/Xibeca/Core/Src/main.c b/Xibeca/Core/Src/main.c index e4fd43c8..9168715d 100644 --- a/Xibeca/Core/Src/main.c +++ b/Xibeca/Core/Src/main.c @@ -1040,9 +1040,9 @@ static void MX_GPIO_Init(void) HAL_GPIO_Init(EXTI10_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : EXTI13_Pin EXTI14_Pin EXTI15_Pin PC9 - PC8 */ + PC8 PC4 */ GPIO_InitStruct.Pin = EXTI13_Pin|EXTI14_Pin|EXTI15_Pin|GPIO_PIN_9 - |GPIO_PIN_8; + |GPIO_PIN_8|GPIO_PIN_4; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); @@ -1071,11 +1071,11 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(EXTI11_GPIO_Port, &GPIO_InitStruct); - /*Configure GPIO pin : EXTI4_Pin */ - GPIO_InitStruct.Pin = EXTI4_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + /*Configure GPIO pins : PH4 PH6 PH7 */ + GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_6|GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(EXTI4_GPIO_Port, &GPIO_InitStruct); + HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); /*Configure GPIO pin : ADC_RST_Pin */ GPIO_InitStruct.Pin = ADC_RST_Pin; @@ -1084,14 +1084,8 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(ADC_RST_GPIO_Port, &GPIO_InitStruct); - /*Configure GPIO pins : PH6 PH7 */ - GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7; - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); - - /*Configure GPIO pins : EXTI0_Pin EXTI3_Pin EXTI7_Pin */ - GPIO_InitStruct.Pin = EXTI0_Pin|EXTI3_Pin|EXTI7_Pin; + /*Configure GPIO pins : EXTI0_Pin PA6 EXTI3_Pin EXTI7_Pin */ + GPIO_InitStruct.Pin = EXTI0_Pin|GPIO_PIN_6|EXTI3_Pin|EXTI7_Pin; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); diff --git a/Xibeca/Core/Src/stm32h7xx_hal_msp.c b/Xibeca/Core/Src/stm32h7xx_hal_msp.c index 80e60765..58c7dbea 100644 --- a/Xibeca/Core/Src/stm32h7xx_hal_msp.c +++ b/Xibeca/Core/Src/stm32h7xx_hal_msp.c @@ -104,24 +104,22 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) /**ADC1 GPIO Configuration PC0 ------> ADC1_INP10 PC1 ------> ADC1_INP11 - PC4 ------> ADC1_INP4 PA2 ------> ADC1_INP14 - PA6 ------> ADC1_INP3 PC5 ------> ADC1_INP8 PB1 ------> ADC1_INP5 PB0 ------> ADC1_INP9 */ - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5; + GPIO_InitStruct.Pin = ADC1_Pin|ADC5_Pin|ADC4_Pin; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_6; + GPIO_InitStruct.Pin = ADC2_Pin; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + HAL_GPIO_Init(ADC2_GPIO_Port, &GPIO_InitStruct); - GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_0; + GPIO_InitStruct.Pin = ADC3_Pin|ADC7_Pin; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); @@ -174,18 +172,16 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) /**ADC1 GPIO Configuration PC0 ------> ADC1_INP10 PC1 ------> ADC1_INP11 - PC4 ------> ADC1_INP4 PA2 ------> ADC1_INP14 - PA6 ------> ADC1_INP3 PC5 ------> ADC1_INP8 PB1 ------> ADC1_INP5 PB0 ------> ADC1_INP9 */ - HAL_GPIO_DeInit(GPIOC, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5); + HAL_GPIO_DeInit(GPIOC, ADC1_Pin|ADC5_Pin|ADC4_Pin); - HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_6); + HAL_GPIO_DeInit(ADC2_GPIO_Port, ADC2_Pin); - HAL_GPIO_DeInit(GPIOB, GPIO_PIN_1|GPIO_PIN_0); + HAL_GPIO_DeInit(GPIOB, ADC3_Pin|ADC7_Pin); /* ADC1 DMA DeInit */ HAL_DMA_DeInit(hadc->DMA_Handle); diff --git a/Xibeca/Xibeca.ioc b/Xibeca/Xibeca.ioc index ef97b424..49a35353 100644 --- a/Xibeca/Xibeca.ioc +++ b/Xibeca/Xibeca.ioc @@ -20,6 +20,7 @@ SH.FMC_SDNWE.ConfNb=1 PG14.GPIOParameters=GPIO_Speed,GPIO_Label SH.ADCx_INP5.0=ADC1_INP5,IN5-Single-Ended SH.FMC_D5_DA5.0=FMC_D5,sd-32b-d1 +PA2.GPIOParameters=GPIO_Label SH.FMC_D9_DA9.0=FMC_D9,sd-32b-d1 RCC.LPTIM1Freq_Value=120000000 USB_DEVICE.PID_AUDIO_FS=0xDADA @@ -56,6 +57,7 @@ PE9.Signal=FMC_D6_DA6 Dma.SAI1_A.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING Dma.ADC1.3.Mode=DMA_CIRCULAR SH.FMC_A2.0=FMC_A2,13b-sda1 +PB1.GPIO_Label=ADC3 RCC.USART16Freq_Value=120000000 PA8.Signal=UART7_RX SH.FMC_D1_DA1.0=FMC_D1,sd-32b-d1 @@ -63,9 +65,7 @@ Dma.SPI3_TX.2.Direction=DMA_MEMORY_TO_PERIPH VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 ProjectManager.HalAssertFull=true RCC.DIVP2Freq_Value=25000000 -SH.ADCx_INP3.0=ADC1_INP3,IN3-Single-Ended PA0.Signal=GPXTI0 -SH.ADCx_INP4.ConfNb=1 Mcu.Package=UFBGA176 SAI1.AudioFrequency-SAI_A_MasterWithClock=SAI_AUDIO_FREQUENCY_48K PB1.Signal=ADCx_INP5 @@ -110,7 +110,7 @@ FREERTOS.Tasks01=defaultTask,0,1024,StartDefaultTask,Default,NULL,Dynamic,NULL,N PH13.Signal=FMC_D21 Mcu.Pin79=PC1 USB_DEVICE.VirtualMode-AUDIO_FS=Audio -Mcu.PinsNb=122 +Mcu.PinsNb=121 PC14-OSC32_IN\ (OSC32_IN).GPIOParameters=GPIO_Label PC11.Locked=true Mcu.Pin73=PF8 @@ -190,8 +190,8 @@ Mcu.Pin35=PH15 Mcu.Pin36=PI1 SH.FMC_D14_DA14.ConfNb=1 Mcu.Pin39=PI10 -Dma.ADC1.3.SyncSignalID=NONE PI2.Signal=FMC_D26 +Dma.ADC1.3.SyncSignalID=NONE Mcu.Pin30=PA11 Mcu.Pin33=PI4 Mcu.Pin34=PD2 @@ -336,7 +336,7 @@ SH.FMC_D27.ConfNb=1 SH.FMC_D16.ConfNb=1 SAI1.OutputDrive-SAI_A_MasterWithClock=SAI_OUTPUTDRIVE_ENABLE USB_DEVICE.PRODUCT_STRING_AUDIO_FS=OWL-XIBECA -PA6.Signal=ADCx_INP3 +PA6.Signal=GPXTI6 Dma.SAI1_A.0.MemDataAlignment=DMA_MDATAALIGN_WORD SH.FMC_D4_DA4.ConfNb=1 NVIC.OTG_FS_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true @@ -347,22 +347,22 @@ PF8.Signal=QUADSPI_BK1_IO0 SH.FMC_D30.ConfNb=1 RCC.DIVR1Freq_Value=480000000 NVIC.SPI3_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true -Mcu.Pin95=PD10 -Mcu.Pin96=PA2 -Mcu.Pin93=PE13 -Mcu.Pin94=PD12 -Mcu.Pin99=PF12 -Mcu.Pin97=PA6 -Mcu.Pin98=PC5 +Mcu.Pin95=PA2 +Mcu.Pin96=PA6 +Mcu.Pin93=PD12 +Mcu.Pin94=PD10 +Mcu.Pin99=PF15 +Mcu.Pin97=PC5 +Mcu.Pin98=PF12 Dma.Request2=SPI3_TX Dma.Request1=SAI1_B Dma.SAI1_B.1.PeriphInc=DMA_PINC_DISABLE Dma.Request3=ADC1 FREERTOS.configUSE_TICK_HOOK=0 -Mcu.Pin91=PF13 -Mcu.Pin92=PG0 +Mcu.Pin91=PG0 +Mcu.Pin92=PE13 NVIC.DMA1_Stream0_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true -Mcu.Pin90=PC4 +Mcu.Pin90=PF13 PC5.Signal=ADCx_INP8 PH2.Mode=SdramChipSelect1_1 PE7.Signal=FMC_D4_DA4 @@ -405,6 +405,7 @@ USB_DEVICE.IPParameters=VirtualMode-AUDIO_FS,VirtualModeFS,CLASS_NAME_FS,VID-AUD PinOutPanel.CurrentBGAView=Top RCC.FamilyName=M PH1-OSC_OUT\ (PH1).Signal=RCC_OSC_OUT +SH.GPXTI6.0=GPIO_EXTI6 FREERTOS.configUSE_IDLE_HOOK=0 VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 SAI1.RealAudioFreq-SAI_A_MasterWithClock=47.991 KHz @@ -420,6 +421,7 @@ RCC.VCO1OutputFreq_Value=960000000 SH.FMC_D13_DA13.0=FMC_D13,sd-32b-d1 PH8.Signal=FMC_D16 Dma.ADC1.3.SyncRequestNumber=1 +PC5.GPIOParameters=GPIO_Label RCC.AXIClockFreq_Value=240000000 SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,DataSize,NSSPMode,CLKPolarity,CLKPhase PG10.GPIOParameters=GPIO_Label @@ -441,6 +443,7 @@ RCC.FDCANFreq_Value=192000000 PI4.Signal=FMC_NBL2 PE5.Mode=SAI_A_MasterWithClock RCC.ADCFreq_Value=25000000 +PC1.GPIO_Label=ADC5 VP_SYS_VS_Systick.Mode=SysTick SH.FMC_D12_DA12.0=FMC_D12,sd-32b-d1 SAI1.SlotNumber-SAI_A_MasterWithClock=8 @@ -482,12 +485,12 @@ PE5.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH PB7.Locked=true NVIC.DMA1_Stream3_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true PC8.Locked=true -SH.ADCx_INP3.ConfNb=1 SH.FMC_D8_DA8.ConfNb=1 PG14.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM PC12.GPIO_Speed=GPIO_SPEED_FREQ_HIGH Dma.SAI1_A.0.SyncEnable=DISABLE PA3.GPIO_Label=EXTI3 +PA6.Locked=true SAI1.SlotActive-SAI_A_MasterWithClock=0x0000FFFF SH.FMC_D7_DA7.0=FMC_D7,sd-32b-d1 SH.FMC_D24.0=FMC_D24,sd-32b-d1 @@ -529,7 +532,6 @@ RCC.DIVQ3Freq_Value=98285714.2857143 SH.FMC_D17.ConfNb=1 PE5.Signal=SAI1_SCK_A PF10.GPIO_Label=FLASH_CLK -SH.ADCx_INP4.0=ADC1_INP4,IN4-Single-Ended Dma.SAI1_B.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD PA4.Locked=true RCC.DIVM3=7 @@ -538,6 +540,7 @@ RCC.DIVM1=1 Dma.ADC1.3.Instance=DMA1_Stream3 SH.GPXTI7.0=GPIO_EXTI7 MxDb.Version=DB.6.0.21 +PB0.GPIOParameters=GPIO_Label SH.FMC_D26.0=FMC_D26,sd-32b-d1 PI6.Signal=FMC_D28 PI3.Signal=FMC_D27 @@ -589,7 +592,7 @@ SAI1.DataSize-SAI_B_SyncSlave=SAI_DATASIZE_24 RCC.DIVQ1=5 ADC1.Rank-0\#ChannelRegularConversion=1 SH.FMC_D28.0=FMC_D28,sd-32b-d1 -ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,master,NbrOfConversion,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,OffsetNumber-1\#ChannelRegularConversion,OffsetSignedSaturation-1\#ChannelRegularConversion,Rank-2\#ChannelRegularConversion,Channel-2\#ChannelRegularConversion,SamplingTime-2\#ChannelRegularConversion,OffsetNumber-2\#ChannelRegularConversion,OffsetSignedSaturation-2\#ChannelRegularConversion,Rank-3\#ChannelRegularConversion,Channel-3\#ChannelRegularConversion,SamplingTime-3\#ChannelRegularConversion,OffsetNumber-3\#ChannelRegularConversion,OffsetSignedSaturation-3\#ChannelRegularConversion,OversamplingMode,ContinuousConvMode,EOCSelection,Resolution,ClockPrescaler +ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,NbrOfConversion,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,OffsetNumber-1\#ChannelRegularConversion,OffsetSignedSaturation-1\#ChannelRegularConversion,Rank-2\#ChannelRegularConversion,Channel-2\#ChannelRegularConversion,SamplingTime-2\#ChannelRegularConversion,OffsetNumber-2\#ChannelRegularConversion,OffsetSignedSaturation-2\#ChannelRegularConversion,Rank-3\#ChannelRegularConversion,Channel-3\#ChannelRegularConversion,SamplingTime-3\#ChannelRegularConversion,OffsetNumber-3\#ChannelRegularConversion,OffsetSignedSaturation-3\#ChannelRegularConversion,OversamplingMode,ContinuousConvMode,EOCSelection,Resolution,ClockPrescaler,master RCC.SWPMI1Freq_Value=120000000 FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 Dma.SPI3_TX.2.EventEnable=DISABLE @@ -605,6 +608,7 @@ PC9.Stacked=true PG10.Signal=GPXTI10 PG10.Locked=true SH.FMC_A3.0=FMC_A3,13b-sda1 +SH.GPXTI6.ConfNb=1 RCC.USART234578Freq_Value=120000000 SH.FMC_D31.ConfNb=1 RCC.SPI123Freq_Value=25000000 @@ -626,22 +630,22 @@ PB10.Signal=SPI2_SCK SH.ADCx_INP5.ConfNb=1 RCC.USBCLockSelection=RCC_USBCLKSOURCE_HSI48 ProjectManager.LastFirmware=true -Mcu.Pin116=PE15 -Mcu.Pin117=PB10 -Mcu.Pin118=PB11 -Mcu.Pin119=VP_FREERTOS_VS_CMSIS_V1 +Mcu.Pin116=PB10 +Mcu.Pin117=PB11 +Mcu.Pin118=VP_FREERTOS_VS_CMSIS_V1 +Mcu.Pin119=VP_SYS_VS_Systick Dma.SAI1_A.0.PeriphInc=DMA_PINC_DISABLE SH.FMC_D20.ConfNb=1 PE15.Signal=FMC_D12_DA12 PE8.Signal=FMC_D5_DA5 PI1.Signal=FMC_D25 RCC.RNGFreq_Value=48000000 -Mcu.Pin112=PF14 -Mcu.Pin113=PE7 -Mcu.Pin114=PE10 -Mcu.Pin115=PE12 -Mcu.Pin110=PB0 -Mcu.Pin111=PF11 +Mcu.Pin112=PE7 +Mcu.Pin113=PE10 +Mcu.Pin114=PE12 +Mcu.Pin115=PE15 +Mcu.Pin110=PF11 +Mcu.Pin111=PF14 SH.FMC_SDNCAS.0=FMC_SDNCAS,13b-sda1 PG14.GPIO_Label=OLED_CS ProjectManager.FreePins=true @@ -653,8 +657,7 @@ Dma.SAI1_B.1.MemDataAlignment=DMA_MDATAALIGN_WORD PA4.Signal=GPIO_Output ADC1.SamplingTime-1\#ChannelRegularConversion=ADC_SAMPLETIME_387CYCLES_5 PB5.Signal=UART5_RX -Mcu.Pin120=VP_SYS_VS_Systick -Mcu.Pin121=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS +Mcu.Pin120=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS PE3.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH SH.FMC_A10.ConfNb=1 Dma.SPI3_TX.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber @@ -672,14 +675,14 @@ ProjectManager.ComputerToolchain=false PF9.Signal=QUADSPI_BK1_IO1 RCC.LTDCFreq_Value=98285714.2857143 PB3\ (JTDO/TRACESWO).Mode=Trace_Asynchronous_SW -Mcu.Pin109=PB1 +Mcu.Pin109=PB0 Dma.ADC1.3.EventEnable=DISABLE -Mcu.Pin105=PD9 +Mcu.Pin105=PD8 PA8.Mode=Asynchronous -Mcu.Pin106=PD8 +Mcu.Pin106=PA3 SPI2.DataSize=SPI_DATASIZE_8BIT -Mcu.Pin107=PA3 -Mcu.Pin108=PA7 +Mcu.Pin107=PA7 +Mcu.Pin108=PB1 SH.FMC_NBL3.0=FMC_NBL3,Sd4ByteEnable1 PG3.GPIO_Label=ADC_RST SH.FMC_D12_DA12.ConfNb=1 @@ -695,12 +698,12 @@ PG10.GPIO_Label=EXTI10 PD2.GPIO_Label=EXTI2 PG7.GPIOParameters=GPIO_Speed Dma.SAI1_A.0.PeriphDataAlignment=DMA_PDATAALIGN_WORD -Mcu.Pin101=PE8 +Mcu.Pin101=PE9 PA13\ (JTMS/SWDIO).Signal=DEBUG_JTMS-SWDIO -Mcu.Pin102=PE9 -Mcu.Pin103=PE11 -Mcu.Pin104=PE14 -Mcu.Pin100=PF15 +Mcu.Pin102=PE11 +Mcu.Pin103=PE14 +Mcu.Pin104=PD9 +Mcu.Pin100=PE8 Dma.SAI1_A.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber RCC.DIVQ2Freq_Value=75000000 SH.S_TIM4_CH2.ConfNb=1 @@ -717,8 +720,11 @@ SPI3.NSSPMode=SPI_NSS_PULSE_DISABLE PC10.Signal=SharedStack_PC10 SH.FMC_NBL0.0=FMC_NBL0,Sd4ByteEnable1 ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_QUADSPI_Init-QUADSPI-false-HAL-true,5-MX_FMC_Init-FMC-false-HAL-true,6-MX_SAI1_Init-SAI1-false-HAL-true,7-MX_ADC1_Init-ADC1-false-HAL-true,8-MX_SPI2_Init-SPI2-false-HAL-true,9-MX_SPI3_Init-SPI3-false-HAL-true,10-MX_TIM2_Init-TIM2-false-HAL-true,11-MX_TIM3_Init-TIM3-false-HAL-true,12-MX_TIM4_Init-TIM4-false-HAL-true,13-MX_UART5_Init-UART5-false-HAL-true,14-MX_UART7_Init-UART7-false-HAL-true,15-MX_LPTIM1_Init-LPTIM1-false-HAL-true,16-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true +PC0.GPIOParameters=GPIO_Label +PC0.GPIO_Label=ADC1 SH.FMC_D6_DA6.0=FMC_D6,sd-32b-d1 PC9.Locked=true +PB0.GPIO_Label=ADC7 PC10.GPIO_Speed=GPIO_SPEED_FREQ_HIGH PC13.GPIO_Label=EXTI13 Dma.ADC1.3.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD @@ -739,6 +745,7 @@ PA12.Signal=USB_OTG_FS_DP PH4.GPIOParameters=GPIO_Label SPI2.CLKPolarity=SPI_POLARITY_HIGH Mcu.UserConstants= +PC1.GPIOParameters=GPIO_Label SH.GPXTI13.ConfNb=1 Mcu.ThirdPartyNb=0 RCC.HCLKFreq_Value=240000000 @@ -791,6 +798,7 @@ Dma.SPI3_TX.2.FIFOMode=DMA_FIFOMODE_DISABLE PA7.Locked=true SH.FMC_D0_DA0.0=FMC_D0,sd-32b-d1 RCC.D1PPRE=RCC_APB3_DIV2 +PA2.GPIO_Label=ADC2 USB_OTG_FS.VirtualMode=Device_Only SH.FMC_A9.0=FMC_A9,13b-sda1 ADC1.OffsetNumber-1\#ChannelRegularConversion=ADC_OFFSET_NONE @@ -822,7 +830,6 @@ SAI1.FSPolarity-SAI_A_MasterWithClock=SAI_FS_ACTIVE_HIGH ADC1.OffsetNumber-3\#ChannelRegularConversion=ADC_OFFSET_NONE RCC.SAI4BFreq_Value=192000000 SH.FMC_SDCLK.ConfNb=1 -PC4.Signal=ADCx_INP4 RCC.D2PPRE2=RCC_APB2_DIV2 RCC.D2PPRE1=RCC_APB1_DIV2 PI10.Signal=FMC_D31 @@ -885,6 +892,7 @@ PA7.GPIO_Label=EXTI7 PA12.Mode=Device_Only Dma.SAI1_B.1.Direction=DMA_MEMORY_TO_PERIPH PC14-OSC32_IN\ (OSC32_IN).Signal=GPXTI14 +PC5.GPIO_Label=ADC4 SH.FMC_D23.0=FMC_D23,sd-32b-d1 SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B PF6.GPIOParameters=GPIO_Label @@ -904,4 +912,5 @@ PB11.Locked=true ProjectManager.DeviceId=STM32H743IIKx ProjectManager.LibraryCopy=1 SAI1.ClockStrobing-SAI_A_MasterWithClock=SAI_CLOCKSTROBING_RISINGEDGE +PB1.GPIOParameters=GPIO_Label PA7.Signal=GPXTI7 From 181955f89395c487becd31f82fe0c73588243a31 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 1 Sep 2021 16:03:13 +0200 Subject: [PATCH 055/286] Xibeca changes --- Source/Owl.cpp | 2 +- Source/device.h | 2 + Source/ssd1309.c | 40 ++++++++++--- Xibeca/Core/Inc/hardware.h | 1 + Xibeca/Core/Inc/main.h | 14 +---- Xibeca/Core/Inc/stm32h7xx_it.h | 4 ++ Xibeca/Core/Src/Xibeca.cpp | 91 +++++++++++++++++++++++++---- Xibeca/Core/Src/main.c | 85 ++++++++++++++++++++------- Xibeca/Core/Src/stm32h7xx_hal_msp.c | 7 ++- Xibeca/Core/Src/stm32h7xx_it.c | 58 ++++++++++++++++++ Xibeca/Xibeca.ioc | 71 +++++++++------------- 11 files changed, 276 insertions(+), 99 deletions(-) diff --git a/Source/Owl.cpp b/Source/Owl.cpp index 323974d3..6d458e0a 100644 --- a/Source/Owl.cpp +++ b/Source/Owl.cpp @@ -53,7 +53,7 @@ ApplicationSettings settings; Codec codec; #endif #ifdef USE_ADC -uint16_t adc_values[NOF_ADC_VALUES] DMA_RAM; +uint16_t adc_values[NOF_ADC_VALUES] DMA_RAM = {}; #endif #ifdef USE_DAC extern DAC_HandleTypeDef hdac; diff --git a/Source/device.h b/Source/device.h index fda8729b..ce4a6dbb 100644 --- a/Source/device.h +++ b/Source/device.h @@ -56,7 +56,9 @@ #define STORAGE_MAX_BLOCKS 64 #endif +#ifndef OWL_XIBECA #define DEBUG_DWT +#endif /* #define DEBUG_STACK */ #define DEBUG_STORAGE /* #define DEBUG_BOOTLOADER */ diff --git a/Source/ssd1309.c b/Source/ssd1309.c index 055f1729..41c52826 100644 --- a/Source/ssd1309.c +++ b/Source/ssd1309.c @@ -21,15 +21,40 @@ #define pDC_Clr() HAL_GPIO_WritePin(OLED_DC_GPIO_Port, OLED_DC_Pin, GPIO_PIN_RESET) #define pCS_Clr() HAL_GPIO_WritePin(OLED_CS_GPIO_Port, OLED_CS_Pin, GPIO_PIN_RESET) -#define OLED_DAT 1 -#define OLED_CMD 0 - // _____ Prototypes ____________________________________________________________________ static void OLED_writeCMD(const uint8_t* data, uint16_t length); // _____ Variables _____________________________________________________________________ -static const uint8_t OLED_initSequence[] = -{ +#define SCREEN_OFFSET 0 +static const uint8_t OLED_initSequence[] = + { +#ifdef SSD1306 + 0xAE, // Display off + 0xD5, // Set display clock divider + 0x80, + 0xA8, // Set multiplex + 0x3F, + 0xD3, // Set display offset + SCREEN_OFFSET, + 0x40, // Set start line to zero + 0x8D, // Set charge pump + 0x14, + 0x20, // Set memory mode + 0x00, + 0xA0 | 0x1, // Set segment remapping + 0xC8, // Set command Scan decode + 0xDA, // Set Comm pins + 0x12, + 0x81, // Set contrast + 0xCF, + 0xd9, // Set precharge + 0xF1, + 0xDB, // Set Vcom detect + 0x30,//40, + 0xA4, // Allow display resume + 0xA6, // Set normal display + 0xAF // Display On +#else 0xfd, 0x12, // Command unlock 0xae, // Display off 0xd5, 0xa0, // Clock divide ratio / Oscillator Frequency @@ -52,13 +77,14 @@ static const uint8_t OLED_initSequence[] = 0x81, 0xcf, // Contrast control: 0 to 0xff. Current increases with contrast. 0xd9, 0x22, // Pre-charge period 0xdb, 0x34, // VCOMH deselect level - /* 0xa4, // Entire display on/off */ - 0xa6, // Normal / inverse display + /* 0xa4, // Entire display on/off : A4 / A5 */ + 0xa6, // Normal / inverse display : A6 / A7 0x20, 0x01, // Vertical addressing mode 0x21, 0x00, 0x7f, // Set column address 0x22, 0x00, 0x07, // Set page address 0xaf, // Display on /* 0xa6, // Set Normal/Inverse Display */ +#endif }; /* static unsigned char* OLED_Buffer; */ diff --git a/Xibeca/Core/Inc/hardware.h b/Xibeca/Core/Inc/hardware.h index c4f77637..11a0ff28 100644 --- a/Xibeca/Core/Inc/hardware.h +++ b/Xibeca/Core/Inc/hardware.h @@ -12,6 +12,7 @@ /* #define USE_DCACHE */ #define ARM_CYCLES_PER_SAMPLE (480000000/AUDIO_SAMPLINGRATE) /* 480MHz / 48kHz */ +#define MAIN_LOOP_SLEEP_MS 20 #define USE_SCREEN #define SSD1309 diff --git a/Xibeca/Core/Inc/main.h b/Xibeca/Core/Inc/main.h index f5c38085..c8bdd545 100644 --- a/Xibeca/Core/Inc/main.h +++ b/Xibeca/Core/Inc/main.h @@ -62,16 +62,12 @@ void Error_Handler(void); #define FLASH_DQ2_GPIO_Port GPIOE #define OLED_CS_Pin GPIO_PIN_14 #define OLED_CS_GPIO_Port GPIOG -#define EXTI10_Pin GPIO_PIN_10 -#define EXTI10_GPIO_Port GPIOG #define EXTI13_Pin GPIO_PIN_13 #define EXTI13_GPIO_Port GPIOC +#define EXTI13_EXTI_IRQn EXTI15_10_IRQn #define EXTI14_Pin GPIO_PIN_14 #define EXTI14_GPIO_Port GPIOC -#define EXTI11_Pin GPIO_PIN_11 -#define EXTI11_GPIO_Port GPIOI -#define EXTI15_Pin GPIO_PIN_15 -#define EXTI15_GPIO_Port GPIOC +#define EXTI14_EXTI_IRQn EXTI15_10_IRQn #define FLASH_NCS_Pin GPIO_PIN_6 #define FLASH_NCS_GPIO_Port GPIOG #define FLASH_DQ3_Pin GPIO_PIN_6 @@ -92,18 +88,12 @@ void Error_Handler(void); #define ADC_SPI_MISO_GPIO_Port GPIOC #define ADC_SPI_MOSI_Pin GPIO_PIN_3 #define ADC_SPI_MOSI_GPIO_Port GPIOC -#define EXTI0_Pin GPIO_PIN_0 -#define EXTI0_GPIO_Port GPIOA #define OLED_RST_Pin GPIO_PIN_4 #define OLED_RST_GPIO_Port GPIOA #define ADC2_Pin GPIO_PIN_2 #define ADC2_GPIO_Port GPIOA #define ADC4_Pin GPIO_PIN_5 #define ADC4_GPIO_Port GPIOC -#define EXTI3_Pin GPIO_PIN_3 -#define EXTI3_GPIO_Port GPIOA -#define EXTI7_Pin GPIO_PIN_7 -#define EXTI7_GPIO_Port GPIOA #define ADC3_Pin GPIO_PIN_1 #define ADC3_GPIO_Port GPIOB #define ADC7_Pin GPIO_PIN_0 diff --git a/Xibeca/Core/Inc/stm32h7xx_it.h b/Xibeca/Core/Inc/stm32h7xx_it.h index 3bca4b74..a359b538 100644 --- a/Xibeca/Core/Inc/stm32h7xx_it.h +++ b/Xibeca/Core/Inc/stm32h7xx_it.h @@ -48,11 +48,15 @@ /* Exported functions prototypes ---------------------------------------------*/ void SysTick_Handler(void); +void EXTI2_IRQHandler(void); void DMA1_Stream0_IRQHandler(void); void DMA1_Stream1_IRQHandler(void); void DMA1_Stream2_IRQHandler(void); void DMA1_Stream3_IRQHandler(void); void ADC_IRQHandler(void); +void EXTI9_5_IRQHandler(void); +void TIM4_IRQHandler(void); +void EXTI15_10_IRQHandler(void); void SPI3_IRQHandler(void); void SAI1_IRQHandler(void); void OTG_FS_IRQHandler(void); diff --git a/Xibeca/Core/Src/Xibeca.cpp b/Xibeca/Core/Src/Xibeca.cpp index a8f6d548..63a95cd8 100644 --- a/Xibeca/Core/Src/Xibeca.cpp +++ b/Xibeca/Core/Src/Xibeca.cpp @@ -19,8 +19,6 @@ #define XIBECA_PIN13 GPIOA, GPIO_PIN_7 #define XIBECA_PIN14 GPIOA, GPIO_PIN_3 -#endif - #define PUSH_A_Pin GPIO_PIN_0 #define PUSH_A_GPIO_Port GPIOA #define PUSH_B_Pin GPIO_PIN_4 @@ -38,6 +36,7 @@ #define PUSH_NOTES_GPIO_Port GPIOB #define PUSH_CV_Pin GPIO_PIN_14 #define PUSH_CV_GPIO_Port GPIOB +#endif #define SYNC_OUT_A_Pin GPIO_PIN_2 #define SYNC_OUT_A_GPIO_Port GPIOD @@ -53,6 +52,24 @@ Graphics graphics; #endif +#define ENCODER_TIM1 htim4 +extern TIM_HandleTypeDef ENCODER_TIM1; + +// void updateEncoders(){ +// static int16_t encoder_values[2] = {INT16_MAX/2, INT16_MAX/2}; +// int16_t value = __HAL_TIM_GET_COUNTER(&ENCODER_TIM1); +// int16_t delta = value - encoder_values[0]; +// if(delta) +// graphics.params.encoderChanged(0, delta); +// encoder_values[0] = value; +// value = __HAL_TIM_GET_COUNTER(&ENCODER_TIM2); +// delta = value - encoder_values[1]; +// if(delta) +// graphics.params.encoderChanged(1, delta); +// encoder_values[1] = value; +// } +// updateEncoders(); + extern "C" void onResourceUpdate(void); void onResourceUpdate(void){ @@ -77,6 +94,7 @@ Pin push_b(GPIOB, GPIO_PIN_4); Pin push_c(GPIOA, GPIO_PIN_6); Pin push_d(GPIOC, GPIO_PIN_4); Pin push_options(GPIOB, GPIO_PIN_5); +Pin push_enc(GPIOB, GPIO_PIN_12); // Pin led_d(PIN30_GPIO_Port, PIN30_Pin); // Pin led_d(XIBECA_PIN30); @@ -120,6 +138,34 @@ void setLed(uint8_t led, uint32_t rgb){ } } +uint16_t adc = 0; +extern "C"{ + void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc){ + adc = hadc->State; + // + } +} + +#define MIN_PERIOD ((AUDIO_SAMPLINGRATE * ARM_CYCLES_PER_SAMPLE) / 32000) +#define MAX_PERIOD ((AUDIO_SAMPLINGRATE * ARM_CYCLES_PER_SAMPLE) / 20) +static uint32_t periods[4] = {}; +void updatePeriod(uint8_t idx){ + static uint32_t times[4] = {}; + uint32_t previous = times[idx]; + uint32_t now = DWT->CYCCNT; + if(now > previous){ + uint32_t elapsed = now - previous; + if(elapsed > MIN_PERIOD && elapsed < MAX_PERIOD){ + periods[idx] = elapsed; + // AUDIO_SAMPLINGRATE + // ARM_CYCLES_PER_SAMPLE + setParameterValue(PARAMETER_AA + idx, (AUDIO_SAMPLINGRATE * ARM_CYCLES_PER_SAMPLE) / elapsed); + led_tune.toggle(); + } + } + times[idx] = now; +} + void onChangePin(uint16_t pin){ switch(pin){ // case PUSH_TUNE_Pin: @@ -139,12 +185,16 @@ void onChangePin(uint16_t pin){ // case PUSH_D_Pin: // break; case SYNC_OUT_A_Pin: - break; + updatePeriod(0); + break; case SYNC_OUT_B_Pin: + updatePeriod(1); break; case SYNC_OUT_C_Pin: + updatePeriod(2); break; case SYNC_OUT_D_Pin: + updatePeriod(3); break; } } @@ -169,6 +219,16 @@ void setGateValue(uint8_t ch, int16_t value){ } void setup(){ + // DWT cycle count enable + // do it here because DEBUG_DWT is disabled + CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; + DWT->CYCCNT = 0; + DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk; + + // __HAL_TIM_SET_COUNTER(&ENCODER_TIM1, INT16_MAX/2); + __HAL_TIM_SET_COUNTER(&ENCODER_TIM1, 2048); + HAL_TIM_Encoder_Start_IT(&ENCODER_TIM1, TIM_CHANNEL_ALL); + led_tune.outputMode(); led_mod.outputMode(); led_notes.outputMode(); @@ -188,6 +248,7 @@ void setup(){ push_c.inputMode(); push_d.inputMode(); push_options.inputMode(); + push_enc.inputMode(); push_tune.setPull(PIN_PULL_UP); push_mod.setPull(PIN_PULL_UP); @@ -197,26 +258,32 @@ void setup(){ push_b.setPull(PIN_PULL_UP); push_c.setPull(PIN_PULL_UP); push_d.setPull(PIN_PULL_UP); - options.setPull(PIN_PULL_UP); + push_options.setPull(PIN_PULL_UP); + push_enc.setPull(PIN_PULL_UP); #ifdef USE_SCREEN HAL_GPIO_WritePin(OLED_RST_GPIO_Port, OLED_RST_Pin, GPIO_PIN_RESET); // OLED off extern SPI_HandleTypeDef OLED_SPI; graphics.begin(&OLED_SPI); #endif - owl.setup(); } void loop(void){ - if(push_a.get()) - led_a.low(); - else - led_a.high(); - led_b.set(push_b.get()); - led_c.set(push_c.get()); - led_d.set(push_d.get()); + led_a.set(!push_a.get()); + led_b.set(!push_b.get()); + led_c.set(!push_c.get()); + led_d.set(!push_d.get()); + + // led_tune.set(!push_tune.get()); + led_mod.set(!push_mod.get()); + led_notes.set(!push_notes.get()); + led_cv.set(!push_cv.get()); + led_options.set(!push_options.get()); + + setButtonValue(BUTTON_A, !push_enc.get()); + setParameterValue(PARAMETER_A, __HAL_TIM_GET_COUNTER(&ENCODER_TIM1) / 2); #ifdef USE_SCREEN graphics.draw(); diff --git a/Xibeca/Core/Src/main.c b/Xibeca/Core/Src/main.c index 9168715d..5a44001a 100644 --- a/Xibeca/Core/Src/main.c +++ b/Xibeca/Core/Src/main.c @@ -774,15 +774,15 @@ static void MX_TIM4_Init(void) htim4.Init.Period = 65535; htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; htim4.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; - sConfig.EncoderMode = TIM_ENCODERMODE_TI1; + sConfig.EncoderMode = TIM_ENCODERMODE_TI12; sConfig.IC1Polarity = TIM_ICPOLARITY_RISING; sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI; sConfig.IC1Prescaler = TIM_ICPSC_DIV1; - sConfig.IC1Filter = 0; + sConfig.IC1Filter = 4; sConfig.IC2Polarity = TIM_ICPOLARITY_RISING; sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI; sConfig.IC2Prescaler = TIM_ICPSC_DIV1; - sConfig.IC2Filter = 0; + sConfig.IC2Filter = 4; if (HAL_TIM_Encoder_Init(&htim4, &sConfig) != HAL_OK) { Error_Handler(); @@ -991,7 +991,13 @@ static void MX_GPIO_Init(void) HAL_GPIO_WritePin(GPIOG, OLED_CS_Pin|ADC_RST_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(OLED_RST_GPIO_Port, OLED_RST_Pin, GPIO_PIN_RESET); + HAL_GPIO_WritePin(GPIOI, GPIO_PIN_11, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(GPIOH, GPIO_PIN_4, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(GPIOA, OLED_RST_Pin|GPIO_PIN_3|GPIO_PIN_7, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(ADC_SPI_NCS_GPIO_Port, ADC_SPI_NCS_Pin, GPIO_PIN_RESET); @@ -1033,16 +1039,14 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Alternate = GPIO_AF4_I2C1; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - /*Configure GPIO pin : EXTI10_Pin */ - GPIO_InitStruct.Pin = EXTI10_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + /*Configure GPIO pin : PG10 */ + GPIO_InitStruct.Pin = GPIO_PIN_10; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(EXTI10_GPIO_Port, &GPIO_InitStruct); + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); - /*Configure GPIO pins : EXTI13_Pin EXTI14_Pin EXTI15_Pin PC9 - PC8 PC4 */ - GPIO_InitStruct.Pin = EXTI13_Pin|EXTI14_Pin|EXTI15_Pin|GPIO_PIN_9 - |GPIO_PIN_8|GPIO_PIN_4; + /*Configure GPIO pins : EXTI13_Pin EXTI14_Pin PC9 */ + GPIO_InitStruct.Pin = EXTI13_Pin|EXTI14_Pin|GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); @@ -1065,16 +1069,24 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - /*Configure GPIO pin : EXTI11_Pin */ - GPIO_InitStruct.Pin = EXTI11_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + /*Configure GPIO pin : PI11 */ + GPIO_InitStruct.Pin = GPIO_PIN_11; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(EXTI11_GPIO_Port, &GPIO_InitStruct); + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); - /*Configure GPIO pins : PH4 PH6 PH7 */ - GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_6|GPIO_PIN_7; - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + /*Configure GPIO pin : PC15 */ + GPIO_InitStruct.Pin = GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /*Configure GPIO pin : PH4 */ + GPIO_InitStruct.Pin = GPIO_PIN_4; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); /*Configure GPIO pin : ADC_RST_Pin */ @@ -1084,9 +1096,15 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(ADC_RST_GPIO_Port, &GPIO_InitStruct); - /*Configure GPIO pins : EXTI0_Pin PA6 EXTI3_Pin EXTI7_Pin */ - GPIO_InitStruct.Pin = EXTI0_Pin|GPIO_PIN_6|EXTI3_Pin|EXTI7_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + /*Configure GPIO pins : PH6 PH7 */ + GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); + + /*Configure GPIO pins : PA0 PA6 */ + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_6; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); @@ -1097,6 +1115,19 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; HAL_GPIO_Init(OLED_RST_GPIO_Port, &GPIO_InitStruct); + /*Configure GPIO pin : PC4 */ + GPIO_InitStruct.Pin = GPIO_PIN_4; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /*Configure GPIO pins : PA3 PA7 */ + GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + /*Configure GPIO pin : ADC_SPI_NCS_Pin */ GPIO_InitStruct.Pin = ADC_SPI_NCS_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; @@ -1104,6 +1135,16 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(ADC_SPI_NCS_GPIO_Port, &GPIO_InitStruct); + /* EXTI interrupt init*/ + HAL_NVIC_SetPriority(EXTI2_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(EXTI2_IRQn); + + HAL_NVIC_SetPriority(EXTI9_5_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); + + HAL_NVIC_SetPriority(EXTI15_10_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(EXTI15_10_IRQn); + } /* USER CODE BEGIN 4 */ diff --git a/Xibeca/Core/Src/stm32h7xx_hal_msp.c b/Xibeca/Core/Src/stm32h7xx_hal_msp.c index 58c7dbea..06d81c1b 100644 --- a/Xibeca/Core/Src/stm32h7xx_hal_msp.c +++ b/Xibeca/Core/Src/stm32h7xx_hal_msp.c @@ -598,11 +598,14 @@ void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef* htim_encoder) */ GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_12; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF2_TIM4; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + /* TIM4 interrupt Init */ + HAL_NVIC_SetPriority(TIM4_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(TIM4_IRQn); /* USER CODE BEGIN TIM4_MspInit 1 */ /* USER CODE END TIM4_MspInit 1 */ @@ -668,6 +671,8 @@ void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef* htim_encoder) */ HAL_GPIO_DeInit(GPIOD, GPIO_PIN_13|GPIO_PIN_12); + /* TIM4 interrupt DeInit */ + HAL_NVIC_DisableIRQ(TIM4_IRQn); /* USER CODE BEGIN TIM4_MspDeInit 1 */ /* USER CODE END TIM4_MspDeInit 1 */ diff --git a/Xibeca/Core/Src/stm32h7xx_it.c b/Xibeca/Core/Src/stm32h7xx_it.c index 9aa592c7..945b2f95 100644 --- a/Xibeca/Core/Src/stm32h7xx_it.c +++ b/Xibeca/Core/Src/stm32h7xx_it.c @@ -67,6 +67,7 @@ extern SAI_HandleTypeDef hsai_BlockA1; extern SAI_HandleTypeDef hsai_BlockB1; extern DMA_HandleTypeDef hdma_spi3_tx; extern SPI_HandleTypeDef hspi3; +extern TIM_HandleTypeDef htim4; /* USER CODE BEGIN EV */ /* USER CODE END EV */ @@ -103,6 +104,20 @@ void SysTick_Handler(void) /* please refer to the startup file (startup_stm32h7xx.s). */ /******************************************************************************/ +/** + * @brief This function handles EXTI line2 interrupt. + */ +void EXTI2_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI2_IRQn 0 */ + + /* USER CODE END EXTI2_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2); + /* USER CODE BEGIN EXTI2_IRQn 1 */ + + /* USER CODE END EXTI2_IRQn 1 */ +} + /** * @brief This function handles DMA1 stream0 global interrupt. */ @@ -173,6 +188,49 @@ void ADC_IRQHandler(void) /* USER CODE END ADC_IRQn 1 */ } +/** + * @brief This function handles EXTI line[9:5] interrupts. + */ +void EXTI9_5_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI9_5_IRQn 0 */ + + /* USER CODE END EXTI9_5_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_9); + /* USER CODE BEGIN EXTI9_5_IRQn 1 */ + + /* USER CODE END EXTI9_5_IRQn 1 */ +} + +/** + * @brief This function handles TIM4 global interrupt. + */ +void TIM4_IRQHandler(void) +{ + /* USER CODE BEGIN TIM4_IRQn 0 */ + + /* USER CODE END TIM4_IRQn 0 */ + HAL_TIM_IRQHandler(&htim4); + /* USER CODE BEGIN TIM4_IRQn 1 */ + + /* USER CODE END TIM4_IRQn 1 */ +} + +/** + * @brief This function handles EXTI line[15:10] interrupts. + */ +void EXTI15_10_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI15_10_IRQn 0 */ + + /* USER CODE END EXTI15_10_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_13); + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_14); + /* USER CODE BEGIN EXTI15_10_IRQn 1 */ + + /* USER CODE END EXTI15_10_IRQn 1 */ +} + /** * @brief This function handles SPI3 global interrupt. */ diff --git a/Xibeca/Xibeca.ioc b/Xibeca/Xibeca.ioc index 49a35353..b86a811f 100644 --- a/Xibeca/Xibeca.ioc +++ b/Xibeca/Xibeca.ioc @@ -24,7 +24,6 @@ PA2.GPIOParameters=GPIO_Label SH.FMC_D9_DA9.0=FMC_D9,sd-32b-d1 RCC.LPTIM1Freq_Value=120000000 USB_DEVICE.PID_AUDIO_FS=0xDADA -SH.GPXTI7.ConfNb=1 NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false SH.FMC_D25.0=FMC_D25,sd-32b-d1 SAI1.FSDefinition-SAI_B_SyncSlave=SAI_FS_CHANNEL_IDENTIFICATION @@ -42,6 +41,7 @@ PD0.Signal=FMC_D2_DA2 SAI1.AudioMode-SAI_A_MasterWithClock=SAI_MODEMASTER_RX PD8.Signal=FMC_D13_DA13 PE1.Signal=FMC_NBL1 +NVIC.EXTI15_10_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true ProjectManager.ProjectBuild=false NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false PA0.Locked=true @@ -65,7 +65,7 @@ Dma.SPI3_TX.2.Direction=DMA_MEMORY_TO_PERIPH VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 ProjectManager.HalAssertFull=true RCC.DIVP2Freq_Value=25000000 -PA0.Signal=GPXTI0 +PA0.Signal=GPIO_Input Mcu.Package=UFBGA176 SAI1.AudioFrequency-SAI_A_MasterWithClock=SAI_AUDIO_FREQUENCY_48K PB1.Signal=ADCx_INP5 @@ -85,6 +85,7 @@ SH.FMC_A11.ConfNb=1 SH.FMC_D27.0=FMC_D27,sd-32b-d1 FREERTOS.FootprintOK=true Dma.SAI1_A.0.SyncSignalID=NONE +NVIC.EXTI2_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true SH.S_TIM4_CH1.0=TIM4_CH1,Encoder_Interface RCC.LPUART1Freq_Value=120000000 PF10.Mode=Single Bank 1 @@ -98,7 +99,6 @@ SH.FMC_D3_DA3.ConfNb=1 PG12.Signal=LPTIM1_IN1 SAI1.NoDivider-SAI_A_MasterWithClock=SAI_MASTERDIVIDER_ENABLE Dma.SAI1_B.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -SH.GPXTI10.0=GPIO_EXTI10 USB_DEVICE.VID-AUDIO_FS=0x1209 Mcu.Pin80=PC2_C Mcu.Pin81=PC3_C @@ -118,8 +118,8 @@ Mcu.Pin74=PH11 Dma.SAI1_B.1.MemInc=DMA_MINC_ENABLE Mcu.Pin71=PF10 Mcu.Pin72=PF9 -PC13.Locked=true Mcu.Pin77=PG2 +PC13.Locked=true SAI1.MClockEnable-SAI_A_MasterWithClock=SAI_MASTERCLOCK_ENABLE PG5.Signal=FMC_A15_BA1 Mcu.Pin78=PC0 @@ -190,8 +190,8 @@ Mcu.Pin35=PH15 Mcu.Pin36=PI1 SH.FMC_D14_DA14.ConfNb=1 Mcu.Pin39=PI10 -PI2.Signal=FMC_D26 Dma.ADC1.3.SyncSignalID=NONE +PI2.Signal=FMC_D26 Mcu.Pin30=PA11 Mcu.Pin33=PI4 Mcu.Pin34=PD2 @@ -204,9 +204,10 @@ FREERTOS.configUSE_MUTEXES=0 PF13.Signal=FMC_A7 PC10.GPIOParameters=GPIO_Speed SH.SharedStack_PC8.0=SDMMC1_D0 -SH.SharedStack_PC8.1=GPIO_EXTI8 +SH.SharedStack_PC8.1=GPIO_EXTI8+0 SH.FMC_NBL2.0=FMC_NBL2,Sd4ByteEnable1 PC9.GPIOParameters=GPIO_Label +SH.SharedStack_PC8.2=GPIO_Output PF9.GPIOParameters=GPIO_Label Mcu.Pin26=PI5 SH.FMC_D18.0=FMC_D18,sd-32b-d1 @@ -230,22 +231,18 @@ Dma.ADC1.3.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlign SH.FMC_SDNRAS.ConfNb=1 ProjectManager.HeapSize=0x200 Mcu.Pin15=PB6 -PA0.GPIOParameters=GPIO_Label NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false Mcu.Pin16=PG15 Mcu.Pin13=PE6 Mcu.Pin14=PB7 PF10.GPIOParameters=GPIO_Label Mcu.Pin19=PG10 -SH.GPXTI15.ConfNb=1 Mcu.Pin17=PG12 Mcu.Pin18=PG11 NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 Mcu.Pin11=PE4 Mcu.Pin12=PE5 Mcu.Pin10=PA13 (JTMS/SWDIO) -SH.GPXTI10.ConfNb=1 -PI11.GPIO_Label=EXTI11 PE3.Signal=SAI1_SD_B PF4.Signal=FMC_A4 SH.FMC_D26.ConfNb=1 @@ -256,8 +253,8 @@ ProjectManager.MainLocation=Core/Src SH.SharedStack_PC12.0=SDMMC1_CK SH.FMC_A6.ConfNb=1 USB_DEVICE.CLASS_NAME_FS=AUDIO -SH.FMC_A8.0=FMC_A8,13b-sda1 ADC1.OffsetSignedSaturation-1\#ChannelRegularConversion=DISABLE +SH.FMC_A8.0=FMC_A8,13b-sda1 ProjectManager.KeepUserCode=true PH14.Signal=FMC_D22 PH10.Signal=FMC_D18 @@ -266,8 +263,8 @@ SH.FMC_D14_DA14.0=FMC_D14,sd-32b-d1 PH0-OSC_IN\ (PH0).Signal=RCC_OSC_IN PG2.Signal=FMC_A12 SAI1.FrameLength-SAI_B_SyncSlave=256 +TIM4.EncoderMode=TIM_ENCODERMODE_TI12 SAI1.FSDefinition-SAI_A_MasterWithClock=SAI_FS_CHANNEL_IDENTIFICATION -PA0.GPIO_Label=EXTI0 PA11.Mode=Device_Only RCC.PLL2FRACN=6144 SAI1.OutputDrive-SAI_B_SyncSlave=SAI_OUTPUTDRIVE_ENABLE @@ -336,12 +333,11 @@ SH.FMC_D27.ConfNb=1 SH.FMC_D16.ConfNb=1 SAI1.OutputDrive-SAI_A_MasterWithClock=SAI_OUTPUTDRIVE_ENABLE USB_DEVICE.PRODUCT_STRING_AUDIO_FS=OWL-XIBECA -PA6.Signal=GPXTI6 +PA6.Signal=GPIO_Input Dma.SAI1_A.0.MemDataAlignment=DMA_MDATAALIGN_WORD SH.FMC_D4_DA4.ConfNb=1 NVIC.OTG_FS_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true ProjectManager.ToolChainLocation= -SH.GPXTI0.0=GPIO_EXTI0 SAI1.FSOffset-SAI_A_MasterWithClock=SAI_FS_BEFOREFIRSTBIT PF8.Signal=QUADSPI_BK1_IO0 SH.FMC_D30.ConfNb=1 @@ -375,7 +371,7 @@ Mcu.Pin85=PD14 Mcu.Pin82=PG1 Mcu.Pin83=PH8 Mcu.Pin88=PA0 -PA3.Signal=GPXTI3 +PA3.Signal=GPIO_Output Mcu.Pin89=PA4 Mcu.Pin86=PD13 Mcu.Pin87=PA1 @@ -405,7 +401,6 @@ USB_DEVICE.IPParameters=VirtualMode-AUDIO_FS,VirtualModeFS,CLASS_NAME_FS,VID-AUD PinOutPanel.CurrentBGAView=Top RCC.FamilyName=M PH1-OSC_OUT\ (PH1).Signal=RCC_OSC_OUT -SH.GPXTI6.0=GPIO_EXTI6 FREERTOS.configUSE_IDLE_HOOK=0 VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 SAI1.RealAudioFreq-SAI_A_MasterWithClock=47.991 KHz @@ -414,7 +409,7 @@ SH.FMC_A15_BA1.ConfNb=1 SH.SharedStack_PD2.0=SDMMC1_CMD PF6.Signal=QUADSPI_BK1_IO3 SH.SharedStack_PD2.1=GPIO_EXTI2 -PC15-OSC32_OUT\ (OSC32_OUT).Signal=GPXTI15 +PC15-OSC32_OUT\ (OSC32_OUT).Signal=GPIO_Input PB10.GPIO_Label=ADC_SPI_CLK Dma.SAI1_A.0.Mode=DMA_CIRCULAR RCC.VCO1OutputFreq_Value=960000000 @@ -424,7 +419,6 @@ Dma.ADC1.3.SyncRequestNumber=1 PC5.GPIOParameters=GPIO_Label RCC.AXIClockFreq_Value=240000000 SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,DataSize,NSSPMode,CLKPolarity,CLKPhase -PG10.GPIOParameters=GPIO_Label PE2.GPIOParameters=GPIO_Label RCC.USBFreq_Value=48000000 PF9.GPIO_Label=FLASH_DQ1 @@ -436,7 +430,6 @@ Dma.ADC1.3.Direction=DMA_PERIPH_TO_MEMORY board=custom PG12.Mode=Encoder_mode_occur1 PI9.Signal=FMC_D30 -PH4.GPIO_Label=EXTI4 SH.FMC_D22.0=FMC_D22,sd-32b-d1 MxCube.Version=6.2.1 RCC.FDCANFreq_Value=192000000 @@ -470,26 +463,22 @@ Mcu.IP7=NVIC ProjectManager.CoupleFile=false RCC.SYSCLKFreq_VALUE=480000000 RCC.I2C123Freq_Value=120000000 -SH.SharedStack_PC8.ConfNb=2 -SH.GPXTI4.0=GPIO_EXTI4 +SH.SharedStack_PC8.ConfNb=3 ADC1.Rank-3\#ChannelRegularConversion=4 ADC1.SamplingTime-3\#ChannelRegularConversion=ADC_SAMPLETIME_387CYCLES_5 KeepUserPlacement=false -PC15-OSC32_OUT\ (OSC32_OUT).GPIO_Label=EXTI15 SH.ADCx_INP14.ConfNb=1 -SH.GPXTI4.ConfNb=1 -SH.GPXTI15.0=GPIO_EXTI15 +NVIC.EXTI9_5_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true PH3.Signal=FMC_SDNE0 PC3_C.Signal=SPI2_MOSI -PE5.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH PB7.Locked=true +PE5.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH NVIC.DMA1_Stream3_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true PC8.Locked=true SH.FMC_D8_DA8.ConfNb=1 PG14.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM PC12.GPIO_Speed=GPIO_SPEED_FREQ_HIGH Dma.SAI1_A.0.SyncEnable=DISABLE -PA3.GPIO_Label=EXTI3 PA6.Locked=true SAI1.SlotActive-SAI_A_MasterWithClock=0x0000FFFF SH.FMC_D7_DA7.0=FMC_D7,sd-32b-d1 @@ -508,7 +497,6 @@ PC12.Signal=SharedStack_PC12 PG6.GPIO_Label=FLASH_NCS PG3.GPIOParameters=GPIO_Label PI11.Locked=true -PA3.GPIOParameters=GPIO_Label PG6.Mode=Single Bank 1 PinOutPanel.RotationAngle=0 PF6.GPIO_Label=FLASH_DQ3 @@ -522,7 +510,6 @@ Dma.ADC1.3.MemInc=DMA_MINC_ENABLE PA14\ (JTCK/SWCLK).Signal=DEBUG_JTCK-SWCLK SH.FMC_A12.ConfNb=1 PH5.Signal=FMC_SDNWE -SH.GPXTI3.ConfNb=1 Dma.SPI3_TX.2.SyncRequestNumber=1 PE2.Mode=Single Bank 1 ADC1.Channel-2\#ChannelRegularConversion=ADC_CHANNEL_5 @@ -538,7 +525,6 @@ RCC.DIVM3=7 RCC.DIVM2=1 RCC.DIVM1=1 Dma.ADC1.3.Instance=DMA1_Stream3 -SH.GPXTI7.0=GPIO_EXTI7 MxDb.Version=DB.6.0.21 PB0.GPIOParameters=GPIO_Label SH.FMC_D26.0=FMC_D26,sd-32b-d1 @@ -552,7 +538,6 @@ SH.SharedStack_PC12.ConfNb=2 PE2.Signal=QUADSPI_BK1_IO2 PF8.Mode=Single Bank 1 PA14\ (JTCK/SWCLK).Mode=Trace_Asynchronous_SW -SH.GPXTI11.ConfNb=1 NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:false PF3.Signal=FMC_A3 SH.FMC_D25.ConfNb=1 @@ -563,7 +548,6 @@ ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_387CYCLES_5 RCC.MCO2PinFreq_Value=480000000 PC8.GPIOParameters=GPIO_Label PF8.GPIOParameters=GPIO_Label -SH.GPXTI11.0=GPIO_EXTI11 RCC.DFSDMFreq_Value=120000000 SH.FMC_A1.0=FMC_A1,13b-sda1 SH.GPXTI14.ConfNb=1 @@ -577,7 +561,7 @@ PF14.Signal=FMC_A8 NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false SAI1.FrameLength-SAI_A_MasterWithClock=256 PB10.GPIOParameters=GPIO_Speed,GPIO_Label -PI11.Signal=GPXTI11 +PI11.Signal=GPIO_Output PH0-OSC_IN\ (PH0).Mode=HSE-External-Oscillator PE6.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH SH.FMC_D3_DA3.0=FMC_D3,sd-32b-d1 @@ -598,20 +582,21 @@ FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 Dma.SPI3_TX.2.EventEnable=DISABLE PC6.Signal=S_TIM3_CH1 PB11.GPIO_Label=ADC_SPI_NCS +PD13.GPIOParameters=GPIO_PuPd PD1.Signal=FMC_D3_DA3 -SH.GPXTI0.ConfNb=1 RCC.DIVP2=6 +TIM4.IC2Filter=4 PC0.Signal=ADCx_INP10 PC11.GPIOParameters=GPIO_Speed,GPIO_Label RCC.QSPIFreq_Value=240000000 PC9.Stacked=true -PG10.Signal=GPXTI10 +PG10.Signal=GPIO_Input PG10.Locked=true SH.FMC_A3.0=FMC_A3,13b-sda1 -SH.GPXTI6.ConfNb=1 RCC.USART234578Freq_Value=120000000 SH.FMC_D31.ConfNb=1 RCC.SPI123Freq_Value=25000000 +TIM4.IPParameters=EncoderMode,IC1Filter,IC2Filter Dma.SAI1_A.0.RequestNumber=1 SH.FMC_D15_DA15.0=FMC_D15,sd-32b-d1 PC3_C.GPIOParameters=GPIO_Speed,GPIO_Label @@ -691,10 +676,8 @@ PB0.Signal=ADCx_INP9 SAI1.SlotSize-SAI_B_SyncSlave=SAI_SLOTSIZE_32B SH.FMC_D19.0=FMC_D19,sd-32b-d1 Dma.SAI1_A.0.FIFOMode=DMA_FIFOMODE_DISABLE -PA7.GPIOParameters=GPIO_Label PC1.Signal=ADCx_INP11 Dma.SAI1_A.0.Instance=DMA1_Stream0 -PG10.GPIO_Label=EXTI10 PD2.GPIO_Label=EXTI2 PG7.GPIOParameters=GPIO_Speed Dma.SAI1_A.0.PeriphDataAlignment=DMA_PDATAALIGN_WORD @@ -734,7 +717,6 @@ Dma.SPI3_TX.2.SyncSignalID=NONE PE5.GPIOParameters=GPIO_Speed ProjectManager.StackSize=0x400 SH.SharedStack_PC11.2=GPIO_Output -PI11.GPIOParameters=GPIO_Label RCC.VCOInput3Freq_Value=1142857.142857143 PH3.Mode=SdramChipSelect1_1 SH.SharedStack_PC11.0=SDMMC1_D3 @@ -742,7 +724,6 @@ SH.SharedStack_PC11.1=SPI3_MISO NVIC.ADC_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true SH.FMC_A7.0=FMC_A7,13b-sda1 PA12.Signal=USB_OTG_FS_DP -PH4.GPIOParameters=GPIO_Label SPI2.CLKPolarity=SPI_POLARITY_HIGH Mcu.UserConstants= PC1.GPIOParameters=GPIO_Label @@ -804,6 +785,7 @@ SH.FMC_A9.0=FMC_A9,13b-sda1 ADC1.OffsetNumber-1\#ChannelRegularConversion=ADC_OFFSET_NONE SH.FMC_D4_DA4.0=FMC_D4,sd-32b-d1 SPI2.CLKPhase=SPI_PHASE_2EDGE +TIM4.IC1Filter=4 PF5.Signal=FMC_A5 Dma.SAI1_B.1.SignalID=NONE SH.FMC_D19.ConfNb=1 @@ -850,14 +832,14 @@ SH.ADCx_INP9.ConfNb=1 SH.S_TIM2_CH2.0=TIM2_CH2,Encoder_Interface SH.FMC_NBL3.ConfNb=1 RCC.SPI45Freq_Value=120000000 -PH4.Signal=GPXTI4 +PH4.Signal=GPIO_Output +PD12.GPIOParameters=GPIO_PuPd PB3\ (JTDO/TRACESWO).Signal=DEBUG_JTDO-SWO ProjectManager.TargetToolchain=Other Toolchains (GPDSC) SAI1.SlotSize-SAI_A_MasterWithClock=SAI_SLOTSIZE_32B ADC1.OffsetSignedSaturation-2\#ChannelRegularConversion=DISABLE SH.FMC_D1_DA1.ConfNb=1 ADC1.Channel-1\#ChannelRegularConversion=ADC_CHANNEL_14 -PC15-OSC32_OUT\ (OSC32_OUT).GPIOParameters=GPIO_Label SAI1.DataSize-SAI_A_MasterWithClock=SAI_DATASIZE_24 PF2.Signal=FMC_A2 ProjectManager.RegisterCallBack= @@ -870,7 +852,6 @@ PG14.Signal=GPIO_Output SH.S_TIM3_CH2.0=TIM3_CH2,Encoder_Interface Dma.ADC1.3.MemDataAlignment=DMA_MDATAALIGN_HALFWORD SAI1.IPParameters=Instance-SAI_A_MasterWithClock,VirtualMode-SAI_A_MasterWithClock,MClockEnable-SAI_A_MasterWithClock,RealAudioFreq-SAI_A_MasterWithClock,ErrorAudioFreq-SAI_A_MasterWithClock,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,FrameLength-SAI_A_MasterWithClock,FrameLength-SAI_B_SyncSlave,DataSize-SAI_A_MasterWithClock,SlotSize-SAI_A_MasterWithClock,SlotSize-SAI_B_SyncSlave,SlotNumber-SAI_A_MasterWithClock,AudioFrequency-SAI_A_MasterWithClock,DataSize-SAI_B_SyncSlave,SlotNumber-SAI_B_SyncSlave,AudioMode-SAI_A_MasterWithClock,AudioMode-SAI_B_SyncSlave,FSOffset-SAI_A_MasterWithClock,FSOffset-SAI_B_SyncSlave,FSPolarity-SAI_A_MasterWithClock,FSPolarity-SAI_B_SyncSlave,VirtualSlotActive-SAI_A_MasterWithClock,SlotActive-SAI_A_MasterWithClock,NoDivider-SAI_A_MasterWithClock,ClockStrobing-SAI_A_MasterWithClock,OutputDrive-SAI_A_MasterWithClock,VirtualSlotActive-SAI_B_SyncSlave,SlotActive-SAI_B_SyncSlave,OutputDrive-SAI_B_SyncSlave,FSDefinition-SAI_A_MasterWithClock,FSDefinition-SAI_B_SyncSlave,ActiveFrameLength-SAI_A_MasterWithClock,ActiveFrameLength-SAI_B_SyncSlave -SH.GPXTI3.0=GPIO_EXTI3 RCC.VCOInput1Freq_Value=8000000 PG7.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH NVIC.SavedSystickIrqHandlerGenerated=true @@ -881,6 +862,7 @@ PC13.GPIOParameters=GPIO_Label PF10.Signal=QUADSPI_CLK Dma.SPI3_TX.2.MemDataAlignment=DMA_MDATAALIGN_BYTE SPI3.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_16 +PD13.GPIO_PuPd=GPIO_PULLUP PF15.Signal=FMC_A9 PA4.GPIOParameters=GPIO_Speed,GPIO_Label PE6.Signal=SAI1_SD_A @@ -888,7 +870,6 @@ Mcu.Name=STM32H743IIKx SH.FMC_D23.ConfNb=1 PA2.Signal=ADCx_INP14 PD14.Signal=FMC_D0_DA0 -PA7.GPIO_Label=EXTI7 PA12.Mode=Device_Only Dma.SAI1_B.1.Direction=DMA_MEMORY_TO_PERIPH PC14-OSC32_IN\ (OSC32_IN).Signal=GPXTI14 @@ -905,6 +886,7 @@ PC2_C.GPIOParameters=GPIO_Speed,GPIO_Label Dma.SAI1_B.1.SyncRequestNumber=1 RCC.D3PPRE=RCC_APB4_DIV2 PC9.Signal=SharedStack_PC9 +NVIC.TIM4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true RCC.VCOInput2Freq_Value=8000000 RCC.APB1Freq_Value=120000000 ADC1.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV4 @@ -912,5 +894,6 @@ PB11.Locked=true ProjectManager.DeviceId=STM32H743IIKx ProjectManager.LibraryCopy=1 SAI1.ClockStrobing-SAI_A_MasterWithClock=SAI_CLOCKSTROBING_RISINGEDGE +PD12.GPIO_PuPd=GPIO_PULLUP PB1.GPIOParameters=GPIO_Label -PA7.Signal=GPXTI7 +PA7.Signal=GPIO_Output From 023abb88a802c39cccc2af03e62fe528736ff8a2 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 1 Sep 2021 18:24:09 +0200 Subject: [PATCH 056/286] support PolyVCO screen --- Source/Graphics.h | 2 ++ Source/ssd1309.c | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Source/Graphics.h b/Source/Graphics.h index ff2e2f19..698553b8 100644 --- a/Source/Graphics.h +++ b/Source/Graphics.h @@ -15,6 +15,8 @@ #include "EffectsBoxParameterController.hpp" #elif defined OWL_GENIUS #include "GeniusParameterController.hpp" +#elif defined OWL_XIBECA +#include "XibecaParameterController.hpp" #else #include "ParameterController.hpp" #endif diff --git a/Source/ssd1309.c b/Source/ssd1309.c index 41c52826..63756e83 100644 --- a/Source/ssd1309.c +++ b/Source/ssd1309.c @@ -39,10 +39,14 @@ static const uint8_t OLED_initSequence[] = 0x40, // Set start line to zero 0x8D, // Set charge pump 0x14, - 0x20, // Set memory mode - 0x00, - 0xA0 | 0x1, // Set segment remapping - 0xC8, // Set command Scan decode + 0x20, 0x01, // Vertical addressing mode +#ifdef OLED_UPSIDE_DOWN + 0xa0, + 0xc1, +#else + 0xa1, + 0xc8, +#endif 0xDA, // Set Comm pins 0x12, 0x81, // Set contrast @@ -61,18 +65,15 @@ static const uint8_t OLED_initSequence[] = 0xa8, 0x3f, // Multiplex ratio 64 // Scan direction: c0: scan dir normal, c8: reverse #ifdef OLED_UPSIDE_DOWN + 0xa0, 0xc1, #else + 0xa1, 0xc8, #endif 0xd3, 0x00, // Display offset 0x40, // Start line // Segment re-map: a0: col0 -> SEG0, a1: col127 -> SEG0 -#ifdef OLED_UPSIDE_DOWN - 0xa0, -#else - 0xa1, -#endif 0xda, 0x12, // COM pins 0x81, 0xcf, // Contrast control: 0 to 0xff. Current increases with contrast. 0xd9, 0x22, // Pre-charge period From 1b2b86293c419e950b45e2ac6ffd320b119af4f5 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 6 Sep 2021 15:04:41 +0200 Subject: [PATCH 057/286] xibeca screen working --- Xibeca/Core/Inc/XibecaParameterController.hpp | 198 ++++++++++++++++++ Xibeca/Core/Inc/hardware.h | 1 + Xibeca/Core/Inc/main.h | 2 + Xibeca/Core/Src/Xibeca.cpp | 50 ++++- Xibeca/Core/Src/main.c | 26 ++- Xibeca/Xibeca.ioc | 7 +- 6 files changed, 261 insertions(+), 23 deletions(-) create mode 100644 Xibeca/Core/Inc/XibecaParameterController.hpp diff --git a/Xibeca/Core/Inc/XibecaParameterController.hpp b/Xibeca/Core/Inc/XibecaParameterController.hpp new file mode 100644 index 00000000..6e09912a --- /dev/null +++ b/Xibeca/Core/Inc/XibecaParameterController.hpp @@ -0,0 +1,198 @@ +#ifndef __ParameterController_hpp__ +#define __ParameterController_hpp__ + +#include +#include +#include "device.h" +#include "errorhandlers.h" +#include "ProgramVector.h" +#include "VersionToken.h" +#include "ScreenBuffer.h" +#include "Owl.h" +#ifdef USE_DIGITALBUS +#include "DigitalBusReader.h" +extern DigitalBusReader bus; +#endif + +#ifndef min +#define min(a,b) ((a)<(b)?(a):(b)) +#endif +#ifndef max +#define max(a,b) ((a)>(b)?(a):(b)) +#endif +#ifndef abs +#define abs(x) ((x)>0?(x):-(x)) +#endif + +extern VersionToken* bootloader_token; + +void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height); + +/* shows a single parameter selected and controlled with a single encoder + */ +template +class ParameterController { +public: + char title[11] = "Xibeca"; + int16_t parameters[SIZE]; + char names[SIZE][12]; + int8_t selected = 0; + ParameterController(){ + reset(); + } + void setTitle(const char* str){ + strncpy(title, str, 10); + } + void reset(){ + drawCallback = defaultDrawCallback; + for(int i=0; i 2) + screen.print(1, y-30, names[selected-3]); + if(selected > 1) + screen.print(1, y-20, names[selected-2]); + if(selected > 0) + screen.print(1, y-10, names[selected-1]); + screen.print(1, y, names[selected]); + if(selected < size-1) + screen.print(1, y+10, names[selected+1]); + if(selected < size-2) + screen.print(1, y+20, names[selected+2]); + if(selected < size-3) + screen.print(1, y+30, names[selected+3]); + screen.invert(0, y-9, screen.getWidth(), 10); + } + + void drawGlobalParameterNames(int y, ScreenBuffer& screen){ + drawParameterNames(y, 0, names, SIZE, screen); + } + + void drawStats(ScreenBuffer& screen){ + screen.setTextSize(1); + ProgramVector* pv = getProgramVector(); + if(pv->message != NULL) + screen.print(2, 16, pv->message); + screen.print(2, 26, "cpu/mem: "); + float percent = (pv->cycles_per_block/pv->audio_blocksize) / (float)ARM_CYCLES_PER_SAMPLE; + screen.print((int)(percent*100)); + screen.print("% "); + screen.print((int)(pv->heap_bytes_used)/1024); + screen.print("kB"); + + // draw firmware version + screen.print(1, 36, getFirmwareVersion()); + if (bootloader_token->magic == BOOTLOADER_MAGIC){ + screen.print(" bt."); + screen.print(getBootloaderVersion()); + } +#ifdef USE_DIGITALBUS + screen.print(1, 56, "Bus: "); + screen.print(bus.getStatusString()); + screen.print(" "); + extern uint32_t bus_tx_packets, bus_rx_packets; + screen.print((int)bus_tx_packets); + screen.print("/"); + screen.print((int)bus_rx_packets); + if (bus.getStatus() == BUS_STATUS_CONNECTED) { + screen.print(", "); + screen.print(bus.getPeers()); + screen.print(" peers"); + } +#endif + } + + void encoderChanged(uint8_t encoder, int32_t delta){ + if(encoder == 0){ + if(sw2()){ + if(delta > 1) + selected = min(SIZE-1, selected+1); + else if(delta < 1) + selected = max(0, selected-1); + }else{ + parameters[selected] += delta*10; + parameters[selected] = min(4095, max(0, parameters[selected])); + } + } // todo: change patch with enc1/sw1 + } + void setName(uint8_t pid, const char* name){ + if(pid < SIZE) + strncpy(names[pid], name, 11); + } + uint8_t getSize(){ + return SIZE; + } + void setValue(uint8_t ch, int16_t value){ + parameters[ch] = value; + } + + void drawMessage(int16_t y, ScreenBuffer& screen){ + ProgramVector* pv = getProgramVector(); + if(pv->message != NULL){ + screen.setTextSize(1); + screen.setTextWrap(true); + screen.print(0, y, pv->message); + screen.setTextWrap(false); + } + } + + void drawTitle(ScreenBuffer& screen){ + drawTitle(title, screen); + } + + void drawTitle(const char* title, ScreenBuffer& screen){ + // draw title + screen.setTextSize(2); + screen.print(1, 17, title); + } + + void setCallback(void *callback){ + if(callback == NULL) + drawCallback = defaultDrawCallback; + else + drawCallback = (void (*)(uint8_t*, uint16_t, uint16_t))callback; + } + +private: + void (*drawCallback)(uint8_t*, uint16_t, uint16_t); + bool sw1(){ + return HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0) != GPIO_PIN_SET; + } + bool sw2(){ + return HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_4) != GPIO_PIN_SET; + } +}; + +#endif // __ParameterController_hpp__ diff --git a/Xibeca/Core/Inc/hardware.h b/Xibeca/Core/Inc/hardware.h index 11a0ff28..d9469339 100644 --- a/Xibeca/Core/Inc/hardware.h +++ b/Xibeca/Core/Inc/hardware.h @@ -15,6 +15,7 @@ #define MAIN_LOOP_SLEEP_MS 20 #define USE_SCREEN +#define OLED_UPSIDE_DOWN #define SSD1309 #define SSD1306 #define OLED_SPI hspi3 diff --git a/Xibeca/Core/Inc/main.h b/Xibeca/Core/Inc/main.h index c8bdd545..1fd9ff73 100644 --- a/Xibeca/Core/Inc/main.h +++ b/Xibeca/Core/Inc/main.h @@ -62,6 +62,8 @@ void Error_Handler(void); #define FLASH_DQ2_GPIO_Port GPIOE #define OLED_CS_Pin GPIO_PIN_14 #define OLED_CS_GPIO_Port GPIOG +#define OLED_DC_Pin GPIO_PIN_11 +#define OLED_DC_GPIO_Port GPIOC #define EXTI13_Pin GPIO_PIN_13 #define EXTI13_GPIO_Port GPIOC #define EXTI13_EXTI_IRQn EXTI15_10_IRQn diff --git a/Xibeca/Core/Src/Xibeca.cpp b/Xibeca/Core/Src/Xibeca.cpp index 63a95cd8..e9921e74 100644 --- a/Xibeca/Core/Src/Xibeca.cpp +++ b/Xibeca/Core/Src/Xibeca.cpp @@ -104,6 +104,10 @@ Pin push_enc(GPIOB, GPIO_PIN_12); // Pin hard_sync_c(PIN21_GPIO_Port, PIN21_Pin); // Pin hard_sync_d(PIN22_GPIO_Port, PIN22_Pin); +Pin hard_sync_a(GPIOG, GPIO_PIN_12); +Pin hard_sync_b(GPIOA, GPIO_PIN_15); +Pin hard_sync_c(GPIOC, GPIO_PIN_6); +Pin hard_sync_d(GPIOD, GPIO_PIN_7); void setLed(uint8_t led, uint32_t rgb){ bool value = rgb; @@ -144,6 +148,9 @@ extern "C"{ adc = hadc->State; // } + void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc){ + error(CONFIG_ERROR, "ADC error"); + } } #define MIN_PERIOD ((AUDIO_SAMPLINGRATE * ARM_CYCLES_PER_SAMPLE) / 32000) @@ -159,13 +166,20 @@ void updatePeriod(uint8_t idx){ periods[idx] = elapsed; // AUDIO_SAMPLINGRATE // ARM_CYCLES_PER_SAMPLE - setParameterValue(PARAMETER_AA + idx, (AUDIO_SAMPLINGRATE * ARM_CYCLES_PER_SAMPLE) / elapsed); - led_tune.toggle(); + setParameterValue(PARAMETER_BB + idx, (AUDIO_SAMPLINGRATE * ARM_CYCLES_PER_SAMPLE) / elapsed); + // led_tune.toggle(); } } times[idx] = now; } +void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* adc_values, size_t adc_len){ + parameter_values[0] = (parameter_values[0]*3 + adc_values[ADC_A])>>2; + parameter_values[1] = (parameter_values[1]*3 + adc_values[ADC_B])>>2; + parameter_values[2] = (parameter_values[2]*3 + adc_values[ADC_C])>>2; + parameter_values[3] = (parameter_values[3]*3 + adc_values[ADC_D])>>2; +} + void onChangePin(uint16_t pin){ switch(pin){ // case PUSH_TUNE_Pin: @@ -202,8 +216,21 @@ void onChangePin(uint16_t pin){ void setGateValue(uint8_t ch, int16_t value){ int idx = 1 + ch - BUTTON_A; setLed(idx, value ? RED_COLOUR : NO_COLOUR); + switch(ch){ + case BUTTON_E: + hard_sync_a.set(value ? true : false); + break; + case BUTTON_F: + hard_sync_b.set(value ? true : false); + break; + case BUTTON_G: + hard_sync_c.set(value ? true : false); + break; + case BUTTON_H: + hard_sync_d.set(value ? true : false); + break; + } // switch(ch){ - // case BUTTON_A: // setLed(1, value ? RED_COLOUR : NO_COLOUR); // break; // case BUTTON_B: @@ -239,6 +266,11 @@ void setup(){ led_d.outputMode(); led_options.outputMode(); + hard_sync_a.outputMode(); + hard_sync_b.outputMode(); + hard_sync_c.outputMode(); + hard_sync_d.outputMode(); + push_tune.inputMode(); push_mod.inputMode(); push_notes.inputMode(); @@ -271,19 +303,19 @@ void setup(){ } void loop(void){ - led_a.set(!push_a.get()); - led_b.set(!push_b.get()); - led_c.set(!push_c.get()); - led_d.set(!push_d.get()); - // led_tune.set(!push_tune.get()); + led_tune.set(!push_tune.get()); led_mod.set(!push_mod.get()); led_notes.set(!push_notes.get()); led_cv.set(!push_cv.get()); led_options.set(!push_options.get()); + led_a.set(!push_a.get()); + led_b.set(!push_b.get()); + led_c.set(!push_c.get()); + led_d.set(!push_d.get()); setButtonValue(BUTTON_A, !push_enc.get()); - setParameterValue(PARAMETER_A, __HAL_TIM_GET_COUNTER(&ENCODER_TIM1) / 2); + setParameterValue(PARAMETER_BA, __HAL_TIM_GET_COUNTER(&ENCODER_TIM1) / 2); #ifdef USE_SCREEN graphics.draw(); diff --git a/Xibeca/Core/Src/main.c b/Xibeca/Core/Src/main.c index 5a44001a..7b424c02 100644 --- a/Xibeca/Core/Src/main.c +++ b/Xibeca/Core/Src/main.c @@ -347,8 +347,8 @@ static void MX_ADC1_Init(void) hadc1.Init.DiscontinuousConvMode = DISABLE; hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START; hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; - hadc1.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DR; - hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED; + hadc1.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DMA_CIRCULAR; + hadc1.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN; hadc1.Init.LeftBitShift = ADC_LEFTBITSHIFT_NONE; hadc1.Init.OversamplingMode = DISABLE; if (HAL_ADC_Init(&hadc1) != HAL_OK) @@ -990,6 +990,9 @@ static void MX_GPIO_Init(void) /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOG, OLED_CS_Pin|ADC_RST_Pin, GPIO_PIN_RESET); + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(OLED_DC_GPIO_Port, OLED_DC_Pin, GPIO_PIN_RESET); + /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOI, GPIO_PIN_11, GPIO_PIN_RESET); @@ -1002,9 +1005,9 @@ static void MX_GPIO_Init(void) /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(ADC_SPI_NCS_GPIO_Port, ADC_SPI_NCS_Pin, GPIO_PIN_RESET); - /*Configure GPIO pins : PB8 PB4 PB9 PB2 + /*Configure GPIO pins : PB1 PB8 PB4 PB9 PB2 PB12 PB13 PB14 PB15 */ - GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_4|GPIO_PIN_9|GPIO_PIN_2 + GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_8|GPIO_PIN_4|GPIO_PIN_9|GPIO_PIN_2 |GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; @@ -1045,6 +1048,13 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + /*Configure GPIO pin : OLED_DC_Pin */ + GPIO_InitStruct.Pin = OLED_DC_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; + HAL_GPIO_Init(OLED_DC_GPIO_Port, &GPIO_InitStruct); + /*Configure GPIO pins : EXTI13_Pin EXTI14_Pin PC9 */ GPIO_InitStruct.Pin = EXTI13_Pin|EXTI14_Pin|GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; @@ -1063,8 +1073,8 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); - /*Configure GPIO pins : PA10 PA5 */ - GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_5; + /*Configure GPIO pins : PA2 PA10 PA5 */ + GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_10|GPIO_PIN_5; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); @@ -1115,8 +1125,8 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; HAL_GPIO_Init(OLED_RST_GPIO_Port, &GPIO_InitStruct); - /*Configure GPIO pin : PC4 */ - GPIO_InitStruct.Pin = GPIO_PIN_4; + /*Configure GPIO pin : PC0 PC4 PC5 */ + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_4|GPIO_PIN_5; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); diff --git a/Xibeca/Xibeca.ioc b/Xibeca/Xibeca.ioc index b86a811f..c22ac147 100644 --- a/Xibeca/Xibeca.ioc +++ b/Xibeca/Xibeca.ioc @@ -386,7 +386,7 @@ Dma.SAI1_B.1.RequestNumber=1 Dma.SPI3_TX.2.Polarity=HAL_DMAMUX_REQ_GEN_RISING NVIC.SavedSvcallIrqHandlerGenerated=true Dma.SAI1_A.0.Direction=DMA_PERIPH_TO_MEMORY -PC11.Signal=SharedStack_PC11 +PC11.Signal=GPIO_Output Dma.SAI1_A.0.SignalID=NONE SPI2.NSSPMode=SPI_NSS_PULSE_DISABLE PC8.Signal=SharedStack_PC8 @@ -440,7 +440,6 @@ PC1.GPIO_Label=ADC5 VP_SYS_VS_Systick.Mode=SysTick SH.FMC_D12_DA12.0=FMC_D12,sd-32b-d1 SAI1.SlotNumber-SAI_A_MasterWithClock=8 -SH.SharedStack_PC11.ConfNb=3 SH.FMC_D29.ConfNb=1 SH.FMC_D18.ConfNb=1 PF1.Signal=FMC_A1 @@ -716,11 +715,8 @@ SAI1.ActiveFrameLength-SAI_A_MasterWithClock=128 Dma.SPI3_TX.2.SyncSignalID=NONE PE5.GPIOParameters=GPIO_Speed ProjectManager.StackSize=0x400 -SH.SharedStack_PC11.2=GPIO_Output RCC.VCOInput3Freq_Value=1142857.142857143 PH3.Mode=SdramChipSelect1_1 -SH.SharedStack_PC11.0=SDMMC1_D3 -SH.SharedStack_PC11.1=SPI3_MISO NVIC.ADC_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true SH.FMC_A7.0=FMC_A7,13b-sda1 PA12.Signal=USB_OTG_FS_DP @@ -749,7 +745,6 @@ Mcu.Pin1=PE2 GPIO.groupedBy=Group By Peripherals Mcu.Pin2=PE1 Mcu.Pin3=PE0 -PC11.Stacked=true Mcu.Pin4=PB5 Mcu.Pin5=PG14 SH.FMC_D8_DA8.0=FMC_D8,sd-32b-d1 From cd5aefade31ed00bbf6e6a6bf95c2742876e2382 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 6 Sep 2021 18:29:10 +0200 Subject: [PATCH 058/286] qspi flash driver --- Source/flash.c | 550 +++++++++++++++++++++++++++++++++++++++++++++++++ Source/flash.h | 28 +++ 2 files changed, 578 insertions(+) create mode 100644 Source/flash.c create mode 100644 Source/flash.h diff --git a/Source/flash.c b/Source/flash.c new file mode 100644 index 00000000..c36e9c78 --- /dev/null +++ b/Source/flash.c @@ -0,0 +1,550 @@ +#include "flash.h" +#include "main.h" +#include "qspi.h" + +/* #define QSPI_TIMEOUT HAL_QPSI_TIMEOUT_DEFAULT_VALUE */ +#define QSPI_TIMEOUT 50000 + +#define QSPIHandle hqspi +extern QSPI_HandleTypeDef QSPIHandle; + +volatile uint8_t CmdCplt, RxCplt, TxCplt, StatusMatch; + +static void QSPI_WriteEnable(QSPI_HandleTypeDef *hqspi, bool nv); +static void QSPI_AutoPollingMemReady(QSPI_HandleTypeDef *hqspi); +static void QSPI_DummyCyclesCfg(QSPI_HandleTypeDef *hqspi); + +/* Buffer used for transmission */ + +QSPI_CommandTypeDef sCommand; +QSPI_MemoryMappedTypeDef sMemMappedCfg; + +/* + Single bit wide commands start with an instruction and may provide an address + or data, all sent only on the SI signal. Data may be sent back to the host + serially on the SO signal. This is referenced as a 1-1-1 command protocol for + single bit width instruction, single bit width address and modifier, single bit + data. + */ +void flash_init(){ + QSPIHandle.Instance = QUADSPI; + /* QSPI clock = 480MHz / (1+9) = 48MHz */ + /* QSPI clock = 480MHz / (1+4) = 96MHz */ + QSPIHandle.Init.ClockPrescaler = 9; + /* QSPIHandle.Init.ClockPrescaler = 4; // 4 and 5 don't work? 8 works */ +/* #define IS_QSPI_FIFO_THRESHOLD(THR) (((THR) > 0U) && ((THR) <= 32U)) */ + QSPIHandle.Init.FifoThreshold = 4; + QSPIHandle.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_NONE; + QSPIHandle.Init.FlashSize = 22; // 2^(22+1) = 8M / 64Mbit + QSPIHandle.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_1_CYCLE; + QSPIHandle.Init.ClockMode = QSPI_CLOCK_MODE_0; + + sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE; + sCommand.AddressSize = QSPI_ADDRESS_24_BITS; + sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; // QSPI_ALTERNATE_BYTES_8_BITS + sCommand.DdrMode = QSPI_DDR_MODE_DISABLE; + sCommand.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; + sCommand.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; + sCommand.AlternateBytesSize = QSPI_ALTERNATE_BYTES_8_BITS; + /* Initialize QuadSPI ------------------------------------------------ */ + HAL_QSPI_DeInit(&QSPIHandle); + if (HAL_QSPI_Init(&QSPIHandle) != HAL_OK) + { + Error_Handler(); + } + if( HAL_QSPI_SetFifoThreshold(&QSPIHandle, 16) != HAL_OK) + { + Error_Handler(); + } +} + +int flash_read_register(int instruction){ + QSPI_CommandTypeDef cmd; + /* Initialize the read flag status register command */ + cmd.InstructionMode = QSPI_INSTRUCTION_1_LINE; + cmd.Instruction = instruction; + cmd.AddressMode = QSPI_ADDRESS_NONE; + cmd.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; + cmd.DataMode = QSPI_DATA_1_LINE; + cmd.DummyCycles = 0; + cmd.NbData = 1; + cmd.DdrMode = QSPI_DDR_MODE_DISABLE; + cmd.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; + cmd.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; + + if (HAL_QSPI_Command(&QSPIHandle, &cmd, QSPI_TIMEOUT) != HAL_OK) + return -1; + + uint8_t value; + /* Reception of the data */ + if (HAL_QSPI_Receive(&QSPIHandle, &value, QSPI_TIMEOUT) != HAL_OK) + return -1; + + return value; +} + +int flash_status(){ + // Read Status Register 1 (RDSR1 05h) + // Read Status Register 2 (RDSR2 07h) + // Read Configuration Register 1 (RDCR1 35h) + // Read Configuration Register 2 (RDCR2 15h) + // Read Configuration Register 3 (RDCR3 33h) + /* It is possible to read CR1V, CR2V and CR3V continuously by providing multiples of eight clock cycles. */ + return flash_read_register(0x35); +} + +int flash_quad_mode(uint8_t cr1, uint8_t cr2){ //, uint8_t cr3){ + uint8_t data[3] = {0x00, cr1, cr2}; + QSPI_CommandTypeDef cmd; + /* QSPI_WriteEnable(&QSPIHandle, false); // WRENV */ + + // WRENV + cmd.InstructionMode = QSPI_INSTRUCTION_1_LINE; + cmd.Instruction = 0x50; + cmd.AddressMode = QSPI_ADDRESS_NONE; + cmd.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; + cmd.DataMode = QSPI_DATA_NONE; + cmd.DummyCycles = 0; + cmd.DdrMode = QSPI_DDR_MODE_DISABLE; + cmd.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; + cmd.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; + if (HAL_QSPI_Command(&QSPIHandle, &cmd, QSPI_TIMEOUT) != HAL_OK) + return -1; + + // WRR + cmd.InstructionMode = QSPI_INSTRUCTION_1_LINE; + cmd.Instruction = 0x01; // WRR + cmd.AddressMode = QSPI_ADDRESS_NONE; + cmd.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; + cmd.DataMode = QSPI_DATA_1_LINE; + cmd.DummyCycles = 0; + cmd.DdrMode = QSPI_DDR_MODE_DISABLE; + cmd.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; + cmd.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; + cmd.NbData = sizeof(data); + if (HAL_QSPI_Command(&QSPIHandle, &cmd, QSPI_TIMEOUT) != HAL_OK) + return -1; + if (HAL_QSPI_Transmit(&QSPIHandle, data, QSPI_TIMEOUT) != HAL_OK) + return -1; + return 0; + /* + WRENV 0x50 + WRR 0x01 + WRAR 0x71 + The Write Enable Volatile (WRENV) command must be written prior to Write Register (WRR) command that modifies volatile registers data. + */ +} + +int flash_erase(uint32_t address, uint32_t size){ + /* Enable write operations ------------------------------------------- */ + QSPI_WriteEnable(&QSPIHandle, true); + + /* Erasing Sequence -------------------------------------------------- */ + sCommand.Instruction = SECTOR_ERASE_CMD; + sCommand.AddressMode = QSPI_ADDRESS_1_LINE; + sCommand.DataMode = QSPI_DATA_NONE; + sCommand.DummyCycles = 0; + sCommand.NbData = 0; + int remain = size; + while(remain > 0){ + sCommand.Address = address; + if (HAL_QSPI_Command(&QSPIHandle, &sCommand, QSPI_TIMEOUT) != HAL_OK) + return -1; + address += QSPI_ERASE_BLOCK_SIZE; + remain -= QSPI_ERASE_BLOCK_SIZE; + } + return 0; +} + +#ifndef min +#define min(a,b) ((a)<(b)?(a):(b)) +#endif + +int flash_write_page(uint32_t address, void* data, uint32_t size){ + /* Enable write operations ----------------------------------------- */ + QSPI_WriteEnable(&QSPIHandle, true); + + /* Writing Sequence ------------------------------------------------ */ + sCommand.Instruction = QUAD_IN_FAST_PROG_CMD; + sCommand.AddressMode = QSPI_ADDRESS_1_LINE; + sCommand.DataMode = QSPI_DATA_4_LINES; + sCommand.DummyCycles = 0; + sCommand.Address = address; + sCommand.NbData = size; + + // To use Quad Page Program the Quad Enable Bit in the Configuration Register must be set (QUAD=1). A Write Enable command must be executed before the device will accept the QPP command (Status Register 1, WEL=1). + + // SPI alternative + sCommand.Instruction = PAGE_PROG_CMD; + sCommand.AddressMode = QSPI_ADDRESS_1_LINE; + sCommand.DataMode = QSPI_DATA_1_LINE; + + /* The Page Program command accepts from 1-byte up to 256 consecutive bytes of data (page) to be programmed in one operation. */ + + if (HAL_QSPI_Command(&QSPIHandle, &sCommand, QSPI_TIMEOUT) != HAL_OK) + return -1; + if (HAL_QSPI_Transmit(&QSPIHandle, data, QSPI_TIMEOUT) != HAL_OK) + return -1; + return 0; +} + +int flash_write_block(uint32_t address, void* data, uint32_t size){ + size_t pages = (size+QSPI_FLASH_PAGE_SIZE-1)/QSPI_FLASH_PAGE_SIZE; + uint8_t* source = (uint8_t*)data; + int ret = 0; + while(ret == 0 && pages--){ + flash_wait(); + ret = flash_write_page(address, source, min(QSPI_FLASH_PAGE_SIZE, size)); + address += QSPI_FLASH_PAGE_SIZE; + source += QSPI_FLASH_PAGE_SIZE; + size -= QSPI_FLASH_PAGE_SIZE; + } + return ret; +} + +int flash_qpi_mode(bool quad){ + /* The recommended procedure for moving to QPI mode is to first use the QPIEN (38h) command, the WRR or WRAR command can also set CR2V[3] = 1, QPI mode + QPI CR2V[3]: This bit controls the expected instruction width for all commands. This volatile QPI configuration bit enables the + device to enter and exit QPI mode during normal operation. When this bit is set to QPI mode, the QUAD mode is active, independent + of the setting of QIO mode (CR1V[1]). When this bit is cleared to legacy SPI mode, the QUAD bit is not affected. The QPI CR2V[3] + bit can also be set to “1” by the QPIEN (38h) command and set to “0” by the QPIEX (F5h) command. + + The enter QPI Mode (QPIEN) command enables the QPI mode by setting the volatile QPI bit (CR2V[3] = 1). The time required to enter QPI Mode is tQEN, 1.5uS, no other commands are allowed during the tQEN transition time to QPI mode. + */ + sCommand.AddressMode = QSPI_ADDRESS_NONE; + sCommand.DataMode = QSPI_DATA_NONE; + sCommand.DummyCycles = 0; + sCommand.NbData = 0; + if(quad){ + // enable quad mode QPIEN + sCommand.Instruction = ENTER_QUAD_CMD; + sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE; + if (HAL_QSPI_Command(&QSPIHandle, &sCommand, QSPI_TIMEOUT) != HAL_OK) + return -1; + sCommand.InstructionMode = QSPI_INSTRUCTION_4_LINES; + }else{ + // exit quad mode QPIEX + sCommand.Instruction = EXIT_QUAD_CMD; + sCommand.InstructionMode = QSPI_INSTRUCTION_4_LINES; + if (HAL_QSPI_Command(&QSPIHandle, &sCommand, QSPI_TIMEOUT) != HAL_OK) + return -1; + sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE; + } + volatile size_t counter = 10000; + while(counter--) + __NOP(); + return 0; +} + +int flash_read_mode(int mode){ +/* Configure Volatile Configuration register (with new dummy cycles) */ + /* QSPI_DummyCyclesCfg(&QSPIHandle); */ + + // defaults for all modes + sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE; + sCommand.AddressMode = QSPI_ADDRESS_1_LINE; + sCommand.DataMode = QSPI_DATA_1_LINE; + sCommand.AddressSize = QSPI_ADDRESS_32_BITS; + sCommand.DummyCycles = 8; + sCommand.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; + sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; + sCommand.AlternateBytes = 0xA0; // Continuous read feature is enabled if the mode bits value is Axh. + + switch(mode){ + case -111: // SPI read 1-1-1 + sCommand.Instruction = QSPI_FLASH_CMD_FAST_READ; + sCommand.AddressSize = QSPI_ADDRESS_24_BITS; + break; + case -112: // Dual out fast read 1-1-2 + sCommand.Instruction = QSPI_FLASH_CMD_DOR; + sCommand.DataMode = QSPI_DATA_2_LINES; + sCommand.AddressSize = QSPI_ADDRESS_24_BITS; + break; + case -114: // Quad out read 1-1-4 + sCommand.Instruction = QSPI_FLASH_CMD_QOR; + sCommand.DataMode = QSPI_DATA_4_LINES; + sCommand.AddressSize = QSPI_ADDRESS_24_BITS; + break; + case -122: // Dual I/O 1-2-2, mode cycles 4 + sCommand.Instruction = QSPI_FLASH_CMD_DIOR; + sCommand.AddressMode = QSPI_ADDRESS_2_LINES; + sCommand.DataMode = QSPI_DATA_2_LINES; + sCommand.AddressSize = QSPI_ADDRESS_24_BITS; + sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_2_LINES; + sCommand.SIOOMode = QSPI_SIOO_INST_ONLY_FIRST_CMD; + break; + case -144: // Quad I/O read 1-4-4, mode cycles 2 + sCommand.Instruction = QSPI_FLASH_CMD_QIOR; + sCommand.AddressMode = QSPI_ADDRESS_4_LINES; + sCommand.DataMode = QSPI_DATA_4_LINES; + sCommand.AddressSize = QSPI_ADDRESS_24_BITS; + sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_4_LINES; + sCommand.SIOOMode = QSPI_SIOO_INST_ONLY_FIRST_CMD; + break; + case -444: // Quad I/O 4-4-4, mode cycles 2 + // QSPI read + sCommand.Instruction = QSPI_FLASH_CMD_QIOR; + sCommand.InstructionMode = QSPI_INSTRUCTION_4_LINES; + sCommand.AddressMode = QSPI_ADDRESS_4_LINES; + sCommand.DataMode = QSPI_DATA_4_LINES; + sCommand.AddressSize = QSPI_ADDRESS_24_BITS; + sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_4_LINES; + sCommand.SIOOMode = QSPI_SIOO_INST_ONLY_FIRST_CMD; + break; + case 111: // SPI read 1-1-1 + sCommand.Instruction = QSPI_FLASH_CMD_4FAST_READ; + break; + case 112: // Dual out fast read 1-1-2 + sCommand.Instruction = QSPI_FLASH_CMD_4DOR; + sCommand.DataMode = QSPI_DATA_2_LINES; + break; + case 122: // Dual I/O 1-2-2, mode cycles 4 + sCommand.Instruction = QSPI_FLASH_CMD_4DIOR; + sCommand.AddressMode = QSPI_ADDRESS_2_LINES; + sCommand.DataMode = QSPI_DATA_2_LINES; + sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_2_LINES; + sCommand.SIOOMode = QSPI_SIOO_INST_ONLY_FIRST_CMD; + break; + case 114: // Quad out 1-1-4 + sCommand.Instruction = QSPI_FLASH_CMD_4QOR; + sCommand.DataMode = QSPI_DATA_4_LINES; + break; + case 144: // Quad I/O 1-4-4, mode cycles 2 + // QSPI read + sCommand.Instruction = QSPI_FLASH_CMD_4QIOR; + sCommand.AddressMode = QSPI_ADDRESS_4_LINES; + sCommand.DataMode = QSPI_DATA_4_LINES; + sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_4_LINES; + sCommand.SIOOMode = QSPI_SIOO_INST_ONLY_FIRST_CMD; + break; + case 444: // Quad I/O 4-4-4, mode cycles 2 + // QSPI read + sCommand.Instruction = QSPI_FLASH_CMD_4QIOR; + sCommand.InstructionMode = QSPI_INSTRUCTION_4_LINES; + sCommand.AddressMode = QSPI_ADDRESS_4_LINES; + sCommand.DataMode = QSPI_DATA_4_LINES; + sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_4_LINES; + sCommand.SIOOMode = QSPI_SIOO_INST_ONLY_FIRST_CMD; + break; + default: + return -1; + } + return 0; +} + +int flash_read_block(int mode, uint32_t address, void* data, uint32_t size){ + flash_read_mode(mode); + sCommand.Address = address; + sCommand.NbData = size; + if (HAL_QSPI_Command(&QSPIHandle, &sCommand, QSPI_TIMEOUT) != HAL_OK) + return -1; + if (HAL_QSPI_Receive(&QSPIHandle, data, QSPI_TIMEOUT) != HAL_OK) + return -1; + return 0; +} + +int flash_wait(){ + while(QSPIHandle.State == HAL_QSPI_STATE_BUSY) + HAL_Delay(10); + /* return QSPIHandle.State == HAL_QSPI_STATE; */ + /* while(CmdCplt != 0) */ + /* HAL_Delay(10); */ + /* CmdCplt = 0; */ + /* StatusMatch = 0; */ + /* /\* Configure automatic polling mode to wait for end of erase or write *\/ */ + QSPI_AutoPollingMemReady(&QSPIHandle); + /* while(StatusMatch != 0) */ + /* HAL_Delay(10); */ + /* return 0; */ + return HAL_QSPI_GetError(&QSPIHandle); +} + +int flash_memory_map(int mode){ + + if(mode == 114 || mode == 144 || + mode == -114 || mode == -144){ + flash_quad_mode(0x02, 0x60); + flash_qpi_mode(false); + }else if(mode == 444 || mode == -444){ + flash_quad_mode(0x02, 0x68); + flash_qpi_mode(true); + }else{ + flash_quad_mode(0x00, 0x60); + flash_qpi_mode(false); + } + + flash_read_mode(mode); + sMemMappedCfg.TimeOutPeriod = 0; + sMemMappedCfg.TimeOutActivation = QSPI_TIMEOUT_COUNTER_DISABLE; + if (HAL_QSPI_MemoryMapped(&QSPIHandle, &sCommand, &sMemMappedCfg) != HAL_OK) + return -1; + return 0; +} + +/** + * @brief Command completed callbacks. + * @param hqspi: QSPI handle + * @retval None + */ +void HAL_QSPI_CmdCpltCallback(QSPI_HandleTypeDef *hqspi) +{ + CmdCplt++; +} + +/** + * @brief Rx Transfer completed callbacks. + * @param hqspi: QSPI handle + * @retval None + */ +void HAL_QSPI_RxCpltCallback(QSPI_HandleTypeDef *hqspi) +{ + RxCplt++; +} + +/** + * @brief Tx Transfer completed callbacks. + * @param hqspi: QSPI handle + * @retval None + */ +void HAL_QSPI_TxCpltCallback(QSPI_HandleTypeDef *hqspi) +{ + CmdCplt++; + TxCplt++; +} + +/** + * @brief Status Match callbacks + * @param hqspi: QSPI handle + * @retval None + */ +void HAL_QSPI_StatusMatchCallback(QSPI_HandleTypeDef *hqspi) +{ + StatusMatch++; +} + +/** + * @brief This function send a Write Enable and wait it is effective. + * @param hqspi: QSPI handle + * @retval None + */ +static void QSPI_WriteEnable(QSPI_HandleTypeDef *hqspi, bool nv) +{ + QSPI_CommandTypeDef sCommand; + QSPI_AutoPollingTypeDef sConfig; + + /* Enable write operations ------------------------------------------ */ + sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE; + sCommand.Instruction = nv ? 0x06 : 0x50; // WRITE_ENABLE_CMD; + sCommand.AddressMode = QSPI_ADDRESS_NONE; + sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; + sCommand.DataMode = QSPI_DATA_NONE; + sCommand.DummyCycles = 0; + sCommand.DdrMode = QSPI_DDR_MODE_DISABLE; + sCommand.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; + sCommand.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; + + if (HAL_QSPI_Command(hqspi, &sCommand, QSPI_TIMEOUT) != HAL_OK) + { + Error_Handler(); + } + + /* Configure automatic polling mode to wait for write enabling ---- */ + sConfig.Match = 0x02; + sConfig.Mask = 0x02; + sConfig.MatchMode = QSPI_MATCH_MODE_AND; + sConfig.StatusBytesSize = 1; + sConfig.Interval = 0x10; + sConfig.AutomaticStop = QSPI_AUTOMATIC_STOP_ENABLE; + + sCommand.Instruction = READ_STATUS_REG_CMD; + sCommand.DataMode = QSPI_DATA_1_LINE; + + if (HAL_QSPI_AutoPolling(hqspi, &sCommand, &sConfig, QSPI_TIMEOUT) != HAL_OK) + { + Error_Handler(); + } +} + +/** + * @brief This function read the SR of the memory and wait the EOP. + * @param hqspi: QSPI handle + * @retval None + */ +static void QSPI_AutoPollingMemReady(QSPI_HandleTypeDef *hqspi) +{ + QSPI_CommandTypeDef sCommand; + QSPI_AutoPollingTypeDef sConfig; + + /* Configure automatic polling mode to wait for memory ready ------ */ + sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE; + sCommand.Instruction = READ_STATUS_REG_CMD; + sCommand.AddressMode = QSPI_ADDRESS_NONE; + sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; + sCommand.DataMode = QSPI_DATA_1_LINE; + sCommand.DummyCycles = 0; + sCommand.DdrMode = QSPI_DDR_MODE_DISABLE; + sCommand.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; + sCommand.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; + + sConfig.Match = 0x00; + sConfig.Mask = 0x01; + sConfig.MatchMode = QSPI_MATCH_MODE_AND; + sConfig.StatusBytesSize = 1; + sConfig.Interval = 0x10; + sConfig.AutomaticStop = QSPI_AUTOMATIC_STOP_ENABLE; + + if (HAL_QSPI_AutoPolling(hqspi, &sCommand, &sConfig, QSPI_TIMEOUT) != HAL_OK) + { + Error_Handler(); + } +} + +/** + * @brief This function configure the dummy cycles on memory side. + * @param hqspi: QSPI handle + * @retval None + */ +static void QSPI_DummyCyclesCfg(QSPI_HandleTypeDef *hqspi) +{ + QSPI_CommandTypeDef sCommand; + uint8_t reg; + + /* Read Volatile Configuration register --------------------------- */ + sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE; + sCommand.Instruction = READ_VOL_CFG_REG_CMD; + sCommand.AddressMode = QSPI_ADDRESS_NONE; + sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; + sCommand.DataMode = QSPI_DATA_1_LINE; + sCommand.DummyCycles = 0; + sCommand.DdrMode = QSPI_DDR_MODE_DISABLE; + sCommand.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; + sCommand.SIOOMode = QSPI_SIOO_INST_EVERY_CMD; + sCommand.NbData = 1; + + if (HAL_QSPI_Command(hqspi, &sCommand, QSPI_TIMEOUT) != HAL_OK) + { + Error_Handler(); + } + + if (HAL_QSPI_Receive(hqspi, ®, QSPI_TIMEOUT) != HAL_OK) + { + Error_Handler(); + } + + /* Enable write operations ---------------------------------------- */ + QSPI_WriteEnable(hqspi, false); + + /* Write Volatile Configuration register (with new dummy cycles) -- */ + sCommand.Instruction = WRITE_VOL_CFG_REG_CMD; + MODIFY_REG(reg, 0xF0, (DUMMY_CLOCK_CYCLES_READ_QUAD << POSITION_VAL(0xF0))); + + if (HAL_QSPI_Command(hqspi, &sCommand, QSPI_TIMEOUT) != HAL_OK) + { + Error_Handler(); + } + + if (HAL_QSPI_Transmit(hqspi, ®, QSPI_TIMEOUT) != HAL_OK) + { + Error_Handler(); + } +} diff --git a/Source/flash.h b/Source/flash.h new file mode 100644 index 00000000..56d69eb5 --- /dev/null +++ b/Source/flash.h @@ -0,0 +1,28 @@ +#ifndef __FLASH_H +#define __FLASH_H + +#include +#include + +#define QSPI_FLASH_BASE 0x90000000 +#define QSPI_FLASH_SIZE (8*1024*1024) // 8M / 64Mbit + +#ifdef __cplusplus + extern "C" { +#endif + + void flash_init(); + int flash_status(); + int flash_quad_mode(uint8_t, uint8_t); + int flash_qpi_mode(bool qpi); + int flash_write_block(uint32_t address, void* data, uint32_t size); + int flash_read_block(int mode, uint32_t address, void* data, uint32_t size); + int flash_wait(); + int flash_erase(uint32_t address, uint32_t size); + int flash_memory_map(int mode); + +#ifdef __cplusplus +} +#endif + +#endif /* __EEPROM_CONTROL_H */ From 7bed3156b5a52efef2cd2cd2c928407ce1fa512e Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 6 Sep 2021 18:30:37 +0200 Subject: [PATCH 059/286] added MDMA --- Hardware/h7-libs.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/Hardware/h7-libs.mk b/Hardware/h7-libs.mk index 6756fcc1..51ce0a41 100644 --- a/Hardware/h7-libs.mk +++ b/Hardware/h7-libs.mk @@ -30,6 +30,7 @@ C_SRC_RTC += $(DRIVERS)/Src/stm32h7xx_hal_pwr.c C_SRC_RTC += $(DRIVERS)/Src/stm32h7xx_hal_rtc_ex.c C_SRC_IWDG = $(DRIVERS)/Src/stm32h7xx_hal_iwdg.c C_SRC_QSPI = $(DRIVERS)/Src/stm32h7xx_hal_qspi.c +C_SRC_MDMA = $(DRIVERS)/Src/stm32h7xx_hal_mdma.c # required by OWL 2 C_SRC_SAI = $(DRIVERS)/Src/stm32h7xx_hal_sai.c From a5d24cbbb047df181bc7acadf313eab2b356c70b Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 6 Sep 2021 18:31:03 +0200 Subject: [PATCH 060/286] added QSPI support --- Xibeca/Core/Inc/main.h | 3 --- Xibeca/Core/Inc/stm32h7xx_it.h | 1 + Xibeca/Core/Src/Xibeca.cpp | 3 ++- Xibeca/Core/Src/main.c | 22 ++++++++++---------- Xibeca/Core/Src/stm32h7xx_hal_msp.c | 13 ++++++++---- Xibeca/Core/Src/stm32h7xx_it.c | 16 +++++++++++++++ Xibeca/Makefile | 3 +++ Xibeca/Xibeca.ioc | 32 ++++++++++++++++++++--------- 8 files changed, 64 insertions(+), 29 deletions(-) diff --git a/Xibeca/Core/Inc/main.h b/Xibeca/Core/Inc/main.h index 1fd9ff73..ee56745a 100644 --- a/Xibeca/Core/Inc/main.h +++ b/Xibeca/Core/Inc/main.h @@ -115,9 +115,6 @@ void Error_Handler(void); #define ADC_RESET_Pin ADC_RST_Pin #define ADC_RESET_GPIO_Port ADC_RST_GPIO_Port - - - /* USER CODE END Private defines */ #ifdef __cplusplus diff --git a/Xibeca/Core/Inc/stm32h7xx_it.h b/Xibeca/Core/Inc/stm32h7xx_it.h index a359b538..8bfa4d85 100644 --- a/Xibeca/Core/Inc/stm32h7xx_it.h +++ b/Xibeca/Core/Inc/stm32h7xx_it.h @@ -59,6 +59,7 @@ void TIM4_IRQHandler(void); void EXTI15_10_IRQHandler(void); void SPI3_IRQHandler(void); void SAI1_IRQHandler(void); +void QUADSPI_IRQHandler(void); void OTG_FS_IRQHandler(void); /* USER CODE BEGIN EFP */ diff --git a/Xibeca/Core/Src/Xibeca.cpp b/Xibeca/Core/Src/Xibeca.cpp index e9921e74..0d55ecdd 100644 --- a/Xibeca/Core/Src/Xibeca.cpp +++ b/Xibeca/Core/Src/Xibeca.cpp @@ -4,6 +4,7 @@ #include "Pin.h" #include "ApplicationSettings.h" #include "OpenWareMidiControl.h" +#include "message.h" #if 0 #define XIBECA_PIN3 GPIOD, GPIO_PIN_2 @@ -251,7 +252,7 @@ void setup(){ CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; DWT->CYCCNT = 0; DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk; - + // __HAL_TIM_SET_COUNTER(&ENCODER_TIM1, INT16_MAX/2); __HAL_TIM_SET_COUNTER(&ENCODER_TIM1, 2048); HAL_TIM_Encoder_Start_IT(&ENCODER_TIM1, TIM_CHANNEL_ALL); diff --git a/Xibeca/Core/Src/main.c b/Xibeca/Core/Src/main.c index 7b424c02..03eb6af6 100644 --- a/Xibeca/Core/Src/main.c +++ b/Xibeca/Core/Src/main.c @@ -458,10 +458,10 @@ static void MX_QUADSPI_Init(void) /* USER CODE END QUADSPI_Init 1 */ /* QUADSPI parameter configuration*/ hqspi.Instance = QUADSPI; - hqspi.Init.ClockPrescaler = 255; - hqspi.Init.FifoThreshold = 1; + hqspi.Init.ClockPrescaler = 9; + hqspi.Init.FifoThreshold = 4; hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_NONE; - hqspi.Init.FlashSize = 1; + hqspi.Init.FlashSize = 22; hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_1_CYCLE; hqspi.Init.ClockMode = QSPI_CLOCK_MODE_0; hqspi.Init.FlashID = QSPI_FLASH_ID_1; @@ -1005,9 +1005,9 @@ static void MX_GPIO_Init(void) /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(ADC_SPI_NCS_GPIO_Port, ADC_SPI_NCS_Pin, GPIO_PIN_RESET); - /*Configure GPIO pins : PB1 PB8 PB4 PB9 PB2 + /*Configure GPIO pins : PB8 PB4 PB9 PB2 PB12 PB13 PB14 PB15 */ - GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_8|GPIO_PIN_4|GPIO_PIN_9|GPIO_PIN_2 + GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_4|GPIO_PIN_9|GPIO_PIN_2 |GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; @@ -1055,8 +1055,8 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; HAL_GPIO_Init(OLED_DC_GPIO_Port, &GPIO_InitStruct); - /*Configure GPIO pins : EXTI13_Pin EXTI14_Pin PC9 */ - GPIO_InitStruct.Pin = EXTI13_Pin|EXTI14_Pin|GPIO_PIN_9; + /*Configure GPIO pins : EXTI13_Pin EXTI14_Pin PC9 PC8 */ + GPIO_InitStruct.Pin = EXTI13_Pin|EXTI14_Pin|GPIO_PIN_9|GPIO_PIN_8; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); @@ -1073,8 +1073,8 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); - /*Configure GPIO pins : PA2 PA10 PA5 */ - GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_10|GPIO_PIN_5; + /*Configure GPIO pins : PA10 PA5 */ + GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_5; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); @@ -1125,8 +1125,8 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; HAL_GPIO_Init(OLED_RST_GPIO_Port, &GPIO_InitStruct); - /*Configure GPIO pin : PC0 PC4 PC5 */ - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_4|GPIO_PIN_5; + /*Configure GPIO pin : PC4 */ + GPIO_InitStruct.Pin = GPIO_PIN_4; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); diff --git a/Xibeca/Core/Src/stm32h7xx_hal_msp.c b/Xibeca/Core/Src/stm32h7xx_hal_msp.c index 06d81c1b..3bb186c8 100644 --- a/Xibeca/Core/Src/stm32h7xx_hal_msp.c +++ b/Xibeca/Core/Src/stm32h7xx_hal_msp.c @@ -311,31 +311,34 @@ void HAL_QSPI_MspInit(QSPI_HandleTypeDef* hqspi) GPIO_InitStruct.Pin = FLASH_DQ2_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI; HAL_GPIO_Init(FLASH_DQ2_GPIO_Port, &GPIO_InitStruct); GPIO_InitStruct.Pin = FLASH_NCS_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_QUADSPI; HAL_GPIO_Init(FLASH_NCS_GPIO_Port, &GPIO_InitStruct); GPIO_InitStruct.Pin = FLASH_DQ3_Pin|FLASH_CLK_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); GPIO_InitStruct.Pin = FLASH_DQ1_Pin|FLASH_DQ0_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_QUADSPI; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + /* QUADSPI interrupt Init */ + HAL_NVIC_SetPriority(QUADSPI_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(QUADSPI_IRQn); /* USER CODE BEGIN QUADSPI_MspInit 1 */ /* USER CODE END QUADSPI_MspInit 1 */ @@ -373,6 +376,8 @@ void HAL_QSPI_MspDeInit(QSPI_HandleTypeDef* hqspi) HAL_GPIO_DeInit(GPIOF, FLASH_DQ3_Pin|FLASH_CLK_Pin|FLASH_DQ1_Pin|FLASH_DQ0_Pin); + /* QUADSPI interrupt DeInit */ + HAL_NVIC_DisableIRQ(QUADSPI_IRQn); /* USER CODE BEGIN QUADSPI_MspDeInit 1 */ /* USER CODE END QUADSPI_MspDeInit 1 */ diff --git a/Xibeca/Core/Src/stm32h7xx_it.c b/Xibeca/Core/Src/stm32h7xx_it.c index 945b2f95..2015fed9 100644 --- a/Xibeca/Core/Src/stm32h7xx_it.c +++ b/Xibeca/Core/Src/stm32h7xx_it.c @@ -61,6 +61,7 @@ extern PCD_HandleTypeDef hpcd_USB_OTG_FS; extern DMA_HandleTypeDef hdma_adc1; extern ADC_HandleTypeDef hadc1; +extern QSPI_HandleTypeDef hqspi; extern DMA_HandleTypeDef hdma_sai1_a; extern DMA_HandleTypeDef hdma_sai1_b; extern SAI_HandleTypeDef hsai_BlockA1; @@ -196,6 +197,7 @@ void EXTI9_5_IRQHandler(void) /* USER CODE BEGIN EXTI9_5_IRQn 0 */ /* USER CODE END EXTI9_5_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8); HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_9); /* USER CODE BEGIN EXTI9_5_IRQn 1 */ @@ -260,6 +262,20 @@ void SAI1_IRQHandler(void) /* USER CODE END SAI1_IRQn 1 */ } +/** + * @brief This function handles QUADSPI global interrupt. + */ +void QUADSPI_IRQHandler(void) +{ + /* USER CODE BEGIN QUADSPI_IRQn 0 */ + + /* USER CODE END QUADSPI_IRQn 0 */ + HAL_QSPI_IRQHandler(&hqspi); + /* USER CODE BEGIN QUADSPI_IRQn 1 */ + + /* USER CODE END QUADSPI_IRQn 1 */ +} + /** * @brief This function handles USB On The Go FS global interrupt. */ diff --git a/Xibeca/Makefile b/Xibeca/Makefile index 05f96f85..2c35845b 100644 --- a/Xibeca/Makefile +++ b/Xibeca/Makefile @@ -28,6 +28,8 @@ C_SRC += $(BUILDROOT)/USB_DEVICE/Target/usbd_conf.c # C_SRC += $(BUILDROOT)/USB_HOST/Target/usbh_conf.c # C_SRC += $(BUILDROOT)/USB_HOST/App/usb_host.c +C_SRC += $(OPENWARE)/Source/flash.c + include $(OPENWARE)/Hardware/sources.mk C_SRC += $(C_SRC_SAI) @@ -40,5 +42,6 @@ C_SRC += $(C_SRC_OS) C_SRC += $(C_SRC_UART) C_SRC += $(C_SRC_I2C) C_SRC += $(C_SRC_QSPI) +C_SRC += $(C_SRC_MDMA) include $(OPENWARE)/Hardware/h7.mk diff --git a/Xibeca/Xibeca.ioc b/Xibeca/Xibeca.ioc index c22ac147..931f00d6 100644 --- a/Xibeca/Xibeca.ioc +++ b/Xibeca/Xibeca.ioc @@ -41,6 +41,7 @@ PD0.Signal=FMC_D2_DA2 SAI1.AudioMode-SAI_A_MasterWithClock=SAI_MODEMASTER_RX PD8.Signal=FMC_D13_DA13 PE1.Signal=FMC_NBL1 +QUADSPI.FlashSize=22 NVIC.EXTI15_10_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true ProjectManager.ProjectBuild=false NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false @@ -170,7 +171,7 @@ Mcu.Pin49=PH0-OSC_IN (PH0) Mcu.Pin46=PH2 Mcu.Pin47=PC9 SAI1.VirtualMode-SAI_A_MasterWithClock=VM_MASTER -PG6.GPIOParameters=GPIO_Label +PG6.GPIOParameters=GPIO_Speed,GPIO_Label Mcu.Pin40=PI11 Mcu.Pin41=PH13 Mcu.Pin44=PA9 @@ -201,14 +202,14 @@ Mcu.Pin32=PI9 Dma.SAI1_A.0.SyncRequestNumber=1 NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false FREERTOS.configUSE_MUTEXES=0 +QUADSPI.FifoThreshold=4 PF13.Signal=FMC_A7 PC10.GPIOParameters=GPIO_Speed SH.SharedStack_PC8.0=SDMMC1_D0 -SH.SharedStack_PC8.1=GPIO_EXTI8+0 +SH.SharedStack_PC8.1=GPIO_EXTI8 SH.FMC_NBL2.0=FMC_NBL2,Sd4ByteEnable1 PC9.GPIOParameters=GPIO_Label -SH.SharedStack_PC8.2=GPIO_Output -PF9.GPIOParameters=GPIO_Label +PF9.GPIOParameters=GPIO_Speed,GPIO_Label Mcu.Pin26=PI5 SH.FMC_D18.0=FMC_D18,sd-32b-d1 Mcu.Pin27=PD1 @@ -235,7 +236,7 @@ NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false Mcu.Pin16=PG15 Mcu.Pin13=PE6 Mcu.Pin14=PB7 -PF10.GPIOParameters=GPIO_Label +PF10.GPIOParameters=GPIO_Speed,GPIO_Label Mcu.Pin19=PG10 Mcu.Pin17=PG12 Mcu.Pin18=PG11 @@ -243,6 +244,7 @@ NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 Mcu.Pin11=PE4 Mcu.Pin12=PE5 Mcu.Pin10=PA13 (JTMS/SWDIO) +ADC1.ConversionDataManagement=ADC_CONVERSIONDATA_DMA_CIRCULAR PE3.Signal=SAI1_SD_B PF4.Signal=FMC_A4 SH.FMC_D26.ConfNb=1 @@ -258,6 +260,7 @@ SH.FMC_A8.0=FMC_A8,13b-sda1 ProjectManager.KeepUserCode=true PH14.Signal=FMC_D22 PH10.Signal=FMC_D18 +ADC1.Overrun=ADC_OVR_DATA_OVERWRITTEN ADC1.ContinuousConvMode=ENABLE SH.FMC_D14_DA14.0=FMC_D14,sd-32b-d1 PH0-OSC_IN\ (PH0).Signal=RCC_OSC_IN @@ -265,7 +268,9 @@ PG2.Signal=FMC_A12 SAI1.FrameLength-SAI_B_SyncSlave=256 TIM4.EncoderMode=TIM_ENCODERMODE_TI12 SAI1.FSDefinition-SAI_A_MasterWithClock=SAI_FS_CHANNEL_IDENTIFICATION +PE2.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH PA11.Mode=Device_Only +PF9.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH RCC.PLL2FRACN=6144 SAI1.OutputDrive-SAI_B_SyncSlave=SAI_OUTPUTDRIVE_ENABLE PD2.Locked=true @@ -390,6 +395,7 @@ PC11.Signal=GPIO_Output Dma.SAI1_A.0.SignalID=NONE SPI2.NSSPMode=SPI_NSS_PULSE_DISABLE PC8.Signal=SharedStack_PC8 +PF10.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH SH.ADCx_INP14.0=ADC1_INP14,IN14-Single-Ended SH.FMC_D31.0=FMC_D31,sd-32b-d1 ProjectManager.DefaultFWLocation=true @@ -419,7 +425,7 @@ Dma.ADC1.3.SyncRequestNumber=1 PC5.GPIOParameters=GPIO_Label RCC.AXIClockFreq_Value=240000000 SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,DataSize,NSSPMode,CLKPolarity,CLKPhase -PE2.GPIOParameters=GPIO_Label +PE2.GPIOParameters=GPIO_Speed,GPIO_Label RCC.USBFreq_Value=48000000 PF9.GPIO_Label=FLASH_DQ1 SH.FMC_D24.ConfNb=1 @@ -462,7 +468,7 @@ Mcu.IP7=NVIC ProjectManager.CoupleFile=false RCC.SYSCLKFreq_VALUE=480000000 RCC.I2C123Freq_Value=120000000 -SH.SharedStack_PC8.ConfNb=3 +SH.SharedStack_PC8.ConfNb=2 ADC1.Rank-3\#ChannelRegularConversion=4 ADC1.SamplingTime-3\#ChannelRegularConversion=ADC_SAMPLETIME_387CYCLES_5 KeepUserPlacement=false @@ -486,6 +492,7 @@ SH.FMC_A4.ConfNb=1 SPI3.Direction=SPI_DIRECTION_2LINES_TXONLY SPI3.VirtualType=VM_MASTER PH12.Signal=FMC_D20 +QUADSPI.ClockPrescaler=9 SPI2.VirtualType=VM_MASTER PB10.Mode=Full_Duplex_Master PC12.Locked=true @@ -546,7 +553,7 @@ PE10.Signal=FMC_D7_DA7 ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_387CYCLES_5 RCC.MCO2PinFreq_Value=480000000 PC8.GPIOParameters=GPIO_Label -PF8.GPIOParameters=GPIO_Label +PF8.GPIOParameters=GPIO_Speed,GPIO_Label RCC.DFSDMFreq_Value=120000000 SH.FMC_A1.0=FMC_A1,13b-sda1 SH.GPXTI14.ConfNb=1 @@ -566,16 +573,18 @@ PE6.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH SH.FMC_D3_DA3.0=FMC_D3,sd-32b-d1 ProjectManager.CustomerFirmwarePackage= SH.SharedStack_PD2.ConfNb=2 +PG6.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH SH.SharedStack_PC9.ConfNb=2 Dma.SAI1_B.1.EventEnable=DISABLE SH.FMC_A7.ConfNb=1 +NVIC.QUADSPI_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true PH15.Signal=FMC_D23 SH.FMC_A1.ConfNb=1 SAI1.DataSize-SAI_B_SyncSlave=SAI_DATASIZE_24 RCC.DIVQ1=5 ADC1.Rank-0\#ChannelRegularConversion=1 SH.FMC_D28.0=FMC_D28,sd-32b-d1 -ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,NbrOfConversion,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,OffsetNumber-1\#ChannelRegularConversion,OffsetSignedSaturation-1\#ChannelRegularConversion,Rank-2\#ChannelRegularConversion,Channel-2\#ChannelRegularConversion,SamplingTime-2\#ChannelRegularConversion,OffsetNumber-2\#ChannelRegularConversion,OffsetSignedSaturation-2\#ChannelRegularConversion,Rank-3\#ChannelRegularConversion,Channel-3\#ChannelRegularConversion,SamplingTime-3\#ChannelRegularConversion,OffsetNumber-3\#ChannelRegularConversion,OffsetSignedSaturation-3\#ChannelRegularConversion,OversamplingMode,ContinuousConvMode,EOCSelection,Resolution,ClockPrescaler,master +ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,NbrOfConversion,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,OffsetNumber-1\#ChannelRegularConversion,OffsetSignedSaturation-1\#ChannelRegularConversion,Rank-2\#ChannelRegularConversion,Channel-2\#ChannelRegularConversion,SamplingTime-2\#ChannelRegularConversion,OffsetNumber-2\#ChannelRegularConversion,OffsetSignedSaturation-2\#ChannelRegularConversion,Rank-3\#ChannelRegularConversion,Channel-3\#ChannelRegularConversion,SamplingTime-3\#ChannelRegularConversion,OffsetNumber-3\#ChannelRegularConversion,OffsetSignedSaturation-3\#ChannelRegularConversion,OversamplingMode,ContinuousConvMode,EOCSelection,Resolution,ClockPrescaler,master,ConversionDataManagement,Overrun RCC.SWPMI1Freq_Value=120000000 FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 Dma.SPI3_TX.2.EventEnable=DISABLE @@ -588,6 +597,7 @@ TIM4.IC2Filter=4 PC0.Signal=ADCx_INP10 PC11.GPIOParameters=GPIO_Speed,GPIO_Label RCC.QSPIFreq_Value=240000000 +QUADSPI.IPParameters=ClockPrescaler,FifoThreshold,FlashSize PC9.Stacked=true PG10.Signal=GPIO_Input PG10.Locked=true @@ -685,6 +695,7 @@ PA13\ (JTMS/SWDIO).Signal=DEBUG_JTMS-SWDIO Mcu.Pin102=PE11 Mcu.Pin103=PE14 Mcu.Pin104=PD9 +PF6.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH Mcu.Pin100=PE8 Dma.SAI1_A.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber RCC.DIVQ2Freq_Value=75000000 @@ -871,11 +882,12 @@ PC14-OSC32_IN\ (OSC32_IN).Signal=GPXTI14 PC5.GPIO_Label=ADC4 SH.FMC_D23.0=FMC_D23,sd-32b-d1 SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B -PF6.GPIOParameters=GPIO_Label +PF6.GPIOParameters=GPIO_Speed,GPIO_Label RCC.SAI4AFreq_Value=192000000 SH.ADCx_INP11.0=ADC1_INP11,IN11-Single-Ended ADC1.NbrOfConversionFlag=1 SAI1.FSOffset-SAI_B_SyncSlave=SAI_FS_BEFOREFIRSTBIT +PF8.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH RCC.DIVQ1Freq_Value=192000000 PC2_C.GPIOParameters=GPIO_Speed,GPIO_Label Dma.SAI1_B.1.SyncRequestNumber=1 From a5f8a8c84fc94fe4e485c62a42d76cb9662cc518 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 7 Sep 2021 16:59:41 +0200 Subject: [PATCH 061/286] driver for 256Mbit SDRAM for Xibeca --- Source/sdram-as4cXm32.c | 64 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 Source/sdram-as4cXm32.c diff --git a/Source/sdram-as4cXm32.c b/Source/sdram-as4cXm32.c new file mode 100644 index 00000000..d5056042 --- /dev/null +++ b/Source/sdram-as4cXm32.c @@ -0,0 +1,64 @@ +#include +#include "sdram.h" + +/** + * Alliance Memory DRAM 256Mbits, 3.3V, 8Mx32 SDRAM AS4C8M32SA-6BIN + */ + +#define SDRAM_MODEREG_BURST_LENGTH_2 (1 << 0) +#define SDRAM_MODEREG_BURST_LENGTH_4 (1 << 1) +#define SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL (0 << 3) +#define SDRAM_MODEREG_CAS_LATENCY_3 ((1 << 4) | (1 << 5)) +#define SDRAM_MODEREG_WRITEBURST_MODE_SINGLE (1 << 9) +#define SDRAM_MODEREG_WRITEBURST_MODE_PROG_BURST (0 << 9) + +void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram){ + FMC_SDRAM_CommandTypeDef Command; + + __IO uint32_t tmpmrd = 0; + /* Step 3: Configure a clock configuration enable command */ + Command.CommandMode = FMC_SDRAM_CMD_CLK_ENABLE; + Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; + Command.AutoRefreshNumber = 1; + Command.ModeRegisterDefinition = 0; + + /* Send the command */ + HAL_SDRAM_SendCommand(hsdram, &Command, 0x1000); + + /* Step 4: Insert 100 ms delay */ + HAL_Delay(100); + + /* Step 5: Configure a PALL (precharge all) command */ + Command.CommandMode = FMC_SDRAM_CMD_PALL; + Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; + Command.AutoRefreshNumber = 1; + Command.ModeRegisterDefinition = 0; + + /* Send the command */ + HAL_SDRAM_SendCommand(hsdram, &Command, 0x1000); + + /* Step 6 : Configure a Auto-Refresh command */ + Command.CommandMode = FMC_SDRAM_CMD_AUTOREFRESH_MODE; + Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; + Command.AutoRefreshNumber = 4; + Command.ModeRegisterDefinition = 0; + + /* Send the command */ + HAL_SDRAM_SendCommand(hsdram, &Command, 0x1000); + + /* Step 7: Program the external memory mode register */ + tmpmrd = SDRAM_MODEREG_BURST_LENGTH_4 + | SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL + | SDRAM_MODEREG_CAS_LATENCY_3 + | SDRAM_MODEREG_WRITEBURST_MODE_SINGLE; + Command.CommandMode = FMC_SDRAM_CMD_LOAD_MODE; + Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; + Command.AutoRefreshNumber = 1; + Command.ModeRegisterDefinition = tmpmrd; + + /* Send the command */ + HAL_SDRAM_SendCommand(hsdram, &Command, 0x1000); + + /* Set refresh rate */ + HAL_SDRAM_ProgramRefreshRate(hsdram, 0x81A - 20); +} From 34247b6d72674f027a8630e21326d911f7a682c1 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 7 Sep 2021 17:02:11 +0200 Subject: [PATCH 062/286] enabled extram --- Xibeca/Core/Inc/hardware.h | 2 +- Xibeca/Core/Src/main.c | 23 +++++++------ Xibeca/Core/Src/test-qspi.h | 68 +++++++++++++++++++++++++++++++++++++ Xibeca/Makefile | 4 ++- 4 files changed, 84 insertions(+), 13 deletions(-) create mode 100644 Xibeca/Core/Src/test-qspi.h diff --git a/Xibeca/Core/Inc/hardware.h b/Xibeca/Core/Inc/hardware.h index d9469339..0f116bf4 100644 --- a/Xibeca/Core/Inc/hardware.h +++ b/Xibeca/Core/Inc/hardware.h @@ -4,7 +4,7 @@ #define OWL_XIBECA #define HARDWARE_ID XIBECA_HARDWARE #define HARDWARE_VERSION "Xibeca" -#define NO_EXTERNAL_RAM +/* #define NO_EXTERNAL_RAM */ /* #define NO_CCM_RAM */ #define DMA_RAM __attribute__ ((section (".dmadata"))) #define USE_PLUS_RAM diff --git a/Xibeca/Core/Src/main.c b/Xibeca/Core/Src/main.c index 03eb6af6..1ffdf427 100644 --- a/Xibeca/Core/Src/main.c +++ b/Xibeca/Core/Src/main.c @@ -939,23 +939,24 @@ static void MX_FMC_Init(void) hsdram1.Instance = FMC_SDRAM_DEVICE; /* hsdram1.Init */ hsdram1.Init.SDBank = FMC_SDRAM_BANK1; - hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8; + hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_9; // 8; hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_13; hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_32; hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4; - hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_1; + hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3; // 1; hsdram1.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE; - hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_DISABLE; - hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_DISABLE; + hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2; + /* hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_DISABLE; // PERIOD_2; */ + hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE; // DISABLE; hsdram1.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0; /* SdramTiming */ - SdramTiming.LoadToActiveDelay = 16; - SdramTiming.ExitSelfRefreshDelay = 16; - SdramTiming.SelfRefreshTime = 16; - SdramTiming.RowCycleDelay = 16; - SdramTiming.WriteRecoveryTime = 16; - SdramTiming.RPDelay = 16; - SdramTiming.RCDDelay = 16; + SdramTiming.LoadToActiveDelay = 2; // 16; + SdramTiming.ExitSelfRefreshDelay = 7; // 16; + SdramTiming.SelfRefreshTime = 4; // 16; + SdramTiming.RowCycleDelay = 8; // 16; + SdramTiming.WriteRecoveryTime = 3; // 16; + SdramTiming.RPDelay = 1; // 0 causes assertion error; // 16; + SdramTiming.RCDDelay = 10; // 16; if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK) { diff --git a/Xibeca/Core/Src/test-qspi.h b/Xibeca/Core/Src/test-qspi.h new file mode 100644 index 00000000..50054980 --- /dev/null +++ b/Xibeca/Core/Src/test-qspi.h @@ -0,0 +1,68 @@ + +#include "flash.h" + +static int cmp(void* a, void* b, size_t len){ + uint8_t* lhs = (uint8_t*)a; + uint8_t* rhs = (uint8_t*)b; + while(len--){ + if(*lhs++ != *rhs++) + return -1; + } + return 0; +} + +int setError(const char* msg){ + error(CONFIG_ERROR, msg); + return -1; +} +int flashExternal(uint8_t* source, size_t size, int sector, uint32_t address){ + flash_init(); + int memloc = sector*128*1024; + // size_t size = getSize(); + // uint8_t* source = getData(); + // uint32_t address = QSPI_FLASH_BASE+memloc; + if(address < QSPI_FLASH_BASE || address+size > QSPI_FLASH_BASE+QSPI_FLASH_SIZE) + return setError("Invalid QSPI FLASH sector or size"); + if(flash_erase(memloc, size) != 0) + return setError("QSPI Flash erase failed"); + flash_wait(); + if(flash_write_block(memloc, source, size) != 0) + return setError("QSPI Flash write failed"); + flash_wait(); + flash_memory_map(122); + if(cmp((void*)address, source, size) != 0) + return setError("QSPI FLASH verify failed"); + return 0; +} + +extern "C" { + void HAL_QSPI_ErrorCallback(QSPI_HandleTypeDef *hqspi){ + debugMessage("QSPI Error", (int)hqspi->ErrorCode); + } + void HAL_QSPI_AbortCpltCallback(QSPI_HandleTypeDef *hqspi){ + debugMessage("QSPI Abort", (int)hqspi->ErrorCode); + } +} + + +const char flashdata[] = "This is the new data."; + +#ifdef DEBUG +#include +#endif + +void setup(){ + printf("QSPI flash test: %s.\n", flashdata); + + flashExternal((uint8_t*)flashdata, sizeof(flashdata), 0, QSPI_FLASH_BASE); + + // flash_reset(); + flash_init(); + int fs1 = flash_status(); + flash_memory_map(-122); + int fs2 = flash_status(); + // flash_memory_map(-444); +#ifdef DEBUG + printf("FLASH %s %d %d.\n", (const char*)QSPI_FLASH_BASE, fs1, fs2); +#endif +} diff --git a/Xibeca/Makefile b/Xibeca/Makefile index 2c35845b..869a580e 100644 --- a/Xibeca/Makefile +++ b/Xibeca/Makefile @@ -2,13 +2,15 @@ PROJECT = Xibeca BUILDROOT = . OPENWARE ?= $(BUILDROOT)/.. +LDSCRIPT = $(OPENWARE)/Hardware/xibeca.ld include $(OPENWARE)/Hardware/owl3.mk C_SRC = $(wildcard Core/Src/*.c) CPP_SRC = $(wildcard Core/Src/*.cpp) -C_SRC += $(OPENWARE)/Source/sdram.c C_SRC += $(OPENWARE)/Source/pcm3168a.c C_SRC += $(OPENWARE)/Source/usbd_audio.c +# C_SRC += $(OPENWARE)/Source/sdram.c +C_SRC += $(OPENWARE)/Source/sdram-as4cXm32.c C_SRC += $(OPENWARE)/Source/ssd1309.c CPP_SRC += $(OPENWARE)/Source/ScreenBuffer.cpp From f5cec232ffe3825a25b7a245e7c7a8c67e4e8b02 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 7 Sep 2021 17:33:58 +0200 Subject: [PATCH 063/286] changed SDRAM size and comment --- Hardware/xibeca.ld | 224 ++++++++++++++++++++++++++++++++++++++++ Source/sdram-as4cXm32.c | 2 +- 2 files changed, 225 insertions(+), 1 deletion(-) create mode 100644 Hardware/xibeca.ld diff --git a/Hardware/xibeca.ld b/Hardware/xibeca.ld new file mode 100644 index 00000000..5b80fbad --- /dev/null +++ b/Hardware/xibeca.ld @@ -0,0 +1,224 @@ +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Generate a link error if heap and stack don't fit into RAM */ +_Min_Heap_Size = 0x200; /* required amount of heap */ +_Min_Stack_Size = 0x200; /* required amount of stack */ + +/* Specify the memory areas */ +MEMORY +{ + /* DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K */ + /* RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 512K */ + /* RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K */ + /* RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K */ + /* ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K */ + /* FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 2048K */ +DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 48K +PATCHRAM (rwx) : ORIGIN = 0x2000c000, LENGTH = 80K +PLUSRAM (xrw) : ORIGIN = 0x24000000, LENGTH = 512K /* D1 RAM */ +HEAP_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 256K +DMA_D2 (xrw) : ORIGIN = 0x30040000, LENGTH = 32K +RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K +ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 2K +CCMRAM (xrw) : ORIGIN = 0x00000800, LENGTH = 62K +/* EXTRAM (rwx) : ORIGIN = 0xD0000000, LENGTH = 8M */ +EXTRAM (rwx) : ORIGIN = 0xC0000000, LENGTH = 64M /* 64M in Rev01 prototypes */ + +BOOTLOADER (rx) : ORIGIN = 0x08000000, LENGTH = 0K +FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K +/* BOOTLOADER (rx) : ORIGIN = 0x08000000, LENGTH = 128K */ +/* FLASH (rx) : ORIGIN = 0x08020000, LENGTH = 384K */ +STORAGE (rx) : ORIGIN = 0x08080000, LENGTH = 512K /* Assuming 1Mb FLASH */ +/* STORAGE (rx) : ORIGIN = 0x08080000, LENGTH = 1536K /\* Assuming 2Mb FLASH *\/ */ +} + +/* Define output sections */ +SECTIONS +{ + /* The startup code goes first into FLASH */ + .isr_vector : + { + . = ALIGN(4); + PROVIDE ( _ISR_VECTOR = . ); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + PROVIDE ( _ISR_VECTOR_END = . ); + } >FLASH + _ISR_VECTOR_SIZE = _ISR_VECTOR_END - _ISR_VECTOR; + + /* The program code and other data goes into FLASH */ + .text : + { + . = ALIGN(4); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + } >FLASH + + /* Constant data goes into FLASH */ + .rodata : + { + . = ALIGN(4); + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } >FLASH + + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH + .ARM : { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } >FLASH + + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } >FLASH + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + } >FLASH + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) + PROVIDE_HIDDEN (__fini_array_end = .); + } >FLASH + + /* used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* Initialized data sections goes into RAM, load LMA copy after code */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + } >DTCMRAM AT> FLASH + + + /* Uninitialized data section */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss secion */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + + end = .; /* system heap, used e.g. by printf in DEBUG builds */ + . = . + _Min_Heap_Size; + } >DTCMRAM + + /* User_heap_stack section, used to check that there is enough RAM left */ + ._user_heap_stack : + { + . = . + _Min_Stack_Size; + . = ALIGN(8); + } >ITCMRAM + _estack = ORIGIN(ITCMRAM)+LENGTH(ITCMRAM); + + /* CCM section, vars must be located here explicitly */ + /* Example: int foo __attribute__ ((section (".ccmdata"))); */ + .ccmdata (NOLOAD) : + { + *(.ccmdata) + . = ALIGN(8); + PROVIDE (_CCMRAM = .); + } >CCMRAM + _CCMRAM_END = ORIGIN(CCMRAM) + LENGTH(CCMRAM); + _CCMRAM_SIZE = _CCMRAM_END - _CCMRAM; + + /* Bootloader end will be used for finding bootloader token */ + .bootloader (NOLOAD) : + { + PROVIDE (_BOOTLOADER = .); + } >BOOTLOADER + _BOOTLOADER_END = ORIGIN(BOOTLOADER) + LENGTH(BOOTLOADER); + + /* External memory, vars must be located here explicitly */ + /* Example: int foo __attribute__ ((section (".extdata"))); */ + .extdata (NOLOAD) : + { + /* *(.extdata) */ + /* . = ALIGN(8); */ + PROVIDE ( _EXTRAM = . ); + /* } >RAM_D1 */ + /* _EXTRAM_END = ORIGIN(RAM_D1) + LENGTH(RAM_D1); */ + /* _EXTRAM_SIZE = LENGTH(RAM_D1); */ + } >EXTRAM + _EXTRAM_END = ORIGIN(EXTRAM) + LENGTH(EXTRAM); + _EXTRAM_SIZE = LENGTH(EXTRAM); + + .patchram (NOLOAD) : + { + PROVIDE (_PATCHRAM = .); + } >PATCHRAM + _PATCHRAM_END = ORIGIN(PATCHRAM) + LENGTH(PATCHRAM); + _PATCHRAM_SIZE = LENGTH(PATCHRAM); + + .plusram (NOLOAD) : + { + PROVIDE (_PLUSRAM = .); + } >PLUSRAM + _PLUSRAM_END = ORIGIN(PLUSRAM) + LENGTH(PLUSRAM); + _PLUSRAM_SIZE = LENGTH(PLUSRAM); + + .heapd2 (NOLOAD) : + { + PROVIDE (_HEAP_D2 = .); + } >HEAP_D2 + _HEAP_D2_END = ORIGIN(HEAP_D2) + LENGTH(HEAP_D2); + _HEAP_D2_SIZE = LENGTH(HEAP_D2); + + .dmadata (NOLOAD) : + { + PROVIDE (_DMA_DATA = .); + *(.dmadata) + } >DMA_D2 + + .flash_storage (NOLOAD) : + { + PROVIDE (_FLASH_STORAGE_BEGIN = .); + } >STORAGE + _FLASH_STORAGE_END = ORIGIN(STORAGE) + LENGTH(STORAGE); + _FLASH_STORAGE_SIZE = LENGTH(STORAGE); + + /* Remove information from the standard libraries */ + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { *(.ARM.attributes) } +} + + diff --git a/Source/sdram-as4cXm32.c b/Source/sdram-as4cXm32.c index d5056042..f4c71c1f 100644 --- a/Source/sdram-as4cXm32.c +++ b/Source/sdram-as4cXm32.c @@ -2,7 +2,7 @@ #include "sdram.h" /** - * Alliance Memory DRAM 256Mbits, 3.3V, 8Mx32 SDRAM AS4C8M32SA-6BIN + * Alliance Memory DRAM 256Mbits, 3.3V, 8Mx32 AS4C8M32SA-6BIN */ #define SDRAM_MODEREG_BURST_LENGTH_2 (1 << 0) From 623b9b48c6c7a147500dee3059ba091d5e16cd84 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 10 Sep 2021 17:58:21 +0200 Subject: [PATCH 064/286] no pull-up on footswitch pin --- OwlPedal2/OwlPedal2.ioc | 4 ++-- OwlPedal2/Src/OwlPedal.cpp | 11 +++++++++++ OwlPedal2/Src/main.c | 10 ++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/OwlPedal2/OwlPedal2.ioc b/OwlPedal2/OwlPedal2.ioc index e7a4a723..0ada8a97 100644 --- a/OwlPedal2/OwlPedal2.ioc +++ b/OwlPedal2/OwlPedal2.ioc @@ -438,7 +438,7 @@ ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_9 RCC.HSE_VALUE=25000000 NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false SH.FMC_A14_BA0.ConfNb=1 -PA4.GPIO_PuPd=GPIO_PULLUP +PA4.GPIO_PuPd=GPIO_NOPULL ADC3.InjNumberOfConversion=0 SH.FMC_D8_DA8.0=FMC_D8,sd-16b-d1 FMC.ExitSelfRefreshDelay1=6 @@ -602,7 +602,7 @@ RCC.UART5Freq_Value=54000000 ADC1.NbrOfConversion=1 ADC3.Channel-34\#ChannelRegularConversion=ADC_CHANNEL_8 RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CECFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SClocksFreq_Value,I2SFreq_Value,LCDTFToutputFreq_Value,LPTIM1Freq_Value,LSE_VALUE,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLI2SPCLKFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLI2SRoutputFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLQoutputFreq_Value,PLLSAIN,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIRCLKFreq_Value,PLLSAIoutputFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SAI1Freq_Value,SAI2Freq_Value,SAI_AClocksFreq_Value,SAI_BClocksFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,UART4Freq_Value,UART5Freq_Value,UART7Freq_Value,UART8Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USART6Freq_Value,USBFreq_Value,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value,VCOSAIOutputFreq_ValueQ,VcooutputI2S,VcooutputI2SQ -ProjectManager.AskForMigrate=false +ProjectManager.AskForMigrate=true Mcu.Name=STM32F427Z(G-I)Tx PE0.Signal=FMC_NBL0 Dma.SAI1_B.2.Direction=DMA_PERIPH_TO_MEMORY diff --git a/OwlPedal2/Src/OwlPedal.cpp b/OwlPedal2/Src/OwlPedal.cpp index d21eb647..c6231837 100644 --- a/OwlPedal2/Src/OwlPedal.cpp +++ b/OwlPedal2/Src/OwlPedal.cpp @@ -3,9 +3,12 @@ #include "errorhandlers.h" #include "MidiController.h" #include "OpenWareMidiControl.h" +#include "Pin.h" #define PATCH_RESET_COUNTER (1000/MAIN_LOOP_SLEEP_MS) +// Pin bypass_pin(GPIOA, GPIO_PIN_4); + void setLed(uint8_t led, uint32_t rgb){ switch(rgb){ case RED_COLOUR: @@ -71,6 +74,14 @@ void setGateValue(uint8_t ch, int16_t value){ } void setup(){ + // bypass_pin.outputMode(); + // bypass_pin.inputMode(); + // bypass_pin.setPull(PIN_PULL_NONE); + // bypass_pin.set(false); + // bypass_pin.setPull(PIN_PULL_DOWN); + // bypass_pin.setPull(PIN_PULL_UP); + // bypass_pin.get(); + setLed(0, RED_COLOUR); HAL_GPIO_WritePin(EXP_TIP_GPIO_Port, EXP_TIP_Pin, GPIO_PIN_SET); owl.setup(); diff --git a/OwlPedal2/Src/main.c b/OwlPedal2/Src/main.c index 74657ab7..85d94db3 100644 --- a/OwlPedal2/Src/main.c +++ b/OwlPedal2/Src/main.c @@ -730,12 +730,18 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - /*Configure GPIO pins : SW4_Pin SW3_Pin BYPASS_Pin SW1_Pin */ - GPIO_InitStruct.Pin = SW4_Pin|SW3_Pin|BYPASS_Pin|SW1_Pin; + /*Configure GPIO pins : SW4_Pin SW3_Pin SW1_Pin */ + GPIO_InitStruct.Pin = SW4_Pin|SW3_Pin|SW1_Pin; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + /*Configure GPIO pin : BYPASS_Pin */ + GPIO_InitStruct.Pin = BYPASS_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(BYPASS_GPIO_Port, &GPIO_InitStruct); + /*Configure GPIO pins : PB0 PB12 PB13 PB14 PB15 PB4 PB7 PB9 */ GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 From 1c3562dca7b73ec5c7cb76cc89786ff750156ee0 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 10 Sep 2021 17:59:58 +0200 Subject: [PATCH 065/286] removed unused OLED_SOFT_CS define --- Magus3/Inc/hardware.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Magus3/Inc/hardware.h b/Magus3/Inc/hardware.h index 7ee133e1..dc460e88 100644 --- a/Magus3/Inc/hardware.h +++ b/Magus3/Inc/hardware.h @@ -17,7 +17,6 @@ #define USE_SCREEN #define SSD1309 /* #define OLED_DMA */ -#define OLED_SOFT_CS #define OLED_SPI hspi6 /* #define OLED_IT */ /* #define OLED_BITBANG */ From 166771126c9b3ad9c6394ea038422bf0fcbe2055 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 20 Sep 2021 15:33:00 +0200 Subject: [PATCH 066/286] set channels in audio format --- Source/ProgramManager.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Source/ProgramManager.cpp b/Source/ProgramManager.cpp index 717891d6..982108b3 100644 --- a/Source/ProgramManager.cpp +++ b/Source/ProgramManager.cpp @@ -281,11 +281,8 @@ void updateProgramVector(ProgramVector* pv, PatchDefinition* def){ pv->heapSegments = (MemorySegment*)heapSegments; #ifdef USE_WM8731 pv->audio_format = AUDIO_FORMAT_24B16_2X; -#elif defined OWL_BIOSIGNALS || defined OWL_NOCTUA - pv->audio_format = AUDIO_FORMAT_24B32 | AUDIO_CHANNELS; #else - pv->audio_format = AUDIO_FORMAT_24B32; - // pv->audio_format = AUDIO_FORMAT_24B32_2X; + pv->audio_format = AUDIO_FORMAT_24B32 | AUDIO_CHANNELS; #endif #endif /* PROGRAM_VECTOR_V13 */ pv->message = NULL; From d8e252b5276790f5075a38d314767cf53d689f2c Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 20 Sep 2021 15:33:57 +0200 Subject: [PATCH 067/286] temporarily disable HP filter for testing --- OwlPedal2/Inc/hardware.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OwlPedal2/Inc/hardware.h b/OwlPedal2/Inc/hardware.h index 54e6a4c0..16cff6a6 100644 --- a/OwlPedal2/Inc/hardware.h +++ b/OwlPedal2/Inc/hardware.h @@ -39,7 +39,7 @@ /* #define ADC_E 4 */ #define USE_CODEC #define USE_CS4271 -#define CODEC_HP_FILTER +/* #define CODEC_HP_FILTER */ #define CODEC_SPI hspi4 #define NOF_ADC_VALUES 4 From 1b6c09eb0245ed92b5b46321ac9f6c0d21a212ca Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 24 Sep 2021 12:23:15 +0200 Subject: [PATCH 068/286] wip usb audio fixes --- Source/Codec.cpp | 38 ++++++++++++++++++++++++-------------- Source/usbd_audio.h | 9 +++++++++ Witch/Inc/hardware.h | 2 +- 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/Source/Codec.cpp b/Source/Codec.cpp index 8bd17b6c..d73f0bb7 100644 --- a/Source/Codec.cpp +++ b/Source/Codec.cpp @@ -26,10 +26,14 @@ extern "C" { int32_t codec_txbuf[CODEC_BUFFER_SIZE] DMA_RAM; extern DMA_HandleTypeDef HDMA_TX; extern DMA_HandleTypeDef HDMA_RX; +#if defined USE_CS4271 || defined USE_PCM3168A + extern SAI_HandleTypeDef HSAI_RX; + extern SAI_HandleTypeDef HSAI_TX; +#endif } CircularBuffer audio_rx_buffer(codec_rxbuf, CODEC_BUFFER_SIZE); -CircularBuffer audio_tx_buffer(codec_txbuf, CODEC_BUFFER_SIZE);; +CircularBuffer audio_tx_buffer(codec_txbuf, CODEC_BUFFER_SIZE); #ifdef USE_USBD_AUDIO #include "usbd_audio.h" @@ -101,8 +105,9 @@ void usbd_audio_tx_stop_callback(){ void usbd_audio_rx_start_callback(size_t rate, uint8_t channels){ #if defined USE_USBD_AUDIO_RX && USBD_AUDIO_RX_CHANNELS > 0 - // todo: if(wet) { disable RX dma } - __HAL_DMA_DISABLE(&HDMA_RX); // stop codec transfers + // todo: if(wet) { disable RX dma } else { stop patch } + // __HAL_DMA_DISABLE(&HDMA_RX); // stop codec transfers + HAL_SAI_DMAPause(&HSAI_RX); audio_rx_buffer.clear(); update_rx_read_index(); size_t pos = audio_rx_buffer.getWriteIndex(); @@ -110,8 +115,8 @@ void usbd_audio_rx_start_callback(size_t rate, uint8_t channels){ pos = (pos + len/2) % len; pos = (pos/AUDIO_CHANNELS)*AUDIO_CHANNELS; // round down to nearest frame audio_rx_buffer.setWriteIndex(pos); - program.exitProgram(true); - owl.setOperationMode(STREAM_MODE); + // program.exitProgram(true); + // owl.setOperationMode(STREAM_MODE); #ifdef DEBUG printf("start rx %u %u %u\n", rate, channels, pos); #endif @@ -120,11 +125,12 @@ void usbd_audio_rx_start_callback(size_t rate, uint8_t channels){ void usbd_audio_rx_stop_callback(){ #if defined USE_USBD_AUDIO_RX && USBD_AUDIO_RX_CHANNELS > 0 - __HAL_DMA_ENABLE(&HDMA_RX); // restart codec transfers + // __HAL_DMA_ENABLE(&HDMA_RX); // restart codec transfers + HAL_SAI_DMAResume(&HSAI_RX); audio_rx_buffer.clear(); - program.loadProgram(program.getProgramIndex()); - program.startProgram(true); - owl.setOperationMode(RUN_MODE); + // program.loadProgram(program.getProgramIndex()); + // program.startProgram(true); + // owl.setOperationMode(RUN_MODE); #ifdef DEBUG printf("stop rx\n"); #endif @@ -163,6 +169,7 @@ size_t usbd_audio_rx_callback(uint8_t* data, size_t len){ } static int32_t usbd_audio_tx_flow = 0; +static uint32_t usbd_audio_rx_count = 0; // expect a 1 in 10k sample underflow (-0.01% sample accuracy) void usbd_audio_tx_callback(uint8_t* data, size_t len){ #if defined USE_USBD_AUDIO_TX && USBD_AUDIO_TX_CHANNELS > 0 @@ -183,6 +190,7 @@ void usbd_audio_tx_callback(uint8_t* data, size_t len){ audio_tx_buffer.moveReadHead(AUDIO_CHANNELS); } usbd_audio_write(data, len); + usbd_audio_rx_count += len; #endif } #endif // USE_USBD_AUDIO @@ -196,7 +204,11 @@ void usbd_audio_gain_callback(int16_t gain){ } uint32_t usbd_audio_get_rx_count(){ - return 0; // todo! + // NDTR: the number of remaining data units in the current DMA Stream transfer. + size_t pos = CODEC_BUFFER_SIZE - __HAL_DMA_GET_COUNTER(&HDMA_TX); + pos += usbd_audio_rx_count; + usbd_audio_rx_count = 0; + return pos; } uint16_t Codec::getBlockSize(){ @@ -387,12 +399,10 @@ extern "C"{ #if defined USE_CS4271 || defined USE_PCM3168A extern "C" { - extern SAI_HandleTypeDef HSAI_RX; - extern SAI_HandleTypeDef HSAI_TX; - void HAL_SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai){ + void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai){ audioCallback(codec_rxbuf, codec_txbuf, codec_blocksize); } - void HAL_SAI_RxCpltCallback(SAI_HandleTypeDef *hsai){ + void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai){ audioCallback(codec_rxbuf+codec_blocksize*AUDIO_CHANNELS, codec_txbuf+codec_blocksize*AUDIO_CHANNELS, codec_blocksize); } void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai){ diff --git a/Source/usbd_audio.h b/Source/usbd_audio.h index 42386a19..3d2d9bd0 100644 --- a/Source/usbd_audio.h +++ b/Source/usbd_audio.h @@ -82,6 +82,15 @@ #endif +#if AUDIO_BITS_PER_SAMPLE == 8 +typedef int8_t audio_t; +#else if AUDIO_BITS_PER_SAMPLE == 16 +typedef int16_t audio_t; +#else if AUDIO_BITS_PER_SAMPLE == 32 +typedef int32_t audio_t; +#else +#error "Unsupported AUDIO_BITS_PER_SAMPLE" +#endif /** @defgroup USBD_CORE_Exported_TypesDefinitions * @{ diff --git a/Witch/Inc/hardware.h b/Witch/Inc/hardware.h index 68f13857..c5e01a3b 100644 --- a/Witch/Inc/hardware.h +++ b/Witch/Inc/hardware.h @@ -16,7 +16,7 @@ #define USE_USBD_AUDIO #define USE_USBD_AUDIO_TX // microphone -/* #define USE_USBD_AUDIO_RX // speaker */ +#define USE_USBD_AUDIO_RX // speaker #define USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS #define USBH_HANDLE hUsbHostHS From 213c75ead2353583d7988fb91a6f4fac7c3dc511 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 24 Sep 2021 23:54:32 +0200 Subject: [PATCH 069/286] draft usbd tx with CircularBuffer --- Source/CircularBuffer.h | 5 + Source/Codec.cpp | 147 +++++++++++++----------- Source/{usbd_audio.c => usbd_audio.cpp} | 25 +++- Source/usbd_audio.h | 8 +- 4 files changed, 109 insertions(+), 76 deletions(-) rename Source/{usbd_audio.c => usbd_audio.cpp} (95%) diff --git a/Source/CircularBuffer.h b/Source/CircularBuffer.h index 6da13988..93761f0d 100644 --- a/Source/CircularBuffer.h +++ b/Source/CircularBuffer.h @@ -21,6 +21,11 @@ class CircularBuffer { CircularBuffer(): data(NULL), size(0){} CircularBuffer(T* data, size_t size): data(data), size(size){} + void setData(T* data, size_t len) { + this->data = data; + size = len; + } + size_t getSize() const { return size; } diff --git a/Source/Codec.cpp b/Source/Codec.cpp index d73f0bb7..fd44f699 100644 --- a/Source/Codec.cpp +++ b/Source/Codec.cpp @@ -32,46 +32,43 @@ extern "C" { #endif } -CircularBuffer audio_rx_buffer(codec_rxbuf, CODEC_BUFFER_SIZE); -CircularBuffer audio_tx_buffer(codec_txbuf, CODEC_BUFFER_SIZE); - #ifdef USE_USBD_AUDIO #include "usbd_audio.h" -#if AUDIO_BITS_PER_SAMPLE == 32 -typedef int32_t audio_t; -#elif AUDIO_BITS_PER_SAMPLE == 16 -typedef int16_t audio_t; -#elif AUDIO_BITS_PER_SAMPLE == 8 -typedef int8_t audio_t; -#else -#error Invalid AUDIO_BITS_PER_SAMPLE -#endif +CircularBuffer* usbd_rx = NULL; +CircularBuffer* usbd_tx = NULL; + +// static void update_rx_read_index(){ +// #if defined USE_CS4271 || defined USE_PCM3168A +// // NDTR: the number of remaining data units in the current DMA Stream transfer. +// // use HDMA_TX position in case we have stopped HDMA_RX +// // todo: if(wet) then read position is incremented by audioCallback ? +// size_t pos = CODEC_BUFFER_SIZE - __HAL_DMA_GET_COUNTER(&HDMA_TX); +// // // mask to full frame (assumes AUDIO_CHANNELS is a power of two) +// // audio_rx_buffer.setReadIndex(pos & ~(AUDIO_CHANNELS-1)); +// audio_rx_buffer.setReadIndex(pos); +// #endif +// } -static void update_rx_read_index(){ -#if defined USE_CS4271 || defined USE_PCM3168A - // NDTR: the number of remaining data units in the current DMA Stream transfer. - // use HDMA_TX position in case we have stopped HDMA_RX - // todo: if(wet) then read position is incremented by audioCallback ? - size_t pos = CODEC_BUFFER_SIZE - __HAL_DMA_GET_COUNTER(&HDMA_TX); - // // mask to full frame (assumes AUDIO_CHANNELS is a power of two) - // audio_rx_buffer.setReadIndex(pos & ~(AUDIO_CHANNELS-1)); - audio_rx_buffer.setReadIndex(pos); -#endif -} +// static void update_tx_write_index(){ +// #if defined USE_CS4271 || defined USE_PCM3168A +// // NDTR: the number of remaining data units in the current DMA Stream transfer. +// size_t pos = CODEC_BUFFER_SIZE - __HAL_DMA_GET_COUNTER(&HDMA_TX); +// // // mask to full frame (assumes AUDIO_CHANNELS is a power of two) +// // audio_tx_buffer.setWriteIndex(pos & ~(AUDIO_CHANNELS-1)); +// audio_tx_buffer.setWriteIndex(pos); +// #endif +// } -static void update_tx_write_index(){ -#if defined USE_CS4271 || defined USE_PCM3168A - // NDTR: the number of remaining data units in the current DMA Stream transfer. - size_t pos = CODEC_BUFFER_SIZE - __HAL_DMA_GET_COUNTER(&HDMA_TX); - // // mask to full frame (assumes AUDIO_CHANNELS is a power of two) - // audio_tx_buffer.setWriteIndex(pos & ~(AUDIO_CHANNELS-1)); - audio_tx_buffer.setWriteIndex(pos); +void usbd_audio_tx_start_callback(size_t rate, uint8_t channels, void* cb){ + usbd_tx = (CircularBuffer*)cb; + usbd_tx->reset(); + usbd_tx->clear(); + usbd_tx->moveWriteHead(usbd_tx->getSize()/2); +#ifdef DEBUG + printf("start tx %u %u %u\n", rate, channels, usbd_tx->getSize()); #endif -} - -void usbd_audio_tx_start_callback(size_t rate, uint8_t channels){ -#if defined USE_USBD_AUDIO_TX && USBD_AUDIO_TX_CHANNELS > 0 +#if 0 && defined USE_USBD_AUDIO_TX && USBD_AUDIO_TX_CHANNELS > 0 update_tx_write_index(); size_t pos = audio_tx_buffer.getWriteIndex(); // not always aligned to AUDIO_CHANNELS samples // mask to full frame (assumes AUDIO_CHANNELS is a power of two) @@ -95,8 +92,34 @@ void usbd_audio_tx_start_callback(size_t rate, uint8_t channels){ #endif } +static int32_t usbd_audio_tx_flow = 0; +static uint32_t usbd_audio_rx_count = 0; +// expect a 1 in 10k sample underflow (-0.01% sample accuracy) +void usbd_audio_tx_callback(uint8_t* data, size_t len){ +#if 0 && defined USE_USBD_AUDIO_TX && USBD_AUDIO_TX_CHANNELS > 0 + update_tx_write_index(); + size_t available = audio_tx_buffer.getReadCapacity()/AUDIO_CHANNELS; + size_t blocksize = len / (USBD_AUDIO_TX_CHANNELS*AUDIO_BYTES_PER_SAMPLE); + if(available < blocksize){ + usbd_audio_tx_flow += blocksize-available; + blocksize = available; + len = blocksize*USBD_AUDIO_TX_CHANNELS*AUDIO_BYTES_PER_SAMPLE; + } + audio_t* dst = (audio_t*)data; + while(blocksize--){ + int32_t* src = audio_tx_buffer.getReadHead(); + size_t ch = USBD_AUDIO_TX_CHANNELS; + while(ch--) + *dst++ = AUDIO_INT32_TO_SAMPLE(*src++); // shift, round, dither, clip, truncate, bitswap + audio_tx_buffer.moveReadHead(AUDIO_CHANNELS); + } + usbd_audio_write(data, len); +#endif +} + void usbd_audio_tx_stop_callback(){ #if defined USE_USBD_AUDIO_TX && USBD_AUDIO_TX_CHANNELS > 0 + usbd_tx = NULL; #ifdef DEBUG printf("stop tx\n"); #endif @@ -104,7 +127,7 @@ void usbd_audio_tx_stop_callback(){ } void usbd_audio_rx_start_callback(size_t rate, uint8_t channels){ -#if defined USE_USBD_AUDIO_RX && USBD_AUDIO_RX_CHANNELS > 0 +#if 0 && defined USE_USBD_AUDIO_RX && USBD_AUDIO_RX_CHANNELS > 0 // todo: if(wet) { disable RX dma } else { stop patch } // __HAL_DMA_DISABLE(&HDMA_RX); // stop codec transfers HAL_SAI_DMAPause(&HSAI_RX); @@ -124,7 +147,7 @@ void usbd_audio_rx_start_callback(size_t rate, uint8_t channels){ } void usbd_audio_rx_stop_callback(){ -#if defined USE_USBD_AUDIO_RX && USBD_AUDIO_RX_CHANNELS > 0 +#if 0 && defined USE_USBD_AUDIO_RX && USBD_AUDIO_RX_CHANNELS > 0 // __HAL_DMA_ENABLE(&HDMA_RX); // restart codec transfers HAL_SAI_DMAResume(&HSAI_RX); audio_rx_buffer.clear(); @@ -139,7 +162,7 @@ void usbd_audio_rx_stop_callback(){ static int32_t usbd_audio_rx_flow = 0; size_t usbd_audio_rx_callback(uint8_t* data, size_t len){ -#if defined USE_USBD_AUDIO_RX && USBD_AUDIO_RX_CHANNELS > 0 +#if 0 && defined USE_USBD_AUDIO_RX && USBD_AUDIO_RX_CHANNELS > 0 // copy audio to codec_txbuf aka audio_rx_buffer update_rx_read_index(); audio_t* src = (audio_t*)data; @@ -164,36 +187,10 @@ size_t usbd_audio_rx_callback(uint8_t* data, size_t len){ // available = audio_rx_buffer.getWriteCapacity()*AUDIO_BYTES_PER_SAMPLE*USBD_AUDIO_RX_CHANNELS/AUDIO_CHANNELS; // if(available < AUDIO_RX_PACKET_SIZE) // return available; -#endif - return len; -} - -static int32_t usbd_audio_tx_flow = 0; -static uint32_t usbd_audio_rx_count = 0; -// expect a 1 in 10k sample underflow (-0.01% sample accuracy) -void usbd_audio_tx_callback(uint8_t* data, size_t len){ -#if defined USE_USBD_AUDIO_TX && USBD_AUDIO_TX_CHANNELS > 0 - update_tx_write_index(); - size_t available = audio_tx_buffer.getReadCapacity()/AUDIO_CHANNELS; - size_t blocksize = len / (USBD_AUDIO_TX_CHANNELS*AUDIO_BYTES_PER_SAMPLE); - if(available < blocksize){ - usbd_audio_tx_flow += blocksize-available; - blocksize = available; - len = blocksize*USBD_AUDIO_TX_CHANNELS*AUDIO_BYTES_PER_SAMPLE; - } - audio_t* dst = (audio_t*)data; - while(blocksize--){ - int32_t* src = audio_tx_buffer.getReadHead(); - size_t ch = USBD_AUDIO_TX_CHANNELS; - while(ch--) - *dst++ = AUDIO_INT32_TO_SAMPLE(*src++); // shift, round, dither, clip, truncate, bitswap - audio_tx_buffer.moveReadHead(AUDIO_CHANNELS); - } - usbd_audio_write(data, len); usbd_audio_rx_count += len; #endif + return len; } -#endif // USE_USBD_AUDIO void usbd_audio_mute_callback(int16_t gain){ // todo! @@ -210,6 +207,7 @@ uint32_t usbd_audio_get_rx_count(){ usbd_audio_rx_count = 0; return pos; } +#endif // USE_USBD_AUDIO uint16_t Codec::getBlockSize(){ return codec_blocksize; @@ -226,16 +224,16 @@ void Codec::init(){ // todo: else // audio_tx_buffer = CircularBuffer(codec_rxbuf, CODEC_BUFFER_SIZE); // audio_rx_buffer = CircularBuffer(codec_txbuf, CODEC_BUFFER_SIZE); - audio_tx_buffer.reset(); - audio_rx_buffer.reset(); + // audio_tx_buffer.reset(); + // audio_rx_buffer.reset(); codec_init(); } void Codec::reset(){ // todo: this is called when blocksize is changed stop(); - audio_tx_buffer.reset(); - audio_rx_buffer.reset(); + // audio_tx_buffer.reset(); + // audio_rx_buffer.reset(); start(); } @@ -399,10 +397,23 @@ extern "C"{ #if defined USE_CS4271 || defined USE_PCM3168A extern "C" { + void usbd_tx_convert(int32_t* src, size_t len){ +#if USBD_AUDIO_TX_CHANNELS != AUDIO_CHANNELS +#error "todo: support for USBD_AUDIO_TX_CHANNELS != AUDIO_CHANNELS" +#endif + while(len--){ + audio_t sample = AUDIO_INT32_TO_SAMPLE(*src++); // shift, round, dither, clip, truncate, bitswap + usbd_tx->write(sample); + } + } void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai){ + if(usbd_tx) + usbd_tx_convert(codec_rxbuf, codec_blocksize*AUDIO_CHANNELS); audioCallback(codec_rxbuf, codec_txbuf, codec_blocksize); } void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai){ + if(usbd_tx) + usbd_tx_convert(codec_rxbuf+codec_blocksize*AUDIO_CHANNELS, codec_blocksize*AUDIO_CHANNELS); audioCallback(codec_rxbuf+codec_blocksize*AUDIO_CHANNELS, codec_txbuf+codec_blocksize*AUDIO_CHANNELS, codec_blocksize); } void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai){ diff --git a/Source/usbd_audio.c b/Source/usbd_audio.cpp similarity index 95% rename from Source/usbd_audio.c rename to Source/usbd_audio.cpp index e42b9caf..7d1ebf05 100644 --- a/Source/usbd_audio.c +++ b/Source/usbd_audio.cpp @@ -17,6 +17,12 @@ #include "usbd_conf.h" #include "usbd_ctlreq.h" +#include "CircularBuffer.h" + +// todo: not static/global +CircularBuffer rx_buffer; +CircularBuffer tx_buffer; + #define AUDIO_SAMPLE_FREQ(frq) (uint8_t)(frq), (uint8_t)((frq >> 8)), (uint8_t)((frq >> 16)) #define AUDIO_FREQ_FROM_DATA(bytes) ((((uint32_t)((bytes)[2]))<<16)|(((uint32_t)((bytes)[1]))<<8)|(((uint32_t)((bytes)[0])))) #define AUDIO_FREQ_TO_DATA(frq , bytes) do{ \ @@ -650,6 +656,8 @@ static uint8_t USBD_AUDIO_Init (USBD_HandleTypeDef *pdev, haudio->rx_alt_setting = 0; haudio->midi_alt_setting = 0; haudio->volume = 0; + rx_buffer.setData((audio_t*)haudio->audio_rx_buffer, AUDIO_TX_TOTAL_BUF_SIZE/sizeof(audio_t)); + tx_buffer.setData((audio_t*)haudio->audio_tx_buffer, AUDIO_TX_TOTAL_BUF_SIZE/sizeof(audio_t)); #ifdef USE_USBD_AUDIO_TX_FALSE USBD_AUDIO_OpenEndpoint(pdev, haudio, AUDIO_TX_EP, USBD_EP_TYPE_ISOC, AUDIO_TX_PACKET_SIZE); @@ -760,9 +768,10 @@ static uint8_t USBD_AUDIO_SetInterfaceAlternate(USBD_HandleTypeDef *pdev, USBD_AUDIO_OpenEndpoint(pdev, haudio, AUDIO_TX_EP, USBD_EP_TYPE_ISOC, AUDIO_TX_PACKET_SIZE); haudio->audio_tx_active = 1; haudio->tx_soffn = USB_SOF_NUMBER(); - usbd_audio_tx_start_callback(USBD_AUDIO_TX_FREQ, USBD_AUDIO_TX_CHANNELS); + usbd_audio_tx_start_callback(USBD_AUDIO_TX_FREQ, USBD_AUDIO_TX_CHANNELS, &tx_buffer); /* send first audio data */ - usbd_audio_tx_callback(haudio->audio_tx_buffer, AUDIO_TX_PACKET_SIZE); + usbd_audio_write((uint8_t*)tx_buffer.getReadHead(), AUDIO_TX_PACKET_SIZE); + // usbd_audio_tx_callback(haudio->audio_tx_buffer, AUDIO_TX_PACKET_SIZE); } haudio->tx_alt_setting = new_alt; } @@ -919,7 +928,11 @@ static uint8_t USBD_AUDIO_DataIn (USBD_HandleTypeDef *pdev, #ifdef USE_USBD_AUDIO_TX case AUDIO_TX_EP: haudio->tx_soffn = USB_SOF_NUMBER(); - usbd_audio_tx_callback(haudio->audio_tx_buffer, AUDIO_TX_PACKET_SIZE); + // todo: can we find out how much data was actually read? + tx_buffer.moveReadHead(AUDIO_TX_PACKET_SIZE/sizeof(audio_t)); + // todo: write no more than available data + usbd_audio_write((uint8_t*)tx_buffer.getReadHead(), AUDIO_TX_PACKET_SIZE); + // usbd_audio_tx_callback(haudio->audio_tx_buffer, AUDIO_TX_PACKET_SIZE); break; #endif #ifdef USE_USBD_MIDI @@ -1228,7 +1241,11 @@ static uint8_t USBD_AUDIO_IsoINIncomplete (USBD_HandleTypeDef *pdev, uint8_t ep USB_CLEAR_INCOMPLETE_IN_EP(AUDIO_TX_EP); USBD_LL_FlushEP(pdev, AUDIO_TX_EP); haudio->tx_soffn = USB_SOF_NUMBER(); - usbd_audio_tx_callback(haudio->audio_tx_buffer, AUDIO_TX_PACKET_SIZE); + // host has not collected data + // let's not increment readhead + // todo: write no more than available data + usbd_audio_write((uint8_t*)tx_buffer.getReadHead(), AUDIO_TX_PACKET_SIZE); +// usbd_audio_tx_callback(haudio->audio_tx_buffer, AUDIO_TX_PACKET_SIZE); } #endif return USBD_OK; diff --git a/Source/usbd_audio.h b/Source/usbd_audio.h index 3d2d9bd0..0f52d3f6 100644 --- a/Source/usbd_audio.h +++ b/Source/usbd_audio.h @@ -35,7 +35,7 @@ /* Number of sub-packets in the audio transfer buffer. You can modify this value but always make sure that it is an even number and higher than 3 */ #define AUDIO_RX_PACKET_NUM 1 -#define AUDIO_TX_PACKET_NUM 1 +#define AUDIO_TX_PACKET_NUM 3 /* Total size of the audio transfer buffer */ #define AUDIO_RX_TOTAL_BUF_SIZE ((size_t)(AUDIO_RX_PACKET_SIZE * AUDIO_RX_PACKET_NUM)) /* Total size of the IN (i.e. microphopne) transfer buffer */ @@ -84,9 +84,9 @@ #if AUDIO_BITS_PER_SAMPLE == 8 typedef int8_t audio_t; -#else if AUDIO_BITS_PER_SAMPLE == 16 +#elif AUDIO_BITS_PER_SAMPLE == 16 typedef int16_t audio_t; -#else if AUDIO_BITS_PER_SAMPLE == 32 +#elif AUDIO_BITS_PER_SAMPLE == 32 typedef int32_t audio_t; #else #error "Unsupported AUDIO_BITS_PER_SAMPLE" @@ -139,7 +139,7 @@ extern USBD_ClassTypeDef USBD_AUDIO; uint8_t USBD_AUDIO_RegisterInterface (USBD_HandleTypeDef *pdev, void *fops); uint8_t USBD_AUDIO_SetFiFos(PCD_HandleTypeDef *hpcd); -void usbd_audio_tx_start_callback(size_t rate, uint8_t channels); +void usbd_audio_tx_start_callback(size_t rate, uint8_t channels, void* cb); void usbd_audio_tx_stop_callback(); void usbd_audio_tx_callback(uint8_t* data, size_t len); void usbd_audio_rx_start_callback(size_t rate, uint8_t channels); From 676467b6d64167b45cdb365445a284cd05cc2acd Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Sat, 25 Sep 2021 00:32:28 +0200 Subject: [PATCH 070/286] wip usbd rx changes --- Source/Codec.cpp | 33 +++++++++++++++++++++++++-------- Source/device.h | 2 +- Source/usbd_audio.cpp | 21 ++++++++++++++------- Source/usbd_audio.h | 4 ++-- 4 files changed, 42 insertions(+), 18 deletions(-) diff --git a/Source/Codec.cpp b/Source/Codec.cpp index fd44f699..8dc5965a 100644 --- a/Source/Codec.cpp +++ b/Source/Codec.cpp @@ -126,7 +126,15 @@ void usbd_audio_tx_stop_callback(){ #endif } -void usbd_audio_rx_start_callback(size_t rate, uint8_t channels){ +void usbd_audio_rx_start_callback(size_t rate, uint8_t channels, void* cb){ + usbd_rx = (CircularBuffer*)cb; + usbd_rx->reset(); + usbd_rx->clear(); + usbd_rx->moveReadHead(usbd_rx->getSize()/2); + HAL_SAI_DMAPause(&HSAI_RX); +#ifdef DEBUG + printf("start rx %u %u %u\n", rate, channels, usbd_rx->getSize()); +#endif #if 0 && defined USE_USBD_AUDIO_RX && USBD_AUDIO_RX_CHANNELS > 0 // todo: if(wet) { disable RX dma } else { stop patch } // __HAL_DMA_DISABLE(&HDMA_RX); // stop codec transfers @@ -147,6 +155,8 @@ void usbd_audio_rx_start_callback(size_t rate, uint8_t channels){ } void usbd_audio_rx_stop_callback(){ + usbd_rx = 0; + HAL_SAI_DMAResume(&HSAI_RX); #if 0 && defined USE_USBD_AUDIO_RX && USBD_AUDIO_RX_CHANNELS > 0 // __HAL_DMA_ENABLE(&HDMA_RX); // restart codec transfers HAL_SAI_DMAResume(&HSAI_RX); @@ -154,10 +164,10 @@ void usbd_audio_rx_stop_callback(){ // program.loadProgram(program.getProgramIndex()); // program.startProgram(true); // owl.setOperationMode(RUN_MODE); +#endif #ifdef DEBUG printf("stop rx\n"); #endif -#endif } static int32_t usbd_audio_rx_flow = 0; @@ -397,23 +407,30 @@ extern "C"{ #if defined USE_CS4271 || defined USE_PCM3168A extern "C" { + void usbd_rx_convert(int32_t* dst, size_t len){ + while(len--) + *dst++ = AUDIO_SAMPLE_TO_INT32(usbd_rx->read()); + } void usbd_tx_convert(int32_t* src, size_t len){ #if USBD_AUDIO_TX_CHANNELS != AUDIO_CHANNELS #error "todo: support for USBD_AUDIO_TX_CHANNELS != AUDIO_CHANNELS" #endif - while(len--){ - audio_t sample = AUDIO_INT32_TO_SAMPLE(*src++); // shift, round, dither, clip, truncate, bitswap - usbd_tx->write(sample); - } + while(len--) + // macro handles shift, round, dither, clip, truncate, bitswap + usbd_tx->write(AUDIO_INT32_TO_SAMPLE(*src++)); } void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai){ if(usbd_tx) - usbd_tx_convert(codec_rxbuf, codec_blocksize*AUDIO_CHANNELS); + usbd_tx_convert(codec_txbuf, codec_blocksize*AUDIO_CHANNELS); + if(usbd_rx) + usbd_rx_convert(codec_rxbuf, codec_blocksize*AUDIO_CHANNELS); audioCallback(codec_rxbuf, codec_txbuf, codec_blocksize); } void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai){ if(usbd_tx) - usbd_tx_convert(codec_rxbuf+codec_blocksize*AUDIO_CHANNELS, codec_blocksize*AUDIO_CHANNELS); + usbd_tx_convert(codec_txbuf+codec_blocksize*AUDIO_CHANNELS, codec_blocksize*AUDIO_CHANNELS); + if(usbd_rx) + usbd_rx_convert(codec_rxbuf+codec_blocksize*AUDIO_CHANNELS, codec_blocksize*AUDIO_CHANNELS); audioCallback(codec_rxbuf+codec_blocksize*AUDIO_CHANNELS, codec_txbuf+codec_blocksize*AUDIO_CHANNELS, codec_blocksize); } void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai){ diff --git a/Source/device.h b/Source/device.h index 0cb3427f..a817c6d7 100644 --- a/Source/device.h +++ b/Source/device.h @@ -3,7 +3,7 @@ #include "hardware.h" -#define FIRMWARE_VERSION "v22.0.0" +#define FIRMWARE_VERSION "v22.0.1" #ifdef USE_SPI_FLASH #define MAX_SPI_FLASH_HEADERS 32 diff --git a/Source/usbd_audio.cpp b/Source/usbd_audio.cpp index 7d1ebf05..27741826 100644 --- a/Source/usbd_audio.cpp +++ b/Source/usbd_audio.cpp @@ -672,8 +672,9 @@ static uint8_t USBD_AUDIO_Init (USBD_HandleTypeDef *pdev, haudio->audio_rx_active = 0; haudio->fb_soffn = USB_SOF_NUMBER(); /* Prepare OUT endpoint to receive first packet */ - USBD_LL_PrepareReceive(pdev, AUDIO_RX_EP, haudio->audio_rx_buffer, AUDIO_RX_PACKET_SIZE); - usbd_audio_rx_start_callback(USBD_AUDIO_RX_FREQ, USBD_AUDIO_RX_CHANNELS); + USBD_LL_PrepareReceive(pdev, AUDIO_RX_EP, (uint8_t*)rx_buffer->getWriteHead(), AUDIO_RX_PACKET_SIZE); + // USBD_LL_PrepareReceive(pdev, AUDIO_RX_EP, haudio->audio_rx_buffer, AUDIO_RX_PACKET_SIZE); + // usbd_audio_rx_start_callback(USBD_AUDIO_RX_FREQ, USBD_AUDIO_RX_CHANNELS); #endif #ifdef USE_USBD_MIDI @@ -1112,7 +1113,7 @@ static uint8_t USBD_AUDIO_EP0_RxReady (USBD_HandleTypeDef *pdev) } } else if (haudio->control.req_type == AUDIO_STREAMING_REQ) { USBD_DbgLog("STREAMING_REQ 0x%x 0x%x", haudio->control.cs, haudio->control.data[0]); -#ifdef USE_USBD_AUDIO_RX +#ifdef USE_USBD_AUDIO_RX_FALSE // todo! if (haudio->control.cs == AUDIO_STREAMING_REQ_FREQ_CTRL) { /* Frequency Control */ uint32_t new_freq = AUDIO_FREQ_FROM_DATA(haudio->control.data); @@ -1282,17 +1283,20 @@ static uint8_t USBD_AUDIO_DataOut (USBD_HandleTypeDef *pdev, uint32_t len; if(haudio->audio_rx_active == 0){ haudio->audio_rx_active = 1; - usbd_audio_rx_start_callback(USBD_AUDIO_RX_FREQ, USBD_AUDIO_RX_CHANNELS); + usbd_audio_rx_start_callback(USBD_AUDIO_RX_FREQ, USBD_AUDIO_RX_CHANNELS, &rx_buffer); len = AUDIO_RX_PACKET_SIZE; /* send first synchro data */ get_usb_full_speed_rate(USBD_AUDIO_RX_FREQ, fb_data); USBD_LL_Transmit(pdev, AUDIO_FB_EP, fb_data, 3U); }else{ len = USBD_LL_GetRxDataSize(pdev, epnum); + rx_buffer.moveWriteHead(len/sizeof(audio_t)); } - len = usbd_audio_rx_callback(haudio->audio_rx_buffer, len); + // len = usbd_audio_rx_callback(haudio->audio_rx_buffer, len); + // len = std::min(rx_buffer.getWriteCapacity(), AUDIO_RX_PACKET_SIZE); + len = AUDIO_RX_PACKET_SIZE; // todo: ^ /* Prepare Out endpoint to receive next audio packet */ - USBD_LL_PrepareReceive(pdev, AUDIO_RX_EP, haudio->audio_rx_buffer, len); + USBD_LL_PrepareReceive(pdev, AUDIO_RX_EP, (uint8_t*)rx_buffer.getWriteHead(), len); } #endif /* USE_USBD_AUDIO_RX */ #ifdef USE_USBD_MIDI @@ -1342,7 +1346,10 @@ static void AUDIO_OUT_Restart(USBD_HandleTypeDef* pdev) USBD_LL_FlushEP(pdev, AUDIO_RX_EP); /* Prepare Out endpoint to receive first audio packet */ - USBD_LL_PrepareReceive(pdev, AUDIO_RX_EP, haudio->audio_rx_buffer, AUDIO_RX_PACKET_SIZE); + // USBD_LL_PrepareReceive(pdev, AUDIO_RX_EP, haudio->audio_rx_buffer, AUDIO_RX_PACKET_SIZE); + // size_t len = std::min(rx_buffer.getWriteCapacity(), AUDIO_RX_PACKET_SIZE); + size_t len = AUDIO_RX_PACKET_SIZE; // todo: ^ + USBD_LL_PrepareReceive(pdev, AUDIO_RX_EP, (uint8_t*)rx_buffer.getWriteHead(), len); /* get_usb_full_speed_rate(haudio->frequency, fb_data); // reset to new frequency */ diff --git a/Source/usbd_audio.h b/Source/usbd_audio.h index 0f52d3f6..192ab6db 100644 --- a/Source/usbd_audio.h +++ b/Source/usbd_audio.h @@ -34,7 +34,7 @@ /* Number of sub-packets in the audio transfer buffer. You can modify this value but always make sure that it is an even number and higher than 3 */ -#define AUDIO_RX_PACKET_NUM 1 +#define AUDIO_RX_PACKET_NUM 3 #define AUDIO_TX_PACKET_NUM 3 /* Total size of the audio transfer buffer */ #define AUDIO_RX_TOTAL_BUF_SIZE ((size_t)(AUDIO_RX_PACKET_SIZE * AUDIO_RX_PACKET_NUM)) @@ -142,7 +142,7 @@ uint8_t USBD_AUDIO_SetFiFos(PCD_HandleTypeDef *hpcd); void usbd_audio_tx_start_callback(size_t rate, uint8_t channels, void* cb); void usbd_audio_tx_stop_callback(); void usbd_audio_tx_callback(uint8_t* data, size_t len); -void usbd_audio_rx_start_callback(size_t rate, uint8_t channels); +void usbd_audio_rx_start_callback(size_t rate, uint8_t channels, void* cb); void usbd_audio_rx_stop_callback(); size_t usbd_audio_rx_callback(uint8_t* data, size_t len); void usbd_audio_mute_callback(int16_t gain); From b329f9e52fd7799cdf8fc0941ea868534f43921c Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 27 Sep 2021 15:19:16 +0200 Subject: [PATCH 071/286] manage pointers and rx counter --- Source/Codec.cpp | 13 ++++++++----- Source/ProgramManager.cpp | 2 +- Source/device.h | 1 - 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Source/Codec.cpp b/Source/Codec.cpp index 8dc5965a..17b7ac0c 100644 --- a/Source/Codec.cpp +++ b/Source/Codec.cpp @@ -131,6 +131,7 @@ void usbd_audio_rx_start_callback(size_t rate, uint8_t channels, void* cb){ usbd_rx->reset(); usbd_rx->clear(); usbd_rx->moveReadHead(usbd_rx->getSize()/2); + usbd_audio_rx_count = 0; HAL_SAI_DMAPause(&HSAI_RX); #ifdef DEBUG printf("start rx %u %u %u\n", rate, channels, usbd_rx->getSize()); @@ -155,7 +156,7 @@ void usbd_audio_rx_start_callback(size_t rate, uint8_t channels, void* cb){ } void usbd_audio_rx_stop_callback(){ - usbd_rx = 0; + usbd_rx = NULL; HAL_SAI_DMAResume(&HSAI_RX); #if 0 && defined USE_USBD_AUDIO_RX && USBD_AUDIO_RX_CHANNELS > 0 // __HAL_DMA_ENABLE(&HDMA_RX); // restart codec transfers @@ -210,12 +211,13 @@ void usbd_audio_gain_callback(int16_t gain){ // codec_set_gain_in(gain); todo! } +/* Get number of samples transmitted since previous request */ uint32_t usbd_audio_get_rx_count(){ // NDTR: the number of remaining data units in the current DMA Stream transfer. size_t pos = CODEC_BUFFER_SIZE - __HAL_DMA_GET_COUNTER(&HDMA_TX); pos += usbd_audio_rx_count; usbd_audio_rx_count = 0; - return pos; + return pos / AUDIO_CHANNELS; } #endif // USE_USBD_AUDIO @@ -362,8 +364,8 @@ void Codec::stop(){ void Codec::start(){ setInputGain(settings.audio_input_gain); setOutputGain(settings.audio_output_gain); - // codec_blocksize = min(CODEC_BUFFER_SIZE/4, settings.audio_blocksize); - codec_blocksize = CODEC_BUFFER_SIZE/4; + // codec_blocksize = min(AUDIO_BLOCK_SIZE, settings.audio_blocksize); + codec_blocksize = AUDIO_BLOCK_SIZE; HAL_StatusTypeDef ret; /* See STM32F405 Errata, I2S device limitations */ /* The I2S peripheral must be enabled when the external master sets the WS line at: */ @@ -375,7 +377,7 @@ void Codec::start(){ // configuration phase, the Size parameter means the number of 16-bit data length // in the transaction and when a 24-bit data frame or a 32-bit data frame is selected // the Size parameter means the number of 16-bit data length. - ret = HAL_I2SEx_TransmitReceive_DMA(&hi2s2, (uint16_t*)codec_txbuf, (uint16_t*)codec_rxbuf, codec_blocksize*4); + ret = HAL_I2SEx_TransmitReceive_DMA(&hi2s2, (uint16_t*)codec_txbuf, (uint16_t*)codec_rxbuf, codec_blocksize*AUDIO_CHANNELS*2); ASSERT(ret == HAL_OK, "Failed to start I2S DMA"); } @@ -408,6 +410,7 @@ extern "C"{ extern "C" { void usbd_rx_convert(int32_t* dst, size_t len){ + usbd_audio_rx_count += len; while(len--) *dst++ = AUDIO_SAMPLE_TO_INT32(usbd_rx->read()); } diff --git a/Source/ProgramManager.cpp b/Source/ProgramManager.cpp index 717891d6..3db4640c 100644 --- a/Source/ProgramManager.cpp +++ b/Source/ProgramManager.cpp @@ -222,7 +222,7 @@ void updateProgramVector(ProgramVector* pv, PatchDefinition* def){ #ifdef USE_CODEC pv->audio_blocksize = codec.getBlockSize(); #else - pv->audio_blocksize = CODEC_BLOCKSIZE; + pv->audio_blocksize = AUDIO_BLOCK_SIZE; #endif pv->buttons = button_values; pv->registerPatch = onRegisterPatch; diff --git a/Source/device.h b/Source/device.h index a817c6d7..72efd5d6 100644 --- a/Source/device.h +++ b/Source/device.h @@ -134,7 +134,6 @@ #define AUDIO_SAMPLINGRATE 48000 #endif #define AUDIO_BLOCK_SIZE CODEC_BLOCKSIZE /* size in samples of a single channel audio block */ -#define AUDIO_MAX_BLOCK_SIZE (CODEC_BUFFER_SIZE/4) #define USBD_AUDIO_RX_FREQ AUDIO_SAMPLINGRATE #define USBD_AUDIO_TX_FREQ AUDIO_SAMPLINGRATE From 39938278af72b0cfe4c19604113b06745a50f6a1 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 27 Sep 2021 18:32:15 +0200 Subject: [PATCH 072/286] optional feedback in rx i/f --- Source/Codec.cpp | 17 +++++----- Source/usbd_audio.cpp | 76 ++++++++++++++++++++++++++++++++++++------- Source/usbd_audio.h | 14 ++++---- 3 files changed, 80 insertions(+), 27 deletions(-) diff --git a/Source/Codec.cpp b/Source/Codec.cpp index 17b7ac0c..099291f9 100644 --- a/Source/Codec.cpp +++ b/Source/Codec.cpp @@ -35,8 +35,8 @@ extern "C" { #ifdef USE_USBD_AUDIO #include "usbd_audio.h" -CircularBuffer* usbd_rx = NULL; -CircularBuffer* usbd_tx = NULL; +CircularBuffer* volatile usbd_rx = NULL; +CircularBuffer* volatile usbd_tx = NULL; // static void update_rx_read_index(){ // #if defined USE_CS4271 || defined USE_PCM3168A @@ -118,12 +118,10 @@ void usbd_audio_tx_callback(uint8_t* data, size_t len){ } void usbd_audio_tx_stop_callback(){ -#if defined USE_USBD_AUDIO_TX && USBD_AUDIO_TX_CHANNELS > 0 usbd_tx = NULL; #ifdef DEBUG printf("stop tx\n"); #endif -#endif } void usbd_audio_rx_start_callback(size_t rate, uint8_t channels, void* cb){ @@ -213,11 +211,12 @@ void usbd_audio_gain_callback(int16_t gain){ /* Get number of samples transmitted since previous request */ uint32_t usbd_audio_get_rx_count(){ - // NDTR: the number of remaining data units in the current DMA Stream transfer. - size_t pos = CODEC_BUFFER_SIZE - __HAL_DMA_GET_COUNTER(&HDMA_TX); - pos += usbd_audio_rx_count; - usbd_audio_rx_count = 0; - return pos / AUDIO_CHANNELS; + return 0; + // // NDTR: the number of remaining data units in the current DMA Stream transfer. + // size_t pos = CODEC_BUFFER_SIZE - __HAL_DMA_GET_COUNTER(&HDMA_TX); + // pos += usbd_audio_rx_count; + // usbd_audio_rx_count = 0; + // return pos / AUDIO_CHANNELS; } #endif // USE_USBD_AUDIO diff --git a/Source/usbd_audio.cpp b/Source/usbd_audio.cpp index 27741826..cd6be76b 100644 --- a/Source/usbd_audio.cpp +++ b/Source/usbd_audio.cpp @@ -91,7 +91,7 @@ USBD_ClassTypeDef USBD_AUDIO = }; -#if 1 +#ifdef USE_USBD_RX_FB #define FB_REFRESH 5 /* Feedback refresh rate 2^(10-FB_REFRESH) */ #define FB_RATE (1<<(10-FB_REFRESH)) @@ -113,7 +113,7 @@ uint8_t fb_data[3]; #endif -#if defined USE_USBD_AUDIO_RX && defined USE_USBD_AUDIO_TX && defined USE_USBD_MIDI +#if defined USE_USBD_AUDIO_RX && defined USE_USBD_RX_FB && defined USE_USBD_AUDIO_TX && defined USE_USBD_MIDI #define AUDIO_RX_IF 0x01 // bInterfaceNumber #define AUDIO_TX_IF 0x02 #define AUDIO_MIDI_IF 0x03 @@ -122,19 +122,38 @@ uint8_t fb_data[3]; #define AUDIO_TX_EP 0x82 #define MIDI_RX_EP 0x02 #define MIDI_TX_EP 0x83 -#elif defined USE_USBD_AUDIO_RX && defined USE_USBD_AUDIO_TX +#elif defined USE_USBD_AUDIO_RX && defined USE_USBD_RX_FB && defined USE_USBD_AUDIO_TX #define AUDIO_RX_IF 0x01 #define AUDIO_TX_IF 0x02 #define AUDIO_RX_EP 0x01 #define AUDIO_FB_EP 0x81 #define AUDIO_TX_EP 0x82 -#elif defined USE_USBD_AUDIO_RX && defined USE_USBD_MIDI +#elif defined USE_USBD_AUDIO_RX && defined USE_USBD_RX_FB && defined USE_USBD_MIDI #define AUDIO_RX_IF 0x01 #define AUDIO_MIDI_IF 0x02 #define AUDIO_RX_EP 0x01 #define AUDIO_FB_EP 0x81 #define MIDI_RX_EP 0x02 #define MIDI_TX_EP 0x82 +#elif defined USE_USBD_AUDIO_RX && defined USE_USBD_AUDIO_TX && defined USE_USBD_MIDI +#define AUDIO_RX_IF 0x01 // bInterfaceNumber +#define AUDIO_TX_IF 0x02 +#define AUDIO_MIDI_IF 0x03 +#define AUDIO_RX_EP 0x01 // bEndpointAddress +#define AUDIO_TX_EP 0x81 +#define MIDI_RX_EP 0x02 +#define MIDI_TX_EP 0x82 +#elif defined USE_USBD_AUDIO_RX && defined USE_USBD_AUDIO_TX +#define AUDIO_RX_IF 0x01 +#define AUDIO_TX_IF 0x02 +#define AUDIO_RX_EP 0x01 +#define AUDIO_TX_EP 0x81 +#elif defined USE_USBD_AUDIO_RX && defined USE_USBD_MIDI +#define AUDIO_RX_IF 0x01 +#define AUDIO_MIDI_IF 0x02 +#define AUDIO_RX_EP 0x01 +#define MIDI_RX_EP 0x02 +#define MIDI_TX_EP 0x81 #elif defined USE_USBD_AUDIO_TX && defined USE_USBD_MIDI #define AUDIO_TX_IF 0x01 #define AUDIO_MIDI_IF 0x02 @@ -154,7 +173,11 @@ uint8_t fb_data[3]; #ifdef USE_USBD_AUDIO_RX #define USBD_AUDIO_RX_AC_DESC_LEN 30 +#ifdef USE_USBD_RX_FB #define USBD_AUDIO_RX_AS_DESC_LEN 61 +#else +#define USBD_AUDIO_RX_AS_DESC_LEN 52 +#endif #define USBD_AUDIO_RX_NUM_INTERFACES 1 #else #define USBD_AUDIO_RX_AC_DESC_LEN 0 @@ -366,6 +389,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL /* 11 byte */ /* USB Play data ep */ +#ifdef USE_USBD_RX_FB /* Standard AS Isochronous asynchronous Audio Data Endpoint Descriptor*/ 0x09, /* bLength */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType */ @@ -377,6 +401,18 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x00, /* bRefresh */ AUDIO_FB_EP, /* bSynchAddress */ /* 09 byte */ +#else + 0x09, /* bLength */ + USB_DESC_TYPE_ENDPOINT, /* bDescriptorType */ + AUDIO_RX_EP, /* bEndpointAddress 1 out endpoint*/ + USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_SYNC, /* bmAttributes */ + LOBYTE(AUDIO_RX_PACKET_SIZE), /* wMaxPacketSize in bytes */ + HIBYTE(AUDIO_RX_PACKET_SIZE), + 0x01, /* bInterval */ + 0x00, /* bRefresh */ + 0, /* bSynchAddress */ + /* 09 byte */ +#endif /* Class-Specific AS Isochronous Audio Data Endpoint Descriptor*/ 0x07, /* bLength */ @@ -388,6 +424,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x00, /* 07 byte */ +#ifdef USE_USBD_RX_FB /* Endpoint 2 - Standard Descriptor - See UAC Spec 1.0 p.63 4.6.2.1 Standard AS Isochronous Synch Endpoint Descriptor */ 0x09, /* bLength */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType */ @@ -399,6 +436,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL FB_REFRESH, /* bRefresh SOF_RATE */ 0x00, /* bSynchAddress */ /* 09 byte*/ +#endif // 9+9+7+11+9+7+9 = 61 bytes #endif /*USE_USBD_AUDIO_RX */ @@ -454,8 +492,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x09, // Size of the descriptor, in bytes (bLength) 0x05, // ENDPOINT descriptor (bDescriptorType) AUDIO_TX_EP, // IN Endpoint 1. (bEndpointAddress) - /* USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_SYNC, // bmAttributes */ - USBD_EP_TYPE_ISOC, // bmAttributes + USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_SYNC, // bmAttributes LOBYTE(AUDIO_TX_PACKET_SIZE), // wMaxPacketSize in bytes HIBYTE(AUDIO_TX_PACKET_SIZE), 0x01, // Polling interval 1kHz. (bInterval) @@ -656,8 +693,12 @@ static uint8_t USBD_AUDIO_Init (USBD_HandleTypeDef *pdev, haudio->rx_alt_setting = 0; haudio->midi_alt_setting = 0; haudio->volume = 0; - rx_buffer.setData((audio_t*)haudio->audio_rx_buffer, AUDIO_TX_TOTAL_BUF_SIZE/sizeof(audio_t)); +#ifdef USE_USBD_AUDIO_RX + rx_buffer.setData((audio_t*)haudio->audio_rx_buffer, AUDIO_RX_TOTAL_BUF_SIZE/sizeof(audio_t)); +#endif +#ifdef USE_USBD_AUDIO_TX tx_buffer.setData((audio_t*)haudio->audio_tx_buffer, AUDIO_TX_TOTAL_BUF_SIZE/sizeof(audio_t)); +#endif #ifdef USE_USBD_AUDIO_TX_FALSE USBD_AUDIO_OpenEndpoint(pdev, haudio, AUDIO_TX_EP, USBD_EP_TYPE_ISOC, AUDIO_TX_PACKET_SIZE); @@ -704,7 +745,9 @@ static uint8_t USBD_AUDIO_DeInit (USBD_HandleTypeDef *pdev, #ifdef USE_USBD_AUDIO_RX USBD_AUDIO_CloseEndpoint(pdev, haudio, AUDIO_RX_EP); +#ifdef USE_USBD_RX_FB USBD_AUDIO_CloseEndpoint(pdev, haudio, AUDIO_FB_EP); +#endif haudio->audio_rx_active = 0; usbd_audio_rx_stop_callback(); #endif @@ -741,17 +784,23 @@ static uint8_t USBD_AUDIO_SetInterfaceAlternate(USBD_HandleTypeDef *pdev, if(new_alt == 0){ // close old USBD_AUDIO_CloseEndpoint(pdev, haudio, AUDIO_RX_EP); +#ifdef USE_USBD_RX_FB USBD_AUDIO_CloseEndpoint(pdev, haudio, AUDIO_FB_EP); +#endif AUDIO_OUT_StopAndReset(pdev); }else{ // open new USBD_AUDIO_OpenEndpoint(pdev, haudio, AUDIO_RX_EP, USBD_EP_TYPE_ISOC, AUDIO_RX_PACKET_SIZE); +#ifdef USE_USBD_RX_FB USBD_AUDIO_OpenEndpoint(pdev, haudio, AUDIO_FB_EP, USBD_EP_TYPE_ISOC, AUDIO_FB_PACKET_SIZE); +#endif haudio->fb_soffn = USB_SOF_NUMBER(); /* haudio->bit_depth = 16U; // alt 1 */ AUDIO_OUT_Restart(pdev); } +#ifdef USE_USBD_RX_FB USBD_LL_FlushEP(pdev, AUDIO_FB_EP); +#endif haudio->rx_alt_setting = new_alt; } break; @@ -920,7 +969,7 @@ static uint8_t USBD_AUDIO_DataIn (USBD_HandleTypeDef *pdev, USBD_AUDIO_HandleTypeDef *haudio = (USBD_AUDIO_HandleTypeDef*)pdev->pClassData; (void)haudio; switch(epnum | 0x80){ -#ifdef USE_USBD_AUDIO_RX +#ifdef USE_USBD_RX_FB case AUDIO_FB_EP: haudio->fb_soffn = USB_SOF_NUMBER(); USBD_LL_Transmit(pdev, AUDIO_FB_EP, (uint8_t*)fb_data, 3U); @@ -1190,7 +1239,7 @@ static uint8_t USBD_AUDIO_SOF (USBD_HandleTypeDef *pdev) { /* SOF (Start of Frame) Every millisecond the USB host transmits a special SOF (start of frame) token, containing an 11-bit incrementing frame number in place of a device address. This is used to synchronize isochronous and interrupt data transfers. */ USBD_AUDIO_HandleTypeDef* haudio; haudio = (USBD_AUDIO_HandleTypeDef*)pdev->pClassData; -#ifdef USE_USBD_AUDIO_RX +#ifdef USE_USBD_RX_FB static uint32_t sof_count = 0; if(haudio->audio_rx_active && ++sof_count == FB_RATE){ sof_count = 0; @@ -1225,8 +1274,7 @@ static uint8_t USBD_AUDIO_IsoINIncomplete (USBD_HandleTypeDef *pdev, uint8_t ep uint16_t current_sof; current_sof = USB_SOF_NUMBER(); -#ifdef USE_USBD_AUDIO_RX - // todo: fix this to work for FB and TX endpoints +#ifdef USE_USBD_RX_FB if(pdev->ep_in[AUDIO_FB_EP & 0xFU].is_used && IS_ISO_IN_INCOMPLETE_EP(AUDIO_FB_EP & 0xFU, current_sof, haudio->fb_soffn)){ USB_CLEAR_INCOMPLETE_IN_EP(AUDIO_FB_EP); @@ -1285,9 +1333,11 @@ static uint8_t USBD_AUDIO_DataOut (USBD_HandleTypeDef *pdev, haudio->audio_rx_active = 1; usbd_audio_rx_start_callback(USBD_AUDIO_RX_FREQ, USBD_AUDIO_RX_CHANNELS, &rx_buffer); len = AUDIO_RX_PACKET_SIZE; +#ifdef USE_USBD_RX_FB /* send first synchro data */ get_usb_full_speed_rate(USBD_AUDIO_RX_FREQ, fb_data); USBD_LL_Transmit(pdev, AUDIO_FB_EP, fb_data, 3U); +#endif }else{ len = USBD_LL_GetRxDataSize(pdev, epnum); rx_buffer.moveWriteHead(len/sizeof(audio_t)); @@ -1324,7 +1374,9 @@ static void AUDIO_OUT_StopAndReset(USBD_HandleTypeDef* pdev) USBD_DbgLog("AUDIO_OUT_StopAndReset %lu", haudio->frequency); haudio->audio_rx_active = 0; +#ifdef USE_USBD_RX_FB USBD_LL_FlushEP(pdev, AUDIO_FB_EP); +#endif USBD_LL_FlushEP(pdev, AUDIO_RX_EP); usbd_audio_rx_stop_callback(); /* ((USBD_AUDIO_ItfTypeDef*)pdev->pUserData)->DeInit(0); */ @@ -1342,7 +1394,9 @@ static void AUDIO_OUT_Restart(USBD_HandleTypeDef* pdev) /* AUDIO_OUT_StopAndReset(pdev); */ haudio->audio_rx_active = 0; +#ifdef USE_USBD_RX_FB USBD_LL_FlushEP(pdev, AUDIO_FB_EP); +#endif USBD_LL_FlushEP(pdev, AUDIO_RX_EP); /* Prepare Out endpoint to receive first audio packet */ diff --git a/Source/usbd_audio.h b/Source/usbd_audio.h index 192ab6db..b812e771 100644 --- a/Source/usbd_audio.h +++ b/Source/usbd_audio.h @@ -31,14 +31,14 @@ #define AUDIO_RX_PACKET_SIZE (uint16_t)(((USBD_AUDIO_RX_FREQ * USBD_AUDIO_RX_CHANNELS * AUDIO_BYTES_PER_SAMPLE) /1000)) #define AUDIO_TX_PACKET_SIZE (uint16_t)(((USBD_AUDIO_TX_FREQ * USBD_AUDIO_TX_CHANNELS * AUDIO_BYTES_PER_SAMPLE) /1000)) #define AUDIO_FB_PACKET_SIZE 3U - -/* Number of sub-packets in the audio transfer buffer. You can modify this value but always make sure - that it is an even number and higher than 3 */ -#define AUDIO_RX_PACKET_NUM 3 -#define AUDIO_TX_PACKET_NUM 3 -/* Total size of the audio transfer buffer */ + +/* Number of sub-packets in the audio transfer buffer. */ +#define AUDIO_RX_PACKET_NUM 2 +#define AUDIO_TX_PACKET_NUM 2 + +/* Total size of the OUT audio transfer buffer */ #define AUDIO_RX_TOTAL_BUF_SIZE ((size_t)(AUDIO_RX_PACKET_SIZE * AUDIO_RX_PACKET_NUM)) -/* Total size of the IN (i.e. microphopne) transfer buffer */ +/* Total size of the IN transfer buffer */ #define AUDIO_TX_TOTAL_BUF_SIZE ((size_t)(AUDIO_TX_PACKET_SIZE * AUDIO_TX_PACKET_NUM)) #define MIDI_TX_PACKET_SIZE 0x40 From d57063378b2c7dcba35a3d163dd3f2c24b29192b Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 28 Sep 2021 03:37:27 +0200 Subject: [PATCH 073/286] apparently working asynch rx/tx on linux --- Source/Codec.cpp | 39 ++++++----------------------- Source/usbd_audio.cpp | 58 +++++++++++++++++-------------------------- Source/usbd_audio.h | 20 ++++++++++++--- Witch/Inc/hardware.h | 3 ++- Witch/Makefile | 2 +- 5 files changed, 50 insertions(+), 72 deletions(-) diff --git a/Source/Codec.cpp b/Source/Codec.cpp index 099291f9..087a8619 100644 --- a/Source/Codec.cpp +++ b/Source/Codec.cpp @@ -130,40 +130,17 @@ void usbd_audio_rx_start_callback(size_t rate, uint8_t channels, void* cb){ usbd_rx->clear(); usbd_rx->moveReadHead(usbd_rx->getSize()/2); usbd_audio_rx_count = 0; - HAL_SAI_DMAPause(&HSAI_RX); + // HAL_SAI_DMAStop(&HSAI_RX); + // HAL_SAI_DMAPause(&HSAI_RX); #ifdef DEBUG printf("start rx %u %u %u\n", rate, channels, usbd_rx->getSize()); #endif -#if 0 && defined USE_USBD_AUDIO_RX && USBD_AUDIO_RX_CHANNELS > 0 - // todo: if(wet) { disable RX dma } else { stop patch } - // __HAL_DMA_DISABLE(&HDMA_RX); // stop codec transfers - HAL_SAI_DMAPause(&HSAI_RX); - audio_rx_buffer.clear(); - update_rx_read_index(); - size_t pos = audio_rx_buffer.getWriteIndex(); - size_t len = audio_rx_buffer.getSize(); - pos = (pos + len/2) % len; - pos = (pos/AUDIO_CHANNELS)*AUDIO_CHANNELS; // round down to nearest frame - audio_rx_buffer.setWriteIndex(pos); - // program.exitProgram(true); - // owl.setOperationMode(STREAM_MODE); -#ifdef DEBUG - printf("start rx %u %u %u\n", rate, channels, pos); -#endif -#endif } void usbd_audio_rx_stop_callback(){ usbd_rx = NULL; - HAL_SAI_DMAResume(&HSAI_RX); -#if 0 && defined USE_USBD_AUDIO_RX && USBD_AUDIO_RX_CHANNELS > 0 - // __HAL_DMA_ENABLE(&HDMA_RX); // restart codec transfers - HAL_SAI_DMAResume(&HSAI_RX); - audio_rx_buffer.clear(); - // program.loadProgram(program.getProgramIndex()); - // program.startProgram(true); - // owl.setOperationMode(RUN_MODE); -#endif + // HAL_SAI_Transmit_DMA(&HSAI_RX, (uint8_t*)codec_txbuf, codec_blocksize*AUDIO_CHANNELS*2); + // HAL_SAI_DMAResume(&HSAI_RX); #ifdef DEBUG printf("stop rx\n"); #endif @@ -422,18 +399,18 @@ extern "C" { usbd_tx->write(AUDIO_INT32_TO_SAMPLE(*src++)); } void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai){ - if(usbd_tx) - usbd_tx_convert(codec_txbuf, codec_blocksize*AUDIO_CHANNELS); if(usbd_rx) usbd_rx_convert(codec_rxbuf, codec_blocksize*AUDIO_CHANNELS); audioCallback(codec_rxbuf, codec_txbuf, codec_blocksize); + if(usbd_tx) + usbd_tx_convert(codec_txbuf, codec_blocksize*AUDIO_CHANNELS); } void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai){ - if(usbd_tx) - usbd_tx_convert(codec_txbuf+codec_blocksize*AUDIO_CHANNELS, codec_blocksize*AUDIO_CHANNELS); if(usbd_rx) usbd_rx_convert(codec_rxbuf+codec_blocksize*AUDIO_CHANNELS, codec_blocksize*AUDIO_CHANNELS); audioCallback(codec_rxbuf+codec_blocksize*AUDIO_CHANNELS, codec_txbuf+codec_blocksize*AUDIO_CHANNELS, codec_blocksize); + if(usbd_tx) + usbd_tx_convert(codec_txbuf+codec_blocksize*AUDIO_CHANNELS, codec_blocksize*AUDIO_CHANNELS); } void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai){ error(CONFIG_ERROR, "SAI DMA Error"); diff --git a/Source/usbd_audio.cpp b/Source/usbd_audio.cpp index cd6be76b..6406c214 100644 --- a/Source/usbd_audio.cpp +++ b/Source/usbd_audio.cpp @@ -93,7 +93,7 @@ USBD_ClassTypeDef USBD_AUDIO = #ifdef USE_USBD_RX_FB -#define FB_REFRESH 5 /* Feedback refresh rate 2^(10-FB_REFRESH) */ +#define FB_REFRESH 4 /* Feedback refresh rate 2^(10-FB_REFRESH) */ #define FB_RATE (1<<(10-FB_REFRESH)) /** @@ -359,7 +359,11 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL USB_DESC_TYPE_INTERFACE, /* bDescriptorType 0x04 */ AUDIO_RX_IF, /* bInterfaceNumber */ 0x01, /* bAlternateSetting */ +#ifdef USE_USBD_RX_FB 0x02, /* bNumEndpoints */ +#else + 0x01, /* bNumEndpoints */ +#endif 0x01, /* bInterfaceClass */ 0x02, /* bInterfaceSubClass */ 0x00, /* bInterfaceProtocol */ @@ -381,7 +385,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x24, /* bDescriptorType */ 0x02, /* bDescriptorSubtype */ 0x01, /* bFormatType */ - USBD_AUDIO_RX_CHANNELS, /* bNrChannels */ + USBD_AUDIO_RX_CHANNELS, /* bNrChannels */ AUDIO_BYTES_PER_SAMPLE, /* bSubFrameSize */ AUDIO_BITS_PER_SAMPLE, /* bBitResolution */ 0x01, /* bSamFreqType only one frequency supported */ @@ -394,9 +398,9 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x09, /* bLength */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType */ AUDIO_RX_EP, /* bEndpointAddress 1 out endpoint*/ - USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_ASYNC, /* bmAttributes */ - LOBYTE(AUDIO_RX_PACKET_SIZE), /* wMaxPacketSize in bytes */ - HIBYTE(AUDIO_RX_PACKET_SIZE), + USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_ADAPT|USBD_EP_ATTR_ISOC_DATA, /* bmAttributes */ + LOBYTE(AUDIO_RX_MAX_PACKET_SIZE), /* wMaxPacketSize in bytes */ + HIBYTE(AUDIO_RX_MAX_PACKET_SIZE), 0x01, /* bInterval */ 0x00, /* bRefresh */ AUDIO_FB_EP, /* bSynchAddress */ @@ -405,9 +409,9 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x09, /* bLength */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType */ AUDIO_RX_EP, /* bEndpointAddress 1 out endpoint*/ - USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_SYNC, /* bmAttributes */ - LOBYTE(AUDIO_RX_PACKET_SIZE), /* wMaxPacketSize in bytes */ - HIBYTE(AUDIO_RX_PACKET_SIZE), + USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_ASYNC|USBD_EP_ATTR_ISOC_DATA, /* bmAttributes */ + LOBYTE(AUDIO_RX_MAX_PACKET_SIZE), /* wMaxPacketSize in bytes */ + HIBYTE(AUDIO_RX_MAX_PACKET_SIZE), 0x01, /* bInterval */ 0x00, /* bRefresh */ 0, /* bSynchAddress */ @@ -429,9 +433,9 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x09, /* bLength */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType */ AUDIO_FB_EP, /* bEndpointAddress */ - USBD_EP_TYPE_ISOC, /* bmAttributes */ - LOBYTE(AUDIO_RX_PACKET_SIZE), /* wMaxPacketSize */ - HIBYTE(AUDIO_RX_PACKET_SIZE), + USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_NOSYNC|USBD_EP_ATTR_ISOC_FB, /* bmAttributes */ + LOBYTE(AUDIO_RX_MAX_PACKET_SIZE), /* wMaxPacketSize */ + HIBYTE(AUDIO_RX_MAX_PACKET_SIZE), 0x01, /* bInterval 1ms */ FB_REFRESH, /* bRefresh SOF_RATE */ 0x00, /* bSynchAddress */ @@ -481,7 +485,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x24, // bDescriptorType 0x02, // bDescriptorSubtype 0x01, // FORMAT_TYPE_I. (bFormatType) - USBD_AUDIO_TX_CHANNELS , // Audio channels.(bNrChannels) + USBD_AUDIO_TX_CHANNELS, // Audio channels.(bNrChannels) AUDIO_BYTES_PER_SAMPLE, // Two bytes per audio subframe.(bSubFrameSize) AUDIO_BITS_PER_SAMPLE, // 16 bits per sample.(bBitResolution) 0x01, // One frequency supported. (bSamFreqType) @@ -492,9 +496,11 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x09, // Size of the descriptor, in bytes (bLength) 0x05, // ENDPOINT descriptor (bDescriptorType) AUDIO_TX_EP, // IN Endpoint 1. (bEndpointAddress) - USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_SYNC, // bmAttributes - LOBYTE(AUDIO_TX_PACKET_SIZE), // wMaxPacketSize in bytes - HIBYTE(AUDIO_TX_PACKET_SIZE), + // USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_SYNC, // bmAttributes + USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_ASYNC|USBD_EP_ATTR_ISOC_DATA, // bmAttributes + // USBD_EP_TYPE_ISOC, // bmAttributes (device not recognised in Windows if sync or async) + LOBYTE(AUDIO_TX_MAX_PACKET_SIZE), // wMaxPacketSize in bytes + HIBYTE(AUDIO_TX_MAX_PACKET_SIZE), 0x01, // Polling interval 1kHz. (bInterval) 0x00, // Unused. (bRefresh) 0x00, // Unused. (bSynchAddress) @@ -700,24 +706,6 @@ static uint8_t USBD_AUDIO_Init (USBD_HandleTypeDef *pdev, tx_buffer.setData((audio_t*)haudio->audio_tx_buffer, AUDIO_TX_TOTAL_BUF_SIZE/sizeof(audio_t)); #endif -#ifdef USE_USBD_AUDIO_TX_FALSE - USBD_AUDIO_OpenEndpoint(pdev, haudio, AUDIO_TX_EP, USBD_EP_TYPE_ISOC, AUDIO_TX_PACKET_SIZE); - haudio->audio_tx_active = 1; - haudio->tx_soffn = USB_SOF_NUMBER(); - usbd_audio_tx_callback(haudio->audio_tx_buffer, AUDIO_TX_PACKET_SIZE); -#endif - -#ifdef USE_USBD_AUDIO_RX_FALSE - USBD_AUDIO_OpenEndpoint(pdev, haudio, AUDIO_RX_EP, USBD_EP_TYPE_ISOC, AUDIO_RX_PACKET_SIZE); - USBD_AUDIO_OpenEndpoint(pdev, haudio, AUDIO_FB_EP, USBD_EP_TYPE_ISOC, AUDIO_FB_PACKET_SIZE); - haudio->audio_rx_active = 0; - haudio->fb_soffn = USB_SOF_NUMBER(); - /* Prepare OUT endpoint to receive first packet */ - USBD_LL_PrepareReceive(pdev, AUDIO_RX_EP, (uint8_t*)rx_buffer->getWriteHead(), AUDIO_RX_PACKET_SIZE); - // USBD_LL_PrepareReceive(pdev, AUDIO_RX_EP, haudio->audio_rx_buffer, AUDIO_RX_PACKET_SIZE); - // usbd_audio_rx_start_callback(USBD_AUDIO_RX_FREQ, USBD_AUDIO_RX_CHANNELS); -#endif - #ifdef USE_USBD_MIDI USBD_AUDIO_OpenEndpoint(pdev, haudio, MIDI_TX_EP, USBD_EP_TYPE_BULK, MIDI_TX_PACKET_SIZE); USBD_AUDIO_OpenEndpoint(pdev, haudio, MIDI_RX_EP, USBD_EP_TYPE_BULK, MIDI_RX_PACKET_SIZE); @@ -790,7 +778,7 @@ static uint8_t USBD_AUDIO_SetInterfaceAlternate(USBD_HandleTypeDef *pdev, AUDIO_OUT_StopAndReset(pdev); }else{ // open new - USBD_AUDIO_OpenEndpoint(pdev, haudio, AUDIO_RX_EP, USBD_EP_TYPE_ISOC, AUDIO_RX_PACKET_SIZE); + USBD_AUDIO_OpenEndpoint(pdev, haudio, AUDIO_RX_EP, USBD_EP_TYPE_ISOC, AUDIO_RX_MAX_PACKET_SIZE); #ifdef USE_USBD_RX_FB USBD_AUDIO_OpenEndpoint(pdev, haudio, AUDIO_FB_EP, USBD_EP_TYPE_ISOC, AUDIO_FB_PACKET_SIZE); #endif @@ -815,7 +803,7 @@ static uint8_t USBD_AUDIO_SetInterfaceAlternate(USBD_HandleTypeDef *pdev, haudio->audio_tx_active = 0; }else{ // open new - USBD_AUDIO_OpenEndpoint(pdev, haudio, AUDIO_TX_EP, USBD_EP_TYPE_ISOC, AUDIO_TX_PACKET_SIZE); + USBD_AUDIO_OpenEndpoint(pdev, haudio, AUDIO_TX_EP, USBD_EP_TYPE_ISOC, AUDIO_TX_MAX_PACKET_SIZE); haudio->audio_tx_active = 1; haudio->tx_soffn = USB_SOF_NUMBER(); usbd_audio_tx_start_callback(USBD_AUDIO_TX_FREQ, USBD_AUDIO_TX_CHANNELS, &tx_buffer); diff --git a/Source/usbd_audio.h b/Source/usbd_audio.h index b812e771..cb5259df 100644 --- a/Source/usbd_audio.h +++ b/Source/usbd_audio.h @@ -28,13 +28,18 @@ #define AUDIO_IN_STREAMING_CTRL 0x03 #define AUDIO_OUT_STREAMING_CTRL 0x04 -#define AUDIO_RX_PACKET_SIZE (uint16_t)(((USBD_AUDIO_RX_FREQ * USBD_AUDIO_RX_CHANNELS * AUDIO_BYTES_PER_SAMPLE) /1000)) -#define AUDIO_TX_PACKET_SIZE (uint16_t)(((USBD_AUDIO_TX_FREQ * USBD_AUDIO_TX_CHANNELS * AUDIO_BYTES_PER_SAMPLE) /1000)) +#define AUDIO_RX_SAMPLES_PER_MS (USBD_AUDIO_RX_FREQ / 1000) +#define AUDIO_RX_PACKET_SIZE ((uint16_t)(AUDIO_RX_SAMPLES_PER_MS * USBD_AUDIO_RX_CHANNELS * AUDIO_BYTES_PER_SAMPLE)) +#define AUDIO_RX_MAX_PACKET_SIZE ((uint16_t)(AUDIO_RX_PACKET_SIZE + USBD_AUDIO_RX_CHANNELS * AUDIO_BYTES_PER_SAMPLE)) + +#define AUDIO_TX_SAMPLES_PER_MS (USBD_AUDIO_TX_FREQ / 1000) +#define AUDIO_TX_PACKET_SIZE ((uint16_t)(AUDIO_TX_SAMPLES_PER_MS * USBD_AUDIO_TX_CHANNELS * AUDIO_BYTES_PER_SAMPLE)) +#define AUDIO_TX_MAX_PACKET_SIZE ((uint16_t)(AUDIO_TX_PACKET_SIZE + USBD_AUDIO_TX_CHANNELS * AUDIO_BYTES_PER_SAMPLE)) #define AUDIO_FB_PACKET_SIZE 3U /* Number of sub-packets in the audio transfer buffer. */ -#define AUDIO_RX_PACKET_NUM 2 -#define AUDIO_TX_PACKET_NUM 2 +#define AUDIO_RX_PACKET_NUM 4 +#define AUDIO_TX_PACKET_NUM 4 /* Total size of the OUT audio transfer buffer */ #define AUDIO_RX_TOTAL_BUF_SIZE ((size_t)(AUDIO_RX_PACKET_SIZE * AUDIO_RX_PACKET_NUM)) @@ -44,11 +49,18 @@ #define MIDI_TX_PACKET_SIZE 0x40 #define MIDI_RX_PACKET_SIZE 0x40 +/* Isochronous Synchronisation Type */ #define USBD_EP_ATTR_ISOC_NOSYNC 0x00 /* no synchro */ #define USBD_EP_ATTR_ISOC_ASYNC 0x04 /* synchronisation by feedback */ #define USBD_EP_ATTR_ISOC_ADAPT 0x08 /* adaptative synchronisation */ #define USBD_EP_ATTR_ISOC_SYNC 0x0C /* synchronous mode */ +/* Isochronous Usage Type */ +#define USBD_EP_ATTR_ISOC_DATA 0x00 /* Data Endpoint */ +#define USBD_EP_ATTR_ISOC_FB 0x10 /* Feedback Endpoint */ +#define USBD_EP_ATTR_ISOC_IMPL_FB 0x20 /* Implicit Feedback Data Endpoint */ + + /* Class-Specific AS Isochronous Audio Data Endpoint Descriptor bmAttributes */ #define USBD_AUDIO_AS_CONTROL_SAMPLING_FREQUENCY 0x0001 /* D0 = 1*/ #define USBD_AUDIO_AS_CONTROL_PITCH 0x0002 /* D1 = 1*/ diff --git a/Witch/Inc/hardware.h b/Witch/Inc/hardware.h index c5e01a3b..e40a86d2 100644 --- a/Witch/Inc/hardware.h +++ b/Witch/Inc/hardware.h @@ -15,8 +15,9 @@ #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) #define USE_USBD_AUDIO -#define USE_USBD_AUDIO_TX // microphone +/* #define USE_USBD_RX_FB */ #define USE_USBD_AUDIO_RX // speaker +#define USE_USBD_AUDIO_TX // microphone #define USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS #define USBH_HANDLE hUsbHostHS diff --git a/Witch/Makefile b/Witch/Makefile index 0997a6e0..49f18cf6 100644 --- a/Witch/Makefile +++ b/Witch/Makefile @@ -8,7 +8,7 @@ C_SRC = $(wildcard Src/*.c) CPP_SRC = $(wildcard Src/*.cpp) C_SRC += $(OPENWARE)/Source/sdram.c C_SRC += $(OPENWARE)/Source/cs4272.c -C_SRC += $(OPENWARE)/Source/usbd_audio.c +CPP_SRC += $(OPENWARE)/Source/usbd_audio.cpp CPP_SRC += $(OPENWARE)/Source/usbh_midi.cpp include $(OPENWARE)/Hardware/sources.mk From 389c3afb0490840cac08bd624bae53d6a79f9a19 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 28 Sep 2021 11:13:12 +0200 Subject: [PATCH 074/286] moved midi rx/tx to loop() --- Source/Owl.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Owl.cpp b/Source/Owl.cpp index 929ecfc3..323974d3 100644 --- a/Source/Owl.cpp +++ b/Source/Owl.cpp @@ -215,6 +215,8 @@ void Owl::setOperationMode(OperationMode mode){ } void Owl::loop(){ + midi_tx.transmit(); + midi_rx.receive(); // push queued up MIDI messages through to patch #ifdef USE_DIGITALBUS busstatus = bus_status(); #endif From bf98926404505c308314c4945fae2e34621331b9 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 28 Sep 2021 11:13:31 +0200 Subject: [PATCH 075/286] moved usbd callbacks to ProgramManager --- Source/Codec.cpp | 53 ++++++++++-------------- Source/Codec.h | 1 + Source/ProgramManager.cpp | 84 ++++++++++++++++++++++++++++++++++++--- 3 files changed, 101 insertions(+), 37 deletions(-) diff --git a/Source/Codec.cpp b/Source/Codec.cpp index 087a8619..f1b2c5cf 100644 --- a/Source/Codec.cpp +++ b/Source/Codec.cpp @@ -6,8 +6,6 @@ #include #include "ProgramManager.h" -#include "CircularBuffer.h" - #ifdef USE_CS4271 #define HSAI_RX hsai_BlockB1 #define HSAI_TX hsai_BlockA1 @@ -35,8 +33,11 @@ extern "C" { #ifdef USE_USBD_AUDIO #include "usbd_audio.h" +#if 0 + CircularBuffer* volatile usbd_rx = NULL; CircularBuffer* volatile usbd_tx = NULL; +static uint32_t usbd_audio_rx_count = 0; // static void update_rx_read_index(){ // #if defined USE_CS4271 || defined USE_PCM3168A @@ -93,7 +94,6 @@ void usbd_audio_tx_start_callback(size_t rate, uint8_t channels, void* cb){ } static int32_t usbd_audio_tx_flow = 0; -static uint32_t usbd_audio_rx_count = 0; // expect a 1 in 10k sample underflow (-0.01% sample accuracy) void usbd_audio_tx_callback(uint8_t* data, size_t len){ #if 0 && defined USE_USBD_AUDIO_TX && USBD_AUDIO_TX_CHANNELS > 0 @@ -178,14 +178,6 @@ size_t usbd_audio_rx_callback(uint8_t* data, size_t len){ return len; } -void usbd_audio_mute_callback(int16_t gain){ - // todo! -} - -void usbd_audio_gain_callback(int16_t gain){ - // codec_set_gain_in(gain); todo! -} - /* Get number of samples transmitted since previous request */ uint32_t usbd_audio_get_rx_count(){ return 0; @@ -195,6 +187,16 @@ uint32_t usbd_audio_get_rx_count(){ // usbd_audio_rx_count = 0; // return pos / AUDIO_CHANNELS; } + +#endif + +void usbd_audio_mute_callback(int16_t gain){ + // todo! +} + +void usbd_audio_gain_callback(int16_t gain){ + // codec_set_gain_in(gain); todo! +} #endif // USE_USBD_AUDIO uint16_t Codec::getBlockSize(){ @@ -385,32 +387,11 @@ extern "C"{ #if defined USE_CS4271 || defined USE_PCM3168A extern "C" { - void usbd_rx_convert(int32_t* dst, size_t len){ - usbd_audio_rx_count += len; - while(len--) - *dst++ = AUDIO_SAMPLE_TO_INT32(usbd_rx->read()); - } - void usbd_tx_convert(int32_t* src, size_t len){ -#if USBD_AUDIO_TX_CHANNELS != AUDIO_CHANNELS -#error "todo: support for USBD_AUDIO_TX_CHANNELS != AUDIO_CHANNELS" -#endif - while(len--) - // macro handles shift, round, dither, clip, truncate, bitswap - usbd_tx->write(AUDIO_INT32_TO_SAMPLE(*src++)); - } void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai){ - if(usbd_rx) - usbd_rx_convert(codec_rxbuf, codec_blocksize*AUDIO_CHANNELS); audioCallback(codec_rxbuf, codec_txbuf, codec_blocksize); - if(usbd_tx) - usbd_tx_convert(codec_txbuf, codec_blocksize*AUDIO_CHANNELS); } void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai){ - if(usbd_rx) - usbd_rx_convert(codec_rxbuf+codec_blocksize*AUDIO_CHANNELS, codec_blocksize*AUDIO_CHANNELS); audioCallback(codec_rxbuf+codec_blocksize*AUDIO_CHANNELS, codec_txbuf+codec_blocksize*AUDIO_CHANNELS, codec_blocksize); - if(usbd_tx) - usbd_tx_convert(codec_txbuf+codec_blocksize*AUDIO_CHANNELS, codec_blocksize*AUDIO_CHANNELS); } void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai){ error(CONFIG_ERROR, "SAI DMA Error"); @@ -455,6 +436,14 @@ void Codec::resume(){ HAL_SAI_DMAResume(&HSAI_TX); } +size_t Codec::getSampleCounter(){ + // does not work: always returns values <= 5 + // return DMA_GetCurrDataCounter(DMA2_Stream0); + // // NDTR: the number of remaining data units in the current DMA Stream transfer. + return CODEC_BUFFER_SIZE - __HAL_DMA_GET_COUNTER(&HDMA_TX); + // return (DWT->CYCCNT)/ARM_CYCLES_PER_SAMPLE; +} + extern "C" { // void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai){ diff --git a/Source/Codec.h b/Source/Codec.h index c1b16c7a..8b2282b7 100644 --- a/Source/Codec.h +++ b/Source/Codec.h @@ -47,6 +47,7 @@ class Codec { int32_t getMax(); float getAvg(); uint16_t getBlockSize(); + size_t getSampleCounter(); }; extern Codec codec; diff --git a/Source/ProgramManager.cpp b/Source/ProgramManager.cpp index 3db4640c..0387aea6 100644 --- a/Source/ProgramManager.cpp +++ b/Source/ProgramManager.cpp @@ -26,6 +26,72 @@ #include "bus.h" #endif +#ifdef USE_USBD_AUDIO +#include "usbd_audio.h" +#include "CircularBuffer.h" + +CircularBuffer* volatile usbd_rx = NULL; +CircularBuffer* volatile usbd_tx = NULL; +static uint32_t usbd_audio_rx_count = 0; + +/* Get number of samples transmitted since previous request */ +uint32_t usbd_audio_get_rx_count(){ + return 0; + // // NDTR: the number of remaining data units in the current DMA Stream transfer. + // size_t pos = codec.getSampleCounter() + usbd_audio_rx_count; + // usbd_audio_rx_count = 0; + // return pos / AUDIO_CHANNELS; +} + +void usbd_audio_tx_start_callback(size_t rate, uint8_t channels, void* cb){ + usbd_tx = (CircularBuffer*)cb; + usbd_tx->reset(); + usbd_tx->clear(); + usbd_tx->moveWriteHead(usbd_tx->getSize()/2); +} + +void usbd_audio_tx_stop_callback(){ + usbd_tx = NULL; +#ifdef DEBUG + printf("stop tx\n"); +#endif +} + +void usbd_audio_rx_start_callback(size_t rate, uint8_t channels, void* cb){ + usbd_rx = (CircularBuffer*)cb; + usbd_rx->reset(); + usbd_rx->clear(); + usbd_rx->moveReadHead(usbd_rx->getSize()/2); + usbd_audio_rx_count = 0; +#ifdef DEBUG + printf("start rx %u %u %u\n", rate, channels, usbd_rx->getSize()); +#endif +} + +void usbd_audio_rx_stop_callback(){ + usbd_rx = NULL; +#ifdef DEBUG + printf("stop rx\n"); +#endif +} + +void usbd_rx_convert(int32_t* dst, size_t len){ + usbd_audio_rx_count += len; + while(len--) + *dst++ = AUDIO_SAMPLE_TO_INT32(usbd_rx->read()); +} + +void usbd_tx_convert(int32_t* src, size_t len){ +#if USBD_AUDIO_TX_CHANNELS != AUDIO_CHANNELS +#error "todo: support for USBD_AUDIO_TX_CHANNELS != AUDIO_CHANNELS" +#endif + while(len--) + // macro handles shift, round, dither, clip, truncate, bitswap + usbd_tx->write(AUDIO_INT32_TO_SAMPLE(*src++)); +} + +#endif + // FreeRTOS low priority numbers denote low priority tasks. // The idle task has priority zero (tskIDLE_PRIORITY). // #define SCREEN_TASK_STACK_SIZE (2*1024/sizeof(portSTACK_TYPE)) @@ -140,18 +206,23 @@ void setButtonValue(uint8_t ch, uint8_t value){ /* called by the program when a block has been processed */ void onProgramReady(){ - midi_tx.transmit(); ProgramVector* pv = getProgramVector(); +#ifdef USE_USBD_AUDIO_TX + if(usbd_tx) // after patch runs: convert wet output to USBD audio + usbd_tx_convert(pv->audio_output, pv->audio_blocksize*AUDIO_CHANNELS); +#endif #ifdef DEBUG_DWT pv->cycles_per_block = DWT->CYCCNT; #endif - /* Block indefinitely */ - // uint32_t ulNotifiedValue = + /* Block indefinitely (released by audioCallback) */ ulTaskNotifyTake(pdTRUE, portMAX_DELAY); +#ifdef USE_USBD_AUDIO_RX + if(usbd_rx) // before patch runs: convert USBD audio to input + usbd_rx_convert(pv->audio_input, pv->audio_blocksize*AUDIO_CHANNELS); +#endif #ifdef DEBUG_DWT DWT->CYCCNT = 0; #endif - midi_rx.receive(); // push queued up MIDI messages through to patch #ifdef USE_ADC #ifdef USE_SCREEN updateParameters(graphics.params.parameters, NOF_PARAMETERS, adc_values, NOF_ADC_VALUES); @@ -675,5 +746,8 @@ void ProgramManager::saveToFlash(uint8_t sector, void* address, uint32_t length) uint16_t getSampleCounter(){ // does not work: always returns values <= 5 // return DMA_GetCurrDataCounter(DMA2_Stream0); - return (DWT->CYCCNT)/ARM_CYCLES_PER_SAMPLE; + // // NDTR: the number of remaining data units in the current DMA Stream transfer. + // size_t pos = CODEC_BUFFER_SIZE - __HAL_DMA_GET_COUNTER(&HDMA_TX); + // return (DWT->CYCCNT)/ARM_CYCLES_PER_SAMPLE; + return codec.getSampleCounter() / AUDIO_CHANNELS; } From afeb234e2016455aeae81ffa6a3aad696952781f Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 28 Sep 2021 13:13:34 +0200 Subject: [PATCH 076/286] updated terminal ids, added tx feature unit (crashes windows\!) --- Source/usbd_audio.cpp | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/Source/usbd_audio.cpp b/Source/usbd_audio.cpp index 6406c214..462f9ad8 100644 --- a/Source/usbd_audio.cpp +++ b/Source/usbd_audio.cpp @@ -186,7 +186,7 @@ uint8_t fb_data[3]; #endif #ifdef USE_USBD_AUDIO_TX -#define USBD_AUDIO_TX_AC_DESC_LEN 21 +#define USBD_AUDIO_TX_AC_DESC_LEN 30 #define USBD_AUDIO_TX_AS_DESC_LEN 52 #define USBD_AUDIO_TX_NUM_INTERFACES 1 #else @@ -291,8 +291,9 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x02, // bUnitID 0x01, // bSourceID 0x01, // bControlSize - 0x01|0x02, // bmaControls(0) AUDIO_CONTROL_MUTE|AUDIO_CONTROL_VOLUME - 0, // bmaControls(1) + // 0x01|0x02, // bmaControls(0) AUDIO_CONTROL_MUTE|AUDIO_CONTROL_VOLUME + 0x00, // bmaControls(0) + 0x00, // bmaControls(1) 0x00, // iTerminal /* 09 byte */ @@ -300,7 +301,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x09, // bLength 0x024, // bDescriptorType 0x03, // bDescriptorSubtype - 0x03, // bTerminalID + 0x03, // bTerminalID 0x01, // wTerminalType 0x0301 0x03, // wTerminalType 0x0301 0x00, // bAssocTerminal @@ -316,29 +317,42 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x0C, // Size of the descriptor, in bytes 0x24, // bDescriptorType CS_INTERFACE Descriptor Type 0x24 0x02, // bDescriptorSubtype INPUT_TERMINAL descriptor subtype 0x02 - 0x01, // bTerminalID ID of this Terminal. + 0x04, // bTerminalID ID of this Terminal. 0x01, // wTerminalType 0x02, // wTerminalType Terminal is Microphone (0x0201) 0x00, // bAssocTerminal No association - USBD_AUDIO_TX_CHANNELS, // bNrChannels + USBD_AUDIO_TX_CHANNELS, // bNrChannels 0x03, // wChannelConfig 0x00, // wChannelConfig Mono sets no position bits 0x00, // iChannelNames Unused 0x00, // iTerminal Unused /* 12 bytes */ + /* Feature Unit Descriptor*/ + 0x09, // bLength + 0x24, // bDescriptorType + 0x06, // bDescriptorSubtype + 0x05, // bUnitID + 0x04, // bSourceID + 0x01, // bControlSize + // 0x01|0x02, // bmaControls(0) AUDIO_CONTROL_MUTE|AUDIO_CONTROL_VOLUME + 0x00, // bmaControls(0) + 0x00, // bmaControls(1) + 0x00, // iTerminal + /* 09 byte */ + /* USB Microphone Output Terminal Descriptor */ 0x09, // Size of the descriptor, in bytes (bLength) 0x24, // bDescriptorType 0x03, // bDescriptorSubtype - 0x02, // bTerminalID - 0x01, 0x01, // wTerminalType + 0x06, // bTerminalID + 0x01, 0x01, // wTerminalType 0x0101 USB Streaming 0x00, // bAssocTerminal - 0x01, // From Input Terminal.(bSourceID) + 0x05, // From Input Terminal.(bSourceID) 0x00, // unused (iTerminal) /* 9 bytes */ - // 12+9 = 21 bytes + // 12+9+9 = 30 bytes #endif #ifdef USE_USBD_AUDIO_RX @@ -434,8 +448,8 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL USB_DESC_TYPE_ENDPOINT, /* bDescriptorType */ AUDIO_FB_EP, /* bEndpointAddress */ USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_NOSYNC|USBD_EP_ATTR_ISOC_FB, /* bmAttributes */ - LOBYTE(AUDIO_RX_MAX_PACKET_SIZE), /* wMaxPacketSize */ - HIBYTE(AUDIO_RX_MAX_PACKET_SIZE), + LOBYTE(AUDIO_FB_PACKET_SIZE), /* wMaxPacketSize */ + HIBYTE(AUDIO_FB_PACKET_SIZE), 0x01, /* bInterval 1ms */ FB_REFRESH, /* bRefresh SOF_RATE */ 0x00, /* bSynchAddress */ @@ -474,7 +488,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x07, // Size of the descriptor, in bytes (bLength) 0x24, // bDescriptorType 0x01, // bDescriptorSubtype - 0x02, // Unit ID of the Output Terminal.(bTerminalLink) + 0x04, // Unit ID of the Output Terminal.(bTerminalLink) 0x00, // Interface delay. (bDelay) 0x01, 0x00, // PCM Format (wFormatTag) See 'USB Audio Data formats' @@ -995,7 +1009,7 @@ static void AUDIO_REQ_GetCurrent(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* USBD_AUDIO_HandleTypeDef* haudio; haudio = (USBD_AUDIO_HandleTypeDef*)pdev->pClassData; - if ((req->bmRequest & 0x1f) == AUDIO_CONTROL_REQ) { + if ((req->bmRequest & 0x1f) == AUDIO_CONTROL_REQ) { // should AUDIO_CONTROL_REQ the bUnitID of IN/OUT feature? switch (HIBYTE(req->wValue)) { case AUDIO_CONTROL_REQ_FU_MUTE: { /* Current mute state */ From 1be2a0d0dd819189242107c6e34563ac83090524 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 28 Sep 2021 19:04:30 +0200 Subject: [PATCH 077/286] removed Feature Units, fixed terminal bSourceID --- Source/usbd_audio.cpp | 111 ++++++++++++++++++++++++++++-------------- Witch/Inc/usbd_conf.h | 2 +- 2 files changed, 76 insertions(+), 37 deletions(-) diff --git a/Source/usbd_audio.cpp b/Source/usbd_audio.cpp index 462f9ad8..4a4877e9 100644 --- a/Source/usbd_audio.cpp +++ b/Source/usbd_audio.cpp @@ -172,7 +172,7 @@ uint8_t fb_data[3]; #endif #ifdef USE_USBD_AUDIO_RX -#define USBD_AUDIO_RX_AC_DESC_LEN 30 +#define USBD_AUDIO_RX_AC_DESC_LEN 21 // 31 #ifdef USE_USBD_RX_FB #define USBD_AUDIO_RX_AS_DESC_LEN 61 #else @@ -186,7 +186,7 @@ uint8_t fb_data[3]; #endif #ifdef USE_USBD_AUDIO_TX -#define USBD_AUDIO_TX_AC_DESC_LEN 30 +#define USBD_AUDIO_TX_AC_DESC_LEN 21 // 31 #define USBD_AUDIO_TX_AS_DESC_LEN 52 #define USBD_AUDIO_TX_NUM_INTERFACES 1 #else @@ -217,8 +217,8 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL /* Configuration 1 */ 0x09, /* bLength */ 0x02, /* bDescriptorType */ - LOBYTE(USBD_AUDIO_CONFIG_DESC_SIZ), /* wTotalLength */ - HIBYTE(USBD_AUDIO_CONFIG_DESC_SIZ), /* wTotalLength */ + LOBYTE(USBD_AUDIO_CONFIG_DESC_SIZ), /* wTotalLength */ + HIBYTE(USBD_AUDIO_CONFIG_DESC_SIZ), /* wTotalLength */ (AUDIO_NUM_INTERFACES+1), /* bNumInterfaces (+1 for AC Interface) */ 0x01, /* bConfigurationValue */ 0x00, /* iConfiguration */ @@ -273,7 +273,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x01, // wTerminalType USBD_AUDIO_TERMINAL_IO_USB_STREAMING 0x0101 0x01, // wTerminalType 0x00, // bAssocTerminal - USBD_AUDIO_RX_CHANNELS, // bNrChannels + USBD_AUDIO_RX_CHANNELS, // bNrChannels #if USBD_AUDIO_RX_CHANNELS == 1 0x00, // wChannelConfig 0x00 sets Mono, no position bits #else @@ -284,18 +284,20 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x00, // iTerminal Unused /* 12 byte */ +#if 0 /* Feature Unit Descriptor*/ - 0x09, // bLength + 0x0a, // bLength 0x24, // bDescriptorType 0x06, // bDescriptorSubtype 0x02, // bUnitID 0x01, // bSourceID 0x01, // bControlSize - // 0x01|0x02, // bmaControls(0) AUDIO_CONTROL_MUTE|AUDIO_CONTROL_VOLUME - 0x00, // bmaControls(0) + 0x01|0x02, // bmaControls(0) AUDIO_CONTROL_MUTE|AUDIO_CONTROL_VOLUME + // 0x00, // bmaControls(0) 0x00, // bmaControls(1) + 0x00, // bmaControls(2) 0x00, // iTerminal - /* 09 byte */ + /* 10 byte */ /* Output Terminal Descriptor */ 0x09, // bLength @@ -304,12 +306,25 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x03, // bTerminalID 0x01, // wTerminalType 0x0301 0x03, // wTerminalType 0x0301 - 0x00, // bAssocTerminal + 0x01, // bAssocTerminal 0x02, // bSourceID 0x00, // iTerminal /* 09 byte */ +#endif - // 12+9+9 = 30 bytes + /* Output Terminal Descriptor */ + 0x09, // bLength + 0x024, // bDescriptorType + 0x03, // bDescriptorSubtype + 0x03, // bTerminalID + 0x01, // wTerminalType 0x0301 + 0x03, // wTerminalType 0x0301 + 0x00, // bAssocTerminal + 0x01, // bSourceID + 0x00, // iTerminal + /* 09 byte */ + + // 12+10+9 = 31 bytes #endif #ifdef USE_USBD_AUDIO_TX @@ -320,7 +335,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x04, // bTerminalID ID of this Terminal. 0x01, // wTerminalType 0x02, // wTerminalType Terminal is Microphone (0x0201) - 0x00, // bAssocTerminal No association + 0x00, // bAssocTerminal USBD_AUDIO_TX_CHANNELS, // bNrChannels 0x03, // wChannelConfig 0x00, // wChannelConfig Mono sets no position bits @@ -328,18 +343,32 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x00, // iTerminal Unused /* 12 bytes */ +#if 0 /* Feature Unit Descriptor*/ - 0x09, // bLength + 0x0a, // bLength 0x24, // bDescriptorType 0x06, // bDescriptorSubtype 0x05, // bUnitID 0x04, // bSourceID 0x01, // bControlSize - // 0x01|0x02, // bmaControls(0) AUDIO_CONTROL_MUTE|AUDIO_CONTROL_VOLUME - 0x00, // bmaControls(0) + 0x01|0x02, // bmaControls(0) AUDIO_CONTROL_MUTE|AUDIO_CONTROL_VOLUME + // 0x00, // bmaControls(0) 0x00, // bmaControls(1) + 0x00, // bmaControls(2) 0x00, // iTerminal - /* 09 byte */ + /* 10 byte */ + + /* USB Microphone Output Terminal Descriptor */ + 0x09, // Size of the descriptor, in bytes (bLength) + 0x24, // bDescriptorType + 0x03, // bDescriptorSubtype + 0x06, // bTerminalID + 0x01, 0x01, // wTerminalType 0x0101 USB Streaming + 0x04, // bAssocTerminal + 0x05, // From Input Terminal.(bSourceID) + 0x00, // unused (iTerminal) + /* 9 bytes */ +#endif /* USB Microphone Output Terminal Descriptor */ 0x09, // Size of the descriptor, in bytes (bLength) @@ -348,11 +377,11 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x06, // bTerminalID 0x01, 0x01, // wTerminalType 0x0101 USB Streaming 0x00, // bAssocTerminal - 0x05, // From Input Terminal.(bSourceID) + 0x04, // From Input Terminal.(bSourceID) 0x00, // unused (iTerminal) /* 9 bytes */ - // 12+9+9 = 30 bytes + // 12+10+9 = 31 bytes #endif #ifdef USE_USBD_AUDIO_RX @@ -488,7 +517,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x07, // Size of the descriptor, in bytes (bLength) 0x24, // bDescriptorType 0x01, // bDescriptorSubtype - 0x04, // Unit ID of the Output Terminal.(bTerminalLink) + 0x06, // Unit ID of the Output Terminal.(bTerminalLink) 0x00, // Interface delay. (bDelay) 0x01, 0x00, // PCM Format (wFormatTag) See 'USB Audio Data formats' @@ -1009,26 +1038,28 @@ static void AUDIO_REQ_GetCurrent(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* USBD_AUDIO_HandleTypeDef* haudio; haudio = (USBD_AUDIO_HandleTypeDef*)pdev->pClassData; - if ((req->bmRequest & 0x1f) == AUDIO_CONTROL_REQ) { // should AUDIO_CONTROL_REQ the bUnitID of IN/OUT feature? + // if ((req->bmRequest & 0x1f) == AUDIO_CONTROL_REQ) { // todo: should AUDIO_CONTROL_REQ match the bUnitID of IN/OUT feature? + uint8_t bUnit = req->bmRequest & 0x1f; + if (bUnit == 0x02 || bUnit == 0x05) { switch (HIBYTE(req->wValue)) { case AUDIO_CONTROL_REQ_FU_MUTE: { /* Current mute state */ uint8_t mute = 0; USBD_CtlSendData(pdev, &mute, 1); }; - break; - case AUDIO_CONTROL_REQ_FU_VOL: { - /* Current volume. See UAC Spec 1.0 p.77 */ - USBD_CtlSendData(pdev, (uint8_t*)&haudio->volume, 2); - }; - break; - } - } else if ((req->bmRequest & 0x1f) == AUDIO_STREAMING_REQ) { - if (HIBYTE(req->wValue) == AUDIO_STREAMING_REQ_FREQ_CTRL) { - /* Current frequency */ - AUDIO_FREQ_TO_DATA(haudio->frequency, haudio->control.data) - USBD_CtlSendData(pdev, haudio->control.data, 3); + break; + case AUDIO_CONTROL_REQ_FU_VOL: { + /* Current volume. See UAC Spec 1.0 p.77 */ + USBD_CtlSendData(pdev, (uint8_t*)&haudio->volume, 2); + }; + break; } + // } else if ((req->bmRequest & 0x1f) == AUDIO_STREAMING_REQ) { + // if (HIBYTE(req->wValue) == AUDIO_STREAMING_REQ_FREQ_CTRL) { + // /* Current frequency */ + // AUDIO_FREQ_TO_DATA(haudio->frequency, haudio->control.data) + // USBD_CtlSendData(pdev, haudio->control.data, 3); + // } } } @@ -1041,7 +1072,9 @@ static void AUDIO_REQ_GetCurrent(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* */ static void AUDIO_REQ_GetMax(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* req) { - if ((req->bmRequest & 0x1f) == AUDIO_CONTROL_REQ) { + // if ((req->bmRequest & 0x1f) == AUDIO_CONTROL_REQ) { + uint8_t bUnit = req->bmRequest & 0x1f; + if (bUnit == 0x02 || bUnit == 0x05) { switch (HIBYTE(req->wValue)) { case AUDIO_CONTROL_REQ_FU_VOL: { int16_t vol_max = USBD_AUDIO_VOL_MAX; @@ -1067,7 +1100,9 @@ static void AUDIO_REQ_GetMax(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* req */ static void AUDIO_REQ_GetMin(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* req) { - if ((req->bmRequest & 0x1f) == AUDIO_CONTROL_REQ) { + uint8_t bUnit = req->bmRequest & 0x1f; + if (bUnit == 0x02 || bUnit == 0x05) { + // if ((req->bmRequest & 0x1f) == AUDIO_CONTROL_REQ) { switch (HIBYTE(req->wValue)) { case AUDIO_CONTROL_REQ_FU_VOL: { int16_t vol_min = USBD_AUDIO_VOL_MIN; @@ -1093,7 +1128,9 @@ static void AUDIO_REQ_GetMin(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* req */ static void AUDIO_REQ_GetRes(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* req) { - if ((req->bmRequest & 0x1f) == AUDIO_CONTROL_REQ) { + uint8_t bUnit = req->bmRequest & 0x1f; + if (bUnit == 0x02 || bUnit == 0x05) { + // if ((req->bmRequest & 0x1f) == AUDIO_CONTROL_REQ) { switch (HIBYTE(req->wValue)) { case AUDIO_CONTROL_REQ_FU_VOL: { int16_t vol_res = USBD_AUDIO_VOL_STEP; @@ -1144,7 +1181,9 @@ static uint8_t USBD_AUDIO_EP0_RxReady (USBD_HandleTypeDef *pdev) (void)haudio; #if 1 if (haudio->control.cmd == AUDIO_REQ_SET_CUR) { /* In this driver, to simplify code, only SET_CUR request is managed */ - if (haudio->control.req_type == AUDIO_CONTROL_REQ) { + // if (haudio->control.req_type == AUDIO_CONTROL_REQ) { + uint8_t bUnit = haudio->control.req_type; + if (bUnit == 0x02 || bUnit == 0x05) { USBD_DbgLog("CONTROL_REQ 0x%x 0x%x", haudio->control.cs, haudio->control.data[0]); switch (haudio->control.cs) { /* Mute Control */ diff --git a/Witch/Inc/usbd_conf.h b/Witch/Inc/usbd_conf.h index 4efc673d..008bfcc3 100644 --- a/Witch/Inc/usbd_conf.h +++ b/Witch/Inc/usbd_conf.h @@ -79,7 +79,7 @@ /*---------- -----------*/ #define USBD_LPM_ENABLED 0U /*---------- -----------*/ -#define USBD_SELF_POWERED 1U +#define USBD_SELF_POWERED 0U /*---------- -----------*/ /****************************************/ From 619cf1e7277ee0d12c932aa4744e7f1f1b506c94 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 29 Sep 2021 23:14:47 +0200 Subject: [PATCH 078/286] use extra transmit buffer for audio tx --- Source/CircularBuffer.h | 17 +++++++++++------ Source/Codec.cpp | 3 --- Source/ProgramManager.cpp | 12 ++++++------ Source/usbd_audio.cpp | 38 +++++++++++++++++++++++++++----------- Source/usbd_audio.h | 21 ++++++++++++--------- 5 files changed, 56 insertions(+), 35 deletions(-) diff --git a/Source/CircularBuffer.h b/Source/CircularBuffer.h index 93761f0d..1c67fb6e 100644 --- a/Source/CircularBuffer.h +++ b/Source/CircularBuffer.h @@ -4,19 +4,24 @@ #include #include // for memcpy -#ifdef DEBUG_CIRCULAR_BUFFER -#define FLOW_ASSERT(x, y) ASSERT(x, y) -#else +#ifndef FLOW_ASSERT #define FLOW_ASSERT(x, y) #endif +// #ifdef DEBUG_CIRCULAR_BUFFER +// #define FLOW_ASSERT(x, y) ASSERT(x, y) +// #else +// #define FLOW_ASSERT(x, y) +// // #define FLOW_ASSERT(x, y) if(!x){debugMessage(y, this->getReadCapacity(), this->getWriteCapacity());} +// #endif + template class CircularBuffer { protected: T* data; size_t size; - size_t writepos = 0; - size_t readpos = 0; + volatile size_t writepos = 0; + volatile size_t readpos = 0; public: CircularBuffer(): data(NULL), size(0){} CircularBuffer(T* data, size_t size): data(data), size(size){} @@ -118,7 +123,7 @@ class CircularBuffer { } void moveWriteHead(size_t samples){ - FLOW_ASSERT(getWriteCapacity() < samples, "overflow"); + FLOW_ASSERT(getWriteCapacity() >= samples, "overflow"); writepos += samples; if(writepos >= size) writepos -= size; diff --git a/Source/Codec.cpp b/Source/Codec.cpp index f1b2c5cf..cb6d9bc3 100644 --- a/Source/Codec.cpp +++ b/Source/Codec.cpp @@ -63,9 +63,6 @@ static uint32_t usbd_audio_rx_count = 0; void usbd_audio_tx_start_callback(size_t rate, uint8_t channels, void* cb){ usbd_tx = (CircularBuffer*)cb; - usbd_tx->reset(); - usbd_tx->clear(); - usbd_tx->moveWriteHead(usbd_tx->getSize()/2); #ifdef DEBUG printf("start tx %u %u %u\n", rate, channels, usbd_tx->getSize()); #endif diff --git a/Source/ProgramManager.cpp b/Source/ProgramManager.cpp index 0387aea6..34d1fc98 100644 --- a/Source/ProgramManager.cpp +++ b/Source/ProgramManager.cpp @@ -45,9 +45,9 @@ uint32_t usbd_audio_get_rx_count(){ void usbd_audio_tx_start_callback(size_t rate, uint8_t channels, void* cb){ usbd_tx = (CircularBuffer*)cb; - usbd_tx->reset(); - usbd_tx->clear(); - usbd_tx->moveWriteHead(usbd_tx->getSize()/2); + // usbd_tx->reset(); + // usbd_tx->clear(); + // usbd_tx->moveWriteHead(usbd_tx->getSize()/2); } void usbd_audio_tx_stop_callback(){ @@ -59,9 +59,9 @@ void usbd_audio_tx_stop_callback(){ void usbd_audio_rx_start_callback(size_t rate, uint8_t channels, void* cb){ usbd_rx = (CircularBuffer*)cb; - usbd_rx->reset(); - usbd_rx->clear(); - usbd_rx->moveReadHead(usbd_rx->getSize()/2); + // usbd_rx->reset(); + // usbd_rx->clear(); + // usbd_rx->moveReadHead(usbd_rx->getSize()/2); usbd_audio_rx_count = 0; #ifdef DEBUG printf("start rx %u %u %u\n", rate, channels, usbd_rx->getSize()); diff --git a/Source/usbd_audio.cpp b/Source/usbd_audio.cpp index 4a4877e9..6150c0d8 100644 --- a/Source/usbd_audio.cpp +++ b/Source/usbd_audio.cpp @@ -17,7 +17,11 @@ #include "usbd_conf.h" #include "usbd_ctlreq.h" +#include "message.h" +int usbd_tx_flow = 0; +#define FLOW_ASSERT(x, y) if(!x){debugMessage(y, usbd_tx_flow, this->getReadCapacity(), this->getWriteCapacity());} #include "CircularBuffer.h" +#include "Codec.h" // todo: not static/global CircularBuffer rx_buffer; @@ -849,10 +853,14 @@ static uint8_t USBD_AUDIO_SetInterfaceAlternate(USBD_HandleTypeDef *pdev, USBD_AUDIO_OpenEndpoint(pdev, haudio, AUDIO_TX_EP, USBD_EP_TYPE_ISOC, AUDIO_TX_MAX_PACKET_SIZE); haudio->audio_tx_active = 1; haudio->tx_soffn = USB_SOF_NUMBER(); + tx_buffer.reset(); + tx_buffer.clear(); + tx_buffer.moveWriteHead(AUDIO_TX_PACKET_SIZE/sizeof(audio_t)); usbd_audio_tx_start_callback(USBD_AUDIO_TX_FREQ, USBD_AUDIO_TX_CHANNELS, &tx_buffer); /* send first audio data */ - usbd_audio_write((uint8_t*)tx_buffer.getReadHead(), AUDIO_TX_PACKET_SIZE); - // usbd_audio_tx_callback(haudio->audio_tx_buffer, AUDIO_TX_PACKET_SIZE); + memset(haudio->audio_tx_transmit, 0, sizeof(haudio->audio_tx_transmit)); + usbd_audio_write((uint8_t*)haudio->audio_tx_transmit, AUDIO_TX_PACKET_SIZE); + usbd_tx_flow = 0; } haudio->tx_alt_setting = new_alt; } @@ -1007,14 +1015,23 @@ static uint8_t USBD_AUDIO_DataIn (USBD_HandleTypeDef *pdev, break; #endif #ifdef USE_USBD_AUDIO_TX - case AUDIO_TX_EP: + case AUDIO_TX_EP: { haudio->tx_soffn = USB_SOF_NUMBER(); - // todo: can we find out how much data was actually read? - tx_buffer.moveReadHead(AUDIO_TX_PACKET_SIZE/sizeof(audio_t)); - // todo: write no more than available data - usbd_audio_write((uint8_t*)tx_buffer.getReadHead(), AUDIO_TX_PACKET_SIZE); - // usbd_audio_tx_callback(haudio->audio_tx_buffer, AUDIO_TX_PACKET_SIZE); + // decide if we should send one set of samples more or less than expected + size_t len = AUDIO_TX_PACKET_SIZE/sizeof(audio_t); + size_t capacity = tx_buffer.getReadCapacity(); + capacity += codec.getSampleCounter(); + if(capacity < 2*AUDIO_TX_PACKET_SIZE/sizeof(audio_t)){ + len -= USBD_AUDIO_TX_CHANNELS; + usbd_tx_flow--; + }else if(tx_buffer.getSize() - capacity < AUDIO_TX_PACKET_SIZE/sizeof(audio_t)){ + len += USBD_AUDIO_TX_CHANNELS; + usbd_tx_flow++; + } + tx_buffer.read((audio_t*)haudio->audio_tx_transmit, len); + usbd_audio_write((uint8_t*)haudio->audio_tx_transmit, len*sizeof(audio_t)); break; + } #endif #ifdef USE_USBD_MIDI case MIDI_TX_EP: @@ -1333,9 +1350,8 @@ static uint8_t USBD_AUDIO_IsoINIncomplete (USBD_HandleTypeDef *pdev, uint8_t ep haudio->tx_soffn = USB_SOF_NUMBER(); // host has not collected data // let's not increment readhead - // todo: write no more than available data - usbd_audio_write((uint8_t*)tx_buffer.getReadHead(), AUDIO_TX_PACKET_SIZE); -// usbd_audio_tx_callback(haudio->audio_tx_buffer, AUDIO_TX_PACKET_SIZE); + // todo: write same amount of data as last time + usbd_audio_write((uint8_t*)haudio->audio_tx_transmit, AUDIO_TX_PACKET_SIZE); } #endif return USBD_OK; diff --git a/Source/usbd_audio.h b/Source/usbd_audio.h index cb5259df..ac57a367 100644 --- a/Source/usbd_audio.h +++ b/Source/usbd_audio.h @@ -29,22 +29,23 @@ #define AUDIO_OUT_STREAMING_CTRL 0x04 #define AUDIO_RX_SAMPLES_PER_MS (USBD_AUDIO_RX_FREQ / 1000) -#define AUDIO_RX_PACKET_SIZE ((uint16_t)(AUDIO_RX_SAMPLES_PER_MS * USBD_AUDIO_RX_CHANNELS * AUDIO_BYTES_PER_SAMPLE)) -#define AUDIO_RX_MAX_PACKET_SIZE ((uint16_t)(AUDIO_RX_PACKET_SIZE + USBD_AUDIO_RX_CHANNELS * AUDIO_BYTES_PER_SAMPLE)) +#define AUDIO_RX_PACKET_SIZE (AUDIO_RX_SAMPLES_PER_MS * USBD_AUDIO_RX_CHANNELS * AUDIO_BYTES_PER_SAMPLE) +#define AUDIO_RX_MAX_PACKET_SIZE (AUDIO_RX_PACKET_SIZE + USBD_AUDIO_RX_CHANNELS * AUDIO_BYTES_PER_SAMPLE) -#define AUDIO_TX_SAMPLES_PER_MS (USBD_AUDIO_TX_FREQ / 1000) -#define AUDIO_TX_PACKET_SIZE ((uint16_t)(AUDIO_TX_SAMPLES_PER_MS * USBD_AUDIO_TX_CHANNELS * AUDIO_BYTES_PER_SAMPLE)) -#define AUDIO_TX_MAX_PACKET_SIZE ((uint16_t)(AUDIO_TX_PACKET_SIZE + USBD_AUDIO_TX_CHANNELS * AUDIO_BYTES_PER_SAMPLE)) #define AUDIO_FB_PACKET_SIZE 3U +#define AUDIO_TX_SAMPLES_PER_MS (USBD_AUDIO_TX_FREQ / 1000) +#define AUDIO_TX_PACKET_SIZE (AUDIO_TX_SAMPLES_PER_MS * USBD_AUDIO_TX_CHANNELS * AUDIO_BYTES_PER_SAMPLE) +#define AUDIO_TX_MAX_PACKET_SIZE (AUDIO_TX_PACKET_SIZE + USBD_AUDIO_TX_CHANNELS * AUDIO_BYTES_PER_SAMPLE) + /* Number of sub-packets in the audio transfer buffer. */ -#define AUDIO_RX_PACKET_NUM 4 -#define AUDIO_TX_PACKET_NUM 4 +#define AUDIO_RX_PACKET_NUM 3 +#define AUDIO_TX_PACKET_NUM 5 /* Total size of the OUT audio transfer buffer */ -#define AUDIO_RX_TOTAL_BUF_SIZE ((size_t)(AUDIO_RX_PACKET_SIZE * AUDIO_RX_PACKET_NUM)) +#define AUDIO_RX_TOTAL_BUF_SIZE (AUDIO_RX_PACKET_SIZE * AUDIO_RX_PACKET_NUM) /* Total size of the IN transfer buffer */ -#define AUDIO_TX_TOTAL_BUF_SIZE ((size_t)(AUDIO_TX_PACKET_SIZE * AUDIO_TX_PACKET_NUM)) +#define AUDIO_TX_TOTAL_BUF_SIZE (AUDIO_TX_PACKET_SIZE * AUDIO_TX_PACKET_NUM) #define MIDI_TX_PACKET_SIZE 0x40 #define MIDI_RX_PACKET_SIZE 0x40 @@ -126,11 +127,13 @@ typedef struct uint8_t ac_alt_setting, tx_alt_setting, rx_alt_setting, midi_alt_setting; #ifdef USE_USBD_AUDIO_TX uint8_t audio_tx_buffer[AUDIO_TX_TOTAL_BUF_SIZE]; + uint8_t audio_tx_transmit[AUDIO_TX_MAX_PACKET_SIZE]; volatile uint8_t audio_tx_active; volatile uint16_t tx_soffn; #endif #ifdef USE_USBD_AUDIO_RX uint8_t audio_rx_buffer[AUDIO_RX_TOTAL_BUF_SIZE]; + uint8_t audio_rx_transmit[AUDIO_RX_MAX_PACKET_SIZE]; volatile uint8_t audio_rx_active; volatile uint16_t fb_soffn; #endif From 8652f732a403faa3107c5e208dd2180a69c5a1ca Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 30 Sep 2021 02:50:11 +0200 Subject: [PATCH 079/286] use extra transmit buffer for audio rx. change fifo allocations if fb is not used. --- Source/ProgramManager.cpp | 4 +- Source/usbd_audio.cpp | 79 +++++++++++++++++++++++++-------------- Source/usbd_audio.h | 2 +- 3 files changed, 54 insertions(+), 31 deletions(-) diff --git a/Source/ProgramManager.cpp b/Source/ProgramManager.cpp index 34d1fc98..9ad314a6 100644 --- a/Source/ProgramManager.cpp +++ b/Source/ProgramManager.cpp @@ -208,7 +208,7 @@ void setButtonValue(uint8_t ch, uint8_t value){ void onProgramReady(){ ProgramVector* pv = getProgramVector(); #ifdef USE_USBD_AUDIO_TX - if(usbd_tx) // after patch runs: convert wet output to USBD audio + if(usbd_tx) // after patch runs: convert wet output to USBD audio tx usbd_tx_convert(pv->audio_output, pv->audio_blocksize*AUDIO_CHANNELS); #endif #ifdef DEBUG_DWT @@ -217,7 +217,7 @@ void onProgramReady(){ /* Block indefinitely (released by audioCallback) */ ulTaskNotifyTake(pdTRUE, portMAX_DELAY); #ifdef USE_USBD_AUDIO_RX - if(usbd_rx) // before patch runs: convert USBD audio to input + if(usbd_rx) // before patch runs: convert USBD audio rx to input (overwriting ADC) usbd_rx_convert(pv->audio_input, pv->audio_blocksize*AUDIO_CHANNELS); #endif #ifdef DEBUG_DWT diff --git a/Source/usbd_audio.cpp b/Source/usbd_audio.cpp index 6150c0d8..796e4778 100644 --- a/Source/usbd_audio.cpp +++ b/Source/usbd_audio.cpp @@ -19,7 +19,8 @@ #include "message.h" int usbd_tx_flow = 0; -#define FLOW_ASSERT(x, y) if(!x){debugMessage(y, usbd_tx_flow, this->getReadCapacity(), this->getWriteCapacity());} +int usbd_rx_flow = 0; +#define FLOW_ASSERT(x, y) if(!x){debugMessage(y, usbd_rx_flow, usbd_tx_flow, this->getWriteCapacity());} #include "CircularBuffer.h" #include "Codec.h" @@ -30,9 +31,9 @@ CircularBuffer tx_buffer; #define AUDIO_SAMPLE_FREQ(frq) (uint8_t)(frq), (uint8_t)((frq >> 8)), (uint8_t)((frq >> 16)) #define AUDIO_FREQ_FROM_DATA(bytes) ((((uint32_t)((bytes)[2]))<<16)|(((uint32_t)((bytes)[1]))<<8)|(((uint32_t)((bytes)[0])))) #define AUDIO_FREQ_TO_DATA(frq , bytes) do{ \ - (bytes)[0]= (uint8_t)(frq); \ - (bytes)[1]= (uint8_t)(((frq) >> 8)); \ - (bytes)[2]= (uint8_t)(((frq) >> 16)); \ + (bytes)[0] = (uint8_t)(frq); \ + (bytes)[1] = (uint8_t)(((frq) >> 8)); \ + (bytes)[2] = (uint8_t)(((frq) >> 16)); \ }while(0); @@ -1377,44 +1378,56 @@ static uint8_t USBD_AUDIO_IsoOutIncomplete (USBD_HandleTypeDef *pdev, uint8_t e * @param epnum: endpoint index * @retval status */ -static uint8_t USBD_AUDIO_DataOut (USBD_HandleTypeDef *pdev, - uint8_t epnum) -{ +static uint8_t USBD_AUDIO_DataOut (USBD_HandleTypeDef *pdev, uint8_t epnum) { USBD_AUDIO_HandleTypeDef *haudio; haudio = (USBD_AUDIO_HandleTypeDef*) pdev->pClassData; (void)haudio; + switch(epnum){ #ifdef USE_USBD_AUDIO_RX - if(epnum == AUDIO_RX_EP){ - uint32_t len; + case AUDIO_RX_EP:{ if(haudio->audio_rx_active == 0){ + // todo: see if we can move this to AUDIO_OUT_Restart and remove the conditional around rx_active haudio->audio_rx_active = 1; usbd_audio_rx_start_callback(USBD_AUDIO_RX_FREQ, USBD_AUDIO_RX_CHANNELS, &rx_buffer); - len = AUDIO_RX_PACKET_SIZE; + usbd_rx_flow = 0; + rx_buffer.reset(); + rx_buffer.clear(); + rx_buffer.moveWriteHead(AUDIO_RX_PACKET_SIZE/sizeof(audio_t)); #ifdef USE_USBD_RX_FB - /* send first synchro data */ + /* send first explicit feedback data */ get_usb_full_speed_rate(USBD_AUDIO_RX_FREQ, fb_data); - USBD_LL_Transmit(pdev, AUDIO_FB_EP, fb_data, 3U); + USBD_LL_Transmit(pdev, AUDIO_FB_EP, fb_data, AUDIO_FB_PACKET_SIZE); #endif - }else{ - len = USBD_LL_GetRxDataSize(pdev, epnum); - rx_buffer.moveWriteHead(len/sizeof(audio_t)); } - // len = usbd_audio_rx_callback(haudio->audio_rx_buffer, len); - // len = std::min(rx_buffer.getWriteCapacity(), AUDIO_RX_PACKET_SIZE); - len = AUDIO_RX_PACKET_SIZE; // todo: ^ + size_t len = USBD_LL_GetRxDataSize(pdev, epnum); + rx_buffer.write((audio_t*)haudio->audio_rx_transmit, len/sizeof(audio_t)); + // decide if we should request one set of samples more or less than usual + len = AUDIO_RX_PACKET_SIZE/sizeof(audio_t); + size_t capacity = rx_buffer.getWriteCapacity(); + capacity += codec.getSampleCounter(); + if(capacity < AUDIO_RX_PACKET_SIZE/sizeof(audio_t)){ + len -= USBD_AUDIO_RX_CHANNELS; + usbd_rx_flow--; + }else if(rx_buffer.getSize() - capacity < 2*AUDIO_RX_PACKET_SIZE/sizeof(audio_t)){ + len += USBD_AUDIO_RX_CHANNELS; + usbd_rx_flow++; + } /* Prepare Out endpoint to receive next audio packet */ - USBD_LL_PrepareReceive(pdev, AUDIO_RX_EP, (uint8_t*)rx_buffer.getWriteHead(), len); + USBD_LL_PrepareReceive(pdev, AUDIO_RX_EP, (uint8_t*)haudio->audio_rx_transmit, len); + break; } #endif /* USE_USBD_AUDIO_RX */ #ifdef USE_USBD_MIDI - if(epnum == MIDI_RX_EP){ + case MIDI_RX_EP:{ /* Forward data to midi callback */ uint32_t len = USBD_LL_GetRxDataSize(pdev, epnum); usbd_midi_rx(haudio->midi_rx_buffer, len); /* Prepare Out endpoint to receive next packet */ USBD_LL_PrepareReceive(pdev, MIDI_RX_EP, haudio->midi_rx_buffer, MIDI_RX_PACKET_SIZE); + break; } #endif + } return USBD_OK; } @@ -1457,14 +1470,11 @@ static void AUDIO_OUT_Restart(USBD_HandleTypeDef* pdev) USBD_LL_FlushEP(pdev, AUDIO_RX_EP); /* Prepare Out endpoint to receive first audio packet */ - // USBD_LL_PrepareReceive(pdev, AUDIO_RX_EP, haudio->audio_rx_buffer, AUDIO_RX_PACKET_SIZE); - // size_t len = std::min(rx_buffer.getWriteCapacity(), AUDIO_RX_PACKET_SIZE); - size_t len = AUDIO_RX_PACKET_SIZE; // todo: ^ - USBD_LL_PrepareReceive(pdev, AUDIO_RX_EP, (uint8_t*)rx_buffer.getWriteHead(), len); + USBD_LL_PrepareReceive(pdev, AUDIO_RX_EP, (uint8_t*)haudio->audio_rx_transmit, AUDIO_RX_PACKET_SIZE); /* get_usb_full_speed_rate(haudio->frequency, fb_data); // reset to new frequency */ - /* usbd_audio_rx_start_callback(USBD_AUDIO_RX_FREQ, USBD_AUDIO_RX_CHANNELS); */ + /* usbd_audio_rx_start_callback(USBD_AUDIO_RX_FREQ, USBD_AUDIO_RX_CHANNELS, &rx_buffer); */ /* ((USBD_AUDIO_ItfTypeDef*)pdev->pUserData)->Init(haudio->frequency, VOL_PERCENT(haudio->volume), 0); */ } #endif /* USE_USBD_AUDIO_RX */ @@ -1495,22 +1505,35 @@ uint8_t USBD_AUDIO_RegisterInterface (USBD_HandleTypeDef *pdev, } uint8_t USBD_AUDIO_SetFiFos(PCD_HandleTypeDef *hpcd){ -#if defined USE_USBD_AUDIO_RX && defined USE_USBD_AUDIO_TX && defined USE_USBD_MIDI +#if defined USE_USBD_AUDIO_RX && defined USE_USBD_AUDIO_TX && defined USE_USBD_MIDI && defined USE_USBD_RX_FB HAL_PCDEx_SetRxFiFo(hpcd, 0x80); HAL_PCDEx_SetTxFiFo(hpcd, 0, 0x20); HAL_PCDEx_SetTxFiFo(hpcd, 1, 0x40); HAL_PCDEx_SetTxFiFo(hpcd, 2, 0x40); HAL_PCDEx_SetTxFiFo(hpcd, 3, 0x20); -#elif defined USE_USBD_AUDIO_RX && defined USE_USBD_AUDIO_TX +#elif defined USE_USBD_AUDIO_RX && defined USE_USBD_AUDIO_TX && defined USE_USBD_RX_FB HAL_PCDEx_SetRxFiFo(hpcd, 0x80); HAL_PCDEx_SetTxFiFo(hpcd, 0, 0x20); HAL_PCDEx_SetTxFiFo(hpcd, 1, 0x60); HAL_PCDEx_SetTxFiFo(hpcd, 2, 0x40); -#elif defined USE_USBD_AUDIO_RX && defined USE_USBD_MIDI +#elif defined USE_USBD_AUDIO_RX && defined USE_USBD_MIDI && defined USE_USBD_RX_FB HAL_PCDEx_SetRxFiFo(hpcd, 0x80); HAL_PCDEx_SetTxFiFo(hpcd, 0, 0x20); HAL_PCDEx_SetTxFiFo(hpcd, 1, 0x60); HAL_PCDEx_SetTxFiFo(hpcd, 2, 0x40); +#elif defined USE_USBD_AUDIO_RX && defined USE_USBD_AUDIO_TX && defined USE_USBD_MIDI + HAL_PCDEx_SetRxFiFo(hpcd, 0x80); + HAL_PCDEx_SetTxFiFo(hpcd, 0, 0x20); + HAL_PCDEx_SetTxFiFo(hpcd, 1, 0x60); + HAL_PCDEx_SetTxFiFo(hpcd, 2, 0x40); +#elif defined USE_USBD_AUDIO_RX && defined USE_USBD_AUDIO_TX + HAL_PCDEx_SetRxFiFo(hpcd, 0xa0); + HAL_PCDEx_SetTxFiFo(hpcd, 0, 0x20); + HAL_PCDEx_SetTxFiFo(hpcd, 1, 0x80); +#elif defined USE_USBD_AUDIO_RX && defined USE_USBD_MIDI + HAL_PCDEx_SetRxFiFo(hpcd, 0xa0); + HAL_PCDEx_SetTxFiFo(hpcd, 0, 0x20); + HAL_PCDEx_SetTxFiFo(hpcd, 1, 0x80); #elif defined USE_USBD_AUDIO_TX && defined USE_USBD_MIDI HAL_PCDEx_SetRxFiFo(hpcd, 0x80); HAL_PCDEx_SetTxFiFo(hpcd, 0, 0x20); diff --git a/Source/usbd_audio.h b/Source/usbd_audio.h index ac57a367..0657a1b3 100644 --- a/Source/usbd_audio.h +++ b/Source/usbd_audio.h @@ -39,7 +39,7 @@ #define AUDIO_TX_MAX_PACKET_SIZE (AUDIO_TX_PACKET_SIZE + USBD_AUDIO_TX_CHANNELS * AUDIO_BYTES_PER_SAMPLE) /* Number of sub-packets in the audio transfer buffer. */ -#define AUDIO_RX_PACKET_NUM 3 +#define AUDIO_RX_PACKET_NUM 5 #define AUDIO_TX_PACKET_NUM 5 /* Total size of the OUT audio transfer buffer */ From 8bb49a63112ff69544a5fb42e9476b678d2306c8 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 30 Sep 2021 06:01:55 +0200 Subject: [PATCH 080/286] updates to explicit fb mode (not sending fb synchro data) --- Genius/Inc/hardware.h | 4 +- Genius/Inc/usbd_conf.h | 4 +- Genius/Makefile | 2 +- Genius/Src/Genius.cpp | 19 +++++ Source/Codec.cpp | 170 ++------------------------------------ Source/Graphics.cpp | 2 +- Source/ProgramManager.cpp | 13 +-- Source/usbd_audio.cpp | 85 +++++++++++-------- 8 files changed, 86 insertions(+), 213 deletions(-) diff --git a/Genius/Inc/hardware.h b/Genius/Inc/hardware.h index f098a386..26fa7332 100644 --- a/Genius/Inc/hardware.h +++ b/Genius/Inc/hardware.h @@ -44,8 +44,9 @@ #define ARM_CYCLES_PER_SAMPLE (480000000/AUDIO_SAMPLINGRATE) /* 480MHz / 48kHz */ #define USE_USBD_AUDIO -#define USE_USBD_AUDIO_TX // microphone +#define USE_USBD_RX_FB #define USE_USBD_AUDIO_RX // speaker +#define USE_USBD_AUDIO_TX // microphone #define USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS #define USBH_HANDLE hUsbHostHS @@ -58,6 +59,7 @@ #define USE_UART_MIDI_TX #define UART_MIDI_HANDLE huart5 #define UART_MIDI_RX_BUFFER_SIZE 256 + // Digital bus /* #define USE_DIGITALBUS */ /* #define DIGITAL_BUS_ENABLED 1 */ diff --git a/Genius/Inc/usbd_conf.h b/Genius/Inc/usbd_conf.h index 7ab14be8..b06311a0 100644 --- a/Genius/Inc/usbd_conf.h +++ b/Genius/Inc/usbd_conf.h @@ -64,13 +64,13 @@ */ /*---------- -----------*/ -#define USBD_MAX_NUM_INTERFACES 1U +#define USBD_MAX_NUM_INTERFACES 5U /*---------- -----------*/ #define USBD_MAX_NUM_CONFIGURATION 1U /*---------- -----------*/ #define USBD_MAX_STR_DESC_SIZ 512U /*---------- -----------*/ -#define USBD_DEBUG_LEVEL 0U +#define USBD_DEBUG_LEVEL DEBUG_LEVEL /*---------- -----------*/ #define USBD_LPM_ENABLED 0U /*---------- -----------*/ diff --git a/Genius/Makefile b/Genius/Makefile index 3f0f3365..2c6d8984 100644 --- a/Genius/Makefile +++ b/Genius/Makefile @@ -9,7 +9,7 @@ CPP_SRC = $(wildcard Src/*.cpp) C_SRC += $(OPENWARE)/Source/sdram.c C_SRC += $(OPENWARE)/Source/cs4272.c C_SRC += $(OPENWARE)/Source/ssd1309.c -C_SRC += $(OPENWARE)/Source/usbd_audio.c +CPP_SRC += $(OPENWARE)/Source/usbd_audio.cpp CPP_SRC += $(OPENWARE)/Source/uart.cpp CPP_SRC += $(OPENWARE)/Source/uart_midi.cpp CPP_SRC += $(OPENWARE)/Source/bus.cpp diff --git a/Genius/Src/Genius.cpp b/Genius/Src/Genius.cpp index 69f35582..774fa077 100644 --- a/Genius/Src/Genius.cpp +++ b/Genius/Src/Genius.cpp @@ -2,6 +2,25 @@ #include "Graphics.h" +void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height){ + extern int usbd_tx_flow; + extern int usbd_rx_flow; + extern int usbd_tx_capacity; + extern int usbd_rx_capacity; + ScreenBuffer& screen = graphics.screen; + graphics.params.drawTitle(screen); + graphics.params.drawMessage(26, screen); + + screen.setTextSize(1); + screen.print(2, 36, "rx "); + screen.print(usbd_rx_flow); + screen.print(" / "); + screen.print(usbd_rx_capacity); + screen.print(2, 46, "tx "); + screen.print(usbd_tx_flow); + screen.print(" / "); + screen.print(usbd_tx_capacity); +} extern "C"{ #if 0 diff --git a/Source/Codec.cpp b/Source/Codec.cpp index cb6d9bc3..3b65f44d 100644 --- a/Source/Codec.cpp +++ b/Source/Codec.cpp @@ -33,160 +33,6 @@ extern "C" { #ifdef USE_USBD_AUDIO #include "usbd_audio.h" -#if 0 - -CircularBuffer* volatile usbd_rx = NULL; -CircularBuffer* volatile usbd_tx = NULL; -static uint32_t usbd_audio_rx_count = 0; - -// static void update_rx_read_index(){ -// #if defined USE_CS4271 || defined USE_PCM3168A -// // NDTR: the number of remaining data units in the current DMA Stream transfer. -// // use HDMA_TX position in case we have stopped HDMA_RX -// // todo: if(wet) then read position is incremented by audioCallback ? -// size_t pos = CODEC_BUFFER_SIZE - __HAL_DMA_GET_COUNTER(&HDMA_TX); -// // // mask to full frame (assumes AUDIO_CHANNELS is a power of two) -// // audio_rx_buffer.setReadIndex(pos & ~(AUDIO_CHANNELS-1)); -// audio_rx_buffer.setReadIndex(pos); -// #endif -// } - -// static void update_tx_write_index(){ -// #if defined USE_CS4271 || defined USE_PCM3168A -// // NDTR: the number of remaining data units in the current DMA Stream transfer. -// size_t pos = CODEC_BUFFER_SIZE - __HAL_DMA_GET_COUNTER(&HDMA_TX); -// // // mask to full frame (assumes AUDIO_CHANNELS is a power of two) -// // audio_tx_buffer.setWriteIndex(pos & ~(AUDIO_CHANNELS-1)); -// audio_tx_buffer.setWriteIndex(pos); -// #endif -// } - -void usbd_audio_tx_start_callback(size_t rate, uint8_t channels, void* cb){ - usbd_tx = (CircularBuffer*)cb; -#ifdef DEBUG - printf("start tx %u %u %u\n", rate, channels, usbd_tx->getSize()); -#endif -#if 0 && defined USE_USBD_AUDIO_TX && USBD_AUDIO_TX_CHANNELS > 0 - update_tx_write_index(); - size_t pos = audio_tx_buffer.getWriteIndex(); // not always aligned to AUDIO_CHANNELS samples - // mask to full frame (assumes AUDIO_CHANNELS is a power of two) - pos &= ~(AUDIO_CHANNELS-1); - // position read head at one USB transfer block back from write head - pos -= AUDIO_CHANNELS*rate/1000; - // // position read head at half a ringbuffer distance from write head - // pos -= audio_tx_buffer.getSize()/2; - audio_tx_buffer.setReadIndex(pos); - - // // set read head at half a ringbuffer distance from write head - // update_tx_write_index(); - // size_t pos = audio_tx_buffer.getWriteIndex(); - // size_t len = audio_tx_buffer.getSize(); - // pos = (pos + len/2) % len; - // pos = (pos/AUDIO_CHANNELS)*AUDIO_CHANNELS; // round down to nearest frame - // audio_tx_buffer.setReadIndex(pos); -#ifdef DEBUG - printf("start tx %u %u %u\n", rate, channels, pos); -#endif -#endif -} - -static int32_t usbd_audio_tx_flow = 0; -// expect a 1 in 10k sample underflow (-0.01% sample accuracy) -void usbd_audio_tx_callback(uint8_t* data, size_t len){ -#if 0 && defined USE_USBD_AUDIO_TX && USBD_AUDIO_TX_CHANNELS > 0 - update_tx_write_index(); - size_t available = audio_tx_buffer.getReadCapacity()/AUDIO_CHANNELS; - size_t blocksize = len / (USBD_AUDIO_TX_CHANNELS*AUDIO_BYTES_PER_SAMPLE); - if(available < blocksize){ - usbd_audio_tx_flow += blocksize-available; - blocksize = available; - len = blocksize*USBD_AUDIO_TX_CHANNELS*AUDIO_BYTES_PER_SAMPLE; - } - audio_t* dst = (audio_t*)data; - while(blocksize--){ - int32_t* src = audio_tx_buffer.getReadHead(); - size_t ch = USBD_AUDIO_TX_CHANNELS; - while(ch--) - *dst++ = AUDIO_INT32_TO_SAMPLE(*src++); // shift, round, dither, clip, truncate, bitswap - audio_tx_buffer.moveReadHead(AUDIO_CHANNELS); - } - usbd_audio_write(data, len); -#endif -} - -void usbd_audio_tx_stop_callback(){ - usbd_tx = NULL; -#ifdef DEBUG - printf("stop tx\n"); -#endif -} - -void usbd_audio_rx_start_callback(size_t rate, uint8_t channels, void* cb){ - usbd_rx = (CircularBuffer*)cb; - usbd_rx->reset(); - usbd_rx->clear(); - usbd_rx->moveReadHead(usbd_rx->getSize()/2); - usbd_audio_rx_count = 0; - // HAL_SAI_DMAStop(&HSAI_RX); - // HAL_SAI_DMAPause(&HSAI_RX); -#ifdef DEBUG - printf("start rx %u %u %u\n", rate, channels, usbd_rx->getSize()); -#endif -} - -void usbd_audio_rx_stop_callback(){ - usbd_rx = NULL; - // HAL_SAI_Transmit_DMA(&HSAI_RX, (uint8_t*)codec_txbuf, codec_blocksize*AUDIO_CHANNELS*2); - // HAL_SAI_DMAResume(&HSAI_RX); -#ifdef DEBUG - printf("stop rx\n"); -#endif -} - -static int32_t usbd_audio_rx_flow = 0; -size_t usbd_audio_rx_callback(uint8_t* data, size_t len){ -#if 0 && defined USE_USBD_AUDIO_RX && USBD_AUDIO_RX_CHANNELS > 0 - // copy audio to codec_txbuf aka audio_rx_buffer - update_rx_read_index(); - audio_t* src = (audio_t*)data; - size_t blocksize = len / (USBD_AUDIO_RX_CHANNELS*AUDIO_BYTES_PER_SAMPLE); - size_t available = audio_rx_buffer.getWriteCapacity()/AUDIO_CHANNELS; - if(available < blocksize){ - usbd_audio_rx_flow += blocksize-available; - // skip some frames start and end of this block - // src += (blocksize - available)*USBD_AUDIO_RX_CHANNELS/2; - blocksize = available; - len = blocksize*USBD_AUDIO_RX_CHANNELS*AUDIO_BYTES_PER_SAMPLE; - } - while(blocksize--){ - int32_t* dst = audio_rx_buffer.getWriteHead(); - size_t ch = USBD_AUDIO_RX_CHANNELS; - while(ch--) - *dst++ = AUDIO_SAMPLE_TO_INT32(*src++); - // should we leave in place or zero out any remaining channels? - memset(dst, 0, (AUDIO_CHANNELS-USBD_AUDIO_RX_CHANNELS)*sizeof(int32_t)); - audio_rx_buffer.moveWriteHead(AUDIO_CHANNELS); - } - // available = audio_rx_buffer.getWriteCapacity()*AUDIO_BYTES_PER_SAMPLE*USBD_AUDIO_RX_CHANNELS/AUDIO_CHANNELS; - // if(available < AUDIO_RX_PACKET_SIZE) - // return available; - usbd_audio_rx_count += len; -#endif - return len; -} - -/* Get number of samples transmitted since previous request */ -uint32_t usbd_audio_get_rx_count(){ - return 0; - // // NDTR: the number of remaining data units in the current DMA Stream transfer. - // size_t pos = CODEC_BUFFER_SIZE - __HAL_DMA_GET_COUNTER(&HDMA_TX); - // pos += usbd_audio_rx_count; - // usbd_audio_rx_count = 0; - // return pos / AUDIO_CHANNELS; -} - -#endif - void usbd_audio_mute_callback(int16_t gain){ // todo! } @@ -433,20 +279,14 @@ void Codec::resume(){ HAL_SAI_DMAResume(&HSAI_TX); } +/** Get the number of individual samples (across channels) that have already been + * transferred to/from the codec in this block + */ size_t Codec::getSampleCounter(){ - // does not work: always returns values <= 5 - // return DMA_GetCurrDataCounter(DMA2_Stream0); - // // NDTR: the number of remaining data units in the current DMA Stream transfer. - return CODEC_BUFFER_SIZE - __HAL_DMA_GET_COUNTER(&HDMA_TX); + // read NDTR: the number of remaining data units in the current DMA Stream transfer. + return (CODEC_BUFFER_SIZE - __HAL_DMA_GET_COUNTER(&HDMA_TX)) % (codec_blocksize*AUDIO_CHANNELS); // return (DWT->CYCCNT)/ARM_CYCLES_PER_SAMPLE; } -extern "C" { - -// void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai){ -// } - -} - #endif /* USE_PCM3168A */ diff --git a/Source/Graphics.cpp b/Source/Graphics.cpp index 85e7d591..446d36ba 100644 --- a/Source/Graphics.cpp +++ b/Source/Graphics.cpp @@ -40,7 +40,7 @@ Graphics::Graphics() : { } -void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height){ +__weak void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height){ graphics.params.drawTitle(graphics.screen); graphics.params.drawMessage(26, graphics.screen); } diff --git a/Source/ProgramManager.cpp b/Source/ProgramManager.cpp index 9ad314a6..3af5061d 100644 --- a/Source/ProgramManager.cpp +++ b/Source/ProgramManager.cpp @@ -36,11 +36,10 @@ static uint32_t usbd_audio_rx_count = 0; /* Get number of samples transmitted since previous request */ uint32_t usbd_audio_get_rx_count(){ - return 0; - // // NDTR: the number of remaining data units in the current DMA Stream transfer. - // size_t pos = codec.getSampleCounter() + usbd_audio_rx_count; - // usbd_audio_rx_count = 0; - // return pos / AUDIO_CHANNELS; + // return 0; + uint32_t pos = usbd_audio_rx_count + codec.getSampleCounter(); + usbd_audio_rx_count = 0; + return pos; } void usbd_audio_tx_start_callback(size_t rate, uint8_t channels, void* cb){ @@ -744,10 +743,6 @@ void ProgramManager::saveToFlash(uint8_t sector, void* address, uint32_t length) } uint16_t getSampleCounter(){ - // does not work: always returns values <= 5 - // return DMA_GetCurrDataCounter(DMA2_Stream0); - // // NDTR: the number of remaining data units in the current DMA Stream transfer. - // size_t pos = CODEC_BUFFER_SIZE - __HAL_DMA_GET_COUNTER(&HDMA_TX); // return (DWT->CYCCNT)/ARM_CYCLES_PER_SAMPLE; return codec.getSampleCounter() / AUDIO_CHANNELS; } diff --git a/Source/usbd_audio.cpp b/Source/usbd_audio.cpp index 796e4778..4320cf21 100644 --- a/Source/usbd_audio.cpp +++ b/Source/usbd_audio.cpp @@ -20,6 +20,8 @@ #include "message.h" int usbd_tx_flow = 0; int usbd_rx_flow = 0; +int usbd_tx_capacity = 0; +int usbd_rx_capacity = 0; #define FLOW_ASSERT(x, y) if(!x){debugMessage(y, usbd_rx_flow, usbd_tx_flow, this->getWriteCapacity());} #include "CircularBuffer.h" #include "Codec.h" @@ -98,20 +100,19 @@ USBD_ClassTypeDef USBD_AUDIO = #ifdef USE_USBD_RX_FB -#define FB_REFRESH 4 /* Feedback refresh rate 2^(10-FB_REFRESH) */ -#define FB_RATE (1<<(10-FB_REFRESH)) +#define FB_REFRESH 4 /* Feedback refresh rate */ +#define FB_RATE (1<> 2; - buf[1] = freq >> 10; - buf[2] = freq >> 18; + usbd_rx_capacity = rate; + // convert sample rate to 10.14 format + rate = (rate / 1000.0f) * (1<<14); + AUDIO_FREQ_TO_DATA(rate, buf); + // usbd_rx_capacity = rate - 786432; } uint8_t fb_data[3]; @@ -446,7 +447,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x09, /* bLength */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType */ AUDIO_RX_EP, /* bEndpointAddress 1 out endpoint*/ - USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_ADAPT|USBD_EP_ATTR_ISOC_DATA, /* bmAttributes */ + USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_ADAPT, /* bmAttributes */ LOBYTE(AUDIO_RX_MAX_PACKET_SIZE), /* wMaxPacketSize in bytes */ HIBYTE(AUDIO_RX_MAX_PACKET_SIZE), 0x01, /* bInterval */ @@ -457,12 +458,12 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x09, /* bLength */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType */ AUDIO_RX_EP, /* bEndpointAddress 1 out endpoint*/ - USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_ASYNC|USBD_EP_ATTR_ISOC_DATA, /* bmAttributes */ - LOBYTE(AUDIO_RX_MAX_PACKET_SIZE), /* wMaxPacketSize in bytes */ + USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_ASYNC, /* bmAttributes */ + LOBYTE(AUDIO_RX_MAX_PACKET_SIZE), /* wMaxPacketSize in bytes */ HIBYTE(AUDIO_RX_MAX_PACKET_SIZE), 0x01, /* bInterval */ 0x00, /* bRefresh */ - 0, /* bSynchAddress */ + 0x00, /* bSynchAddress */ /* 09 byte */ #endif @@ -481,12 +482,12 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x09, /* bLength */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType */ AUDIO_FB_EP, /* bEndpointAddress */ - USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_NOSYNC|USBD_EP_ATTR_ISOC_FB, /* bmAttributes */ + USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_NOSYNC, /* bmAttributes */ LOBYTE(AUDIO_FB_PACKET_SIZE), /* wMaxPacketSize */ HIBYTE(AUDIO_FB_PACKET_SIZE), - 0x01, /* bInterval 1ms */ + 0x01, /* bInterval : Must be set to 1 */ FB_REFRESH, /* bRefresh SOF_RATE */ - 0x00, /* bSynchAddress */ + 0x00, /* bSynchAddress : Must be reset to zero */ /* 09 byte*/ #endif @@ -544,8 +545,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x09, // Size of the descriptor, in bytes (bLength) 0x05, // ENDPOINT descriptor (bDescriptorType) AUDIO_TX_EP, // IN Endpoint 1. (bEndpointAddress) - // USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_SYNC, // bmAttributes - USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_ASYNC|USBD_EP_ATTR_ISOC_DATA, // bmAttributes + USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_ASYNC, // bmAttributes // USBD_EP_TYPE_ISOC, // bmAttributes (device not recognised in Windows if sync or async) LOBYTE(AUDIO_TX_MAX_PACKET_SIZE), // wMaxPacketSize in bytes HIBYTE(AUDIO_TX_MAX_PACKET_SIZE), @@ -1012,7 +1012,7 @@ static uint8_t USBD_AUDIO_DataIn (USBD_HandleTypeDef *pdev, #ifdef USE_USBD_RX_FB case AUDIO_FB_EP: haudio->fb_soffn = USB_SOF_NUMBER(); - USBD_LL_Transmit(pdev, AUDIO_FB_EP, (uint8_t*)fb_data, 3U); + USBD_LL_Transmit(pdev, AUDIO_FB_EP, fb_data, AUDIO_FB_PACKET_SIZE); break; #endif #ifdef USE_USBD_AUDIO_TX @@ -1022,6 +1022,7 @@ static uint8_t USBD_AUDIO_DataIn (USBD_HandleTypeDef *pdev, size_t len = AUDIO_TX_PACKET_SIZE/sizeof(audio_t); size_t capacity = tx_buffer.getReadCapacity(); capacity += codec.getSampleCounter(); + usbd_tx_capacity = capacity; if(capacity < 2*AUDIO_TX_PACKET_SIZE/sizeof(audio_t)){ len -= USBD_AUDIO_TX_CHANNELS; usbd_tx_flow--; @@ -1300,14 +1301,27 @@ static uint8_t USBD_AUDIO_SOF (USBD_HandleTypeDef *pdev) { haudio = (USBD_AUDIO_HandleTypeDef*)pdev->pClassData; #ifdef USE_USBD_RX_FB static uint32_t sof_count = 0; - if(haudio->audio_rx_active && ++sof_count == FB_RATE){ - sof_count = 0; + if(haudio->audio_rx_active){ + if(++sof_count == FB_RATE){ + sof_count = 0; // number of samples since last request (or 0 if unknown) - uint32_t samples = usbd_audio_get_rx_count(); - if(samples != 0){ - samples <<= (14 - FB_REFRESH); // convert to n.14 format - AUDIO_FREQ_TO_DATA(samples, fb_data); // pack into 3 bytes + + // size_t capacity = rx_buffer.getWriteCapacity(); + // capacity += codec.getSampleCounter(); + + uint32_t samples = usbd_audio_get_rx_count(); // across channels and fb rate + if(samples != 0){ + // if(abs(samples - USBD_AUDIO_RX_FREQ*FB_RATE*USBD_AUDIO_RX_CHANNELS/1000) < 8){ + samples * (1<<14); // convert to n.14 format + samples /= USBD_AUDIO_RX_CHANNELS * FB_RATE; + usbd_rx_capacity = samples - 786432; + AUDIO_FREQ_TO_DATA(samples, fb_data); // pack into 3 bytes (todo: make this atomic) + // } + } + // USBD_LL_Transmit(pdev, AUDIO_FB_EP, fb_data, AUDIO_FB_PACKET_SIZE); } + // }else{ + // sof_count = 0; } #endif return USBD_OK; @@ -1339,7 +1353,7 @@ static uint8_t USBD_AUDIO_IsoINIncomplete (USBD_HandleTypeDef *pdev, uint8_t ep USB_CLEAR_INCOMPLETE_IN_EP(AUDIO_FB_EP); USBD_LL_FlushEP(pdev, AUDIO_FB_EP); haudio->fb_soffn = USB_SOF_NUMBER(); - USBD_LL_Transmit(pdev, AUDIO_FB_EP, fb_data, 3U); + USBD_LL_Transmit(pdev, AUDIO_FB_EP, fb_data, AUDIO_FB_PACKET_SIZE); } #endif @@ -1393,27 +1407,24 @@ static uint8_t USBD_AUDIO_DataOut (USBD_HandleTypeDef *pdev, uint8_t epnum) { rx_buffer.reset(); rx_buffer.clear(); rx_buffer.moveWriteHead(AUDIO_RX_PACKET_SIZE/sizeof(audio_t)); -#ifdef USE_USBD_RX_FB - /* send first explicit feedback data */ - get_usb_full_speed_rate(USBD_AUDIO_RX_FREQ, fb_data); - USBD_LL_Transmit(pdev, AUDIO_FB_EP, fb_data, AUDIO_FB_PACKET_SIZE); -#endif } size_t len = USBD_LL_GetRxDataSize(pdev, epnum); rx_buffer.write((audio_t*)haudio->audio_rx_transmit, len/sizeof(audio_t)); - // decide if we should request one set of samples more or less than usual len = AUDIO_RX_PACKET_SIZE/sizeof(audio_t); +#if 1 + // in asynch / adaptive mode, we have no control over the number of samples transferred + // decide if we should request one set of samples more or less than usual size_t capacity = rx_buffer.getWriteCapacity(); capacity += codec.getSampleCounter(); + // usbd_rx_capacity = capacity; if(capacity < AUDIO_RX_PACKET_SIZE/sizeof(audio_t)){ - len -= USBD_AUDIO_RX_CHANNELS; usbd_rx_flow--; }else if(rx_buffer.getSize() - capacity < 2*AUDIO_RX_PACKET_SIZE/sizeof(audio_t)){ - len += USBD_AUDIO_RX_CHANNELS; usbd_rx_flow++; } +#endif /* Prepare Out endpoint to receive next audio packet */ - USBD_LL_PrepareReceive(pdev, AUDIO_RX_EP, (uint8_t*)haudio->audio_rx_transmit, len); + USBD_LL_PrepareReceive(pdev, AUDIO_RX_EP, (uint8_t*)haudio->audio_rx_transmit, len*sizeof(audio_t)); break; } #endif /* USE_USBD_AUDIO_RX */ @@ -1472,6 +1483,12 @@ static void AUDIO_OUT_Restart(USBD_HandleTypeDef* pdev) /* Prepare Out endpoint to receive first audio packet */ USBD_LL_PrepareReceive(pdev, AUDIO_RX_EP, (uint8_t*)haudio->audio_rx_transmit, AUDIO_RX_PACKET_SIZE); +#ifdef USE_USBD_RX_FB + /* send first explicit feedback data */ + get_usb_full_speed_rate(USBD_AUDIO_RX_FREQ, fb_data); + USBD_LL_Transmit(pdev, AUDIO_FB_EP, fb_data, AUDIO_FB_PACKET_SIZE); +#endif + /* get_usb_full_speed_rate(haudio->frequency, fb_data); // reset to new frequency */ /* usbd_audio_rx_start_callback(USBD_AUDIO_RX_FREQ, USBD_AUDIO_RX_CHANNELS, &rx_buffer); */ From e0a740f9c11b2d103845a24ecffbd74226565e0a Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 30 Sep 2021 11:34:35 +0200 Subject: [PATCH 081/286] added optional Feature Unit inclusion, ensure SOF callback is enabled --- Genius/Genius.ioc | 7 +-- Genius/Src/main.c | 6 +-- Genius/Src/usbd_conf.c | 2 +- Source/usbd_audio.cpp | 111 ++++++++++++++++++++++------------------- Witch/Inc/hardware.h | 3 +- Witch/Src/usbd_conf.c | 2 +- 6 files changed, 72 insertions(+), 59 deletions(-) diff --git a/Genius/Genius.ioc b/Genius/Genius.ioc index fd3d7f3f..6848334f 100644 --- a/Genius/Genius.ioc +++ b/Genius/Genius.ioc @@ -100,7 +100,7 @@ RCC.APB1TimFreq_Value=84000000 RCC.LPUART1Freq_Value=120000000 Dma.USART2_TX.7.SyncSignalID=NONE FMC.RowCycleDelay1=6 -USB_OTG_FS.IPParameters=VirtualMode +USB_OTG_FS.IPParameters=VirtualMode,Sof_enable PB13.Mode=Asynchronous PD15.Signal=FMC_D1_DA1 RCC.PLLSAIQCLKFreq_Value=50000000 @@ -432,7 +432,7 @@ board=Player RCC.VCOOutputFreq_Value=336000000 PB15.Mode=Host_FS RCC.UART4Freq_Value=42000000 -MxCube.Version=6.2.0 +MxCube.Version=6.2.1 RCC.FDCANFreq_Value=48000000 PE5.Mode=SAI_A_AsyncSlave RCC.ADCFreq_Value=30000000 @@ -442,6 +442,7 @@ PD4.GPIOParameters=GPIO_Label VP_SYS_VS_Systick.Mode=SysTick TIM6.TIM_MasterOutputTrigger=TIM_TRGO_UPDATE SH.FMC_D12_DA12.0=FMC_D12,sd-16b-d1 +USB_OTG_FS.Sof_enable=ENABLE PF1.Signal=FMC_A1 SH.FMC_D11_DA11.ConfNb=1 RCC.UART5Freq_Value=42000000 @@ -540,7 +541,7 @@ RCC.DIVM1=5 UART5.DMADisableonRxErrorParam=UART_ADVFEATURE_DMA_DISABLEONRXERROR Dma.ADC1.3.Instance=DMA1_Stream0 Dma.USART2_RX.6.EventEnable=DISABLE -MxDb.Version=DB.6.0.20 +MxDb.Version=DB.6.0.21 PA1.GPIOParameters=GPIO_Label Dma.UART5_RX.4.Direction=DMA_PERIPH_TO_MEMORY SH.FMC_D15_DA15.ConfNb=1 diff --git a/Genius/Src/main.c b/Genius/Src/main.c index b6d5b3f5..5427a30b 100644 --- a/Genius/Src/main.c +++ b/Genius/Src/main.c @@ -184,8 +184,8 @@ int main(void) MX_ADC1_Init(); MX_DAC1_Init(); MX_UART5_Init(); - /* MX_USB_OTG_FS_PCD_Init(); */ - /* MX_USB_OTG_HS_HCD_Init(); */ + MX_USB_OTG_FS_PCD_Init(); + MX_USB_OTG_HS_HCD_Init(); /* USER CODE BEGIN 2 */ HAL_SAI_DeInit(&hsai_BlockA1); HAL_SAI_DeInit(&hsai_BlockB1); @@ -873,7 +873,7 @@ static void MX_USB_OTG_FS_PCD_Init(void) hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; - hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; + hpcd_USB_OTG_FS.Init.Sof_enable = ENABLE; hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; hpcd_USB_OTG_FS.Init.battery_charging_enable = ENABLE; diff --git a/Genius/Src/usbd_conf.c b/Genius/Src/usbd_conf.c index eabadcf8..ebe07ef9 100644 --- a/Genius/Src/usbd_conf.c +++ b/Genius/Src/usbd_conf.c @@ -277,7 +277,7 @@ USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; hpcd_USB_OTG_FS.Init.phy_itface = USB_OTG_EMBEDDED_PHY; - hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; + hpcd_USB_OTG_FS.Init.Sof_enable = ENABLE; hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; hpcd_USB_OTG_FS.Init.battery_charging_enable = ENABLE; diff --git a/Source/usbd_audio.cpp b/Source/usbd_audio.cpp index 4320cf21..c332d96f 100644 --- a/Source/usbd_audio.cpp +++ b/Source/usbd_audio.cpp @@ -22,7 +22,7 @@ int usbd_tx_flow = 0; int usbd_rx_flow = 0; int usbd_tx_capacity = 0; int usbd_rx_capacity = 0; -#define FLOW_ASSERT(x, y) if(!x){debugMessage(y, usbd_rx_flow, usbd_tx_flow, this->getWriteCapacity());} +#define FLOW_ASSERT(x, y) if(!(x)){debugMessage(y, usbd_rx_flow, usbd_tx_flow, this->getWriteCapacity());} #include "CircularBuffer.h" #include "Codec.h" @@ -178,7 +178,11 @@ uint8_t fb_data[3]; #endif #ifdef USE_USBD_AUDIO_RX -#define USBD_AUDIO_RX_AC_DESC_LEN 21 // 31 +#ifdef USE_USBD_AUDIO_FEATURES +#define USBD_AUDIO_RX_AC_DESC_LEN 31 +#else +#define USBD_AUDIO_RX_AC_DESC_LEN 21 +#endif #ifdef USE_USBD_RX_FB #define USBD_AUDIO_RX_AS_DESC_LEN 61 #else @@ -192,7 +196,11 @@ uint8_t fb_data[3]; #endif #ifdef USE_USBD_AUDIO_TX -#define USBD_AUDIO_TX_AC_DESC_LEN 21 // 31 +#ifdef USE_USBD_AUDIO_FEATURES +#define USBD_AUDIO_TX_AC_DESC_LEN 31 +#else +#define USBD_AUDIO_TX_AC_DESC_LEN 21 +#endif #define USBD_AUDIO_TX_AS_DESC_LEN 52 #define USBD_AUDIO_TX_NUM_INTERFACES 1 #else @@ -278,7 +286,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x01, // bTerminalID 0x01, // wTerminalType USBD_AUDIO_TERMINAL_IO_USB_STREAMING 0x0101 0x01, // wTerminalType - 0x00, // bAssocTerminal + 0x03, // bAssocTerminal USBD_AUDIO_RX_CHANNELS, // bNrChannels #if USBD_AUDIO_RX_CHANNELS == 1 0x00, // wChannelConfig 0x00 sets Mono, no position bits @@ -290,7 +298,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x00, // iTerminal Unused /* 12 byte */ -#if 0 +#ifdef USE_USBD_AUDIO_FEATURES /* Feature Unit Descriptor*/ 0x0a, // bLength 0x24, // bDescriptorType @@ -311,25 +319,24 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x03, // bDescriptorSubtype 0x03, // bTerminalID 0x01, // wTerminalType 0x0301 - 0x03, // wTerminalType 0x0301 + 0x03, // wTerminalType 0x01, // bAssocTerminal 0x02, // bSourceID 0x00, // iTerminal /* 09 byte */ -#endif - +#else /* Output Terminal Descriptor */ 0x09, // bLength 0x024, // bDescriptorType 0x03, // bDescriptorSubtype 0x03, // bTerminalID 0x01, // wTerminalType 0x0301 - 0x03, // wTerminalType 0x0301 - 0x00, // bAssocTerminal + 0x03, // wTerminalType + 0x01, // bAssocTerminal 0x01, // bSourceID 0x00, // iTerminal /* 09 byte */ - +#endif // 12+10+9 = 31 bytes #endif @@ -341,7 +348,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x04, // bTerminalID ID of this Terminal. 0x01, // wTerminalType 0x02, // wTerminalType Terminal is Microphone (0x0201) - 0x00, // bAssocTerminal + 0x06, // bAssocTerminal USBD_AUDIO_TX_CHANNELS, // bNrChannels 0x03, // wChannelConfig 0x00, // wChannelConfig Mono sets no position bits @@ -349,7 +356,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x00, // iTerminal Unused /* 12 bytes */ -#if 0 +#ifdef USE_USBD_AUDIO_FEATURES /* Feature Unit Descriptor*/ 0x0a, // bLength 0x24, // bDescriptorType @@ -358,7 +365,6 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x04, // bSourceID 0x01, // bControlSize 0x01|0x02, // bmaControls(0) AUDIO_CONTROL_MUTE|AUDIO_CONTROL_VOLUME - // 0x00, // bmaControls(0) 0x00, // bmaControls(1) 0x00, // bmaControls(2) 0x00, // iTerminal @@ -374,18 +380,18 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x05, // From Input Terminal.(bSourceID) 0x00, // unused (iTerminal) /* 9 bytes */ -#endif - +#else /* USB Microphone Output Terminal Descriptor */ 0x09, // Size of the descriptor, in bytes (bLength) 0x24, // bDescriptorType 0x03, // bDescriptorSubtype 0x06, // bTerminalID 0x01, 0x01, // wTerminalType 0x0101 USB Streaming - 0x00, // bAssocTerminal + 0x04, // bAssocTerminal 0x04, // From Input Terminal.(bSourceID) 0x00, // unused (iTerminal) /* 9 bytes */ +#endif // 12+10+9 = 31 bytes #endif @@ -447,7 +453,8 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x09, /* bLength */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType */ AUDIO_RX_EP, /* bEndpointAddress 1 out endpoint*/ - USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_ADAPT, /* bmAttributes */ + // USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_ADAPT, /* bmAttributes */ + USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_ASYNC, /* bmAttributes */ LOBYTE(AUDIO_RX_MAX_PACKET_SIZE), /* wMaxPacketSize in bytes */ HIBYTE(AUDIO_RX_MAX_PACKET_SIZE), 0x01, /* bInterval */ @@ -823,7 +830,8 @@ static uint8_t USBD_AUDIO_SetInterfaceAlternate(USBD_HandleTypeDef *pdev, #ifdef USE_USBD_RX_FB USBD_AUDIO_CloseEndpoint(pdev, haudio, AUDIO_FB_EP); #endif - AUDIO_OUT_StopAndReset(pdev); + haudio->audio_rx_active = 0; + // AUDIO_OUT_StopAndReset(pdev); }else{ // open new USBD_AUDIO_OpenEndpoint(pdev, haudio, AUDIO_RX_EP, USBD_EP_TYPE_ISOC, AUDIO_RX_MAX_PACKET_SIZE); @@ -1057,9 +1065,9 @@ static void AUDIO_REQ_GetCurrent(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* USBD_AUDIO_HandleTypeDef* haudio; haudio = (USBD_AUDIO_HandleTypeDef*)pdev->pClassData; - // if ((req->bmRequest & 0x1f) == AUDIO_CONTROL_REQ) { // todo: should AUDIO_CONTROL_REQ match the bUnitID of IN/OUT feature? - uint8_t bUnit = req->bmRequest & 0x1f; - if (bUnit == 0x02 || bUnit == 0x05) { + if ((req->bmRequest & 0x1f) == AUDIO_CONTROL_REQ) { // todo: should AUDIO_CONTROL_REQ match the bUnitID of IN/OUT feature? + // uint8_t bUnit = req->bmRequest & 0x1f; + // if (bUnit == 0x02 || bUnit == 0x05) { switch (HIBYTE(req->wValue)) { case AUDIO_CONTROL_REQ_FU_MUTE: { /* Current mute state */ @@ -1091,9 +1099,9 @@ static void AUDIO_REQ_GetCurrent(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* */ static void AUDIO_REQ_GetMax(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* req) { - // if ((req->bmRequest & 0x1f) == AUDIO_CONTROL_REQ) { - uint8_t bUnit = req->bmRequest & 0x1f; - if (bUnit == 0x02 || bUnit == 0x05) { + if ((req->bmRequest & 0x1f) == AUDIO_CONTROL_REQ) { + // uint8_t bUnit = req->bmRequest & 0x1f; + // if (bUnit == 0x02 || bUnit == 0x05) { switch (HIBYTE(req->wValue)) { case AUDIO_CONTROL_REQ_FU_VOL: { int16_t vol_max = USBD_AUDIO_VOL_MAX; @@ -1119,9 +1127,9 @@ static void AUDIO_REQ_GetMax(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* req */ static void AUDIO_REQ_GetMin(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* req) { - uint8_t bUnit = req->bmRequest & 0x1f; - if (bUnit == 0x02 || bUnit == 0x05) { - // if ((req->bmRequest & 0x1f) == AUDIO_CONTROL_REQ) { + // uint8_t bUnit = req->bmRequest & 0x1f; + // if (bUnit == 0x02 || bUnit == 0x05) { + if ((req->bmRequest & 0x1f) == AUDIO_CONTROL_REQ) { switch (HIBYTE(req->wValue)) { case AUDIO_CONTROL_REQ_FU_VOL: { int16_t vol_min = USBD_AUDIO_VOL_MIN; @@ -1147,9 +1155,9 @@ static void AUDIO_REQ_GetMin(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* req */ static void AUDIO_REQ_GetRes(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* req) { - uint8_t bUnit = req->bmRequest & 0x1f; - if (bUnit == 0x02 || bUnit == 0x05) { - // if ((req->bmRequest & 0x1f) == AUDIO_CONTROL_REQ) { + // uint8_t bUnit = req->bmRequest & 0x1f; + // if (bUnit == 0x02 || bUnit == 0x05) { + if ((req->bmRequest & 0x1f) == AUDIO_CONTROL_REQ) { switch (HIBYTE(req->wValue)) { case AUDIO_CONTROL_REQ_FU_VOL: { int16_t vol_res = USBD_AUDIO_VOL_STEP; @@ -1200,9 +1208,9 @@ static uint8_t USBD_AUDIO_EP0_RxReady (USBD_HandleTypeDef *pdev) (void)haudio; #if 1 if (haudio->control.cmd == AUDIO_REQ_SET_CUR) { /* In this driver, to simplify code, only SET_CUR request is managed */ - // if (haudio->control.req_type == AUDIO_CONTROL_REQ) { - uint8_t bUnit = haudio->control.req_type; - if (bUnit == 0x02 || bUnit == 0x05) { + if (haudio->control.req_type == AUDIO_CONTROL_REQ) { + // uint8_t bUnit = haudio->control.req_type; + // if (bUnit == 0x02 || bUnit == 0x05) { USBD_DbgLog("CONTROL_REQ 0x%x 0x%x", haudio->control.cs, haudio->control.data[0]); switch (haudio->control.cs) { /* Mute Control */ @@ -1312,15 +1320,16 @@ static uint8_t USBD_AUDIO_SOF (USBD_HandleTypeDef *pdev) { uint32_t samples = usbd_audio_get_rx_count(); // across channels and fb rate if(samples != 0){ // if(abs(samples - USBD_AUDIO_RX_FREQ*FB_RATE*USBD_AUDIO_RX_CHANNELS/1000) < 8){ - samples * (1<<14); // convert to n.14 format + samples *= (1<<14); // convert to n.14 format samples /= USBD_AUDIO_RX_CHANNELS * FB_RATE; usbd_rx_capacity = samples - 786432; AUDIO_FREQ_TO_DATA(samples, fb_data); // pack into 3 bytes (todo: make this atomic) // } } - // USBD_LL_Transmit(pdev, AUDIO_FB_EP, fb_data, AUDIO_FB_PACKET_SIZE); } - // }else{ + // transmit on every SOF if audio_rx_active + // USBD_LL_Transmit(pdev, AUDIO_FB_EP, fb_data, AUDIO_FB_PACKET_SIZE); + // }else{ // sof_count = 0; } #endif @@ -1344,25 +1353,23 @@ static uint8_t USBD_AUDIO_IsoINIncomplete (USBD_HandleTypeDef *pdev, uint8_t ep /* - EPENA = 1 (in OTG_DOEPCTLx) */ USBD_AUDIO_HandleTypeDef* haudio; haudio = (USBD_AUDIO_HandleTypeDef*)pdev->pClassData; - uint16_t current_sof; - current_sof = USB_SOF_NUMBER(); - + uint16_t current_sof = USB_SOF_NUMBER(); #ifdef USE_USBD_RX_FB if(pdev->ep_in[AUDIO_FB_EP & 0xFU].is_used && - IS_ISO_IN_INCOMPLETE_EP(AUDIO_FB_EP & 0xFU, current_sof, haudio->fb_soffn)){ + IS_ISO_IN_INCOMPLETE_EP(AUDIO_FB_EP & 0x0FU, current_sof, haudio->fb_soffn)){ USB_CLEAR_INCOMPLETE_IN_EP(AUDIO_FB_EP); USBD_LL_FlushEP(pdev, AUDIO_FB_EP); - haudio->fb_soffn = USB_SOF_NUMBER(); + haudio->fb_soffn = current_sof; USBD_LL_Transmit(pdev, AUDIO_FB_EP, fb_data, AUDIO_FB_PACKET_SIZE); } #endif #ifdef USE_USBD_AUDIO_TX if(pdev->ep_in[AUDIO_TX_EP & 0xFU].is_used && - IS_ISO_IN_INCOMPLETE_EP(AUDIO_TX_EP & 0xFU, current_sof, haudio->tx_soffn)){ + IS_ISO_IN_INCOMPLETE_EP(AUDIO_TX_EP & 0x0FU, current_sof, haudio->tx_soffn)){ USB_CLEAR_INCOMPLETE_IN_EP(AUDIO_TX_EP); USBD_LL_FlushEP(pdev, AUDIO_TX_EP); - haudio->tx_soffn = USB_SOF_NUMBER(); + haudio->tx_soffn = current_sof; // host has not collected data // let's not increment readhead // todo: write same amount of data as last time @@ -1381,7 +1388,6 @@ static uint8_t USBD_AUDIO_IsoINIncomplete (USBD_HandleTypeDef *pdev, uint8_t ep */ static uint8_t USBD_AUDIO_IsoOutIncomplete (USBD_HandleTypeDef *pdev, uint8_t epnum) { - return USBD_OK; } @@ -1458,9 +1464,10 @@ static void AUDIO_OUT_StopAndReset(USBD_HandleTypeDef* pdev) #ifdef USE_USBD_RX_FB USBD_LL_FlushEP(pdev, AUDIO_FB_EP); #endif +#ifdef USE_USBD_AUDIO_RX USBD_LL_FlushEP(pdev, AUDIO_RX_EP); usbd_audio_rx_stop_callback(); - /* ((USBD_AUDIO_ItfTypeDef*)pdev->pUserData)->DeInit(0); */ +#endif } /** @@ -1475,17 +1482,21 @@ static void AUDIO_OUT_Restart(USBD_HandleTypeDef* pdev) /* AUDIO_OUT_StopAndReset(pdev); */ haudio->audio_rx_active = 0; -#ifdef USE_USBD_RX_FB - USBD_LL_FlushEP(pdev, AUDIO_FB_EP); -#endif - USBD_LL_FlushEP(pdev, AUDIO_RX_EP); +// #ifdef USE_USBD_RX_FB +// USBD_LL_FlushEP(pdev, AUDIO_FB_EP); +// #endif +// #ifdef USE_USBD_AUDIO_RX +// USBD_LL_FlushEP(pdev, AUDIO_RX_EP); +// #endif /* Prepare Out endpoint to receive first audio packet */ USBD_LL_PrepareReceive(pdev, AUDIO_RX_EP, (uint8_t*)haudio->audio_rx_transmit, AUDIO_RX_PACKET_SIZE); #ifdef USE_USBD_RX_FB + USBD_LL_FlushEP(pdev, AUDIO_FB_EP); /* send first explicit feedback data */ get_usb_full_speed_rate(USBD_AUDIO_RX_FREQ, fb_data); + haudio->fb_soffn = USB_SOF_NUMBER(); USBD_LL_Transmit(pdev, AUDIO_FB_EP, fb_data, AUDIO_FB_PACKET_SIZE); #endif diff --git a/Witch/Inc/hardware.h b/Witch/Inc/hardware.h index e40a86d2..8b8992d9 100644 --- a/Witch/Inc/hardware.h +++ b/Witch/Inc/hardware.h @@ -15,7 +15,8 @@ #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) #define USE_USBD_AUDIO -/* #define USE_USBD_RX_FB */ +#define USE_USBD_RX_FB +#define USE_USBD_AUDIO_FEATURES #define USE_USBD_AUDIO_RX // speaker #define USE_USBD_AUDIO_TX // microphone #define USE_USBD_FS diff --git a/Witch/Src/usbd_conf.c b/Witch/Src/usbd_conf.c index 15eb9fd3..52b42927 100644 --- a/Witch/Src/usbd_conf.c +++ b/Witch/Src/usbd_conf.c @@ -344,7 +344,7 @@ USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; - hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; + hpcd_USB_OTG_FS.Init.Sof_enable = ENABLE; hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE; From ca0e12af9eb73fb76bbae790135e640c5ad6f48f Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 30 Sep 2021 23:46:21 +0200 Subject: [PATCH 082/286] changed how rx fb is calculated: fixed 0.5 samples up or down --- Source/usbd_audio.cpp | 39 ++++++++++++++++++++------------------- Source/usbd_audio.h | 8 ++++++-- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/Source/usbd_audio.cpp b/Source/usbd_audio.cpp index c332d96f..84d4fdfb 100644 --- a/Source/usbd_audio.cpp +++ b/Source/usbd_audio.cpp @@ -114,9 +114,6 @@ static void get_usb_full_speed_rate(unsigned int rate, uint8_t* buf){ AUDIO_FREQ_TO_DATA(rate, buf); // usbd_rx_capacity = rate - 786432; } - -uint8_t fb_data[3]; - #endif #if defined USE_USBD_AUDIO_RX && defined USE_USBD_RX_FB && defined USE_USBD_AUDIO_TX && defined USE_USBD_MIDI @@ -831,6 +828,7 @@ static uint8_t USBD_AUDIO_SetInterfaceAlternate(USBD_HandleTypeDef *pdev, USBD_AUDIO_CloseEndpoint(pdev, haudio, AUDIO_FB_EP); #endif haudio->audio_rx_active = 0; + usbd_audio_rx_stop_callback(); // AUDIO_OUT_StopAndReset(pdev); }else{ // open new @@ -1020,7 +1018,7 @@ static uint8_t USBD_AUDIO_DataIn (USBD_HandleTypeDef *pdev, #ifdef USE_USBD_RX_FB case AUDIO_FB_EP: haudio->fb_soffn = USB_SOF_NUMBER(); - USBD_LL_Transmit(pdev, AUDIO_FB_EP, fb_data, AUDIO_FB_PACKET_SIZE); + USBD_LL_Transmit(pdev, AUDIO_FB_EP, haudio->fb_data.buf, AUDIO_FB_PACKET_SIZE); break; #endif #ifdef USE_USBD_AUDIO_TX @@ -1313,17 +1311,13 @@ static uint8_t USBD_AUDIO_SOF (USBD_HandleTypeDef *pdev) { if(++sof_count == FB_RATE){ sof_count = 0; // number of samples since last request (or 0 if unknown) - - // size_t capacity = rx_buffer.getWriteCapacity(); - // capacity += codec.getSampleCounter(); - uint32_t samples = usbd_audio_get_rx_count(); // across channels and fb rate if(samples != 0){ // if(abs(samples - USBD_AUDIO_RX_FREQ*FB_RATE*USBD_AUDIO_RX_CHANNELS/1000) < 8){ samples *= (1<<14); // convert to n.14 format samples /= USBD_AUDIO_RX_CHANNELS * FB_RATE; usbd_rx_capacity = samples - 786432; - AUDIO_FREQ_TO_DATA(samples, fb_data); // pack into 3 bytes (todo: make this atomic) + // AUDIO_FREQ_TO_DATA(samples, haudio->fb_data.buf); // pack into 3 bytes (todo: make this atomic) // } } } @@ -1360,7 +1354,7 @@ static uint8_t USBD_AUDIO_IsoINIncomplete (USBD_HandleTypeDef *pdev, uint8_t ep USB_CLEAR_INCOMPLETE_IN_EP(AUDIO_FB_EP); USBD_LL_FlushEP(pdev, AUDIO_FB_EP); haudio->fb_soffn = current_sof; - USBD_LL_Transmit(pdev, AUDIO_FB_EP, fb_data, AUDIO_FB_PACKET_SIZE); + USBD_LL_Transmit(pdev, AUDIO_FB_EP, haudio->fb_data.buf, AUDIO_FB_PACKET_SIZE); } #endif @@ -1416,21 +1410,28 @@ static uint8_t USBD_AUDIO_DataOut (USBD_HandleTypeDef *pdev, uint8_t epnum) { } size_t len = USBD_LL_GetRxDataSize(pdev, epnum); rx_buffer.write((audio_t*)haudio->audio_rx_transmit, len/sizeof(audio_t)); - len = AUDIO_RX_PACKET_SIZE/sizeof(audio_t); -#if 1 +#ifdef USE_USBD_RX_FB // in asynch / adaptive mode, we have no control over the number of samples transferred - // decide if we should request one set of samples more or less than usual + // instead we update the feedback value size_t capacity = rx_buffer.getWriteCapacity(); capacity += codec.getSampleCounter(); - // usbd_rx_capacity = capacity; + usbd_rx_capacity = capacity; if(capacity < AUDIO_RX_PACKET_SIZE/sizeof(audio_t)){ - usbd_rx_flow--; - }else if(rx_buffer.getSize() - capacity < 2*AUDIO_RX_PACKET_SIZE/sizeof(audio_t)){ + // write capacity too small: slow down usbd_rx_flow++; + haudio->fb_data.val = 0x0be000; // 47.5 * 16384 + // haudio->fb_data.val = 0x0bf000; // 47.75 * 16384 + }else if(rx_buffer.getSize() - capacity < 2*AUDIO_RX_PACKET_SIZE/sizeof(audio_t)){ + // read capacity too small: speed up + usbd_rx_flow--; + haudio->fb_data.val = 0x0c2000; // 48.5 * 16384 + // haudio->fb_data.val = 0x0c1000; // 48.25 * 16384 + }else{ + haudio->fb_data.val = 0x0c0000; // 48 * 16384 } #endif /* Prepare Out endpoint to receive next audio packet */ - USBD_LL_PrepareReceive(pdev, AUDIO_RX_EP, (uint8_t*)haudio->audio_rx_transmit, len*sizeof(audio_t)); + USBD_LL_PrepareReceive(pdev, AUDIO_RX_EP, (uint8_t*)haudio->audio_rx_transmit, AUDIO_RX_PACKET_SIZE); break; } #endif /* USE_USBD_AUDIO_RX */ @@ -1495,9 +1496,9 @@ static void AUDIO_OUT_Restart(USBD_HandleTypeDef* pdev) #ifdef USE_USBD_RX_FB USBD_LL_FlushEP(pdev, AUDIO_FB_EP); /* send first explicit feedback data */ - get_usb_full_speed_rate(USBD_AUDIO_RX_FREQ, fb_data); + get_usb_full_speed_rate(USBD_AUDIO_RX_FREQ, haudio->fb_data.buf); haudio->fb_soffn = USB_SOF_NUMBER(); - USBD_LL_Transmit(pdev, AUDIO_FB_EP, fb_data, AUDIO_FB_PACKET_SIZE); + USBD_LL_Transmit(pdev, AUDIO_FB_EP, haudio->fb_data.buf, AUDIO_FB_PACKET_SIZE); #endif /* get_usb_full_speed_rate(haudio->frequency, fb_data); // reset to new frequency */ diff --git a/Source/usbd_audio.h b/Source/usbd_audio.h index 0657a1b3..547ef547 100644 --- a/Source/usbd_audio.h +++ b/Source/usbd_audio.h @@ -120,8 +120,6 @@ typedef int32_t audio_t; } USBD_AUDIO_ControlTypeDef; - - typedef struct { uint8_t ac_alt_setting, tx_alt_setting, rx_alt_setting, midi_alt_setting; @@ -135,7 +133,13 @@ typedef struct uint8_t audio_rx_buffer[AUDIO_RX_TOTAL_BUF_SIZE]; uint8_t audio_rx_transmit[AUDIO_RX_MAX_PACKET_SIZE]; volatile uint8_t audio_rx_active; +#ifdef USE_USBD_RX_FB volatile uint16_t fb_soffn; + union { + uint8_t buf[3]; + uint32_t val; + } fb_data; +#endif #endif #ifdef USE_USBD_MIDI uint8_t midi_rx_buffer[MIDI_RX_PACKET_SIZE]; From c5320b2b87e0c596731007d6fd7084c4a1020599 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 30 Sep 2021 23:46:44 +0200 Subject: [PATCH 083/286] suppress build message --- Hardware/common.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Hardware/common.mk b/Hardware/common.mk index ffc3a0ff..891167f5 100644 --- a/Hardware/common.mk +++ b/Hardware/common.mk @@ -45,7 +45,7 @@ vpath %.s $(sort $(dir $(S_SRC))) build_dir: $(BUILD) $(BUILD): - $(MKDIR) $(BUILD) + @$(MKDIR) $(BUILD) # Build executable $(ELF) : $(OBJS) $(LDSCRIPT) From 97def61e18d94dffe55c99ac2fa8b430c2b09544 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 1 Oct 2021 16:59:09 +0200 Subject: [PATCH 084/286] added overdub methods --- Source/CircularBuffer.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Source/CircularBuffer.h b/Source/CircularBuffer.h index 1c67fb6e..cb716ed5 100644 --- a/Source/CircularBuffer.h +++ b/Source/CircularBuffer.h @@ -67,6 +67,16 @@ class CircularBuffer { data[index % size] = value; } + void overdub(T c){ + data[writepos++] += c; + if(writepos >= size) + writepos = 0; + } + + void overdubAt(size_t index, T value){ + data[index % size] += value; + } + T read(){ T c = data[readpos++]; if(readpos >= size) From 4970845a3b23622a6a2e0ba9b018d608b70c4789 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 1 Oct 2021 17:02:51 +0200 Subject: [PATCH 085/286] sum USB rx stream with patch output and send to DAC --- Source/ProgramManager.cpp | 28 +++++++++++++++++++++++----- Source/usbd_audio.cpp | 31 ++++++++++++++++++++++--------- 2 files changed, 45 insertions(+), 14 deletions(-) diff --git a/Source/ProgramManager.cpp b/Source/ProgramManager.cpp index 3af5061d..4d645af2 100644 --- a/Source/ProgramManager.cpp +++ b/Source/ProgramManager.cpp @@ -80,15 +80,27 @@ void usbd_rx_convert(int32_t* dst, size_t len){ *dst++ = AUDIO_SAMPLE_TO_INT32(usbd_rx->read()); } +void usbd_rx_convert_add(int32_t* dst, size_t len){ + usbd_audio_rx_count += len; + while(len--) + *dst++ = __SSAT(*dst + AUDIO_SAMPLE_TO_INT32(usbd_rx->read()), 24); +} + void usbd_tx_convert(int32_t* src, size_t len){ -#if USBD_AUDIO_TX_CHANNELS != AUDIO_CHANNELS -#error "todo: support for USBD_AUDIO_TX_CHANNELS != AUDIO_CHANNELS" -#endif while(len--) // macro handles shift, round, dither, clip, truncate, bitswap usbd_tx->write(AUDIO_INT32_TO_SAMPLE(*src++)); } +void usbd_tx_convert_add(int32_t* src, size_t len){ + while(len--) + usbd_tx->overdub(AUDIO_INT32_TO_SAMPLE(*src++)); +} + +#if USBD_AUDIO_TX_CHANNELS != AUDIO_CHANNELS +#error "todo: support for USBD_AUDIO_TX_CHANNELS != AUDIO_CHANNELS" +#endif + #endif // FreeRTOS low priority numbers denote low priority tasks. @@ -210,14 +222,20 @@ void onProgramReady(){ if(usbd_tx) // after patch runs: convert wet output to USBD audio tx usbd_tx_convert(pv->audio_output, pv->audio_blocksize*AUDIO_CHANNELS); #endif +#ifdef USE_USBD_AUDIO_RX + if(usbd_rx) // after patch runs: convert USBD audio rx to DAC (summing patch output) + usbd_rx_convert_add(pv->audio_output, pv->audio_blocksize*AUDIO_CHANNELS); +#endif #ifdef DEBUG_DWT pv->cycles_per_block = DWT->CYCCNT; #endif /* Block indefinitely (released by audioCallback) */ ulTaskNotifyTake(pdTRUE, portMAX_DELAY); #ifdef USE_USBD_AUDIO_RX - if(usbd_rx) // before patch runs: convert USBD audio rx to input (overwriting ADC) - usbd_rx_convert(pv->audio_input, pv->audio_blocksize*AUDIO_CHANNELS); + // if(usbd_rx) // before patch runs: convert USBD audio rx to input (overwriting ADC) + // usbd_rx_convert(pv->audio_input, pv->audio_blocksize*AUDIO_CHANNELS); + // if(usbd_rx) // before patch runs: convert USBD audio rx to input (summing ADC) + // usbd_rx_convert_add(pv->audio_input, pv->audio_blocksize*AUDIO_CHANNELS); #endif #ifdef DEBUG_DWT DWT->CYCCNT = 0; diff --git a/Source/usbd_audio.cpp b/Source/usbd_audio.cpp index 84d4fdfb..a9d3ecf4 100644 --- a/Source/usbd_audio.cpp +++ b/Source/usbd_audio.cpp @@ -22,11 +22,14 @@ int usbd_tx_flow = 0; int usbd_rx_flow = 0; int usbd_tx_capacity = 0; int usbd_rx_capacity = 0; + +#ifdef DEBUG #define FLOW_ASSERT(x, y) if(!(x)){debugMessage(y, usbd_rx_flow, usbd_tx_flow, this->getWriteCapacity());} +#endif #include "CircularBuffer.h" #include "Codec.h" -// todo: not static/global +// todo: not static/global; move the buffers out of this compilation unit CircularBuffer rx_buffer; CircularBuffer tx_buffer; @@ -303,12 +306,16 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x02, // bUnitID 0x01, // bSourceID 0x01, // bControlSize - 0x01|0x02, // bmaControls(0) AUDIO_CONTROL_MUTE|AUDIO_CONTROL_VOLUME // 0x00, // bmaControls(0) - 0x00, // bmaControls(1) - 0x00, // bmaControls(2) + AUDIO_CONTROL_REQ_FU_MUTE, // bmaControls(0) Master + AUDIO_CONTROL_REQ_FU_VOL, // bmaControls(1) Channel 1 + AUDIO_CONTROL_REQ_FU_VOL, // bmaControls(2) Channel 2 0x00, // iTerminal /* 10 byte */ + +#if USBD_AUDIO_RX_CHANNELS != 2 +#error "incompatible channel count / todo" +#endif /* Output Terminal Descriptor */ 0x09, // bLength @@ -361,11 +368,15 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x05, // bUnitID 0x04, // bSourceID 0x01, // bControlSize - 0x01|0x02, // bmaControls(0) AUDIO_CONTROL_MUTE|AUDIO_CONTROL_VOLUME - 0x00, // bmaControls(1) - 0x00, // bmaControls(2) + AUDIO_CONTROL_REQ_FU_MUTE, // bmaControls(0) Master + AUDIO_CONTROL_REQ_FU_VOL, // bmaControls(1) Channel 1 + AUDIO_CONTROL_REQ_FU_VOL, // bmaControls(2) Channel 2 0x00, // iTerminal /* 10 byte */ + +#if USBD_AUDIO_TX_CHANNELS != 2 +#error "incompatible channel count / todo" +#endif /* USB Microphone Output Terminal Descriptor */ 0x09, // Size of the descriptor, in bytes (bLength) @@ -475,7 +486,8 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x07, /* bLength */ 0x25, /* bDescriptorType */ 0x01, /* bDescriptor */ - 0x00, /* bmAttributes 0x01: Sampling Frequency control. See UAC Spec 1.0 p.62 */ + // USBD_AUDIO_AS_CONTROL_SAMPLING_FREQUENCY /* bmAttributes 0x01: Sampling Frequency control. See UAC Spec 1.0 p.62 */ + 0x00, /* bmAttributes */ 0x00, /* bLockDelayUnits */ 0x00, /* wLockDelay */ 0x00, @@ -1408,7 +1420,8 @@ static uint8_t USBD_AUDIO_DataOut (USBD_HandleTypeDef *pdev, uint8_t epnum) { rx_buffer.clear(); rx_buffer.moveWriteHead(AUDIO_RX_PACKET_SIZE/sizeof(audio_t)); } - size_t len = USBD_LL_GetRxDataSize(pdev, epnum); + size_t len = USBD_LL_GetRxDataSize(pdev, AUDIO_RX_EP); + // we are required to support null packets: len may be zero rx_buffer.write((audio_t*)haudio->audio_rx_transmit, len/sizeof(audio_t)); #ifdef USE_USBD_RX_FB // in asynch / adaptive mode, we have no control over the number of samples transferred From 61f9677d85df02f40478aec53bc484769779a080 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 4 Oct 2021 04:06:46 +0200 Subject: [PATCH 086/286] changes to usb audio buffer and over/underflow management --- Genius/Inc/hardware.h | 7 +++-- Source/ProgramManager.cpp | 33 ++++++++++++++------ Source/usbd_audio.cpp | 66 +++++++++++++++++++++++++++------------ 3 files changed, 74 insertions(+), 32 deletions(-) diff --git a/Genius/Inc/hardware.h b/Genius/Inc/hardware.h index 26fa7332..6b857929 100644 --- a/Genius/Inc/hardware.h +++ b/Genius/Inc/hardware.h @@ -40,11 +40,9 @@ #define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) -#define MAIN_LOOP_SLEEP_MS 20 -#define ARM_CYCLES_PER_SAMPLE (480000000/AUDIO_SAMPLINGRATE) /* 480MHz / 48kHz */ - #define USE_USBD_AUDIO #define USE_USBD_RX_FB +#define USE_USBD_AUDIO_FEATURES #define USE_USBD_AUDIO_RX // speaker #define USE_USBD_AUDIO_TX // microphone #define USE_USBD_FS @@ -54,6 +52,9 @@ #define USB_HOST_RX_BUFF_SIZE 256 /* Max Received data 64 bytes */ #define USE_USBH_MIDI +#define MAIN_LOOP_SLEEP_MS 20 +#define ARM_CYCLES_PER_SAMPLE (480000000/AUDIO_SAMPLINGRATE) /* 480MHz / 48kHz */ + // Serial MIDI #define USE_UART_MIDI_RX #define USE_UART_MIDI_TX diff --git a/Source/ProgramManager.cpp b/Source/ProgramManager.cpp index 4d645af2..35cc938c 100644 --- a/Source/ProgramManager.cpp +++ b/Source/ProgramManager.cpp @@ -74,28 +74,43 @@ void usbd_audio_rx_stop_callback(){ #endif } -void usbd_rx_convert(int32_t* dst, size_t len){ - usbd_audio_rx_count += len; - while(len--) - *dst++ = AUDIO_SAMPLE_TO_INT32(usbd_rx->read()); -} +// void usbd_rx_convert(int32_t* dst, size_t len){ +// usbd_audio_rx_count += len; +// while(len--) +// *dst++ = AUDIO_SAMPLE_TO_INT32(usbd_rx->read()); +// } void usbd_rx_convert_add(int32_t* dst, size_t len){ usbd_audio_rx_count += len; + size_t cap = usbd_rx->getReadCapacity(); + if(cap < len){ + // rx buffer underflow + memset(dst+cap, 0, (len - cap)*sizeof(int32_t)); + debugMessage("rx unf", (int)(len - cap)); + len = cap; + } while(len--) *dst++ = __SSAT(*dst + AUDIO_SAMPLE_TO_INT32(usbd_rx->read()), 24); } void usbd_tx_convert(int32_t* src, size_t len){ + size_t cap = usbd_tx->getWriteCapacity() - USBD_AUDIO_TX_CHANNELS; + // leave a bit of space to prevent wrapping read/write pointers + if(cap < len){ + // tx buffer overflow + debugMessage("tx ovf", (int)(len - cap)); + len = cap; + // return; // if we write a full buffer, then the write pointer will appear to wrap + } while(len--) // macro handles shift, round, dither, clip, truncate, bitswap usbd_tx->write(AUDIO_INT32_TO_SAMPLE(*src++)); } -void usbd_tx_convert_add(int32_t* src, size_t len){ - while(len--) - usbd_tx->overdub(AUDIO_INT32_TO_SAMPLE(*src++)); -} +// void usbd_tx_convert_add(int32_t* src, size_t len){ +// while(len--) +// usbd_tx->overdub(AUDIO_INT32_TO_SAMPLE(*src++)); +// } #if USBD_AUDIO_TX_CHANNELS != AUDIO_CHANNELS #error "todo: support for USBD_AUDIO_TX_CHANNELS != AUDIO_CHANNELS" diff --git a/Source/usbd_audio.cpp b/Source/usbd_audio.cpp index a9d3ecf4..56515a91 100644 --- a/Source/usbd_audio.cpp +++ b/Source/usbd_audio.cpp @@ -23,9 +23,9 @@ int usbd_rx_flow = 0; int usbd_tx_capacity = 0; int usbd_rx_capacity = 0; -#ifdef DEBUG -#define FLOW_ASSERT(x, y) if(!(x)){debugMessage(y, usbd_rx_flow, usbd_tx_flow, this->getWriteCapacity());} -#endif +// #ifdef DEBUG +// #define FLOW_ASSERT(x, y) if(!(x)){debugMessage(y, usbd_rx_flow, usbd_tx_flow, this->getWriteCapacity());} +// #endif #include "CircularBuffer.h" #include "Codec.h" @@ -874,7 +874,7 @@ static uint8_t USBD_AUDIO_SetInterfaceAlternate(USBD_HandleTypeDef *pdev, haudio->tx_soffn = USB_SOF_NUMBER(); tx_buffer.reset(); tx_buffer.clear(); - tx_buffer.moveWriteHead(AUDIO_TX_PACKET_SIZE/sizeof(audio_t)); + tx_buffer.moveWriteHead(2*AUDIO_TX_PACKET_SIZE/sizeof(audio_t)); usbd_audio_tx_start_callback(USBD_AUDIO_TX_FREQ, USBD_AUDIO_TX_CHANNELS, &tx_buffer); /* send first audio data */ memset(haudio->audio_tx_transmit, 0, sizeof(haudio->audio_tx_transmit)); @@ -1042,13 +1042,23 @@ static uint8_t USBD_AUDIO_DataIn (USBD_HandleTypeDef *pdev, capacity += codec.getSampleCounter(); usbd_tx_capacity = capacity; if(capacity < 2*AUDIO_TX_PACKET_SIZE/sizeof(audio_t)){ + // read capacity too low: slow down len -= USBD_AUDIO_TX_CHANNELS; - usbd_tx_flow--; - }else if(tx_buffer.getSize() - capacity < AUDIO_TX_PACKET_SIZE/sizeof(audio_t)){ + usbd_tx_flow -= 1; + }else if(tx_buffer.getSize() - capacity < 2*AUDIO_TX_PACKET_SIZE/sizeof(audio_t)){ + // write capacity too low: speed up len += USBD_AUDIO_TX_CHANNELS; - usbd_tx_flow++; + usbd_tx_flow += 1; + } + if(capacity < len){ + // tx buffer underflow + debugMessage("tx unf", (int)(len - capacity)); + usbd_tx_flow -= 1000; + memset(haudio->audio_tx_transmit, 0, sizeof(haudio->audio_tx_transmit)); + tx_buffer.read((audio_t*)haudio->audio_tx_transmit, capacity); + }else{ + tx_buffer.read((audio_t*)haudio->audio_tx_transmit, len); } - tx_buffer.read((audio_t*)haudio->audio_tx_transmit, len); usbd_audio_write((uint8_t*)haudio->audio_tx_transmit, len*sizeof(audio_t)); break; } @@ -1367,6 +1377,7 @@ static uint8_t USBD_AUDIO_IsoINIncomplete (USBD_HandleTypeDef *pdev, uint8_t ep USBD_LL_FlushEP(pdev, AUDIO_FB_EP); haudio->fb_soffn = current_sof; USBD_LL_Transmit(pdev, AUDIO_FB_EP, haudio->fb_data.buf, AUDIO_FB_PACKET_SIZE); + // debugMessage("isocfb", current_sof); } #endif @@ -1376,6 +1387,7 @@ static uint8_t USBD_AUDIO_IsoINIncomplete (USBD_HandleTypeDef *pdev, uint8_t ep USB_CLEAR_INCOMPLETE_IN_EP(AUDIO_TX_EP); USBD_LL_FlushEP(pdev, AUDIO_TX_EP); haudio->tx_soffn = current_sof; + // debugMessage("isoctx", current_sof); // host has not collected data // let's not increment readhead // todo: write same amount of data as last time @@ -1418,31 +1430,45 @@ static uint8_t USBD_AUDIO_DataOut (USBD_HandleTypeDef *pdev, uint8_t epnum) { usbd_rx_flow = 0; rx_buffer.reset(); rx_buffer.clear(); - rx_buffer.moveWriteHead(AUDIO_RX_PACKET_SIZE/sizeof(audio_t)); + rx_buffer.moveWriteHead(2*AUDIO_RX_PACKET_SIZE/sizeof(audio_t)); } - size_t len = USBD_LL_GetRxDataSize(pdev, AUDIO_RX_EP); + size_t len = USBD_LL_GetRxDataSize(pdev, AUDIO_RX_EP) / sizeof(audio_t); // we are required to support null packets: len may be zero - rx_buffer.write((audio_t*)haudio->audio_rx_transmit, len/sizeof(audio_t)); -#ifdef USE_USBD_RX_FB - // in asynch / adaptive mode, we have no control over the number of samples transferred - // instead we update the feedback value + size_t capacity = rx_buffer.getWriteCapacity(); capacity += codec.getSampleCounter(); usbd_rx_capacity = capacity; + + if(capacity < len){ + // rx buffer overflow + debugMessage("rx ovf", (int)(len - capacity)); + len = capacity; + usbd_rx_flow += 100000; + } +#ifdef USE_USBD_RX_FB + // in asynch / adaptive mode, we have no control over the number of samples transferred + // instead we update the feedback value + capacity -= len; if(capacity < AUDIO_RX_PACKET_SIZE/sizeof(audio_t)){ // write capacity too small: slow down - usbd_rx_flow++; - haudio->fb_data.val = 0x0be000; // 47.5 * 16384 - // haudio->fb_data.val = 0x0bf000; // 47.75 * 16384 + usbd_rx_flow += 1000; + haudio->fb_data.val = 0x0c0000 - 0x4000; + }else if(capacity < 2*AUDIO_RX_PACKET_SIZE/sizeof(audio_t)){ + usbd_rx_flow += 1; + haudio->fb_data.val = 0x0c0000 - 0x2000; + // 0x2000 == 0.5<<14, one half sample per frame }else if(rx_buffer.getSize() - capacity < 2*AUDIO_RX_PACKET_SIZE/sizeof(audio_t)){ // read capacity too small: speed up - usbd_rx_flow--; - haudio->fb_data.val = 0x0c2000; // 48.5 * 16384 - // haudio->fb_data.val = 0x0c1000; // 48.25 * 16384 + usbd_rx_flow -= 1; + haudio->fb_data.val = 0x0c0000 + 0x2000; + }else if(rx_buffer.getSize() - capacity < AUDIO_RX_PACKET_SIZE/sizeof(audio_t)){ + usbd_rx_flow -= 1000; + haudio->fb_data.val = 0x0c0000 + 0x4000; }else{ haudio->fb_data.val = 0x0c0000; // 48 * 16384 } #endif + rx_buffer.write((audio_t*)haudio->audio_rx_transmit, len); /* Prepare Out endpoint to receive next audio packet */ USBD_LL_PrepareReceive(pdev, AUDIO_RX_EP, (uint8_t*)haudio->audio_rx_transmit, AUDIO_RX_PACKET_SIZE); break; From 4247f033e7fb079f54661fc7214c36c5cba398b3 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 5 Oct 2021 13:24:16 +0200 Subject: [PATCH 087/286] make usbd audio debug optional --- Genius/Src/Genius.cpp | 2 ++ Source/device.h | 2 +- Source/qint.h | 4 +-- Source/usbd_audio.cpp | 65 ++++++++++++++++++++++++++++++++++--------- 4 files changed, 57 insertions(+), 16 deletions(-) diff --git a/Genius/Src/Genius.cpp b/Genius/Src/Genius.cpp index 774fa077..67209fee 100644 --- a/Genius/Src/Genius.cpp +++ b/Genius/Src/Genius.cpp @@ -2,6 +2,7 @@ #include "Graphics.h" +#ifdef DEBUG_USBD_AUDIO void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height){ extern int usbd_tx_flow; extern int usbd_rx_flow; @@ -21,6 +22,7 @@ void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height){ screen.print(" / "); screen.print(usbd_tx_capacity); } +#endif extern "C"{ #if 0 diff --git a/Source/device.h b/Source/device.h index 72efd5d6..49b17ed5 100644 --- a/Source/device.h +++ b/Source/device.h @@ -3,7 +3,7 @@ #include "hardware.h" -#define FIRMWARE_VERSION "v22.0.1" +#define FIRMWARE_VERSION "v22.0.1rc0" #ifdef USE_SPI_FLASH #define MAX_SPI_FLASH_HEADERS 32 diff --git a/Source/qint.h b/Source/qint.h index 7afe8ba8..fb38ea5d 100644 --- a/Source/qint.h +++ b/Source/qint.h @@ -14,10 +14,10 @@ #define Q7_CLIP(a) ((a) > Q7_MAX ? Q7_MAX : (a) < Q7_MIN ? Q7_MIN : (a)) #define Q15_CLIP(a) ((a) > Q15_MAX ? Q15_MAX : (a) < Q15_MIN ? Q15_MIN : (a)) #define Q31_CLIP(a) ((a) > Q31_MAX ? Q31_MAX : (a) < Q31_MIN ? Q31_MIN : (a)) -#define Q15_MUL_Q15(a,b) Q15_CLIP(((q63_t)(a)*(b))>>15) +#define Q15_MUL_Q15(a,b) Q15_CLIP(((q31_t)(a)*(b))>>15) #define Q31_MUL_Q31(a,b) Q31_CLIP(((q63_t)(a)*(b))>>31) #define FLOAT_TO_Q7(a) Q7_CLIP((q15_t)((a)*128.0f)) -#define FLOAT_TO_Q15(a) Q15_CLIP((q63_t)((a)*32768.0f)) +#define FLOAT_TO_Q15(a) Q15_CLIP((q31_t)((a)*32768.0f)) #define FLOAT_TO_Q31(a) Q31_CLIP((q63_t)((a)*2147483648.0f)) #endif diff --git a/Source/usbd_audio.cpp b/Source/usbd_audio.cpp index 56515a91..fc6863af 100644 --- a/Source/usbd_audio.cpp +++ b/Source/usbd_audio.cpp @@ -17,11 +17,13 @@ #include "usbd_conf.h" #include "usbd_ctlreq.h" +#ifdef DEBUG_USBD_AUDIO #include "message.h" int usbd_tx_flow = 0; int usbd_rx_flow = 0; int usbd_tx_capacity = 0; int usbd_rx_capacity = 0; +#endif // #ifdef DEBUG // #define FLOW_ASSERT(x, y) if(!(x)){debugMessage(y, usbd_rx_flow, usbd_tx_flow, this->getWriteCapacity());} @@ -111,7 +113,7 @@ USBD_ClassTypeDef USBD_AUDIO = * Set feedback value from sample rate */ static void get_usb_full_speed_rate(unsigned int rate, uint8_t* buf){ - usbd_rx_capacity = rate; + // usbd_rx_capacity = rate; // convert sample rate to 10.14 format rate = (rate / 1000.0f) * (1<<14); AUDIO_FREQ_TO_DATA(rate, buf); @@ -874,12 +876,15 @@ static uint8_t USBD_AUDIO_SetInterfaceAlternate(USBD_HandleTypeDef *pdev, haudio->tx_soffn = USB_SOF_NUMBER(); tx_buffer.reset(); tx_buffer.clear(); - tx_buffer.moveWriteHead(2*AUDIO_TX_PACKET_SIZE/sizeof(audio_t)); + tx_buffer.moveWriteHead(AUDIO_TX_PACKET_SIZE/sizeof(audio_t)); usbd_audio_tx_start_callback(USBD_AUDIO_TX_FREQ, USBD_AUDIO_TX_CHANNELS, &tx_buffer); /* send first audio data */ memset(haudio->audio_tx_transmit, 0, sizeof(haudio->audio_tx_transmit)); usbd_audio_write((uint8_t*)haudio->audio_tx_transmit, AUDIO_TX_PACKET_SIZE); +#ifdef DEBUG_USBD_AUDIO usbd_tx_flow = 0; + debugMessage("tx"); +#endif } haudio->tx_alt_setting = new_alt; } @@ -1040,20 +1045,28 @@ static uint8_t USBD_AUDIO_DataIn (USBD_HandleTypeDef *pdev, size_t len = AUDIO_TX_PACKET_SIZE/sizeof(audio_t); size_t capacity = tx_buffer.getReadCapacity(); capacity += codec.getSampleCounter(); +#ifdef DEBUG_USBD_AUDIO usbd_tx_capacity = capacity; +#endif if(capacity < 2*AUDIO_TX_PACKET_SIZE/sizeof(audio_t)){ // read capacity too low: slow down len -= USBD_AUDIO_TX_CHANNELS; +#ifdef DEBUG_USBD_AUDIO usbd_tx_flow -= 1; +#endif }else if(tx_buffer.getSize() - capacity < 2*AUDIO_TX_PACKET_SIZE/sizeof(audio_t)){ // write capacity too low: speed up len += USBD_AUDIO_TX_CHANNELS; +#ifdef DEBUG_USBD_AUDIO usbd_tx_flow += 1; +#endif } if(capacity < len){ // tx buffer underflow +#ifdef DEBUG_USBD_AUDIO debugMessage("tx unf", (int)(len - capacity)); usbd_tx_flow -= 1000; +#endif memset(haudio->audio_tx_transmit, 0, sizeof(haudio->audio_tx_transmit)); tx_buffer.read((audio_t*)haudio->audio_tx_transmit, capacity); }else{ @@ -1327,7 +1340,7 @@ static uint8_t USBD_AUDIO_SOF (USBD_HandleTypeDef *pdev) { /* SOF (Start of Frame) Every millisecond the USB host transmits a special SOF (start of frame) token, containing an 11-bit incrementing frame number in place of a device address. This is used to synchronize isochronous and interrupt data transfers. */ USBD_AUDIO_HandleTypeDef* haudio; haudio = (USBD_AUDIO_HandleTypeDef*)pdev->pClassData; -#ifdef USE_USBD_RX_FB +#if 0 // defined USE_USBD_RX_FB static uint32_t sof_count = 0; if(haudio->audio_rx_active){ if(++sof_count == FB_RATE){ @@ -1338,7 +1351,9 @@ static uint8_t USBD_AUDIO_SOF (USBD_HandleTypeDef *pdev) { // if(abs(samples - USBD_AUDIO_RX_FREQ*FB_RATE*USBD_AUDIO_RX_CHANNELS/1000) < 8){ samples *= (1<<14); // convert to n.14 format samples /= USBD_AUDIO_RX_CHANNELS * FB_RATE; +#ifdef DEBUG_USBD_AUDIO usbd_rx_capacity = samples - 786432; +#endif // AUDIO_FREQ_TO_DATA(samples, haudio->fb_data.buf); // pack into 3 bytes (todo: make this atomic) // } } @@ -1423,27 +1438,32 @@ static uint8_t USBD_AUDIO_DataOut (USBD_HandleTypeDef *pdev, uint8_t epnum) { switch(epnum){ #ifdef USE_USBD_AUDIO_RX case AUDIO_RX_EP:{ - if(haudio->audio_rx_active == 0){ - // todo: see if we can move this to AUDIO_OUT_Restart and remove the conditional around rx_active - haudio->audio_rx_active = 1; - usbd_audio_rx_start_callback(USBD_AUDIO_RX_FREQ, USBD_AUDIO_RX_CHANNELS, &rx_buffer); - usbd_rx_flow = 0; - rx_buffer.reset(); - rx_buffer.clear(); - rx_buffer.moveWriteHead(2*AUDIO_RX_PACKET_SIZE/sizeof(audio_t)); - } + // if(haudio->audio_rx_active == 0){ + // // todo: see if we can move this to AUDIO_OUT_Restart and remove the conditional around rx_active + // haudio->audio_rx_active = 1; + // usbd_audio_rx_start_callback(USBD_AUDIO_RX_FREQ, USBD_AUDIO_RX_CHANNELS, &rx_buffer); + // usbd_rx_flow = 0; + // rx_buffer.reset(); + // rx_buffer.clear(); + // rx_buffer.moveWriteHead(2*AUDIO_RX_PACKET_SIZE/sizeof(audio_t)); + // debugMessage("rx"); + // } size_t len = USBD_LL_GetRxDataSize(pdev, AUDIO_RX_EP) / sizeof(audio_t); // we are required to support null packets: len may be zero size_t capacity = rx_buffer.getWriteCapacity(); capacity += codec.getSampleCounter(); +#ifdef DEBUG_USBD_AUDIO usbd_rx_capacity = capacity; +#endif if(capacity < len){ // rx buffer overflow - debugMessage("rx ovf", (int)(len - capacity)); len = capacity; +#ifdef DEBUG_USBD_AUDIO + debugMessage("rx ovf", (int)(len - capacity)); usbd_rx_flow += 100000; +#endif } #ifdef USE_USBD_RX_FB // in asynch / adaptive mode, we have no control over the number of samples transferred @@ -1451,18 +1471,26 @@ static uint8_t USBD_AUDIO_DataOut (USBD_HandleTypeDef *pdev, uint8_t epnum) { capacity -= len; if(capacity < AUDIO_RX_PACKET_SIZE/sizeof(audio_t)){ // write capacity too small: slow down +#ifdef DEBUG_USBD_AUDIO usbd_rx_flow += 1000; +#endif haudio->fb_data.val = 0x0c0000 - 0x4000; }else if(capacity < 2*AUDIO_RX_PACKET_SIZE/sizeof(audio_t)){ +#ifdef DEBUG_USBD_AUDIO usbd_rx_flow += 1; +#endif haudio->fb_data.val = 0x0c0000 - 0x2000; // 0x2000 == 0.5<<14, one half sample per frame }else if(rx_buffer.getSize() - capacity < 2*AUDIO_RX_PACKET_SIZE/sizeof(audio_t)){ // read capacity too small: speed up +#ifdef DEBUG_USBD_AUDIO usbd_rx_flow -= 1; +#endif haudio->fb_data.val = 0x0c0000 + 0x2000; }else if(rx_buffer.getSize() - capacity < AUDIO_RX_PACKET_SIZE/sizeof(audio_t)){ +#ifdef DEBUG_USBD_AUDIO usbd_rx_flow -= 1000; +#endif haudio->fb_data.val = 0x0c0000 + 0x4000; }else{ haudio->fb_data.val = 0x0c0000; // 48 * 16384 @@ -1540,6 +1568,17 @@ static void AUDIO_OUT_Restart(USBD_HandleTypeDef* pdev) USBD_LL_Transmit(pdev, AUDIO_FB_EP, haudio->fb_data.buf, AUDIO_FB_PACKET_SIZE); #endif + // moved from USBD_AUDIO_DataOut + haudio->audio_rx_active = 1; + usbd_audio_rx_start_callback(USBD_AUDIO_RX_FREQ, USBD_AUDIO_RX_CHANNELS, &rx_buffer); +#ifdef DEBUG_USBD_AUDIO + usbd_rx_flow = 0; + debugMessage("rx"); +#endif + rx_buffer.reset(); + rx_buffer.clear(); + rx_buffer.moveWriteHead(-AUDIO_RX_PACKET_SIZE/sizeof(audio_t)); + /* get_usb_full_speed_rate(haudio->frequency, fb_data); // reset to new frequency */ /* usbd_audio_rx_start_callback(USBD_AUDIO_RX_FREQ, USBD_AUDIO_RX_CHANNELS, &rx_buffer); */ From af8d9a766bf0cd80aaa94975b0696da2720bab98 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 5 Oct 2021 13:31:42 +0200 Subject: [PATCH 088/286] define usbd audio channels --- Witch/Inc/hardware.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Witch/Inc/hardware.h b/Witch/Inc/hardware.h index 8b8992d9..c1314a34 100644 --- a/Witch/Inc/hardware.h +++ b/Witch/Inc/hardware.h @@ -11,6 +11,8 @@ #define AUDIO_BITS_PER_SAMPLE 16 #define AUDIO_BYTES_PER_SAMPLE (AUDIO_BITS_PER_SAMPLE/8) #define AUDIO_CHANNELS 2 +#define USBD_AUDIO_RX_CHANNELS AUDIO_CHANNELS +#define USBD_AUDIO_TX_CHANNELS AUDIO_CHANNELS #define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) From 4a0ea32e57c790569a71f45a7d7f5f8df5055934 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 5 Oct 2021 15:19:24 +0200 Subject: [PATCH 089/286] updated to compile w new usbd drivers: doesn't enumerate on linux --- Noctua/Inc/hardware.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Noctua/Inc/hardware.h b/Noctua/Inc/hardware.h index 7013d576..a2a36c6c 100644 --- a/Noctua/Inc/hardware.h +++ b/Noctua/Inc/hardware.h @@ -31,12 +31,14 @@ /* #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(__REV16(x))<<8) */ #define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) -#define USBD_AUDIO_RX_CHANNELS 4 -#define USBD_AUDIO_TX_CHANNELS 4 +#define USBD_AUDIO_RX_CHANNELS 8 +#define USBD_AUDIO_TX_CHANNELS 8 #define USE_USBD_AUDIO +/* #define USE_USBD_RX_FB */ +/* #define USE_USBD_AUDIO_FEATURES not compatible with 8 channels */ #define USE_USBD_AUDIO_TX // microphone -#define USE_USBD_AUDIO_RX // speaker +/* #define USE_USBD_AUDIO_RX // speaker */ #define USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS #define USBH_HANDLE hUsbHostHS From 45de1f7aad684e3f3038b561467ed64d4d5c0595 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 5 Oct 2021 15:19:41 +0200 Subject: [PATCH 090/286] guard around fb --- Source/usbd_audio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/usbd_audio.cpp b/Source/usbd_audio.cpp index fc6863af..824d7a1f 100644 --- a/Source/usbd_audio.cpp +++ b/Source/usbd_audio.cpp @@ -849,8 +849,8 @@ static uint8_t USBD_AUDIO_SetInterfaceAlternate(USBD_HandleTypeDef *pdev, USBD_AUDIO_OpenEndpoint(pdev, haudio, AUDIO_RX_EP, USBD_EP_TYPE_ISOC, AUDIO_RX_MAX_PACKET_SIZE); #ifdef USE_USBD_RX_FB USBD_AUDIO_OpenEndpoint(pdev, haudio, AUDIO_FB_EP, USBD_EP_TYPE_ISOC, AUDIO_FB_PACKET_SIZE); -#endif haudio->fb_soffn = USB_SOF_NUMBER(); +#endif /* haudio->bit_depth = 16U; // alt 1 */ AUDIO_OUT_Restart(pdev); } From 18f0c64e46e196c996d0535ce4f8bdc4112d9419 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 5 Oct 2021 15:20:14 +0200 Subject: [PATCH 091/286] fix compilation errors --- Source/Codec.cpp | 31 +++++++++++++++++++++---------- Source/ParameterController.hpp | 10 ---------- Source/ProgramManager.cpp | 9 +++++---- Source/cs4272.h | 1 - 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/Source/Codec.cpp b/Source/Codec.cpp index 3b65f44d..79320562 100644 --- a/Source/Codec.cpp +++ b/Source/Codec.cpp @@ -11,11 +11,16 @@ #define HSAI_TX hsai_BlockA1 #define HDMA_RX hdma_sai1_b #define HDMA_TX hdma_sai1_a -#else +#elif defined USE_PCM3168A #define HSAI_RX hsai_BlockA1 #define HSAI_TX hsai_BlockB1 #define HDMA_RX hdma_sai1_a #define HDMA_TX hdma_sai1_b +#elif defined USE_WM8731 +#define HDMA_RX hdma_i2s2_ext_rx +#define HDMA_TX hdma_i2s2_ext_rx // linked +#elif defined USE_ADS1294 +#define HDMA_TX hdma_spi1_rx #endif extern "C" { @@ -35,10 +40,16 @@ extern "C" { void usbd_audio_mute_callback(int16_t gain){ // todo! +#ifdef DEBUG + printf("mute %d\n", gain); +#endif } void usbd_audio_gain_callback(int16_t gain){ // codec_set_gain_in(gain); todo! +#ifdef DEBUG + printf("gain %d\n", gain); +#endif } #endif // USE_USBD_AUDIO @@ -135,6 +146,15 @@ void Codec::setHighPass(bool hpf){ #endif } +/** Get the number of individual samples (across channels) that have already been + * transferred to/from the codec in this block + */ +size_t Codec::getSampleCounter(){ + // read NDTR: the number of remaining data units in the current DMA Stream transfer. + return (CODEC_BUFFER_SIZE - __HAL_DMA_GET_COUNTER(&HDMA_TX)) % (codec_blocksize*AUDIO_CHANNELS); + // return (DWT->CYCCNT)/ARM_CYCLES_PER_SAMPLE; +} + #ifdef USE_IIS3DWB extern "C" { void iis3dwb_read(); @@ -279,14 +299,5 @@ void Codec::resume(){ HAL_SAI_DMAResume(&HSAI_TX); } -/** Get the number of individual samples (across channels) that have already been - * transferred to/from the codec in this block - */ -size_t Codec::getSampleCounter(){ - // read NDTR: the number of remaining data units in the current DMA Stream transfer. - return (CODEC_BUFFER_SIZE - __HAL_DMA_GET_COUNTER(&HDMA_TX)) % (codec_blocksize*AUDIO_CHANNELS); - // return (DWT->CYCCNT)/ARM_CYCLES_PER_SAMPLE; -} - #endif /* USE_PCM3168A */ diff --git a/Source/ParameterController.hpp b/Source/ParameterController.hpp index bc25c830..61e55409 100644 --- a/Source/ParameterController.hpp +++ b/Source/ParameterController.hpp @@ -5,16 +5,6 @@ #include "errorhandlers.h" #include "ProgramVector.h" -#ifndef min -#define min(a,b) ((a)<(b)?(a):(b)) -#endif -#ifndef max -#define max(a,b) ((a)>(b)?(a):(b)) -#endif -#ifndef abs -#define abs(x) ((x)>0?(x):-(x)) -#endif - void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height); /* shows a single parameter selected and controlled with a single encoder diff --git a/Source/ProgramManager.cpp b/Source/ProgramManager.cpp index 35cc938c..20eb726c 100644 --- a/Source/ProgramManager.cpp +++ b/Source/ProgramManager.cpp @@ -19,17 +19,18 @@ #include "BitState.hpp" #include "MidiReceiver.h" #include "MidiController.h" -#ifdef USE_SCREEN -#include "Graphics.h" -#endif #ifdef USE_DIGITALBUS #include "bus.h" #endif - #ifdef USE_USBD_AUDIO #include "usbd_audio.h" #include "CircularBuffer.h" +#endif +#ifdef USE_SCREEN +#include "Graphics.h" +#endif +#ifdef USE_USBD_AUDIO CircularBuffer* volatile usbd_rx = NULL; CircularBuffer* volatile usbd_tx = NULL; static uint32_t usbd_audio_rx_count = 0; diff --git a/Source/cs4272.h b/Source/cs4272.h index 33565314..e20c85e9 100644 --- a/Source/cs4272.h +++ b/Source/cs4272.h @@ -3,7 +3,6 @@ #include #include "device.h" -#include "Codec.h" // Section 8.1 Mode Control #define CODEC_MODE_CTRL1_REG (uint8_t)0x01 From 9fc6cbddcd6dc22e5e029c687f74a6889abee7a6 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 5 Oct 2021 15:20:34 +0200 Subject: [PATCH 092/286] enable/disble high pass filter with CS4271 codec --- Source/Codec.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/Codec.cpp b/Source/Codec.cpp index 79320562..aa6fb3e6 100644 --- a/Source/Codec.cpp +++ b/Source/Codec.cpp @@ -138,6 +138,12 @@ void Codec::setOutputGain(int8_t value){ } void Codec::setHighPass(bool hpf){ +#if defined USE_CS4271 + if(hpf) + codec_write(0x06, 0x10); // hp filters enabled, i2s data + else + codec_write(0x06, 0x10 | 0x03 ); // hp filters disabled +#endif #ifdef USE_PCM3168A if(hpf) codec_write(82, 0b00000000); // enable HPF for all ADC channels From 89ba200dd143963cadb37d4a62a98c1ffeb0ca46 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 5 Oct 2021 15:20:51 +0200 Subject: [PATCH 093/286] fix compilation error --- BioSignals/Src/codec_biosignals.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/BioSignals/Src/codec_biosignals.cpp b/BioSignals/Src/codec_biosignals.cpp index 7a513100..fb323124 100644 --- a/BioSignals/Src/codec_biosignals.cpp +++ b/BioSignals/Src/codec_biosignals.cpp @@ -1,3 +1,4 @@ +#include #include "Codec.h" #include "device.h" #include "errorhandlers.h" From 3c15d1dd8148ec98cc825eb4bca42de2788fcb64 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 5 Oct 2021 16:51:50 +0200 Subject: [PATCH 094/286] allow negative head moves --- Source/CircularBuffer.h | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Source/CircularBuffer.h b/Source/CircularBuffer.h index cb716ed5..aa82def1 100644 --- a/Source/CircularBuffer.h +++ b/Source/CircularBuffer.h @@ -132,11 +132,9 @@ class CircularBuffer { return data+writepos; } - void moveWriteHead(size_t samples){ + void moveWriteHead(int32_t samples){ FLOW_ASSERT(getWriteCapacity() >= samples, "overflow"); - writepos += samples; - if(writepos >= size) - writepos -= size; + writepos = (writepos + samples) % size; } size_t getReadIndex(){ @@ -151,11 +149,9 @@ class CircularBuffer { return data+readpos; } - void moveReadHead(size_t samples){ + void moveReadHead(int32_t samples){ FLOW_ASSERT(getReadCapacity() < samples, "underflow"); - readpos += samples; - if(readpos >= size) - readpos -= size; + readpos = (readpos + samples) % size; } /** From a16eec8dc21cc53378b6c37d8c3a22c15ff8e7df Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 5 Oct 2021 16:52:27 +0200 Subject: [PATCH 095/286] guards around debug output, static initialisation of default blocksize --- Source/ProgramManager.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Source/ProgramManager.cpp b/Source/ProgramManager.cpp index 20eb726c..9e471a05 100644 --- a/Source/ProgramManager.cpp +++ b/Source/ProgramManager.cpp @@ -87,21 +87,28 @@ void usbd_rx_convert_add(int32_t* dst, size_t len){ if(cap < len){ // rx buffer underflow memset(dst+cap, 0, (len - cap)*sizeof(int32_t)); - debugMessage("rx unf", (int)(len - cap)); len = cap; +#ifdef DEBUG_USBD_AUDIO + debugMessage("rx unf", (int)(len - cap)); +#endif } while(len--) *dst++ = __SSAT(*dst + AUDIO_SAMPLE_TO_INT32(usbd_rx->read()), 24); } +#if USBD_AUDIO_RX_CHANNELS != AUDIO_CHANNELS +#error "todo: support for USBD_AUDIO_RX_CHANNELS != AUDIO_CHANNELS" +#endif + void usbd_tx_convert(int32_t* src, size_t len){ size_t cap = usbd_tx->getWriteCapacity() - USBD_AUDIO_TX_CHANNELS; // leave a bit of space to prevent wrapping read/write pointers if(cap < len){ // tx buffer overflow - debugMessage("tx ovf", (int)(len - cap)); len = cap; - // return; // if we write a full buffer, then the write pointer will appear to wrap +#ifdef DEBUG_USBD_AUDIO + debugMessage("tx ovf", (int)(len - cap)); +#endif } while(len--) // macro handles shift, round, dither, clip, truncate, bitswap From cfc0cc6cf7c8afd95a752fb72942b5bcc86b9a1d Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 5 Oct 2021 16:52:34 +0200 Subject: [PATCH 096/286] guards around debug output, static initialisation of default blocksize --- Source/Codec.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Codec.cpp b/Source/Codec.cpp index aa6fb3e6..25f29988 100644 --- a/Source/Codec.cpp +++ b/Source/Codec.cpp @@ -24,7 +24,7 @@ #endif extern "C" { - uint16_t codec_blocksize = 0; + uint16_t codec_blocksize = AUDIO_BLOCK_SIZE; int32_t codec_rxbuf[CODEC_BUFFER_SIZE] DMA_RAM; int32_t codec_txbuf[CODEC_BUFFER_SIZE] DMA_RAM; extern DMA_HandleTypeDef HDMA_TX; From 288adef75fb2f1b7fe549146842327c110e4dd78 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 5 Oct 2021 16:53:07 +0200 Subject: [PATCH 097/286] removed debug output --- Source/usbd_audio.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Source/usbd_audio.cpp b/Source/usbd_audio.cpp index 824d7a1f..0cf039ec 100644 --- a/Source/usbd_audio.cpp +++ b/Source/usbd_audio.cpp @@ -113,11 +113,9 @@ USBD_ClassTypeDef USBD_AUDIO = * Set feedback value from sample rate */ static void get_usb_full_speed_rate(unsigned int rate, uint8_t* buf){ - // usbd_rx_capacity = rate; // convert sample rate to 10.14 format rate = (rate / 1000.0f) * (1<<14); AUDIO_FREQ_TO_DATA(rate, buf); - // usbd_rx_capacity = rate - 786432; } #endif From f0e78279181485a7e135f07b35bd714d938c9f59 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 5 Oct 2021 17:06:02 +0200 Subject: [PATCH 098/286] updated docs --- openware-notes.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/openware-notes.txt b/openware-notes.txt index 112fcb1d..2511185b 100644 --- a/openware-notes.txt +++ b/openware-notes.txt @@ -234,6 +234,11 @@ OWLPORT=`amidi -l|grep OWL|sed 's/.*\(hw:.*\),.*/\1/g'` Record 2 seconds 48k 16bit stereo arecord -D hw:1 -c 2 -r 48000 -f S16_LE out.wav +AUDIODEV=hw:1 rec out.wav + +Playback +aplay -D hw:1 out.wav +AUDIODEV=hw:1 play out.wav ----------------------------------------------------------------- From 3514ff0b2eb8b4a1a8d926b650f03b0d59432d1d Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 5 Oct 2021 17:07:50 +0200 Subject: [PATCH 099/286] bump version and update history --- HISTORY.md | 14 +++++++++++++- Source/device.h | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 8721a7f9..c95ba073 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,15 @@ +22.1.rc1 +------ + +* Fix USBD audio sync issues: +* rx asynchronous mode with explicit feedback +* tx asynchronous mode with variable output size +* Fix USBD audio descriptor issues (Windows support) + +Known Issues: +* USB Host does not support reconnecting devices + + 22.0.0 ------ @@ -119,4 +131,4 @@ Known Issues: 20.0.0 ------ -* First release of the OpenWare firmware as shipped on Alchemist and Wizard Kickstarter rewards \ No newline at end of file +* First release of the OpenWare firmware as shipped on Alchemist and Wizard Kickstarter rewards diff --git a/Source/device.h b/Source/device.h index 49b17ed5..b6019557 100644 --- a/Source/device.h +++ b/Source/device.h @@ -3,7 +3,7 @@ #include "hardware.h" -#define FIRMWARE_VERSION "v22.0.1rc0" +#define FIRMWARE_VERSION "v22.1.rc1" #ifdef USE_SPI_FLASH #define MAX_SPI_FLASH_HEADERS 32 From a3a913ff04e5525d60456b25fd20a4c3ad4df895 Mon Sep 17 00:00:00 2001 From: antisvin Date: Thu, 7 Oct 2021 23:23:27 +0300 Subject: [PATCH 100/286] Sync global param --- Source/MagusParameterController.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/MagusParameterController.hpp b/Source/MagusParameterController.hpp index e1d94c97..e62778f2 100644 --- a/Source/MagusParameterController.hpp +++ b/Source/MagusParameterController.hpp @@ -1023,6 +1023,7 @@ class ParameterController { // We must update encoder value before calculating user value, otherwise // previous value would be displayed user[selectedPid[i]] = getEncoderValue(i); + selectGlobalParameter(selectedPid[i]); } if(displayMode == SELECTBLOCKPARAMETER && selectedBlock == i) displayMode = STANDARD; From 8236ded0de372881f8237fcb03e88c765c7b1d2d Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 8 Oct 2021 02:14:12 +0200 Subject: [PATCH 101/286] changed dependencies from usbd_audio.c to .cpp --- Alchemist/Makefile | 2 +- BioSignals/Makefile | 2 +- Lich/Makefile | 2 +- Magus/Makefile | 2 +- Magus3/Makefile | 2 +- Mussol/Makefile | 2 +- Noctua/Makefile | 2 +- OwlPedal/Makefile | 2 +- Wizard/Makefile | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Alchemist/Makefile b/Alchemist/Makefile index a9db5952..e6d1367f 100644 --- a/Alchemist/Makefile +++ b/Alchemist/Makefile @@ -8,7 +8,7 @@ C_SRC = $(wildcard Src/*.c) CPP_SRC = $(wildcard Src/*.cpp) C_SRC += $(OPENWARE)/Source/sdram.c C_SRC += $(OPENWARE)/Source/cs4272.c -C_SRC += $(OPENWARE)/Source/usbd_audio.c +CPP_SRC += $(OPENWARE)/Source/usbd_audio.cpp include $(OPENWARE)/Hardware/sources.mk diff --git a/BioSignals/Makefile b/BioSignals/Makefile index be1ee131..5ee67eec 100644 --- a/BioSignals/Makefile +++ b/BioSignals/Makefile @@ -8,7 +8,7 @@ include $(OPENWARE)/Hardware/owl2.mk C_SRC = $(wildcard Src/*.c) CPP_SRC = $(wildcard Src/*.cpp) C_SRC += $(OPENWARE)/Source/ble_midi.c -C_SRC += $(OPENWARE)/Source/usbd_audio.c +CPP_SRC += $(OPENWARE)/Source/usbd_audio.cpp include $(OPENWARE)/Hardware/sources.mk diff --git a/Lich/Makefile b/Lich/Makefile index 6c6381da..8d28666c 100644 --- a/Lich/Makefile +++ b/Lich/Makefile @@ -8,7 +8,7 @@ C_SRC = $(wildcard Src/*.c) CPP_SRC = $(wildcard Src/*.cpp) C_SRC += $(OPENWARE)/Source/sdram.c C_SRC += $(OPENWARE)/Source/cs4272.c -C_SRC += $(OPENWARE)/Source/usbd_audio.c +CPP_SRC += $(OPENWARE)/Source/usbd_audio.cpp CPP_SRC += $(OPENWARE)/Source/usbh_midi.cpp CPP_SRC += $(OPENWARE)/Source/uart.cpp CPP_SRC += $(OPENWARE)/Source/bus.cpp diff --git a/Magus/Makefile b/Magus/Makefile index 10b2dd70..2628b40d 100644 --- a/Magus/Makefile +++ b/Magus/Makefile @@ -12,7 +12,7 @@ C_SRC += $(OPENWARE)/Source/ssd1309.c C_SRC += $(OPENWARE)/Source/HAL_MAX11300.c C_SRC += $(OPENWARE)/Source/HAL_TLC5946.c C_SRC += $(OPENWARE)/Source/HAL_Encoders.c -C_SRC += $(OPENWARE)/Source/usbd_audio.c +CPP_SRC += $(OPENWARE)/Source/usbd_audio.cpp CPP_SRC += $(OPENWARE)/Source/usbh_midi.cpp CPP_SRC += $(OPENWARE)/Source/uart.cpp CPP_SRC += $(OPENWARE)/Source/uart_midi.cpp diff --git a/Magus3/Makefile b/Magus3/Makefile index a980a29d..4372e577 100644 --- a/Magus3/Makefile +++ b/Magus3/Makefile @@ -12,7 +12,7 @@ C_SRC += $(OPENWARE)/Source/ssd1309.c C_SRC += $(OPENWARE)/Source/HAL_MAX11300.c C_SRC += $(OPENWARE)/Source/HAL_TLC5946.c C_SRC += $(OPENWARE)/Source/HAL_Encoders.c -C_SRC += $(OPENWARE)/Source/usbd_audio.c +CPP_SRC += $(OPENWARE)/Source/usbd_audio.cpp CPP_SRC += $(OPENWARE)/Source/usbh_midi.cpp CPP_SRC += $(OPENWARE)/Source/uart.cpp CPP_SRC += $(OPENWARE)/Source/ScreenBuffer.cpp diff --git a/Mussol/Makefile b/Mussol/Makefile index 00fa16fd..1a561936 100644 --- a/Mussol/Makefile +++ b/Mussol/Makefile @@ -6,7 +6,7 @@ include $(OPENWARE)/Hardware/mussol.mk C_SRC = $(wildcard Src/*.c) CPP_SRC = $(wildcard Src/*.cpp) -C_SRC += $(OPENWARE)/Source/usbd_audio.c +CPP_SRC += $(OPENWARE)/Source/usbd_audio.cpp C_SRC += $(OPENWARE)/Source/usbh_midi.c include $(OPENWARE)/Hardware/sources.mk diff --git a/Noctua/Makefile b/Noctua/Makefile index 31705a82..ec6e2868 100644 --- a/Noctua/Makefile +++ b/Noctua/Makefile @@ -9,7 +9,7 @@ C_SRC = $(wildcard Src/*.c) CPP_SRC = $(wildcard Src/*.cpp) C_SRC += $(OPENWARE)/Source/iis3dwb_reg.c C_SRC += $(OPENWARE)/Source/pcm3168a.c -C_SRC += $(OPENWARE)/Source/usbd_audio.c +CPP_SRC += $(OPENWARE)/Source/usbd_audio.cpp CPP_SRC += $(OPENWARE)/Source/uart.cpp CPP_SRC += $(OPENWARE)/Source/uart_midi.cpp CPP_SRC += $(OPENWARE)/Source/usbh_midi.cpp diff --git a/OwlPedal/Makefile b/OwlPedal/Makefile index bb6c584e..a2add535 100644 --- a/OwlPedal/Makefile +++ b/OwlPedal/Makefile @@ -6,7 +6,7 @@ include $(OPENWARE)/Hardware/owl1.mk C_SRC = $(wildcard Src/*.c) CPP_SRC = $(wildcard Src/*.cpp) C_SRC += $(OPENWARE)/Source/wm8731.c -C_SRC += $(OPENWARE)/Source/usbd_audio.c +CPP_SRC += $(OPENWARE)/Source/usbd_audio.cpp ifndef PLATFORM PLATFORM = Pedal diff --git a/Wizard/Makefile b/Wizard/Makefile index 36d82d3e..7f84f1c9 100644 --- a/Wizard/Makefile +++ b/Wizard/Makefile @@ -12,7 +12,7 @@ C_SRC += $(OPENWARE)/Source/usb_device.c C_SRC += $(OPENWARE)/Source/usbd_desc.c C_SRC += $(OPENWARE)/Source/usbd_conf.c C_SRC += $(OPENWARE)/Source/usbh_conf.c -C_SRC += $(OPENWARE)/Source/usbd_audio.c +CPP_SRC += $(OPENWARE)/Source/usbd_audio.cpp CPP_SRC += $(OPENWARE)/Source/usbh_midi.cpp include $(OPENWARE)/Hardware/sources.mk From 35d815ccde95f67f454c16bd4926db5805e6ced0 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 8 Oct 2021 14:09:19 +0200 Subject: [PATCH 102/286] allow for channel disparities --- Noctua/Inc/hardware.h | 12 +++---- Source/ProgramManager.cpp | 76 ++++++++++++++++++++++++--------------- Source/usbd_audio.cpp | 45 ++++++++++++++--------- 3 files changed, 81 insertions(+), 52 deletions(-) diff --git a/Noctua/Inc/hardware.h b/Noctua/Inc/hardware.h index a2a36c6c..daa2e0f1 100644 --- a/Noctua/Inc/hardware.h +++ b/Noctua/Inc/hardware.h @@ -31,18 +31,18 @@ /* #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(__REV16(x))<<8) */ #define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) -#define USBD_AUDIO_RX_CHANNELS 8 -#define USBD_AUDIO_TX_CHANNELS 8 +#define USBD_AUDIO_RX_CHANNELS 4 +#define USBD_AUDIO_TX_CHANNELS 4 #define USE_USBD_AUDIO -/* #define USE_USBD_RX_FB */ -/* #define USE_USBD_AUDIO_FEATURES not compatible with 8 channels */ +#define USE_USBD_RX_FB +#define USE_USBD_AUDIO_FEATURES #define USE_USBD_AUDIO_TX // microphone -/* #define USE_USBD_AUDIO_RX // speaker */ +#define USE_USBD_AUDIO_RX // speaker #define USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS #define USBH_HANDLE hUsbHostHS -#define USBD_MAX_POWER 100 // 200mA for iPad compatibility +/* #define USBD_MAX_POWER 100 // 200mA for iPad compatibility */ #define USE_USB_HOST #define USB_HOST_RX_BUFF_SIZE 256 /* Max Received data 64 bytes */ #define USE_USBH_MIDI diff --git a/Source/ProgramManager.cpp b/Source/ProgramManager.cpp index 9e471a05..fa2020ff 100644 --- a/Source/ProgramManager.cpp +++ b/Source/ProgramManager.cpp @@ -75,13 +75,7 @@ void usbd_audio_rx_stop_callback(){ #endif } -// void usbd_rx_convert(int32_t* dst, size_t len){ -// usbd_audio_rx_count += len; -// while(len--) -// *dst++ = AUDIO_SAMPLE_TO_INT32(usbd_rx->read()); -// } - -void usbd_rx_convert_add(int32_t* dst, size_t len){ +void usbd_rx_convert(int32_t* dst, size_t len){ usbd_audio_rx_count += len; size_t cap = usbd_rx->getReadCapacity(); if(cap < len){ @@ -92,13 +86,29 @@ void usbd_rx_convert_add(int32_t* dst, size_t len){ debugMessage("rx unf", (int)(len - cap)); #endif } +#if USBD_AUDIO_RX_CHANNELS == AUDIO_CHANNELS +#if AUDIO_BITS_PER_SAMPLE == 32 + usbd_rx->read(dst, len); +#else while(len--) - *dst++ = __SSAT(*dst + AUDIO_SAMPLE_TO_INT32(usbd_rx->read()), 24); -} - -#if USBD_AUDIO_RX_CHANNELS != AUDIO_CHANNELS -#error "todo: support for USBD_AUDIO_RX_CHANNELS != AUDIO_CHANNELS" + *dst++ = AUDIO_SAMPLE_TO_INT32(usbd_rx->read()); +#endif +#else /* USBD_AUDIO_RX_CHANNELS != AUDIO_CHANNELS */ + len /= AUDIO_CHANNELS; + while(len--){ +#if AUDIO_BITS_PER_SAMPLE == 32 + usbd_rx->read(dst, USBD_AUDIO_RX_CHANNELS); + dst += AUDIO_CHANNELS; +#else + audio_t* src = usbd_rx->getReadHead(); + for(int ch=0; chmoveReadHead(USBD_AUDIO_RX_CHANNELS); + dst += AUDIO_CHANNELS - USBD_AUDIO_RX_CHANNELS; #endif + } +#endif +} void usbd_tx_convert(int32_t* src, size_t len){ size_t cap = usbd_tx->getWriteCapacity() - USBD_AUDIO_TX_CHANNELS; @@ -110,21 +120,31 @@ void usbd_tx_convert(int32_t* src, size_t len){ debugMessage("tx ovf", (int)(len - cap)); #endif } +#if USBD_AUDIO_TX_CHANNELS == AUDIO_CHANNELS +#if AUDIO_BITS_PER_SAMPLE == 32 + usbd_tx->write(src, len); +#else while(len--) - // macro handles shift, round, dither, clip, truncate, bitswap usbd_tx->write(AUDIO_INT32_TO_SAMPLE(*src++)); -} - -// void usbd_tx_convert_add(int32_t* src, size_t len){ -// while(len--) -// usbd_tx->overdub(AUDIO_INT32_TO_SAMPLE(*src++)); -// } - -#if USBD_AUDIO_TX_CHANNELS != AUDIO_CHANNELS -#error "todo: support for USBD_AUDIO_TX_CHANNELS != AUDIO_CHANNELS" #endif - +#else /* USBD_AUDIO_TX_CHANNELS != AUDIO_CHANNELS */ + len /= AUDIO_CHANNELS; + while(len--){ +#if AUDIO_BITS_PER_SAMPLE == 32 + usbd_tx->write(src, USBD_AUDIO_TX_CHANNELS); + src += AUDIO_CHANNELS; +#else + audio_t* dst = usbd_tx->getWriteHead(); + for(int ch=0; chmoveWriteHead(USBD_AUDIO_TX_CHANNELS); + src += AUDIO_CHANNELS - USBD_AUDIO_TX_CHANNELS; #endif + } +#endif +} + +#endif /* USE_USBD_AUDIO */ // FreeRTOS low priority numbers denote low priority tasks. // The idle task has priority zero (tskIDLE_PRIORITY). @@ -242,12 +262,12 @@ void setButtonValue(uint8_t ch, uint8_t value){ void onProgramReady(){ ProgramVector* pv = getProgramVector(); #ifdef USE_USBD_AUDIO_TX - if(usbd_tx) // after patch runs: convert wet output to USBD audio tx + if(usbd_tx) // after patch runs: convert patch output to USBD audio tx usbd_tx_convert(pv->audio_output, pv->audio_blocksize*AUDIO_CHANNELS); #endif #ifdef USE_USBD_AUDIO_RX - if(usbd_rx) // after patch runs: convert USBD audio rx to DAC (summing patch output) - usbd_rx_convert_add(pv->audio_output, pv->audio_blocksize*AUDIO_CHANNELS); + if(usbd_rx) // after patch runs: convert USBD audio rx to DAC (overwriting patch output) + usbd_rx_convert(pv->audio_output, pv->audio_blocksize*AUDIO_CHANNELS); #endif #ifdef DEBUG_DWT pv->cycles_per_block = DWT->CYCCNT; @@ -255,10 +275,8 @@ void onProgramReady(){ /* Block indefinitely (released by audioCallback) */ ulTaskNotifyTake(pdTRUE, portMAX_DELAY); #ifdef USE_USBD_AUDIO_RX - // if(usbd_rx) // before patch runs: convert USBD audio rx to input (overwriting ADC) + // if(usbd_rx) // before patch runs: convert USBD audio rx to patch input (overwriting ADC) // usbd_rx_convert(pv->audio_input, pv->audio_blocksize*AUDIO_CHANNELS); - // if(usbd_rx) // before patch runs: convert USBD audio rx to input (summing ADC) - // usbd_rx_convert_add(pv->audio_input, pv->audio_blocksize*AUDIO_CHANNELS); #endif #ifdef DEBUG_DWT DWT->CYCCNT = 0; diff --git a/Source/usbd_audio.cpp b/Source/usbd_audio.cpp index 0cf039ec..9537e747 100644 --- a/Source/usbd_audio.cpp +++ b/Source/usbd_audio.cpp @@ -177,12 +177,14 @@ static void get_usb_full_speed_rate(unsigned int rate, uint8_t* buf){ #define MIDI_TX_EP 0x81 #endif -#ifdef USE_USBD_AUDIO_RX #ifdef USE_USBD_AUDIO_FEATURES -#define USBD_AUDIO_RX_AC_DESC_LEN 31 +#define USBD_AUDIO_RX_AF_DESC_LEN (8+USBD_AUDIO_RX_CHANNELS) #else -#define USBD_AUDIO_RX_AC_DESC_LEN 21 +#define USBD_AUDIO_RX_AF_DESC_LEN 0 #endif + +#ifdef USE_USBD_AUDIO_RX +#define USBD_AUDIO_RX_AC_DESC_LEN (21+USBD_AUDIO_RX_AF_DESC_LEN) #ifdef USE_USBD_RX_FB #define USBD_AUDIO_RX_AS_DESC_LEN 61 #else @@ -195,12 +197,14 @@ static void get_usb_full_speed_rate(unsigned int rate, uint8_t* buf){ #define USBD_AUDIO_RX_NUM_INTERFACES 0 #endif -#ifdef USE_USBD_AUDIO_TX #ifdef USE_USBD_AUDIO_FEATURES -#define USBD_AUDIO_TX_AC_DESC_LEN 31 +#define USBD_AUDIO_TX_AF_DESC_LEN (8+USBD_AUDIO_TX_CHANNELS) #else -#define USBD_AUDIO_TX_AC_DESC_LEN 21 +#define USBD_AUDIO_TX_AF_DESC_LEN 0 #endif + +#ifdef USE_USBD_AUDIO_TX +#define USBD_AUDIO_TX_AC_DESC_LEN (21+USBD_AUDIO_TX_AF_DESC_LEN) #define USBD_AUDIO_TX_AS_DESC_LEN 52 #define USBD_AUDIO_TX_NUM_INTERFACES 1 #else @@ -306,16 +310,19 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x02, // bUnitID 0x01, // bSourceID 0x01, // bControlSize - // 0x00, // bmaControls(0) AUDIO_CONTROL_REQ_FU_MUTE, // bmaControls(0) Master AUDIO_CONTROL_REQ_FU_VOL, // bmaControls(1) Channel 1 +#if USBD_AUDIO_RX_CHANNELS > 1 AUDIO_CONTROL_REQ_FU_VOL, // bmaControls(2) Channel 2 - 0x00, // iTerminal - /* 10 byte */ - -#if USBD_AUDIO_RX_CHANNELS != 2 -#error "incompatible channel count / todo" +#if USBD_AUDIO_RX_CHANNELS > 2 + AUDIO_CONTROL_REQ_FU_VOL, // bmaControls(3) Channel 3 +#if USBD_AUDIO_RX_CHANNELS > 3 + AUDIO_CONTROL_REQ_FU_VOL, // bmaControls(4) Channel 4 +#endif #endif +#endif + 0x00, // iTerminal + /* 8 + ch byte */ /* Output Terminal Descriptor */ 0x09, // bLength @@ -370,13 +377,17 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x01, // bControlSize AUDIO_CONTROL_REQ_FU_MUTE, // bmaControls(0) Master AUDIO_CONTROL_REQ_FU_VOL, // bmaControls(1) Channel 1 +#if USBD_AUDIO_TX_CHANNELS > 1 AUDIO_CONTROL_REQ_FU_VOL, // bmaControls(2) Channel 2 - 0x00, // iTerminal - /* 10 byte */ - -#if USBD_AUDIO_TX_CHANNELS != 2 -#error "incompatible channel count / todo" +#if USBD_AUDIO_TX_CHANNELS > 2 + AUDIO_CONTROL_REQ_FU_VOL, // bmaControls(3) Channel 3 +#if USBD_AUDIO_TX_CHANNELS > 3 + AUDIO_CONTROL_REQ_FU_VOL, // bmaControls(4) Channel 4 +#endif #endif +#endif + 0x00, // iTerminal + /* 8 + ch byte */ /* USB Microphone Output Terminal Descriptor */ 0x09, // Size of the descriptor, in bytes (bLength) From 22d5c0311ebf36ac9df85d5667a13ab8dc550acc Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 8 Oct 2021 16:34:15 +0200 Subject: [PATCH 103/286] removed redundant USBD_MAX_POWER definition --- MidiBoot3/Inc/hardware.h | 1 - 1 file changed, 1 deletion(-) diff --git a/MidiBoot3/Inc/hardware.h b/MidiBoot3/Inc/hardware.h index d4c8a158..5cd776ee 100644 --- a/MidiBoot3/Inc/hardware.h +++ b/MidiBoot3/Inc/hardware.h @@ -4,7 +4,6 @@ #define USE_BOOTLOADER_MODE #define USE_USBD_MIDI -#define USBD_MAX_POWER 100 // 100mA for iPad compatibility #ifdef USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS #else From fcd3f1d7a8b56825efefc0aa2887d468eebfb3e5 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 13 Oct 2021 16:51:22 +0200 Subject: [PATCH 104/286] changed how fifo sizes are calculated --- Source/usbd_audio.cpp | 76 +++++++++++++++++++++---------------------- Source/usbd_audio.h | 5 ++- 2 files changed, 41 insertions(+), 40 deletions(-) diff --git a/Source/usbd_audio.cpp b/Source/usbd_audio.cpp index 9537e747..03a10dba 100644 --- a/Source/usbd_audio.cpp +++ b/Source/usbd_audio.cpp @@ -128,12 +128,14 @@ static void get_usb_full_speed_rate(unsigned int rate, uint8_t* buf){ #define AUDIO_TX_EP 0x82 #define MIDI_RX_EP 0x02 #define MIDI_TX_EP 0x83 +#define AUDIO_RX_FIFO_SIZE (USBD_TOTAL_FIFO_SIZE - 2*USBD_MIN_FIFO_SIZE - MIDI_TX_PACKET_SIZE - AUDIO_TX_MAX_PACKET_SIZE) #elif defined USE_USBD_AUDIO_RX && defined USE_USBD_RX_FB && defined USE_USBD_AUDIO_TX #define AUDIO_RX_IF 0x01 #define AUDIO_TX_IF 0x02 #define AUDIO_RX_EP 0x01 #define AUDIO_FB_EP 0x81 #define AUDIO_TX_EP 0x82 +#define AUDIO_RX_FIFO_SIZE (USBD_TOTAL_FIFO_SIZE - 2*USBD_MIN_FIFO_SIZE - AUDIO_TX_MAX_PACKET_SIZE) #elif defined USE_USBD_AUDIO_RX && defined USE_USBD_RX_FB && defined USE_USBD_MIDI #define AUDIO_RX_IF 0x01 #define AUDIO_MIDI_IF 0x02 @@ -141,6 +143,7 @@ static void get_usb_full_speed_rate(unsigned int rate, uint8_t* buf){ #define AUDIO_FB_EP 0x81 #define MIDI_RX_EP 0x02 #define MIDI_TX_EP 0x82 +#define AUDIO_RX_FIFO_SIZE (USBD_TOTAL_FIFO_SIZE - 2*USBD_MIN_FIFO_SIZE - MIDI_TX_PACKET_SIZE) #elif defined USE_USBD_AUDIO_RX && defined USE_USBD_AUDIO_TX && defined USE_USBD_MIDI #define AUDIO_RX_IF 0x01 // bInterfaceNumber #define AUDIO_TX_IF 0x02 @@ -149,23 +152,27 @@ static void get_usb_full_speed_rate(unsigned int rate, uint8_t* buf){ #define AUDIO_TX_EP 0x81 #define MIDI_RX_EP 0x02 #define MIDI_TX_EP 0x82 +#define AUDIO_RX_FIFO_SIZE (USBD_TOTAL_FIFO_SIZE - USBD_MIN_FIFO_SIZE - MIDI_TX_PACKET_SIZE - AUDIO_TX_MAX_PACKET_SIZE) #elif defined USE_USBD_AUDIO_RX && defined USE_USBD_AUDIO_TX #define AUDIO_RX_IF 0x01 #define AUDIO_TX_IF 0x02 #define AUDIO_RX_EP 0x01 #define AUDIO_TX_EP 0x81 +#define AUDIO_RX_FIFO_SIZE (USBD_TOTAL_FIFO_SIZE - USBD_MIN_FIFO_SIZE - AUDIO_TX_MAX_PACKET_SIZE) #elif defined USE_USBD_AUDIO_RX && defined USE_USBD_MIDI #define AUDIO_RX_IF 0x01 #define AUDIO_MIDI_IF 0x02 #define AUDIO_RX_EP 0x01 #define MIDI_RX_EP 0x02 #define MIDI_TX_EP 0x81 +#define AUDIO_RX_FIFO_SIZE (USBD_TOTAL_FIFO_SIZE - USBD_MIN_FIFO_SIZE) #elif defined USE_USBD_AUDIO_TX && defined USE_USBD_MIDI #define AUDIO_TX_IF 0x01 #define AUDIO_MIDI_IF 0x02 #define AUDIO_TX_EP 0x81 #define MIDI_RX_EP 0x02 #define MIDI_TX_EP 0x82 +#define AUDIO_RX_FIFO_SIZE (USBD_TOTAL_FIFO_SIZE - USBD_MIN_FIFO_SIZE - MIDI_TX_PACKET_SIZE - AUDIO_TX_MAX_PACKET_SIZE) #else #define AUDIO_RX_IF 0x01 #define AUDIO_TX_IF 0x01 @@ -177,6 +184,13 @@ static void get_usb_full_speed_rate(unsigned int rate, uint8_t* buf){ #define MIDI_TX_EP 0x81 #endif +#if AUDIO_RX_FIFO_SIZE < (AUDIO_RX_MAX_PACKET_SIZE + 2*USBD_MIN_FIFO_SIZE) +#pragma message "USBD RX FIFO small" +#endif +#if AUDIO_RX_FIFO_SIZE < USBD_MIN_FIFO_SIZE +#error "USBD RX FIFO too small" +#endif + #ifdef USE_USBD_AUDIO_FEATURES #define USBD_AUDIO_RX_AF_DESC_LEN (8+USBD_AUDIO_RX_CHANNELS) #else @@ -1621,46 +1635,30 @@ uint8_t USBD_AUDIO_RegisterInterface (USBD_HandleTypeDef *pdev, } uint8_t USBD_AUDIO_SetFiFos(PCD_HandleTypeDef *hpcd){ -#if defined USE_USBD_AUDIO_RX && defined USE_USBD_AUDIO_TX && defined USE_USBD_MIDI && defined USE_USBD_RX_FB - HAL_PCDEx_SetRxFiFo(hpcd, 0x80); - HAL_PCDEx_SetTxFiFo(hpcd, 0, 0x20); - HAL_PCDEx_SetTxFiFo(hpcd, 1, 0x40); - HAL_PCDEx_SetTxFiFo(hpcd, 2, 0x40); - HAL_PCDEx_SetTxFiFo(hpcd, 3, 0x20); -#elif defined USE_USBD_AUDIO_RX && defined USE_USBD_AUDIO_TX && defined USE_USBD_RX_FB - HAL_PCDEx_SetRxFiFo(hpcd, 0x80); - HAL_PCDEx_SetTxFiFo(hpcd, 0, 0x20); - HAL_PCDEx_SetTxFiFo(hpcd, 1, 0x60); - HAL_PCDEx_SetTxFiFo(hpcd, 2, 0x40); -#elif defined USE_USBD_AUDIO_RX && defined USE_USBD_MIDI && defined USE_USBD_RX_FB - HAL_PCDEx_SetRxFiFo(hpcd, 0x80); - HAL_PCDEx_SetTxFiFo(hpcd, 0, 0x20); - HAL_PCDEx_SetTxFiFo(hpcd, 1, 0x60); - HAL_PCDEx_SetTxFiFo(hpcd, 2, 0x40); -#elif defined USE_USBD_AUDIO_RX && defined USE_USBD_AUDIO_TX && defined USE_USBD_MIDI - HAL_PCDEx_SetRxFiFo(hpcd, 0x80); - HAL_PCDEx_SetTxFiFo(hpcd, 0, 0x20); - HAL_PCDEx_SetTxFiFo(hpcd, 1, 0x60); - HAL_PCDEx_SetTxFiFo(hpcd, 2, 0x40); -#elif defined USE_USBD_AUDIO_RX && defined USE_USBD_AUDIO_TX - HAL_PCDEx_SetRxFiFo(hpcd, 0xa0); - HAL_PCDEx_SetTxFiFo(hpcd, 0, 0x20); - HAL_PCDEx_SetTxFiFo(hpcd, 1, 0x80); -#elif defined USE_USBD_AUDIO_RX && defined USE_USBD_MIDI - HAL_PCDEx_SetRxFiFo(hpcd, 0xa0); - HAL_PCDEx_SetTxFiFo(hpcd, 0, 0x20); - HAL_PCDEx_SetTxFiFo(hpcd, 1, 0x80); -#elif defined USE_USBD_AUDIO_TX && defined USE_USBD_MIDI - HAL_PCDEx_SetRxFiFo(hpcd, 0x80); - HAL_PCDEx_SetTxFiFo(hpcd, 0, 0x20); - HAL_PCDEx_SetTxFiFo(hpcd, 1, 0x60); - HAL_PCDEx_SetTxFiFo(hpcd, 2, 0x40); -#else - HAL_PCDEx_SetRxFiFo(hpcd, 0xa0); - HAL_PCDEx_SetTxFiFo(hpcd, 0, 0x40); - HAL_PCDEx_SetTxFiFo(hpcd, 1, 0x60); + // HAL_PCDEx_SetTxFiFo() must be called after HAL_PCDEx_SetRxFiFo(). + // HAL_PCDEx_SetTxFiFo() must be called in the order of the endpoint number. + // Size is represented in terms of 4-byte words. Minimum: 16 words, maximum: 256 words + // The total of FIFO sizes should be no more than the 1.25 Kbytes USB RAM + // Total 0x140 words / 1280 bytes available for rx and tx fifos + // The FIFO is used optimally when used TxFIFOs are allocated in the top + // of the FIFO.Ex: use EP1 and EP2 as IN instead of EP1 and EP3 as IN ones. + // When DMA is used 3n * FIFO locations should be reserved for internal DMA registers + // STM32H7 A dedicated 4-Kbyte RAM can be divided into 1 shared RxFIFO and up to 9 TxFIFOs + HAL_PCDEx_SetRxFiFo(hpcd, AUDIO_RX_FIFO_SIZE/4); + HAL_PCDEx_SetTxFiFo(hpcd, 0x00, USBD_MIN_FIFO_SIZE/4); // control i/f + +#if defined USE_USBD_AUDIO_RX && defined USE_USBD_RX_FB + HAL_PCDEx_SetTxFiFo(hpcd, AUDIO_FB_EP & 0x0f, USBD_MIN_FIFO_SIZE/4); +#endif + +#if defined USE_USBD_AUDIO_TX + HAL_PCDEx_SetTxFiFo(hpcd, AUDIO_TX_EP & 0x0f, AUDIO_TX_MAX_PACKET_SIZE/4); #endif - /* total 0x140 words available for rx and tx fifos */ + +#if defined USE_USBD_MIDI + HAL_PCDEx_SetTxFiFo(hpcd, MIDI_TX_EP & 0x0f, MIDI_TX_PACKET_SIZE/4); +#endif + return USBD_OK; } diff --git a/Source/usbd_audio.h b/Source/usbd_audio.h index 547ef547..ecddbe04 100644 --- a/Source/usbd_audio.h +++ b/Source/usbd_audio.h @@ -49,7 +49,10 @@ #define MIDI_TX_PACKET_SIZE 0x40 #define MIDI_RX_PACKET_SIZE 0x40 - + +#define USBD_TOTAL_FIFO_SIZE 0x500 +#define USBD_MIN_FIFO_SIZE 0x40 + /* Isochronous Synchronisation Type */ #define USBD_EP_ATTR_ISOC_NOSYNC 0x00 /* no synchro */ #define USBD_EP_ATTR_ISOC_ASYNC 0x04 /* synchronisation by feedback */ From 1ada70346c26b6b7192adaa804f800d0d1d62152 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 13 Oct 2021 17:28:47 +0200 Subject: [PATCH 105/286] updated configuration to Rev03 --- OwlPedal2/Inc/main.h | 36 +++-- OwlPedal2/Inc/stm32f4xx_hal_conf.h | 34 +++-- OwlPedal2/Inc/stm32f4xx_it.h | 3 +- OwlPedal2/Makefile | 2 +- OwlPedal2/OwlPedal2.ioc | 205 ++++++++++++++--------------- OwlPedal2/Src/main.c | 89 +++++++------ OwlPedal2/Src/stm32f4xx_hal_msp.c | 10 ++ OwlPedal2/Src/stm32f4xx_it.c | 45 +++---- 8 files changed, 210 insertions(+), 214 deletions(-) diff --git a/OwlPedal2/Inc/main.h b/OwlPedal2/Inc/main.h index 28b54c67..f1bd2d37 100644 --- a/OwlPedal2/Inc/main.h +++ b/OwlPedal2/Inc/main.h @@ -100,10 +100,12 @@ void Error_Handler(void); #define CS_SDA_GPIO_Port GPIOE #define EXTSPI_nCS_Pin GPIO_PIN_15 #define EXTSPI_nCS_GPIO_Port GPIOC -#define LED_RED_Pin GPIO_PIN_7 -#define LED_RED_GPIO_Port GPIOF -#define LED_GREEN_Pin GPIO_PIN_9 -#define LED_GREEN_GPIO_Port GPIOF +#define EXP2_T_Pin GPIO_PIN_7 +#define EXP2_T_GPIO_Port GPIOF +#define EXP2_T_EXTI_IRQn EXTI9_5_IRQn +#define EXP2_R_Pin GPIO_PIN_8 +#define EXP2_R_GPIO_Port GPIOF +#define EXP2_R_EXTI_IRQn EXTI9_5_IRQn #define ADC4_Pin GPIO_PIN_10 #define ADC4_GPIO_Port GPIOF #define ADC3_Pin GPIO_PIN_1 @@ -112,18 +114,11 @@ void Error_Handler(void); #define ADC2_GPIO_Port GPIOC #define ADC1_Pin GPIO_PIN_3 #define ADC1_GPIO_Port GPIOC -#define SW4_Pin GPIO_PIN_2 -#define SW4_GPIO_Port GPIOA -#define SW4_EXTI_IRQn EXTI2_IRQn -#define SW3_Pin GPIO_PIN_3 -#define SW3_GPIO_Port GPIOA -#define SW3_EXTI_IRQn EXTI3_IRQn -#define BYPASS_Pin GPIO_PIN_4 -#define BYPASS_GPIO_Port GPIOA -#define BYPASS_EXTI_IRQn EXTI4_IRQn -#define SW1_Pin GPIO_PIN_5 -#define SW1_GPIO_Port GPIOA -#define SW1_EXTI_IRQn EXTI9_5_IRQn +#define FOOTSWITCH_Pin GPIO_PIN_1 +#define FOOTSWITCH_GPIO_Port GPIOA +#define FOOTSWITCH_EXTI_IRQn EXTI1_IRQn +#define EXP_Pin GPIO_PIN_3 +#define EXP_GPIO_Port GPIOA #define FLASH_MISO_Pin GPIO_PIN_6 #define FLASH_MISO_GPIO_Port GPIOA #define FLASH_MOSI_Pin GPIO_PIN_7 @@ -146,13 +141,16 @@ void Error_Handler(void); #define USBD_DM_GPIO_Port GPIOA #define USBD_DP_Pin GPIO_PIN_12 #define USBD_DP_GPIO_Port GPIOA +#define SW1_Pin GPIO_PIN_2 +#define SW1_GPIO_Port GPIOD +#define SW1_EXTI_IRQn EXTI2_IRQn #define CS_SDIN_Pin GPIO_PIN_6 #define CS_SDIN_GPIO_Port GPIOD +#define SW2_Pin GPIO_PIN_9 +#define SW2_GPIO_Port GPIOG +#define SW2_EXTI_IRQn EXTI9_5_IRQn #define FLASH_SCK_Pin GPIO_PIN_3 #define FLASH_SCK_GPIO_Port GPIOB -#define SW2_Pin GPIO_PIN_8 -#define SW2_GPIO_Port GPIOB -#define SW2_EXTI_IRQn EXTI9_5_IRQn /* USER CODE BEGIN Private defines */ #define CS_CS_Pin GPIO_PIN_10 diff --git a/OwlPedal2/Inc/stm32f4xx_hal_conf.h b/OwlPedal2/Inc/stm32f4xx_hal_conf.h index 2ce794db..396890ad 100644 --- a/OwlPedal2/Inc/stm32f4xx_hal_conf.h +++ b/OwlPedal2/Inc/stm32f4xx_hal_conf.h @@ -76,6 +76,7 @@ /* #define HAL_QSPI_MODULE_ENABLED */ /* #define HAL_CEC_MODULE_ENABLED */ /* #define HAL_FMPI2C_MODULE_ENABLED */ +/* #define HAL_FMPSMBUS_MODULE_ENABLED */ /* #define HAL_SPDIFRX_MODULE_ENABLED */ /* #define HAL_DFSDM_MODULE_ENABLED */ /* #define HAL_LPTIM_MODULE_ENABLED */ @@ -94,11 +95,11 @@ * (when HSE is used as system clock source, directly or through the PLL). */ #if !defined (HSE_VALUE) - #define HSE_VALUE ((uint32_t)25000000U) /*!< Value of the External oscillator in Hz */ + #define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ #endif /* HSE_VALUE */ #if !defined (HSE_STARTUP_TIMEOUT) - #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ + #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ #endif /* HSE_STARTUP_TIMEOUT */ /** @@ -114,7 +115,7 @@ * @brief Internal Low Speed oscillator (LSI) value. */ #if !defined (LSI_VALUE) - #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/ + #define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/ #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz The real value may vary depending on the variations in voltage and temperature.*/ @@ -122,11 +123,11 @@ * @brief External Low Speed oscillator (LSE) value. */ #if !defined (LSE_VALUE) - #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */ + #define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ #endif /* LSE_VALUE */ #if !defined (LSE_STARTUP_TIMEOUT) - #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ + #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ #endif /* LSE_STARTUP_TIMEOUT */ /** @@ -135,7 +136,7 @@ * frequency, this source is inserted directly through I2S_CKIN pad. */ #if !defined (EXTERNAL_CLOCK_VALUE) - #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/ + #define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External audio frequency in Hz*/ #endif /* EXTERNAL_CLOCK_VALUE */ /* Tip: To avoid modifying this file each time you need to use different HSE, @@ -145,8 +146,8 @@ /** * @brief This is the HAL system configuration section */ -#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ -#define TICK_INT_PRIORITY ((uint32_t)15U) /*!< tick interrupt priority */ +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY 15U /*!< tick interrupt priority */ #define USE_RTOS 0U #define PREFETCH_ENABLE 1U #define INSTRUCTION_CACHE_ENABLE 1U @@ -166,6 +167,7 @@ #define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ #define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ #define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */ +#define USE_HAL_FMPSMBUS_REGISTER_CALLBACKS 0U /* FMPSMBUS register callback disabled */ #define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ #define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ #define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ @@ -213,20 +215,20 @@ /* Definition of the Ethernet driver buffers size and count */ #define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ #define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ -#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ -#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ +#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ /* Section 2: PHY configuration section */ /* DP83848_PHY_ADDRESS Address*/ #define DP83848_PHY_ADDRESS 0x01U /* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ -#define PHY_RESET_DELAY ((uint32_t)0x000000FFU) +#define PHY_RESET_DELAY 0x000000FFU /* PHY Configuration delay */ -#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU) +#define PHY_CONFIG_DELAY 0x00000FFFU -#define PHY_READ_TO ((uint32_t)0x0000FFFFU) -#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU) +#define PHY_READ_TO 0x0000FFFFU +#define PHY_WRITE_TO 0x0000FFFFU /* Section 3: Common PHY Registers */ @@ -444,6 +446,10 @@ #include "stm32f4xx_hal_fmpi2c.h" #endif /* HAL_FMPI2C_MODULE_ENABLED */ +#ifdef HAL_FMPSMBUS_MODULE_ENABLED + #include "stm32f4xx_hal_fmpsmbus.h" +#endif /* HAL_FMPSMBUS_MODULE_ENABLED */ + #ifdef HAL_SPDIFRX_MODULE_ENABLED #include "stm32f4xx_hal_spdifrx.h" #endif /* HAL_SPDIFRX_MODULE_ENABLED */ diff --git a/OwlPedal2/Inc/stm32f4xx_it.h b/OwlPedal2/Inc/stm32f4xx_it.h index 692f4f74..c695ac53 100644 --- a/OwlPedal2/Inc/stm32f4xx_it.h +++ b/OwlPedal2/Inc/stm32f4xx_it.h @@ -63,9 +63,8 @@ /* Exported functions prototypes ---------------------------------------------*/ void SysTick_Handler(void); +void EXTI1_IRQHandler(void); void EXTI2_IRQHandler(void); -void EXTI3_IRQHandler(void); -void EXTI4_IRQHandler(void); void ADC_IRQHandler(void); void EXTI9_5_IRQHandler(void); void DMA2_Stream1_IRQHandler(void); diff --git a/OwlPedal2/Makefile b/OwlPedal2/Makefile index 0fe62592..ddbad630 100644 --- a/OwlPedal2/Makefile +++ b/OwlPedal2/Makefile @@ -8,7 +8,7 @@ C_SRC = $(wildcard Src/*.c) CPP_SRC = $(wildcard Src/*.cpp) C_SRC += $(OPENWARE)/Source/sdram.c C_SRC += $(OPENWARE)/Source/cs4272.c -C_SRC += $(OPENWARE)/Source/usbd_audio.c +CPP_SRC += $(OPENWARE)/Source/usbd_audio.cpp include $(OPENWARE)/Hardware/sources.mk diff --git a/OwlPedal2/OwlPedal2.ioc b/OwlPedal2/OwlPedal2.ioc index 0ada8a97..2e9906b2 100644 --- a/OwlPedal2/OwlPedal2.ioc +++ b/OwlPedal2/OwlPedal2.ioc @@ -1,5 +1,5 @@ #MicroXplorer Configuration settings - do not modify -PF7.GPIOParameters=GPIO_Label +PF7.GPIOParameters=GPIO_PuPd,GPIO_Label SH.FMC_D7_DA7.0=FMC_D7,sd-16b-d1 Dma.ADC3.0.FIFOMode=DMA_FIFOMODE_DISABLE SH.FMC_D0_DA0.ConfNb=1 @@ -18,24 +18,24 @@ FMC.SDClockPeriod1=FMC_SDRAM_CLOCK_PERIOD_2 SH.FMC_A0.0=FMC_A0,12b-sda1 SPI1.VirtualType=VM_MASTER Dma.SAI1_B.2.MemDataAlignment=DMA_MDATAALIGN_WORD +SH.GPXTI9.0=GPIO_EXTI9 PG4.Signal=FMC_A14_BA0 PG8.Signal=FMC_SDCLK RCC.PLLCLKFreq_Value=168000000 RCC.PLLQCLKFreq_Value=48000000 PG0.Signal=FMC_A10 -PA3.GPIO_PuPd=GPIO_PULLUP FMC.LoadToActiveDelay1=2 VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled PC3.Locked=true RCC.RTCFreq_Value=32000 -PA3.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PA3.GPIOParameters=GPIO_Label PA6.GPIO_Label=FLASH_MISO Dma.SAI1_A.1.Mode=DMA_CIRCULAR +PD2.GPIOParameters=GPIO_PuPd,GPIO_Label SH.FMC_SDNWE.ConfNb=1 SH.FMC_D5_DA5.0=FMC_D5,sd-16b-d1 Dma.SAI1_A.1.MemDataAlignment=DMA_MDATAALIGN_WORD PD6.GPIO_Label=CS_SDIN -PA2.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI Dma.SAI1_B.2.Mode=DMA_CIRCULAR PinOutPanel.RotationAngle=0 PE6.GPIO_Label=CS_SDA @@ -44,10 +44,11 @@ SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 SH.FMC_D9_DA9.0=FMC_D9,sd-16b-d1 RCC.LPTIM1Freq_Value=54000000 USB_DEVICE.PID_AUDIO_FS=0xdada +SH.GPXTI7.ConfNb=1 NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false SAI1.FSDefinition-SAI_B_SyncSlave=SAI_FS_CHANNEL_IDENTIFICATION -SH.GPXTI3.ConfNb=1 -PF7.Signal=GPIO_Output +NVIC.EXTI1_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true +PF7.Signal=GPXTI7 SH.FMC_SDNWE.0=FMC_SDNWE,12b-sda1 SPI1.Direction=SPI_DIRECTION_2LINES SH.FMC_D11_DA11.0=FMC_D11,sd-16b-d1 @@ -70,34 +71,35 @@ PD8.Signal=FMC_D13_DA13 PE5.Signal=SAI1_SCK_A Dma.SAI1_A.1.FIFOMode=DMA_FIFOMODE_DISABLE PE1.Signal=FMC_NBL1 +PA1.GPIO_PuPd=GPIO_NOPULL PF10.GPIO_Label=ADC4 Dma.SAI1_A.1.MemInc=DMA_MINC_ENABLE RCC.USART3Freq_Value=54000000 RCC.PLLSAIRCLKFreq_Value=50000000 ProjectManager.ProjectBuild=false NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -PB3.Mode=Full_Duplex_Master ADC1.ScanConvMode=ENABLE -PA4.Locked=true +PB3.Mode=Full_Duplex_Master Dma.ADC3.0.PeriphInc=DMA_PINC_DISABLE +SH.GPXTI7.0=GPIO_EXTI7 ADC3.ExternalTrigConv=ADC_SOFTWARE_START FMC.SelfRefreshTime1=4 -ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.25.2 -MxDb.Version=DB.6.0.10 +ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.26.2 +MxDb.Version=DB.6.0.21 USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology USB_DEVICE.USBD_MAX_NUM_CONFIGURATION-AUDIO_FS=2 +PA1.GPIOParameters=GPIO_PuPd,GPIO_Label ProjectManager.BackupPrevious=false SAI1.SlotNumber-SAI_A_AsyncSlave=2 PC4.GPIO_Label=FLASH_HOLD PE9.Signal=FMC_D6_DA6 SH.FMC_A2.0=FMC_A2,12b-sda1 PB1.GPIO_Label=EXP_RING -PA5.GPIO_PuPd=GPIO_PULLUP SH.FMC_D15_DA15.ConfNb=1 ADC3.ContinuousConvMode=ENABLE PE4.GPIO_Label=CS_LRCK PF10.Locked=true -ADC3.IPParameters=Rank-31\#ChannelRegularConversion,Channel-31\#ChannelRegularConversion,SamplingTime-31\#ChannelRegularConversion,NbrOfConversionFlag,ScanConvMode,ContinuousConvMode,DMAContinuousRequests,EOCSelection,InjNumberOfConversion,EnableAnalogWatchDog,ExternalTrigConv,Rank-32\#ChannelRegularConversion,Channel-32\#ChannelRegularConversion,SamplingTime-32\#ChannelRegularConversion,Rank-33\#ChannelRegularConversion,Channel-33\#ChannelRegularConversion,SamplingTime-33\#ChannelRegularConversion,Rank-34\#ChannelRegularConversion,Channel-34\#ChannelRegularConversion,SamplingTime-34\#ChannelRegularConversion,NbrOfConversion,ClockPrescaler,Resolution,DataAlign,DiscontinuousConvMode,ExternalTrigConvEdge +ADC3.IPParameters=Rank-31\#ChannelRegularConversion,Channel-31\#ChannelRegularConversion,SamplingTime-31\#ChannelRegularConversion,NbrOfConversionFlag,ScanConvMode,ContinuousConvMode,DMAContinuousRequests,EOCSelection,InjNumberOfConversion,EnableAnalogWatchDog,ExternalTrigConv,Rank-32\#ChannelRegularConversion,Channel-32\#ChannelRegularConversion,SamplingTime-32\#ChannelRegularConversion,Rank-33\#ChannelRegularConversion,Channel-33\#ChannelRegularConversion,SamplingTime-33\#ChannelRegularConversion,Rank-34\#ChannelRegularConversion,Channel-34\#ChannelRegularConversion,SamplingTime-34\#ChannelRegularConversion,NbrOfConversion,ClockPrescaler,Resolution,DataAlign,DiscontinuousConvMode,ExternalTrigConvEdge,Rank-35\#ChannelRegularConversion,Channel-35\#ChannelRegularConversion,SamplingTime-35\#ChannelRegularConversion SH.ADCx_IN11.ConfNb=2 PE2.Signal=SPI4_SCK ADC3.Channel-33\#ChannelRegularConversion=ADC_CHANNEL_11 @@ -112,23 +114,22 @@ ProjectManager.HalAssertFull=true ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES RCC.MCO2PinFreq_Value=168000000 Mcu.Package=LQFP144 +PF8.GPIOParameters=GPIO_PuPd,GPIO_Label PB1.Signal=ADCx_IN9 -PA5.Locked=true SH.GPXTI8.0=GPIO_EXTI8 Dma.SAI1_A.1.Direction=DMA_MEMORY_TO_PERIPH SH.FMC_SDNCAS.ConfNb=1 VP_SYS_VS_Systick.Signal=SYS_VS_Systick -SH.FMC_A11.ConfNb=1 SH.GPXTI8.ConfNb=1 +SH.FMC_A11.ConfNb=1 FREERTOS.FootprintOK=true -PA5.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI FMC.WriteRecoveryTime1=2 PF7.Locked=true SH.ADCx_IN9.0=ADC1_IN9,IN9 SH.FMC_A1.0=FMC_A1,12b-sda1 ADC3.DMAContinuousRequests=ENABLE RCC.APB2CLKDivider=RCC_HCLK_DIV2 -NVIC.EXTI2_IRQn=true\:5\:0\:false\:false\:true\:false\:true\:true +NVIC.EXTI2_IRQn=true\:15\:0\:true\:false\:true\:false\:true\:true SH.FMC_SDCLK.0=FMC_SDCLK,12b-sda1 RCC.CECFreq_Value=32786.88524590164 PF14.Signal=FMC_A8 @@ -144,7 +145,6 @@ USB_OTG_FS.IPParameters=VirtualMode PB10.GPIOParameters=GPIO_Label ADC3.Rank-34\#ChannelRegularConversion=4 SAI1.SlotSize-SAI_A_AsyncSlave=SAI_SLOTSIZE_32B -PA4.GPIO_Label=BYPASS ADC1.EOCSelection=ADC_EOC_SEQ_CONV PD15.Signal=FMC_D1_DA1 SH.FMC_D3_DA3.0=FMC_D3,sd-16b-d1 @@ -157,7 +157,6 @@ SH.FMC_D3_DA3.ConfNb=1 PA6.GPIOParameters=GPIO_Label USB_DEVICE.VID-AUDIO_FS=0x1209 PD6.GPIOParameters=GPIO_Label -NVIC.EXTI4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true SH.FMC_A4.0=FMC_A4,12b-sda1 SH.FMC_A7.ConfNb=1 RCC.PLLQoutputFreq_Value=48000000 @@ -167,21 +166,23 @@ SH.FMC_A1.ConfNb=1 FREERTOS.Tasks01=defaultTask,0,128,StartDefaultTask,Default,NULL ADC1.Rank-0\#ChannelRegularConversion=1 USB_DEVICE.VirtualMode-AUDIO_FS=Audio -Mcu.PinsNb=76 +Mcu.PinsNb=75 Dma.SAI1_B.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -Mcu.Pin73=VP_RTC_VS_RTC_Activate -Mcu.Pin74=VP_SYS_VS_Systick -Mcu.Pin71=PE1 -Mcu.Pin72=VP_FREERTOS_VS_CMSIS_V1 +PD2.GPIO_PuPd=GPIO_PULLUP +Mcu.Pin73=VP_SYS_VS_Systick +PG9.GPIO_PuPd=GPIO_PULLUP +Mcu.Pin74=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS +Mcu.Pin71=VP_FREERTOS_VS_CMSIS_V1 +Mcu.Pin72=VP_RTC_VS_RTC_Activate ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,NbrOfConversionFlag,master,ClockPrescaler,ScanConvMode,ContinuousConvMode,DMAContinuousRequests,EOCSelection,NbrOfConversion +PG9.Locked=true PG5.Signal=FMC_A15_BA1 -Mcu.Pin75=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS +PG9.Signal=GPXTI9 SH.FMC_D10_DA10.0=FMC_D10,sd-16b-d1 PA9.GPIO_Label=USBD_VBUS FREERTOS.INCLUDE_vTaskDelayUntil=1 FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 -Mcu.Pin70=PE0 -PB8.GPIO_PuPd=GPIO_PULLUP +Mcu.Pin70=PE1 PC2.Signal=ADCx_IN12 PB11.GPIO_Label=CS_nRST PD1.Signal=FMC_D3_DA3 @@ -189,59 +190,56 @@ PA11.GPIO_Label=USBD_DM RCC.VCOSAIOutputFreq_ValueQ=25000000 NVIC.DMA2_Stream1_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true Mcu.Pin68=PB6 -Mcu.Pin69=PB8 +Mcu.Pin69=PE0 RCC.UART8Freq_Value=54000000 PC0.Signal=FMC_SDNWE RCC.APB1CLKDivider=RCC_HCLK_DIV4 ADC3.Channel-31\#ChannelRegularConversion=ADC_CHANNEL_13 PD6.Mode=SAI_A_AsyncSlave -Mcu.Pin62=PD0 -Mcu.Pin63=PD1 -Mcu.Pin60=PA13 -Mcu.Pin61=PA14 +Mcu.Pin62=PD2 +Mcu.Pin63=PD6 +Mcu.Pin60=PD0 +Mcu.Pin61=PD1 Mcu.Pin66=PB3 Mcu.Pin67=PB5 -Mcu.Pin64=PD6 +Mcu.Pin64=PG9 ADC3.Resolution=ADC_RESOLUTION_12B Mcu.Pin65=PG15 Dma.SAI1_B.2.PeriphInc=DMA_PINC_DISABLE -PA3.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PF8.GPIO_Label=EXP2_R PC3.GPIOParameters=GPIO_Label PD10.Signal=FMC_D15_DA15 SH.FMC_A3.0=FMC_A3,12b-sda1 -PB8.GPIO_Label=SW2 -Mcu.Pin59=PA12 +Mcu.Pin59=PA14 FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_3 +Mcu.Pin57=PA12 SH.GPXTI2.ConfNb=1 -Mcu.Pin57=PA9 -Mcu.Pin58=PA11 -Mcu.Pin51=PD10 +Mcu.Pin58=PA13 +Mcu.Pin51=PD15 RCC.USART6Freq_Value=108000000 SH.FMC_D15_DA15.0=FMC_D15,sd-16b-d1 -Mcu.Pin52=PD14 +Mcu.Pin52=PG4 Dma.SAI1_B.2.PeriphDataAlignment=DMA_PDATAALIGN_WORD -Mcu.Pin50=PD9 -Mcu.Pin55=PG5 -Mcu.Pin56=PG8 -Mcu.Pin53=PD15 -Mcu.Pin54=PG4 +Mcu.Pin50=PD14 +Mcu.Pin55=PA9 +Mcu.Pin56=PA11 +Mcu.Pin53=PG5 +Mcu.Pin54=PG8 PA9.Signal=USB_OTG_FS_VBUS PB11.GPIOParameters=GPIO_Label -PA4.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -ADC3.NbrOfConversion=4 -Mcu.Pin48=PB11 -Mcu.Pin49=PD8 -Mcu.Pin46=PE15 -Mcu.Pin47=PB10 +ADC3.NbrOfConversion=5 +Mcu.Pin48=PD9 +Mcu.Pin49=PD10 +Mcu.Pin46=PB11 +Mcu.Pin47=PD8 PB10.Signal=GPIO_Output -PA5.Signal=GPXTI5 -Mcu.Pin40=PE9 -Mcu.Pin41=PE10 +Mcu.Pin40=PE11 +Mcu.Pin41=PE12 FREERTOS.MEMORY_ALLOCATION=2 -Mcu.Pin44=PE13 -Mcu.Pin45=PE14 -Mcu.Pin42=PE11 -Mcu.Pin43=PE12 +Mcu.Pin44=PE15 +Mcu.Pin45=PB10 +Mcu.Pin42=PE13 +Mcu.Pin43=PE14 ProjectManager.LastFirmware=true FMC.ReadBurst1=FMC_SDRAM_RBURST_ENABLE SH.FMC_A6.0=FMC_A6,12b-sda1 @@ -249,25 +247,26 @@ FMC.ReadBurst2=FMC_SDRAM_RBURST_ENABLE PE14.Signal=FMC_D11_DA11 PE6.Mode=TX_Only_Simplex_Unidirect_Master PE15.Signal=FMC_D12_DA12 -Mcu.Pin37=PG1 -Mcu.Pin38=PE7 -Mcu.Pin35=PF15 +Mcu.Pin37=PE8 +Mcu.Pin38=PE9 +Mcu.Pin35=PG1 RCC.I2C1Freq_Value=54000000 -Mcu.Pin36=PG0 +Mcu.Pin36=PE7 PE8.Signal=FMC_D5_DA5 RCC.PLLI2SPCLKFreq_Value=96000000 SPI1.Mode=SPI_MODE_MASTER SH.FMC_D14_DA14.ConfNb=1 -Mcu.Pin39=PE8 +Mcu.Pin39=PE10 PC2.GPIOParameters=GPIO_Label -Mcu.Pin30=PB2/BOOT1 +Mcu.Pin30=PF12 +PA1.GPIO_Label=FOOTSWITCH RCC.EthernetFreq_Value=168000000 SH.ADCx_IN12.ConfNb=2 -Mcu.Pin33=PF13 -Mcu.Pin34=PF14 +Mcu.Pin33=PF15 +Mcu.Pin34=PG0 ADC3.SamplingTime-33\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -Mcu.Pin31=PF11 -Mcu.Pin32=PF12 +Mcu.Pin31=PF13 +Mcu.Pin32=PF14 NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false FREERTOS.configUSE_MUTEXES=0 PF13.Signal=FMC_A7 @@ -276,33 +275,30 @@ PA13.Mode=Serial_Wire SH.FMC_SDNCAS.0=FMC_SDNCAS,12b-sda1 ProjectManager.FreePins=true Dma.ADC3.0.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD -PF9.GPIOParameters=GPIO_Label SH.FMC_NBL1.ConfNb=1 RCC.PLLI2SQCLKFreq_Value=96000000 -Mcu.Pin26=PA7 -Mcu.Pin27=PC4 +Mcu.Pin26=PC5 +Mcu.Pin27=PB1 NVIC.DMA2_Stream4_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true RCC.RTCHSEDivFreq_Value=12500000 -Mcu.Pin24=PA5 +Mcu.Pin24=PA7 ProjectManager.UnderRoot=false -Mcu.Pin25=PA6 -Mcu.Pin28=PC5 -Mcu.Pin29=PB1 +Mcu.Pin25=PC4 +PF7.GPIO_PuPd=GPIO_PULLUP +Mcu.Pin28=PB2/BOOT1 +Mcu.Pin29=PF11 SH.FMC_D7_DA7.ConfNb=1 -PA4.Signal=GPXTI4 Mcu.Pin22=PA3 PB5.Signal=FMC_SDCKE1 -Mcu.Pin23=PA4 +Mcu.Pin23=PA6 Mcu.Pin20=PC3 ADC1.master=1 -PA3.Locked=true -Mcu.Pin21=PA2 -PA5.GPIO_Label=SW1 +Mcu.Pin21=PA1 NVIC.ForceEnableDMAVector=true SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -PE5.GPIO_Label=CS_SCK SH.FMC_A10.ConfNb=1 +PE5.GPIO_Label=CS_SCK ProjectManager.CompilerOptimize=6 SH.FMC_A5.0=FMC_A5,12b-sda1 PA11.Signal=USB_OTG_FS_DM @@ -312,13 +308,13 @@ Mcu.Pin15=PH0/OSC_IN NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false Mcu.Pin16=PH1/OSC_OUT ADC3.EOCSelection=ADC_EOC_SEQ_CONV -Mcu.Pin13=PF9 +Mcu.Pin13=PF8 Dma.ADC3.0.Mode=DMA_CIRCULAR +PF8.Locked=true Mcu.Pin14=PF10 Mcu.Pin19=PC2 PF10.GPIOParameters=GPIO_Label ProjectManager.ComputerToolchain=false -PF9.Signal=GPIO_Output Mcu.Pin17=PC0 Mcu.Pin18=PC1 Dma.SAI1_B.2.Instance=DMA2_Stream4 @@ -334,16 +330,19 @@ Dma.SAI1_A.1.PeriphInc=DMA_PINC_DISABLE PC15/OSC32_OUT.Signal=GPIO_Output PF4.Signal=FMC_A4 Dma.SAI1_B.2.FIFOMode=DMA_FIFOMODE_DISABLE +SH.GPXTI1.ConfNb=1 SH.FMC_D12_DA12.ConfNb=1 +PD2.Signal=GPXTI2 RCC.I2C2Freq_Value=54000000 SAI1.SlotSize-SAI_B_SyncSlave=SAI_SLOTSIZE_32B PA7.GPIOParameters=GPIO_Label PC1.Signal=ADCx_IN11 +PD2.GPIO_Label=SW1 ADC3.EnableAnalogWatchDog=false Mcu.Family=STM32F4 FMC.IPParameters=ReadPipeDelay1,ReadBurst1,ReadBurst2,SDClockPeriod1,SDClockPeriod2,CASLatency1,LoadToActiveDelay1,ExitSelfRefreshDelay1,SelfRefreshTime1,RowCycleDelay1,RowCycleDelay2,WriteRecoveryTime1,RPDelay1,RPDelay2,RCDDelay1 +SH.GPXTI1.0=GPIO_EXTI1 ProjectManager.MainLocation=Src -PA2.GPIO_PuPd=GPIO_PULLUP SH.FMC_A6.ConfNb=1 PA6.Mode=Full_Duplex_Master USB_DEVICE.CLASS_NAME_FS=AUDIO @@ -352,8 +351,10 @@ RCC.SAI1Freq_Value=50000000 RCC.CortexFreq_Value=168000000 SH.FMC_A2.ConfNb=1 PC15/OSC32_OUT.GPIO_Label=EXTSPI_nCS +PG9.GPIOParameters=GPIO_PuPd,GPIO_Label ProjectManager.KeepUserCode=true Mcu.UserName=STM32F427ZITx +ADC3.Channel-35\#ChannelRegularConversion=ADC_CHANNEL_3 ADC1.ContinuousConvMode=ENABLE SH.FMC_D14_DA14.0=FMC_D14,sd-16b-d1 Dma.SAI1_A.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode @@ -367,13 +368,14 @@ PA12.GPIOParameters=GPIO_Label ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-SystemClock_Config-RCC-false-HAL-true,9-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,10-MX_RTC_Init-RTC-false-HAL-true,11-MX_ADC1_Init-ADC1-false-HAL-true PA9.GPIOParameters=GPIO_Label PA11.GPIOParameters=GPIO_Label -NVIC.EXTI3_IRQn=true\:5\:0\:false\:false\:true\:false\:true\:true SH.FMC_D6_DA6.0=FMC_D6,sd-16b-d1 PA11.Mode=Device_Only PB2/BOOT1.GPIOParameters=GPIO_Label RCC.PLLI2SRCLKFreq_Value=96000000 +ADC3.SamplingTime-35\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES RCC.USART2Freq_Value=54000000 SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 +PD2.Locked=true SH.FMC_A11.0=FMC_A11,12b-sda1 PC1.Locked=true PB11.Signal=GPIO_Output @@ -397,8 +399,6 @@ SH.FMC_A7.0=FMC_A7,12b-sda1 Mcu.IP1=ADC3 PA12.Signal=USB_OTG_FS_DP PE4.GPIOParameters=GPIO_Label -PB8.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -PF9.Locked=true Mcu.UserConstants= SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE SPI4.Mode=SPI_MODE_MASTER @@ -407,6 +407,7 @@ RCC.SDMMCFreq_Value=216000000 Mcu.ThirdPartyNb=0 PH0/OSC_IN.Mode=HSE-External-Oscillator RCC.HCLKFreq_Value=168000000 +SH.ADCx_IN3.0=ADC3_IN3,IN3 Mcu.IPNb=14 RCC.I2SClocksFreq_Value=96000000 RCC.PLLI2SRoutputFreq_Value=96000000 @@ -415,6 +416,7 @@ RCC.SPDIFRXFreq_Value=96000000 RCC.VcooutputI2S=96000000 SH.FMC_NBL1.0=FMC_NBL1,Sd2ByteEnable1 PF12.Signal=FMC_A6 +SH.ADCx_IN3.ConfNb=1 FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 Mcu.Pin6=PF0 Mcu.Pin7=PF1 @@ -438,7 +440,6 @@ ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_9 RCC.HSE_VALUE=25000000 NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false SH.FMC_A14_BA0.ConfNb=1 -PA4.GPIO_PuPd=GPIO_NOPULL ADC3.InjNumberOfConversion=0 SH.FMC_D8_DA8.0=FMC_D8,sd-16b-d1 FMC.ExitSelfRefreshDelay1=6 @@ -453,8 +454,9 @@ PC15/OSC32_OUT.GPIOParameters=GPIO_Label SH.FMC_D2_DA2.0=FMC_D2,sd-16b-d1 Mcu.IP13=USB_OTG_FS PE13.Signal=FMC_D10_DA10 -PF7.GPIO_Label=LED_RED +PF7.GPIO_Label=EXP2_T RCC.VCOInputFreq_Value=1000000 +PF8.GPIO_PuPd=GPIO_PULLUP PA14.Mode=Serial_Wire PF11.Signal=FMC_SDNRAS PB5.Mode=SdramChipSelect2_1 @@ -466,7 +468,6 @@ SH.FMC_D5_DA5.ConfNb=1 PB3.GPIOParameters=GPIO_Label Dma.ADC3.0.MemInc=DMA_MINC_ENABLE SH.FMC_D2_DA2.ConfNb=1 -PB8.Locked=true FMC.ReadPipeDelay1=FMC_SDRAM_RPIPE_DELAY_0 PE4.Mode=SAI_A_AsyncSlave SH.FMC_SDNRAS.0=FMC_SDNRAS,12b-sda1 @@ -484,11 +485,10 @@ SAI1.DataSize-SAI_A_AsyncSlave=SAI_DATASIZE_24 SH.FMC_D4_DA4.ConfNb=1 NVIC.OTG_FS_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true ProjectManager.ToolChainLocation= -PA2.GPIO_Label=SW4 RCC.LSI_VALUE=32000 -SH.GPXTI5.ConfNb=1 USB_OTG_FS.VirtualMode=Device_Only SH.FMC_A9.0=FMC_A9,12b-sda1 +PF8.Signal=GPXTI8 SH.FMC_D4_DA4.0=FMC_D4,sd-16b-d1 ADC3.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV8 RCC.PLLSAIN=100 @@ -509,22 +509,18 @@ PC2.GPIO_Label=ADC2 PE2.GPIO_Label=CS_SCK PE3.Mode=SAI_B_SyncSlave PB3.Locked=true -PA3.Signal=GPXTI3 -PA2.Locked=true +PA3.Signal=ADCx_IN3 PB3.GPIO_Label=FLASH_SCK SH.FMC_A3.ConfNb=1 VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate ADC3.SamplingTime-31\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES SH.ADCx_IN13.1=ADC1_IN13 RCC.I2SFreq_Value=96000000 -SH.GPXTI5.0=GPIO_EXTI5 ADC3.DiscontinuousConvMode=DISABLE SH.ADCx_IN13.0=ADC3_IN13,IN13 -PA5.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING SAI1.Synchro_A=SAI_ASYNCHRONOUS SH.FMC_A9.ConfNb=1 SAI1.Synchro_B=SAI_SYNCHRONOUS -PB8.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI PA7.Mode=Full_Duplex_Master RCC.UART7Freq_Value=54000000 ProjectManager.NoMain=false @@ -562,19 +558,19 @@ PE2.GPIOParameters=GPIO_Label PC2.Locked=true ProjectManager.RegisterCallBack= RCC.USBFreq_Value=48000000 -PF9.GPIO_Label=LED_GREEN NVIC.DMA2_Stream3_IRQn=true\:5\:0\:false\:false\:true\:false\:false\:true RCC.PLLSAIoutputFreq_Value=50000000 PE11.Signal=FMC_D8_DA8 RCC.LSE_VALUE=32768 +PA1.Signal=GPXTI1 PB1.Locked=true SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_RX SAI1.FSDefinition-SAI_A_AsyncSlave=SAI_FS_CHANNEL_IDENTIFICATION RCC.VCOI2SOutputFreq_Value=192000000 +PG9.GPIO_Label=SW2 RCC.PLLSAIPCLKFreq_Value=50000000 board=Alchemist SAI1.IPParameters=Instance-SAI_A_AsyncSlave,VirtualMode-SAI_A_AsyncSlave,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,Synchro-SAI_B_SyncSlave,FrameLength-SAI_B_SyncSlave,SlotSize-SAI_B_SyncSlave,AudioMode-SAI_B_SyncSlave,AudioMode-SAI_A_AsyncSlave,DataSize-SAI_A_AsyncSlave,FrameLength-SAI_A_AsyncSlave,SlotSize-SAI_A_AsyncSlave,SlotNumber-SAI_A_AsyncSlave,FSDefinition-SAI_A_AsyncSlave,FSDefinition-SAI_B_SyncSlave,Synchro-SAI_A_AsyncSlave,Synchro_A,Synchro_B -SH.GPXTI3.0=GPIO_EXTI3 RCC.VCOOutputFreq_Value=336000000 PH0/OSC_IN.Signal=RCC_OSC_IN NVIC.SavedSystickIrqHandlerGenerated=true @@ -582,7 +578,7 @@ RCC.APB2Freq_Value=84000000 RCC.UART4Freq_Value=54000000 SH.ADCx_IN11.1=ADC1_IN11 SH.ADCx_IN11.0=ADC3_IN11,IN11 -MxCube.Version=6.1.1 +MxCube.Version=6.2.1 SH.FMC_D13_DA13.ConfNb=1 PF10.Signal=ADC3_IN8 PE5.Mode=SAI_A_AsyncSlave @@ -591,7 +587,6 @@ VP_SYS_VS_Systick.Mode=SysTick SH.FMC_D12_DA12.0=FMC_D12,sd-16b-d1 PF15.Signal=FMC_A9 SPI4.CalculateBaudRate=656.25 KBits/s -PA4.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI Dma.SAI1_B.2.Priority=DMA_PRIORITY_VERY_HIGH PF1.Signal=FMC_A1 VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_FS @@ -608,7 +603,6 @@ PE0.Signal=FMC_NBL0 Dma.SAI1_B.2.Direction=DMA_PERIPH_TO_MEMORY PE12.Signal=FMC_D9_DA9 NVIC.SavedPendsvIrqHandlerGenerated=true -PA2.Signal=GPXTI2 Mcu.IP8=SAI1 Mcu.IP9=SPI1 PD14.Signal=FMC_D0_DA0 @@ -619,16 +613,16 @@ RCC.48MHZClocksFreq_Value=48000000 PB3.Signal=SPI1_SCK RCC.SYSCLKFreq_VALUE=168000000 PA7.GPIO_Label=FLASH_MOSI -SH.GPXTI4.0=GPIO_EXTI4 +PA1.Locked=true PA12.Mode=Device_Only KeepUserPlacement=false PC5.GPIO_Label=FLASH_nCS SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B +SH.GPXTI9.ConfNb=1 NVIC.EXTI9_5_IRQn=true\:15\:0\:true\:false\:true\:false\:true\:true PA14.Signal=SYS_JTCK-SWCLK -SH.GPXTI4.ConfNb=1 +ADC3.Rank-35\#ChannelRegularConversion=5 RCC.HSI_VALUE=16000000 -PA2.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING Dma.ADC3.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode RCC.PLLQ=7 ADC1.NbrOfConversionFlag=1 @@ -636,7 +630,6 @@ RCC.PLLM=25 RCC.PLLN=336 PB2/BOOT1.Locked=true Dma.SAI1_A.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD -PB8.Signal=GPXTI8 PE3.GPIO_Label=CS_SDOUT SH.FMC_D8_DA8.ConfNb=1 RCC.APB1Freq_Value=42000000 @@ -645,7 +638,7 @@ ADC1.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV8 PB11.Locked=true ProjectManager.DeviceId=STM32F427ZITx ProjectManager.LibraryCopy=2 -PA3.GPIO_Label=SW3 +PA3.GPIO_Label=EXP ADC3.Rank-31\#ChannelRegularConversion=1 PB1.GPIOParameters=GPIO_Label PA7.Signal=SPI1_MOSI diff --git a/OwlPedal2/Src/main.c b/OwlPedal2/Src/main.c index 85d94db3..09cf2f4d 100644 --- a/OwlPedal2/Src/main.c +++ b/OwlPedal2/Src/main.c @@ -374,7 +374,7 @@ static void MX_ADC3_Init(void) hadc3.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; hadc3.Init.ExternalTrigConv = ADC_SOFTWARE_START; hadc3.Init.DataAlign = ADC_DATAALIGN_RIGHT; - hadc3.Init.NbrOfConversion = 4; + hadc3.Init.NbrOfConversion = 5; hadc3.Init.DMAContinuousRequests = ENABLE; hadc3.Init.EOCSelection = ADC_EOC_SEQ_CONV; if (HAL_ADC_Init(&hadc3) != HAL_OK) @@ -414,6 +414,14 @@ static void MX_ADC3_Init(void) { Error_Handler(); } + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + */ + sConfig.Channel = ADC_CHANNEL_3; + sConfig.Rank = 5; + if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK) + { + Error_Handler(); + } /* USER CODE BEGIN ADC3_Init 2 */ /* USER CODE END ADC3_Init 2 */ @@ -686,9 +694,6 @@ static void MX_GPIO_Init(void) /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOC, EXTSPI_nCS_Pin|FLASH_HOLD_Pin|FLASH_nCS_Pin, GPIO_PIN_RESET); - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOF, LED_RED_Pin|LED_GREEN_Pin, GPIO_PIN_RESET); - /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOB, EXP_TIP_Pin|CS_nCS_Pin|CS_nRST_Pin, GPIO_PIN_RESET); @@ -709,43 +714,38 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - /*Configure GPIO pins : PF6 PF8 */ - GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_8; + /*Configure GPIO pins : PF6 PF9 */ + GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); - /*Configure GPIO pins : LED_RED_Pin LED_GREEN_Pin */ - GPIO_InitStruct.Pin = LED_RED_Pin|LED_GREEN_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + /*Configure GPIO pins : EXP2_T_Pin EXP2_R_Pin */ + GPIO_InitStruct.Pin = EXP2_T_Pin|EXP2_R_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); - /*Configure GPIO pins : PA0 PA1 PA8 PA10 - PA15 */ - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_8|GPIO_PIN_10 - |GPIO_PIN_15; + /*Configure GPIO pins : PA0 PA2 PA4 PA5 + PA8 PA10 PA15 */ + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_4|GPIO_PIN_5 + |GPIO_PIN_8|GPIO_PIN_10|GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - /*Configure GPIO pins : SW4_Pin SW3_Pin SW1_Pin */ - GPIO_InitStruct.Pin = SW4_Pin|SW3_Pin|SW1_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; - GPIO_InitStruct.Pull = GPIO_PULLUP; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /*Configure GPIO pin : BYPASS_Pin */ - GPIO_InitStruct.Pin = BYPASS_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; + /*Configure GPIO pin : FOOTSWITCH_Pin */ + GPIO_InitStruct.Pin = FOOTSWITCH_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(BYPASS_GPIO_Port, &GPIO_InitStruct); + HAL_GPIO_Init(FOOTSWITCH_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : PB0 PB12 PB13 PB14 - PB15 PB4 PB7 PB9 */ + PB15 PB4 PB7 PB8 + PB9 */ GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 - |GPIO_PIN_15|GPIO_PIN_4|GPIO_PIN_7|GPIO_PIN_9; + |GPIO_PIN_15|GPIO_PIN_4|GPIO_PIN_7|GPIO_PIN_8 + |GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); @@ -757,39 +757,42 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - /*Configure GPIO pins : PD11 PD12 PD13 PD2 - PD3 PD4 PD5 PD7 */ - GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_2 - |GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_7; + /*Configure GPIO pins : PD11 PD12 PD13 PD3 + PD4 PD5 PD7 */ + GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_3 + |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_7; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); /*Configure GPIO pins : PG2 PG3 PG6 PG7 - PG9 PG10 PG11 PG12 - PG13 PG14 */ + PG10 PG11 PG12 PG13 + PG14 */ GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_6|GPIO_PIN_7 - |GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12 - |GPIO_PIN_13|GPIO_PIN_14; + |GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13 + |GPIO_PIN_14; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + /*Configure GPIO pin : SW1_Pin */ + GPIO_InitStruct.Pin = SW1_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + GPIO_InitStruct.Pull = GPIO_PULLUP; + HAL_GPIO_Init(SW1_GPIO_Port, &GPIO_InitStruct); + /*Configure GPIO pin : SW2_Pin */ GPIO_InitStruct.Pin = SW2_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(SW2_GPIO_Port, &GPIO_InitStruct); /* EXTI interrupt init*/ - HAL_NVIC_SetPriority(EXTI2_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(EXTI2_IRQn); + HAL_NVIC_SetPriority(EXTI1_IRQn, 15, 0); + HAL_NVIC_EnableIRQ(EXTI1_IRQn); - HAL_NVIC_SetPriority(EXTI3_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(EXTI3_IRQn); - - HAL_NVIC_SetPriority(EXTI4_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(EXTI4_IRQn); + HAL_NVIC_SetPriority(EXTI2_IRQn, 15, 0); + HAL_NVIC_EnableIRQ(EXTI2_IRQn); HAL_NVIC_SetPriority(EXTI9_5_IRQn, 15, 0); HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); diff --git a/OwlPedal2/Src/stm32f4xx_hal_msp.c b/OwlPedal2/Src/stm32f4xx_hal_msp.c index 3fca90a5..2e97b31d 100644 --- a/OwlPedal2/Src/stm32f4xx_hal_msp.c +++ b/OwlPedal2/Src/stm32f4xx_hal_msp.c @@ -162,11 +162,13 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) __HAL_RCC_GPIOF_CLK_ENABLE(); __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOA_CLK_ENABLE(); /**ADC3 GPIO Configuration PF10 ------> ADC3_IN8 PC1 ------> ADC3_IN11 PC2 ------> ADC3_IN12 PC3 ------> ADC3_IN13 + PA3 ------> ADC3_IN3 */ GPIO_InitStruct.Pin = ADC4_Pin; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; @@ -178,6 +180,11 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + GPIO_InitStruct.Pin = EXP_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(EXP_GPIO_Port, &GPIO_InitStruct); + /* ADC3 DMA Init */ /* ADC3 Init */ hdma_adc3.Instance = DMA2_Stream1; @@ -259,11 +266,14 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) PC1 ------> ADC3_IN11 PC2 ------> ADC3_IN12 PC3 ------> ADC3_IN13 + PA3 ------> ADC3_IN3 */ HAL_GPIO_DeInit(ADC4_GPIO_Port, ADC4_Pin); HAL_GPIO_DeInit(GPIOC, ADC3_Pin|ADC2_Pin|ADC1_Pin); + HAL_GPIO_DeInit(EXP_GPIO_Port, EXP_Pin); + /* ADC3 DMA DeInit */ HAL_DMA_DeInit(hadc->DMA_Handle); diff --git a/OwlPedal2/Src/stm32f4xx_it.c b/OwlPedal2/Src/stm32f4xx_it.c index cebc1da6..97fc86ec 100644 --- a/OwlPedal2/Src/stm32f4xx_it.c +++ b/OwlPedal2/Src/stm32f4xx_it.c @@ -118,45 +118,31 @@ void SysTick_Handler(void) /******************************************************************************/ /** - * @brief This function handles EXTI line2 interrupt. + * @brief This function handles EXTI line1 interrupt. */ -void EXTI2_IRQHandler(void) +void EXTI1_IRQHandler(void) { - /* USER CODE BEGIN EXTI2_IRQn 0 */ + /* USER CODE BEGIN EXTI1_IRQn 0 */ - /* USER CODE END EXTI2_IRQn 0 */ - HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2); - /* USER CODE BEGIN EXTI2_IRQn 1 */ + /* USER CODE END EXTI1_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_1); + /* USER CODE BEGIN EXTI1_IRQn 1 */ - /* USER CODE END EXTI2_IRQn 1 */ + /* USER CODE END EXTI1_IRQn 1 */ } /** - * @brief This function handles EXTI line3 interrupt. - */ -void EXTI3_IRQHandler(void) -{ - /* USER CODE BEGIN EXTI3_IRQn 0 */ - - /* USER CODE END EXTI3_IRQn 0 */ - HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_3); - /* USER CODE BEGIN EXTI3_IRQn 1 */ - - /* USER CODE END EXTI3_IRQn 1 */ -} - -/** - * @brief This function handles EXTI line4 interrupt. + * @brief This function handles EXTI line2 interrupt. */ -void EXTI4_IRQHandler(void) +void EXTI2_IRQHandler(void) { - /* USER CODE BEGIN EXTI4_IRQn 0 */ + /* USER CODE BEGIN EXTI2_IRQn 0 */ - /* USER CODE END EXTI4_IRQn 0 */ - HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_4); - /* USER CODE BEGIN EXTI4_IRQn 1 */ + /* USER CODE END EXTI2_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2); + /* USER CODE BEGIN EXTI2_IRQn 1 */ - /* USER CODE END EXTI4_IRQn 1 */ + /* USER CODE END EXTI2_IRQn 1 */ } /** @@ -182,8 +168,9 @@ void EXTI9_5_IRQHandler(void) /* USER CODE BEGIN EXTI9_5_IRQn 0 */ /* USER CODE END EXTI9_5_IRQn 0 */ - HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_5); + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_7); HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8); + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_9); /* USER CODE BEGIN EXTI9_5_IRQn 1 */ /* USER CODE END EXTI9_5_IRQn 1 */ From 4fedda32e70e5abd2e84d9642f094b095472cf24 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 13 Oct 2021 18:22:06 +0200 Subject: [PATCH 106/286] more Rev03 updates --- OwlPedal2/Inc/hardware.h | 4 +-- OwlPedal2/Src/OwlPedal.cpp | 65 +++++++++++++++++++++++++++----------- 2 files changed, 49 insertions(+), 20 deletions(-) diff --git a/OwlPedal2/Inc/hardware.h b/OwlPedal2/Inc/hardware.h index 16cff6a6..452d4de3 100644 --- a/OwlPedal2/Inc/hardware.h +++ b/OwlPedal2/Inc/hardware.h @@ -36,12 +36,12 @@ #define ADC_B 1 #define ADC_C 2 #define ADC_D 3 -/* #define ADC_E 4 */ +#define ADC_E 4 #define USE_CODEC #define USE_CS4271 /* #define CODEC_HP_FILTER */ #define CODEC_SPI hspi4 -#define NOF_ADC_VALUES 4 +#define NOF_ADC_VALUES 5 #define NOF_PARAMETERS 40 #define NOF_BUTTONS (2+4) diff --git a/OwlPedal2/Src/OwlPedal.cpp b/OwlPedal2/Src/OwlPedal.cpp index c6231837..6e3f8c0a 100644 --- a/OwlPedal2/Src/OwlPedal.cpp +++ b/OwlPedal2/Src/OwlPedal.cpp @@ -7,29 +7,45 @@ #define PATCH_RESET_COUNTER (1000/MAIN_LOOP_SLEEP_MS) -// Pin bypass_pin(GPIOA, GPIO_PIN_4); +// Pin footswitch_pin(GPIOA, GPIO_PIN_0); +Pin bypass_pin(GPIOA, GPIO_PIN_0); +Pin bufpass_pin(GPIOF, GPIO_PIN_9); +Pin exp1_ring_pin(GPIOA, GPIO_PIN_2); +Pin led_green_pin(GPIOB, GPIO_PIN_8); +Pin led_red_pin(GPIOB, GPIO_PIN_9); + +#define SW3_Pin EXP2_T_Pin +#define SW3_GPIO_Port EXP2_T_GPIO_Port +#define SW4_Pin EXP2_R_Pin +#define SW4_GPIO_Port EXP2_R_GPIO_Port void setLed(uint8_t led, uint32_t rgb){ switch(rgb){ case RED_COLOUR: - HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_SET); - HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_RESET); + led_green_pin.low(); + led_red_pin.high(); + // HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_SET); + // HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_RESET); break; case GREEN_COLOUR: - HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_RESET); - HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_SET); + led_green_pin.high(); + led_red_pin.low(); + // HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_RESET); + // HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_SET); break; case NO_COLOUR: - HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_RESET); - HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_RESET); + led_green_pin.low(); + led_red_pin.low(); + // HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_RESET); + // HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_RESET); break; } } void onChangePin(uint16_t pin){ switch(pin){ - case BYPASS_Pin: { - bool state = HAL_GPIO_ReadPin(BYPASS_GPIO_Port, BYPASS_Pin) == GPIO_PIN_RESET; + case FOOTSWITCH_Pin: { + bool state = HAL_GPIO_ReadPin(FOOTSWITCH_GPIO_Port, FOOTSWITCH_Pin) == GPIO_PIN_RESET; setLed(0, state ? NO_COLOUR : GREEN_COLOUR); break; } @@ -60,20 +76,31 @@ void onChangePin(uint16_t pin){ } void setGateValue(uint8_t ch, int16_t value){ - if(ch == PUSHBUTTON){ - HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, value ? GPIO_PIN_RESET : GPIO_PIN_SET); - HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, value ? GPIO_PIN_SET : GPIO_PIN_RESET); + switch(ch){ + case PUSHBUTTON: + setLed(0, value ? RED_COLOUR : GREEN_COLOUR); #ifdef OWL_MODULAR HAL_GPIO_WritePin(PUSH_GATE_OUT_GPIO_Port, PUSH_GATE_OUT_Pin, value ? GPIO_PIN_RESET : GPIO_PIN_SET); #endif - }else if(ch == GREEN_BUTTON){ - setLed(0, GREEN_COLOUR); - }else if(ch == RED_BUTTON){ - setLed(0, RED_COLOUR); + break; + case GREEN_BUTTON: + setLed(0, value ? GREEN_COLOUR : NO_COLOUR); + break; + case RED_BUTTON: + setLed(0, value ? RED_COLOUR : NO_COLOUR); + break; } } void setup(){ + + bypass_pin.outputMode(); + bypass_pin.low(); + bufpass_pin.outputMode(); + bufpass_pin.low(); + exp1_ring_pin.outputMode(); + exp1_ring_pin.high(); + // bypass_pin.outputMode(); // bypass_pin.inputMode(); // bypass_pin.setPull(PIN_PULL_NONE); @@ -81,9 +108,11 @@ void setup(){ // bypass_pin.setPull(PIN_PULL_DOWN); // bypass_pin.setPull(PIN_PULL_UP); // bypass_pin.get(); - + + led_green_pin.outputMode(); + led_red_pin.outputMode(); + setLed(0, RED_COLOUR); - HAL_GPIO_WritePin(EXP_TIP_GPIO_Port, EXP_TIP_Pin, GPIO_PIN_SET); owl.setup(); setLed(0, GREEN_COLOUR); } From 91e0ade497c4efaf7d566f196edfe787ba6090e0 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 13 Oct 2021 18:23:14 +0200 Subject: [PATCH 107/286] changed to rising/falling --- OwlPedal2/OwlPedal2.ioc | 14 +++++++++----- OwlPedal2/Src/main.c | 6 +++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/OwlPedal2/OwlPedal2.ioc b/OwlPedal2/OwlPedal2.ioc index 2e9906b2..b40be477 100644 --- a/OwlPedal2/OwlPedal2.ioc +++ b/OwlPedal2/OwlPedal2.ioc @@ -1,5 +1,5 @@ #MicroXplorer Configuration settings - do not modify -PF7.GPIOParameters=GPIO_PuPd,GPIO_Label +PF7.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI SH.FMC_D7_DA7.0=FMC_D7,sd-16b-d1 Dma.ADC3.0.FIFOMode=DMA_FIFOMODE_DISABLE SH.FMC_D0_DA0.ConfNb=1 @@ -31,7 +31,7 @@ RCC.RTCFreq_Value=32000 PA3.GPIOParameters=GPIO_Label PA6.GPIO_Label=FLASH_MISO Dma.SAI1_A.1.Mode=DMA_CIRCULAR -PD2.GPIOParameters=GPIO_PuPd,GPIO_Label +PD2.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI SH.FMC_SDNWE.ConfNb=1 SH.FMC_D5_DA5.0=FMC_D5,sd-16b-d1 Dma.SAI1_A.1.MemDataAlignment=DMA_MDATAALIGN_WORD @@ -75,6 +75,7 @@ PA1.GPIO_PuPd=GPIO_NOPULL PF10.GPIO_Label=ADC4 Dma.SAI1_A.1.MemInc=DMA_MINC_ENABLE RCC.USART3Freq_Value=54000000 +PD2.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING RCC.PLLSAIRCLKFreq_Value=50000000 ProjectManager.ProjectBuild=false NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false @@ -114,7 +115,7 @@ ProjectManager.HalAssertFull=true ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES RCC.MCO2PinFreq_Value=168000000 Mcu.Package=LQFP144 -PF8.GPIOParameters=GPIO_PuPd,GPIO_Label +PF8.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI PB1.Signal=ADCx_IN9 SH.GPXTI8.0=GPIO_EXTI8 Dma.SAI1_A.1.Direction=DMA_MEMORY_TO_PERIPH @@ -297,8 +298,8 @@ Mcu.Pin21=PA1 NVIC.ForceEnableDMAVector=true SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -SH.FMC_A10.ConfNb=1 PE5.GPIO_Label=CS_SCK +SH.FMC_A10.ConfNb=1 ProjectManager.CompilerOptimize=6 SH.FMC_A5.0=FMC_A5,12b-sda1 PA11.Signal=USB_OTG_FS_DM @@ -351,7 +352,7 @@ RCC.SAI1Freq_Value=50000000 RCC.CortexFreq_Value=168000000 SH.FMC_A2.ConfNb=1 PC15/OSC32_OUT.GPIO_Label=EXTSPI_nCS -PG9.GPIOParameters=GPIO_PuPd,GPIO_Label +PG9.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI ProjectManager.KeepUserCode=true Mcu.UserName=STM32F427ZITx ADC3.Channel-35\#ChannelRegularConversion=ADC_CHANNEL_3 @@ -457,6 +458,7 @@ PE13.Signal=FMC_D10_DA10 PF7.GPIO_Label=EXP2_T RCC.VCOInputFreq_Value=1000000 PF8.GPIO_PuPd=GPIO_PULLUP +PF7.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING PA14.Mode=Serial_Wire PF11.Signal=FMC_SDNRAS PB5.Mode=SdramChipSelect2_1 @@ -488,6 +490,7 @@ ProjectManager.ToolChainLocation= RCC.LSI_VALUE=32000 USB_OTG_FS.VirtualMode=Device_Only SH.FMC_A9.0=FMC_A9,12b-sda1 +PG9.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING PF8.Signal=GPXTI8 SH.FMC_D4_DA4.0=FMC_D4,sd-16b-d1 ADC3.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV8 @@ -603,6 +606,7 @@ PE0.Signal=FMC_NBL0 Dma.SAI1_B.2.Direction=DMA_PERIPH_TO_MEMORY PE12.Signal=FMC_D9_DA9 NVIC.SavedPendsvIrqHandlerGenerated=true +PF8.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING Mcu.IP8=SAI1 Mcu.IP9=SPI1 PD14.Signal=FMC_D0_DA0 diff --git a/OwlPedal2/Src/main.c b/OwlPedal2/Src/main.c index 09cf2f4d..9ef46a90 100644 --- a/OwlPedal2/Src/main.c +++ b/OwlPedal2/Src/main.c @@ -722,7 +722,7 @@ static void MX_GPIO_Init(void) /*Configure GPIO pins : EXP2_T_Pin EXP2_R_Pin */ GPIO_InitStruct.Pin = EXP2_T_Pin|EXP2_R_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); @@ -777,13 +777,13 @@ static void MX_GPIO_Init(void) /*Configure GPIO pin : SW1_Pin */ GPIO_InitStruct.Pin = SW1_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(SW1_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : SW2_Pin */ GPIO_InitStruct.Pin = SW2_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(SW2_GPIO_Port, &GPIO_InitStruct); From 016df2ce8af73b5ef743c2495bc1eb7431fbda47 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 15 Oct 2021 15:26:49 +0200 Subject: [PATCH 108/286] pin changes --- OwlPedal2/Inc/hardware.h | 2 ++ OwlPedal2/OwlPedal2.ioc | 3 ++- OwlPedal2/Src/OwlPedal.cpp | 43 ++++++++++++++------------------------ OwlPedal2/Src/main.c | 2 +- 4 files changed, 21 insertions(+), 29 deletions(-) diff --git a/OwlPedal2/Inc/hardware.h b/OwlPedal2/Inc/hardware.h index 452d4de3..151eaefe 100644 --- a/OwlPedal2/Inc/hardware.h +++ b/OwlPedal2/Inc/hardware.h @@ -8,6 +8,8 @@ #define HARDWARE_VERSION "OWL Pedal mkII" #define USE_USBD_AUDIO +#define USE_USBD_RX_FB +#define USE_USBD_AUDIO_FEATURES #define USE_USBD_AUDIO_TX // microphone #define USE_USBD_AUDIO_RX // speaker #define USE_USBD_MIDI diff --git a/OwlPedal2/OwlPedal2.ioc b/OwlPedal2/OwlPedal2.ioc index b40be477..b7a651c4 100644 --- a/OwlPedal2/OwlPedal2.ioc +++ b/OwlPedal2/OwlPedal2.ioc @@ -89,7 +89,7 @@ ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.26.2 MxDb.Version=DB.6.0.21 USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology USB_DEVICE.USBD_MAX_NUM_CONFIGURATION-AUDIO_FS=2 -PA1.GPIOParameters=GPIO_PuPd,GPIO_Label +PA1.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI ProjectManager.BackupPrevious=false SAI1.SlotNumber-SAI_A_AsyncSlave=2 PC4.GPIO_Label=FLASH_HOLD @@ -508,6 +508,7 @@ SH.FMC_NBL0.ConfNb=1 PD6.Signal=SAI1_SD_A SAI1.Synchro-SAI_A_AsyncSlave=SAI_ASYNCHRONOUS Dma.Request0=ADC3 +PA1.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING PC2.GPIO_Label=ADC2 PE2.GPIO_Label=CS_SCK PE3.Mode=SAI_B_SyncSlave diff --git a/OwlPedal2/Src/OwlPedal.cpp b/OwlPedal2/Src/OwlPedal.cpp index 6e3f8c0a..18a7e5e7 100644 --- a/OwlPedal2/Src/OwlPedal.cpp +++ b/OwlPedal2/Src/OwlPedal.cpp @@ -24,28 +24,23 @@ void setLed(uint8_t led, uint32_t rgb){ case RED_COLOUR: led_green_pin.low(); led_red_pin.high(); - // HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_SET); - // HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_RESET); break; case GREEN_COLOUR: led_green_pin.high(); led_red_pin.low(); - // HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_RESET); - // HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_SET); break; case NO_COLOUR: led_green_pin.low(); led_red_pin.low(); - // HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_RESET); - // HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_RESET); break; } } void onChangePin(uint16_t pin){ switch(pin){ - case FOOTSWITCH_Pin: { + case FOOTSWITCH_Pin: { // stomp switch bool state = HAL_GPIO_ReadPin(FOOTSWITCH_GPIO_Port, FOOTSWITCH_Pin) == GPIO_PIN_RESET; + setButtonValue(0, state); setLed(0, state ? NO_COLOUR : GREEN_COLOUR); break; } @@ -53,7 +48,7 @@ void onChangePin(uint16_t pin){ bool state = HAL_GPIO_ReadPin(SW1_GPIO_Port, SW1_Pin) == GPIO_PIN_RESET; setButtonValue(PUSHBUTTON, state); setButtonValue(BUTTON_A, state); - midi_tx.sendCc(PUSHBUTTON, state ? 127 : 0); + midi_tx.sendCc(PATCH_BUTTON, state ? 127 : 0); setLed(0, state ? RED_COLOUR : GREEN_COLOUR); break; } @@ -62,12 +57,12 @@ void onChangePin(uint16_t pin){ setButtonValue(BUTTON_B, state); break; } - case SW3_Pin: { + case SW3_Pin: { // EXP2 Tip bool state = HAL_GPIO_ReadPin(SW3_GPIO_Port, SW3_Pin) == GPIO_PIN_RESET; setButtonValue(BUTTON_C, state); break; } - case SW4_Pin: { + case SW4_Pin: { // EXP2 Ring bool state = HAL_GPIO_ReadPin(SW4_GPIO_Port, SW4_Pin) == GPIO_PIN_RESET; setButtonValue(BUTTON_D, state); break; @@ -89,28 +84,22 @@ void setGateValue(uint8_t ch, int16_t value){ case RED_BUTTON: setLed(0, value ? RED_COLOUR : NO_COLOUR); break; + case BUTTON_1: + bufpass_pin.set(value); + break; } } void setup(){ - - bypass_pin.outputMode(); - bypass_pin.low(); - bufpass_pin.outputMode(); - bufpass_pin.low(); - exp1_ring_pin.outputMode(); - exp1_ring_pin.high(); - - // bypass_pin.outputMode(); - // bypass_pin.inputMode(); - // bypass_pin.setPull(PIN_PULL_NONE); - // bypass_pin.set(false); - // bypass_pin.setPull(PIN_PULL_DOWN); - // bypass_pin.setPull(PIN_PULL_UP); - // bypass_pin.get(); + bypass_pin.outputMode(); + bypass_pin.low(); + bufpass_pin.outputMode(); + bufpass_pin.low(); + exp1_ring_pin.outputMode(); + exp1_ring_pin.high(); - led_green_pin.outputMode(); - led_red_pin.outputMode(); + led_green_pin.outputMode(); + led_red_pin.outputMode(); setLed(0, RED_COLOUR); owl.setup(); diff --git a/OwlPedal2/Src/main.c b/OwlPedal2/Src/main.c index 9ef46a90..a3918334 100644 --- a/OwlPedal2/Src/main.c +++ b/OwlPedal2/Src/main.c @@ -736,7 +736,7 @@ static void MX_GPIO_Init(void) /*Configure GPIO pin : FOOTSWITCH_Pin */ GPIO_InitStruct.Pin = FOOTSWITCH_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(FOOTSWITCH_GPIO_Port, &GPIO_InitStruct); From 8ee0a85f4c84469ec28435a75fe4ed158c0a35cb Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 15 Oct 2021 16:30:43 +0200 Subject: [PATCH 109/286] pin changes --- Genius/Genius.ioc | 21 ++++++++--- Genius/Inc/hardware.h | 2 +- Genius/Src/Genius.cpp | 87 +++++++++++++++++++++++++++++++++++-------- 3 files changed, 89 insertions(+), 21 deletions(-) diff --git a/Genius/Genius.ioc b/Genius/Genius.ioc index 6848334f..cb2a0c06 100644 --- a/Genius/Genius.ioc +++ b/Genius/Genius.ioc @@ -3,8 +3,8 @@ PF7.GPIOParameters=GPIO_Label Dma.USART2_TX.7.MemInc=DMA_MINC_ENABLE PB13.GPIOParameters=GPIO_Speed Dma.USART2_TX.7.Priority=DMA_PRIORITY_LOW -PA15\ (JTDI).GPIOParameters=GPIO_PuPd,GPIO_Label SH.FMC_D0_DA0.ConfNb=1 +PA15\ (JTDI).GPIOParameters=GPIO_PuPd,GPIO_Label Dma.SAI1_A.1.SignalID=NONE USART2.IPParameters=WordLength,VirtualMode-Asynchronous,OverrunDisableParam,DMADisableonRxErrorParam SH.FMC_A8.ConfNb=1 @@ -54,7 +54,7 @@ PD8.Signal=FMC_D13_DA13 Dma.SAI1_A.1.FIFOMode=DMA_FIFOMODE_DISABLE PE1.Signal=FMC_NBL1 RCC.USART3Freq_Value=42000000 -NVIC.EXTI15_10_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true +NVIC.EXTI15_10_IRQn=true\:15\:0\:true\:false\:true\:false\:true\:true RCC.PLLSAIRCLKFreq_Value=50000000 ProjectManager.ProjectBuild=false NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false @@ -95,6 +95,7 @@ FREERTOS.FootprintOK=true FMC.WriteRecoveryTime1=2 SPI5.CalculateBaudRate=937.5 KBits/s RCC.APB2CLKDivider=RCC_HCLK_DIV2 +NVIC.EXTI2_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true Dma.UART5_RX.4.Polarity=HAL_DMAMUX_REQ_GEN_RISING RCC.APB1TimFreq_Value=84000000 RCC.LPUART1Freq_Value=120000000 @@ -102,6 +103,7 @@ Dma.USART2_TX.7.SyncSignalID=NONE FMC.RowCycleDelay1=6 USB_OTG_FS.IPParameters=VirtualMode,Sof_enable PB13.Mode=Asynchronous +ADC1.EOCSelection=ADC_EOC_SEQ_CONV PD15.Signal=FMC_D1_DA1 RCC.PLLSAIQCLKFreq_Value=50000000 RCC.VCO3OutputFreq_Value=100781250 @@ -272,6 +274,8 @@ Dma.SPI2_TX.0.MemInc=DMA_MINC_ENABLE SH.FMC_A8.0=FMC_A8,12b-sda1 PG9.GPIOParameters=GPIO_Label ProjectManager.KeepUserCode=true +ADC1.Overrun=ADC_OVR_DATA_OVERWRITTEN +ADC1.ContinuousConvMode=ENABLE SH.FMC_D14_DA14.0=FMC_D14,sd-16b-d1 PH0-OSC_IN\ (PH0).Signal=RCC_OSC_IN SH.COMP_DAC12_group.0=DAC1_OUT2,DAC_OUT2 @@ -304,6 +308,7 @@ RCC.DIVP3Freq_Value=50390625 RCC.SDMMCFreq_Value=48000000 Dma.ADC1.3.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT Dma.UART5_RX.4.RequestNumber=1 +ADC1.Resolution=ADC_RESOLUTION_12B ProjectManager.PreviousToolchain=TrueSTUDIO TIM3.Period=0xffff SH.COMP_DAC12_group.ConfNb=1 @@ -446,6 +451,7 @@ USB_OTG_FS.Sof_enable=ENABLE PF1.Signal=FMC_A1 SH.FMC_D11_DA11.ConfNb=1 RCC.UART5Freq_Value=42000000 +ADC1.NbrOfConversion=2 PA15\ (JTDI).GPIO_Label=ENC1_CH1 RCC.IPParameters=ADCFreq_Value,AHB12Freq_Value,AHB4Freq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,APB3Freq_Value,APB4Freq_Value,AXIClockFreq_Value,CECFreq_Value,CKPERFreq_Value,CortexFreq_Value,CpuClockFreq_Value,D1CPREFreq_Value,D1PPRE,D2PPRE1,D2PPRE2,D3PPRE,DFSDMACLkFreq_Value,DFSDMFreq_Value,DIVM1,DIVM2,DIVN1,DIVN2,DIVP1Freq_Value,DIVP2,DIVP2Freq_Value,DIVP3Freq_Value,DIVQ1,DIVQ1Freq_Value,DIVQ2Freq_Value,DIVQ3Freq_Value,DIVR1Freq_Value,DIVR2Freq_Value,DIVR3Freq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FDCANFreq_Value,FMCFreq_Value,FamilyName,HCLK3ClockFreq_Value,HCLKFreq_Value,HPRE,HRTIMFreq_Value,HSE_VALUE,HSI_VALUE,I2C123Freq_Value,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SFreq_Value,LCDTFToutputFreq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPTIM345Freq_Value,LPUART1Freq_Value,LSE_VALUE,LSI_VALUE,LTDCFreq_Value,MCO1PinFreq_Value,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLFRACN,PLLI2SPCLKFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLI2SRoutputFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLQoutputFreq_Value,PLLSAIN,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIRCLKFreq_Value,PLLSAIoutputFreq_Value,ProductRev,QSPIFreq_Value,RNGFreq_Value,RTCFreq_Value,SAI1Freq_Value,SAI23Freq_Value,SAI2Freq_Value,SAI4AFreq_Value,SAI4BFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SPI123Freq_Value,SPI45Freq_Value,SPI6Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,Tim1OutputFreq_Value,Tim2OutputFreq_Value,TraceFreq_Value,UART4Freq_Value,UART5Freq_Value,UART7Freq_Value,UART8Freq_Value,USART16Freq_Value,USART1Freq_Value,USART234578Freq_Value,USART2Freq_Value,USART3Freq_Value,USART6Freq_Value,USBFreq_Value,VCO1OutputFreq_Value,VCO2OutputFreq_Value,VCO3OutputFreq_Value,VCOI2SOutputFreq_Value,VCOInput1Freq_Value,VCOInput2Freq_Value,VCOInput3Freq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value ProjectManager.AskForMigrate=true @@ -556,7 +562,7 @@ NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false PF3.Signal=FMC_A3 RCC.DIVR2Freq_Value=75000000 PE10.Signal=FMC_D7_DA7 -ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_1CYCLE_5 +ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_64CYCLES_5 RCC.MCO2PinFreq_Value=480000000 UART5.OverrunDisableParam=UART_ADVFEATURE_OVERRUN_DISABLE PF8.GPIOParameters=GPIO_Label @@ -583,7 +589,7 @@ Dma.USART2_TX.7.Instance=DMA1_Stream5 SPI5.VirtualType=VM_MASTER ProjectManager.CustomerFirmwarePackage= USART2.OverrunDisableParam=ADVFEATURE_OVERRUN_DISABLE -NVIC.EXTI4_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true +NVIC.EXTI4_IRQn=true\:15\:0\:true\:false\:true\:false\:true\:true SH.FMC_A7.ConfNb=1 RCC.PLLQoutputFreq_Value=48000000 SH.FMC_A1.ConfNb=1 @@ -595,7 +601,7 @@ Dma.SAI1_B.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAli Dma.USART2_RX.6.SyncSignalID=NONE PD2.GPIO_PuPd=GPIO_PULLUP VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC.Mode=SAI_A_BASIC -ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,master +ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,master,ContinuousConvMode,ClockPrescaler,Resolution,Overrun,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,OffsetNumber-1\#ChannelRegularConversion,NbrOfConversion,EOCSelection PG9.Locked=true PG9.Signal=GPIO_Output RCC.SWPMI1Freq_Value=120000000 @@ -651,11 +657,13 @@ Dma.SPI2_TX.0.FIFOMode=DMA_FIFOMODE_DISABLE ProjectManager.UnderRoot=false SH.FMC_D7_DA7.ConfNb=1 PA4.Signal=COMP_DAC11_group +ADC1.SamplingTime-1\#ChannelRegularConversion=ADC_SAMPLETIME_64CYCLES_5 PB5.Signal=FMC_SDCKE1 SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX SH.FMC_A10.ConfNb=1 Dma.SAI1_A.1.SyncRequestNumber=1 ProjectManager.CompilerOptimize=2 +ADC1.Rank-1\#ChannelRegularConversion=2 SH.FMC_A5.0=FMC_A5,12b-sda1 PA11.Signal=USB_OTG_FS_DM Dma.ADC1.3.SignalID=NONE @@ -779,6 +787,7 @@ RCC.D1PPRE=RCC_APB3_DIV2 RCC.LSI_VALUE=32000 USB_OTG_FS.VirtualMode=Device_Only SH.FMC_A9.0=FMC_A9,12b-sda1 +ADC1.OffsetNumber-1\#ChannelRegularConversion=ADC_OFFSET_NONE SH.FMC_D4_DA4.0=FMC_D4,sd-16b-d1 USART2.WordLength=WORDLENGTH_8B RCC.PLLSAIN=100 @@ -824,6 +833,7 @@ PB3\ (JTDO/TRACESWO).Signal=S_TIM2_CH2 ProjectManager.TargetToolchain=Other Toolchains (GPDSC) NVIC.DMA1_Stream5_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true SH.FMC_D1_DA1.ConfNb=1 +ADC1.Channel-1\#ChannelRegularConversion=ADC_CHANNEL_17 PF2.Signal=FMC_A2 ProjectManager.RegisterCallBack= RCC.PLLSAIoutputFreq_Value=50000000 @@ -878,6 +888,7 @@ PC9.Signal=GPIO_Output RCC.VCOInput2Freq_Value=12500000 RCC.APB1Freq_Value=120000000 SAI1.InitProtocol-SAI_B_SyncSlave=Enable +ADC1.ClockPrescaler=ADC_CLOCK_ASYNC_DIV64 PB11.Locked=true ProjectManager.DeviceId=STM32H743ZGTx ProjectManager.LibraryCopy=2 diff --git a/Genius/Inc/hardware.h b/Genius/Inc/hardware.h index 6b857929..8afac283 100644 --- a/Genius/Inc/hardware.h +++ b/Genius/Inc/hardware.h @@ -73,6 +73,6 @@ #define ADC_B 1 #define NOF_ADC_VALUES 2 #define NOF_PARAMETERS 20 -#define NOF_BUTTONS (2+2) +#define NOF_BUTTONS (4+2) #define USE_DAC diff --git a/Genius/Src/Genius.cpp b/Genius/Src/Genius.cpp index 67209fee..5d6c9a5e 100644 --- a/Genius/Src/Genius.cpp +++ b/Genius/Src/Genius.cpp @@ -1,6 +1,8 @@ #include "Owl.h" +#include "OpenWareMidiControl.h" #include "Graphics.h" +#include "Pin.h" #ifdef DEBUG_USBD_AUDIO void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height){ @@ -22,6 +24,15 @@ void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height){ screen.print(" / "); screen.print(usbd_tx_capacity); } +// #else +// void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height){ +// ScreenBuffer& screen = graphics.screen; +// graphics.params.drawTitle(screen); +// graphics.params.drawMessage(26, screen); + +// screen.setTextSize(1); +// encoder_values +// } #endif extern "C"{ @@ -57,7 +68,15 @@ extern TIM_HandleTypeDef ENCODER_TIM2; Graphics graphics; +Pin tr_out_a_pin(GPIOD, GPIO_PIN_3); +Pin tr_out_b_pin(GPIOD, GPIO_PIN_4); + void setup(){ + tr_out_a_pin.outputMode(); + tr_out_b_pin.outputMode(); + tr_out_a_pin.high(); + tr_out_b_pin.high(); + HAL_GPIO_WritePin(OLED_RST_GPIO_Port, OLED_RST_Pin, GPIO_PIN_RESET); // OLED off extern SPI_HandleTypeDef OLED_SPI; graphics.begin(&OLED_SPI); @@ -75,7 +94,59 @@ void setup(){ owl.setup(); } -// int16_t* Encoders_get(){ +void setGateValue(uint8_t ch, int16_t value){ + switch(ch){ + case PUSHBUTTON: + case BUTTON_1: + tr_out_a_pin.set(!value); + break; + case BUTTON_2: + tr_out_b_pin.set(!value); + break; + } +} + +// 12x12 bit multiplication with unsigned operands and result +#define U12_MUL_U12(a,b) (__USAT(((uint32_t)(a)*(b))>>12, 12)) +static uint16_t scaleForDac(int16_t value){ + return U12_MUL_U12(value + 70, 3521); +} + +void setAnalogValue(uint8_t ch, int16_t value){ + // if(owl.getOperationMode() == RUN_MODE){ + extern DAC_HandleTypeDef hdac; + switch(ch){ + case PARAMETER_F: + HAL_DAC_SetValue(&hdac, DAC_CHANNEL_1, DAC_ALIGN_12B_R, scaleForDac(value)); + break; + case PARAMETER_G: + HAL_DAC_SetValue(&hdac, DAC_CHANNEL_2, DAC_ALIGN_12B_R, scaleForDac(value)); + break; + } + // } +} + +void onChangePin(uint16_t pin){ + switch(pin){ + case TR_IN_A_Pin: + case SW_A_Pin: { + bool state = HAL_GPIO_ReadPin(SW_A_GPIO_Port, SW_A_Pin) == GPIO_PIN_RESET; + state |= HAL_GPIO_ReadPin(TR_IN_A_GPIO_Port, TR_IN_A_Pin) == GPIO_PIN_RESET; + setButtonValue(PUSHBUTTON, state); + setButtonValue(BUTTON_A, state); + // midi_tx.sendCc(PATCH_BUTTON, state ? 127 : 0); + break; + } + case TR_IN_B_Pin: + case SW_B_Pin: { + bool state = HAL_GPIO_ReadPin(SW_B_GPIO_Port, SW_B_Pin) == GPIO_PIN_RESET; + state |= HAL_GPIO_ReadPin(TR_IN_B_GPIO_Port, TR_IN_B_Pin) == GPIO_PIN_RESET; + setButtonValue(BUTTON_B, state); + break; + } + } +} + void updateEncoders(){ static int16_t encoder_values[2] = {INT16_MAX/2, INT16_MAX/2}; int16_t value = __HAL_TIM_GET_COUNTER(&ENCODER_TIM1); @@ -90,20 +161,6 @@ void updateEncoders(){ encoder_values[1] = value; } - // case ENC1_SW_Pin: // GPIO_PIN_14: - // setButtonValue(BUTTON_A, !(ENC1_SW_GPIO_Port->IDR & ENC1_SW_Pin)); - // setButtonValue(PUSHBUTTON, !(ENC1_SW_GPIO_Port->IDR & ENC1_SW_Pin)); - // break; - // case ENC2_SW_Pin: // GPIO_PIN_4: - // setButtonValue(BUTTON_B, !(ENC2_SW_GPIO_Port->IDR & ENC2_SW_Pin)); - // break; - // case TR_IN_A_Pin: // GPIO_PIN_11: - // setButtonValue(BUTTON_C, !(TR_IN_A_GPIO_Port->IDR & TR_IN_A_Pin)); - // break; - // case TR_IN_B_Pin: // GPIO_PIN_10: - // setButtonValue(BUTTON_D, !(TR_IN_B_GPIO_Port->IDR & TR_IN_B_Pin)); - // break; - void loop(void){ #ifdef USE_USB_HOST From 5a213ca4034cf2c583e73618dc1acd4fc3a00ee9 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 15 Oct 2021 16:52:36 +0200 Subject: [PATCH 110/286] adc and exti changes --- Genius/Genius.ioc | 6 ++++-- Genius/Inc/hardware.h | 2 +- Genius/Inc/main.h | 1 + Genius/Inc/stm32h7xx_it.h | 2 ++ Genius/Src/Genius.cpp | 11 +++++++++++ Genius/Src/main.c | 36 +++++++++++++++++++++------------- Genius/Src/stm32h7xx_hal_msp.c | 24 ++++++----------------- Genius/Src/stm32h7xx_it.c | 29 +++++++++++++++++++++++++++ 8 files changed, 76 insertions(+), 35 deletions(-) diff --git a/Genius/Genius.ioc b/Genius/Genius.ioc index cb2a0c06..c147896a 100644 --- a/Genius/Genius.ioc +++ b/Genius/Genius.ioc @@ -259,6 +259,7 @@ Mcu.Pin11=PF6 Mcu.Pin12=PF7 Mcu.Pin10=PF5 SH.GPXTI10.ConfNb=1 +ADC1.ConversionDataManagement=ADC_CONVERSIONDATA_DMA_CIRCULAR PE3.Signal=SAI1_SD_B Dma.SAI1_A.1.PeriphInc=DMA_PINC_DISABLE PF4.Signal=FMC_A4 @@ -601,7 +602,7 @@ Dma.SAI1_B.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAli Dma.USART2_RX.6.SyncSignalID=NONE PD2.GPIO_PuPd=GPIO_PULLUP VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC.Mode=SAI_A_BASIC -ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,master,ContinuousConvMode,ClockPrescaler,Resolution,Overrun,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,OffsetNumber-1\#ChannelRegularConversion,NbrOfConversion,EOCSelection +ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,master,ContinuousConvMode,ClockPrescaler,Resolution,Overrun,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,OffsetNumber-1\#ChannelRegularConversion,NbrOfConversion,EOCSelection,ConversionDataManagement PG9.Locked=true PG9.Signal=GPIO_Output RCC.SWPMI1Freq_Value=120000000 @@ -720,6 +721,7 @@ NVIC.UART5_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true Dma.SPI2_TX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE RCC.VCOInput3Freq_Value=781250 RCC.I2C3Freq_Value=42000000 +NVIC.ADC_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true SH.FMC_A7.0=FMC_A7,12b-sda1 PA12.Signal=USB_OTG_FS_DP Dma.SAI1_B.2.SyncRequestNumber=1 @@ -888,7 +890,7 @@ PC9.Signal=GPIO_Output RCC.VCOInput2Freq_Value=12500000 RCC.APB1Freq_Value=120000000 SAI1.InitProtocol-SAI_B_SyncSlave=Enable -ADC1.ClockPrescaler=ADC_CLOCK_ASYNC_DIV64 +ADC1.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV4 PB11.Locked=true ProjectManager.DeviceId=STM32H743ZGTx ProjectManager.LibraryCopy=2 diff --git a/Genius/Inc/hardware.h b/Genius/Inc/hardware.h index 8afac283..84b5308e 100644 --- a/Genius/Inc/hardware.h +++ b/Genius/Inc/hardware.h @@ -72,7 +72,7 @@ #define ADC_A 0 #define ADC_B 1 #define NOF_ADC_VALUES 2 -#define NOF_PARAMETERS 20 +#define NOF_PARAMETERS 40 #define NOF_BUTTONS (4+2) #define USE_DAC diff --git a/Genius/Inc/main.h b/Genius/Inc/main.h index 81a9c44a..c72410f0 100644 --- a/Genius/Inc/main.h +++ b/Genius/Inc/main.h @@ -111,6 +111,7 @@ void Error_Handler(void); #define SW_B_EXTI_IRQn EXTI15_10_IRQn #define TR_IN_B_Pin GPIO_PIN_2 #define TR_IN_B_GPIO_Port GPIOD +#define TR_IN_B_EXTI_IRQn EXTI2_IRQn #define TR_OUT_B_Pin GPIO_PIN_3 #define TR_OUT_B_GPIO_Port GPIOD #define TR_OUT_A_Pin GPIO_PIN_4 diff --git a/Genius/Inc/stm32h7xx_it.h b/Genius/Inc/stm32h7xx_it.h index 4b5f80d3..3ebd5c6c 100644 --- a/Genius/Inc/stm32h7xx_it.h +++ b/Genius/Inc/stm32h7xx_it.h @@ -48,6 +48,7 @@ /* Exported functions prototypes ---------------------------------------------*/ void SysTick_Handler(void); +void EXTI2_IRQHandler(void); void EXTI4_IRQHandler(void); void DMA1_Stream0_IRQHandler(void); void DMA1_Stream1_IRQHandler(void); @@ -55,6 +56,7 @@ void DMA1_Stream2_IRQHandler(void); void DMA1_Stream3_IRQHandler(void); void DMA1_Stream4_IRQHandler(void); void DMA1_Stream5_IRQHandler(void); +void ADC_IRQHandler(void); void TIM2_IRQHandler(void); void TIM3_IRQHandler(void); void SPI2_IRQHandler(void); diff --git a/Genius/Src/Genius.cpp b/Genius/Src/Genius.cpp index 5d6c9a5e..db9ad8ed 100644 --- a/Genius/Src/Genius.cpp +++ b/Genius/Src/Genius.cpp @@ -147,6 +147,17 @@ void onChangePin(uint16_t pin){ } } +extern "C"{ + // void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc){ + // } + void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc){ + error(CONFIG_ERROR, "ADC error"); + } +} + +// void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* adc_values, size_t adc_len){ +// } + void updateEncoders(){ static int16_t encoder_values[2] = {INT16_MAX/2, INT16_MAX/2}; int16_t value = __HAL_TIM_GET_COUNTER(&ENCODER_TIM1); diff --git a/Genius/Src/main.c b/Genius/Src/main.c index 5427a30b..bae8a0ce 100644 --- a/Genius/Src/main.c +++ b/Genius/Src/main.c @@ -273,9 +273,6 @@ void SystemClock_Config(void) __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE0); while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {} - /** Macro to configure the PLL clock source - */ - __HAL_RCC_PLL_PLLSOURCE_CONFIG(RCC_PLLSOURCE_HSE); /** Initializes the RCC Oscillators according to the specified parameters * in the RCC_OscInitTypeDef structure. */ @@ -335,18 +332,18 @@ static void MX_ADC1_Init(void) /** Common config */ hadc1.Instance = ADC1; - hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1; - hadc1.Init.Resolution = ADC_RESOLUTION_16B; - hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE; - hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV; + hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4; + hadc1.Init.Resolution = ADC_RESOLUTION_12B; + hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE; + hadc1.Init.EOCSelection = ADC_EOC_SEQ_CONV; hadc1.Init.LowPowerAutoWait = DISABLE; - hadc1.Init.ContinuousConvMode = DISABLE; - hadc1.Init.NbrOfConversion = 1; + hadc1.Init.ContinuousConvMode = ENABLE; + hadc1.Init.NbrOfConversion = 2; hadc1.Init.DiscontinuousConvMode = DISABLE; hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START; hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; - hadc1.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DR; - hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED; + hadc1.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DMA_CIRCULAR; + hadc1.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN; hadc1.Init.LeftBitShift = ADC_LEFTBITSHIFT_NONE; hadc1.Init.OversamplingMode = DISABLE; if (HAL_ADC_Init(&hadc1) != HAL_OK) @@ -364,7 +361,7 @@ static void MX_ADC1_Init(void) */ sConfig.Channel = ADC_CHANNEL_16; sConfig.Rank = ADC_REGULAR_RANK_1; - sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5; + sConfig.SamplingTime = ADC_SAMPLETIME_64CYCLES_5; sConfig.SingleDiff = ADC_SINGLE_ENDED; sConfig.OffsetNumber = ADC_OFFSET_NONE; sConfig.Offset = 0; @@ -373,6 +370,14 @@ static void MX_ADC1_Init(void) { Error_Handler(); } + /** Configure Regular Channel + */ + sConfig.Channel = ADC_CHANNEL_17; + sConfig.Rank = ADC_REGULAR_RANK_2; + if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) + { + Error_Handler(); + } /* USER CODE BEGIN ADC1_Init 2 */ /* USER CODE END ADC1_Init 2 */ @@ -1151,10 +1156,13 @@ static void MX_GPIO_Init(void) HAL_GPIO_Init(ENC2_SW_GPIO_Port, &GPIO_InitStruct); /* EXTI interrupt init*/ - HAL_NVIC_SetPriority(EXTI4_IRQn, 10, 0); + HAL_NVIC_SetPriority(EXTI2_IRQn, 15, 0); + HAL_NVIC_EnableIRQ(EXTI2_IRQn); + + HAL_NVIC_SetPriority(EXTI4_IRQn, 15, 0); HAL_NVIC_EnableIRQ(EXTI4_IRQn); - HAL_NVIC_SetPriority(EXTI15_10_IRQn, 10, 0); + HAL_NVIC_SetPriority(EXTI15_10_IRQn, 15, 0); HAL_NVIC_EnableIRQ(EXTI15_10_IRQn); } diff --git a/Genius/Src/stm32h7xx_hal_msp.c b/Genius/Src/stm32h7xx_hal_msp.c index e9abf926..b2da2c60 100644 --- a/Genius/Src/stm32h7xx_hal_msp.c +++ b/Genius/Src/stm32h7xx_hal_msp.c @@ -98,29 +98,11 @@ void HAL_MspInit(void) void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) { GPIO_InitTypeDef GPIO_InitStruct = {0}; - RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; if(hadc->Instance==ADC1) { /* USER CODE BEGIN ADC1_MspInit 0 */ /* USER CODE END ADC1_MspInit 0 */ - /** Initializes the peripherals clock - */ - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_ADC; - PeriphClkInitStruct.PLL2.PLL2M = 2; - PeriphClkInitStruct.PLL2.PLL2N = 12; - PeriphClkInitStruct.PLL2.PLL2P = 5; - PeriphClkInitStruct.PLL2.PLL2Q = 2; - PeriphClkInitStruct.PLL2.PLL2R = 2; - PeriphClkInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_3; - PeriphClkInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOMEDIUM; - PeriphClkInitStruct.PLL2.PLL2FRACN = 0; - PeriphClkInitStruct.AdcClockSelection = RCC_ADCCLKSOURCE_PLL2; - if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) - { - Error_Handler(); - } - /* Peripheral clock enable */ __HAL_RCC_ADC12_CLK_ENABLE(); @@ -154,6 +136,9 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) __HAL_LINKDMA(hadc,DMA_Handle,hdma_adc1); + /* ADC1 interrupt Init */ + HAL_NVIC_SetPriority(ADC_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(ADC_IRQn); /* USER CODE BEGIN ADC1_MspInit 1 */ /* USER CODE END ADC1_MspInit 1 */ @@ -186,6 +171,9 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) /* ADC1 DMA DeInit */ HAL_DMA_DeInit(hadc->DMA_Handle); + + /* ADC1 interrupt DeInit */ + HAL_NVIC_DisableIRQ(ADC_IRQn); /* USER CODE BEGIN ADC1_MspDeInit 1 */ /* USER CODE END ADC1_MspDeInit 1 */ diff --git a/Genius/Src/stm32h7xx_it.c b/Genius/Src/stm32h7xx_it.c index 0707f453..b91c1301 100644 --- a/Genius/Src/stm32h7xx_it.c +++ b/Genius/Src/stm32h7xx_it.c @@ -59,6 +59,7 @@ /* External variables --------------------------------------------------------*/ extern DMA_HandleTypeDef hdma_adc1; +extern ADC_HandleTypeDef hadc1; extern DMA_HandleTypeDef hdma_sai1_a; extern DMA_HandleTypeDef hdma_sai1_b; extern DMA_HandleTypeDef hdma_spi2_tx; @@ -109,6 +110,20 @@ void SysTick_Handler(void) /* please refer to the startup file (startup_stm32h7xx.s). */ /******************************************************************************/ +/** + * @brief This function handles EXTI line2 interrupt. + */ +void EXTI2_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI2_IRQn 0 */ + + /* USER CODE END EXTI2_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2); + /* USER CODE BEGIN EXTI2_IRQn 1 */ + + /* USER CODE END EXTI2_IRQn 1 */ +} + /** * @brief This function handles EXTI line4 interrupt. */ @@ -207,6 +222,20 @@ void DMA1_Stream5_IRQHandler(void) /* USER CODE END DMA1_Stream5_IRQn 1 */ } +/** + * @brief This function handles ADC1 and ADC2 global interrupts. + */ +void ADC_IRQHandler(void) +{ + /* USER CODE BEGIN ADC_IRQn 0 */ + + /* USER CODE END ADC_IRQn 0 */ + HAL_ADC_IRQHandler(&hadc1); + /* USER CODE BEGIN ADC_IRQn 1 */ + + /* USER CODE END ADC_IRQn 1 */ +} + /** * @brief This function handles TIM2 global interrupt. */ From bff726357ec6ade4bd2e0ca3f36db7c84abc7361 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 15 Oct 2021 19:16:09 +0200 Subject: [PATCH 111/286] usb updates, midi host not working --- Genius/Genius.ioc | 31 +++++++++++-- Genius/Inc/usbh_conf.h | 14 ++++-- Genius/Src/main.c | 42 +++-------------- Genius/Src/stm32h7xx_hal_msp.c | 83 ---------------------------------- Genius/Src/stm32h7xx_it.c | 2 +- Genius/Src/usbd_conf.c | 4 +- Genius/Src/usbh_conf.c | 79 ++++++++++++++++++++++++++++++-- Genius/Src/usbh_platform.c | 6 +-- 8 files changed, 123 insertions(+), 138 deletions(-) diff --git a/Genius/Genius.ioc b/Genius/Genius.ioc index c147896a..5f62c997 100644 --- a/Genius/Genius.ioc +++ b/Genius/Genius.ioc @@ -118,7 +118,7 @@ ProjectManager.ProjectFileName=Genius.ioc SH.FMC_A5.ConfNb=1 FREERTOS.Tasks01=defaultTask,0,1024,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL Mcu.Pin79=PG15 -Mcu.PinsNb=91 +Mcu.PinsNb=92 PC11.Locked=true Mcu.Pin73=PD3 Mcu.Pin74=PD4 @@ -149,6 +149,7 @@ Mcu.Pin64=PA13 (JTMS/SWDIO) Mcu.Pin65=PA14 (JTCK/SWCLK) Dma.SAI1_B.2.PeriphInc=DMA_PINC_DISABLE PF8.GPIO_Label=Flash_MISO +USB_HOST0.BSP.semaphore= Dma.USART2_RX.6.FIFOMode=DMA_FIFOMODE_DISABLE PD10.Signal=FMC_D15_DA15 RCC.D1CPREFreq_Value=480000000 @@ -284,6 +285,7 @@ Dma.UART5_TX.5.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataA PA0.GPIO_Label=ADC0 SAI1.VirtualProtocol-SAI_A_BASIC=VM_BASIC_PROTOCOL PA11.Mode=Device_Only +VP_USB_HOST_VS_USB_HOST_ALL_CLASS_HS.Signal=USB_HOST_VS_USB_HOST_ALL_CLASS_HS PD6.Locked=true PD2.Locked=true SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 @@ -316,6 +318,7 @@ SH.COMP_DAC12_group.ConfNb=1 SH.FMC_NBL1.0=FMC_NBL1,Sd2ByteEnable1 SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,DataSize,NSSPMode,VirtualType,Direction FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,MEMORY_ALLOCATION,configUSE_MUTEXES,FootprintOK,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,INCLUDE_vTaskDelayUntil +USB_HOST0.BSP.ip=GPIO FREERTOS.configUSE_PREEMPTION=0 RCC.HRTIMFreq_Value=240000000 ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_16 @@ -333,7 +336,7 @@ Mcu.IP11=SPI4 PC10.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING Mcu.IP18=USART2 Mcu.IP17=UART5 -Mcu.IP19=USB_OTG_FS +Mcu.IP19=USB_HOST PA6.GPIO_PuPd=GPIO_PULLUP RCC.DIVP1Freq_Value=480000000 Mcu.IP14=TIM2 @@ -346,7 +349,8 @@ PF11.Signal=FMC_SDNRAS PC11.GPIO_Label=TR_IN_A PB5.Mode=SdramChipSelect2_1 PE3.GPIOParameters=GPIO_Label -Mcu.IP20=USB_OTG_HS +Mcu.IP21=USB_OTG_HS +Mcu.IP20=USB_OTG_FS Dma.UART5_RX.4.Mode=DMA_NORMAL SH.S_TIM3_CH1.0=TIM3_CH1,Encoder_Interface PB3\ (JTDO/TRACESWO).GPIO_PuPd=GPIO_PULLUP @@ -360,10 +364,12 @@ ProjectManager.ToolChainLocation= PF8.Signal=SPI5_MISO UART5.IPParameters=BaudRate,DMADisableonRxErrorParam,OverrunDisableParam RCC.DIVR1Freq_Value=480000000 +USB_HOST0.BSP.name=Drive_VBUS_HS Dma.Request2=SAI1_B Dma.Request1=SAI1_A Dma.Request4=UART5_RX Dma.Request3=ADC1 +Mcu.Pin91=VP_USB_HOST_VS_USB_HOST_ALL_CLASS_HS Dma.Request6=USART2_RX Dma.Request5=UART5_TX NVIC.DMA1_Stream0_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true @@ -387,6 +393,7 @@ Mcu.Pin87=VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC SH.FMC_A3.ConfNb=1 PB3\ (JTDO/TRACESWO).GPIO_Label=ENC1_CH2 RCC.I2SFreq_Value=96000000 +USB_HOST.IPParameters=USBH_HandleTypeDef-ALL_Classes_HS,VirtualModeHS,USBH_MAX_NUM_CONFIGURATION-ALL_Classes_HS Dma.UART5_RX.4.SyncEnable=DISABLE Dma.UART5_TX.5.Mode=DMA_NORMAL SH.S_TIM2_CH1.0=TIM2_CH1,Encoder_Interface @@ -398,6 +405,7 @@ SPI4.DataSize=SPI_DATASIZE_8BIT NVIC.SavedSvcallIrqHandlerGenerated=true PC11.Signal=GPXTI11 TIM6.Prescaler=3500 +USB_HOST0.BSP.solution=PC9 VP_TIM6_VS_ClockSourceINT.Mode=Enable_Timer ProjectManager.DefaultFWLocation=true Dma.UART5_TX.5.MemDataAlignment=DMA_MDATAALIGN_BYTE @@ -449,6 +457,7 @@ VP_SYS_VS_Systick.Mode=SysTick TIM6.TIM_MasterOutputTrigger=TIM_TRGO_UPDATE SH.FMC_D12_DA12.0=FMC_D12,sd-16b-d1 USB_OTG_FS.Sof_enable=ENABLE +VP_USB_HOST_VS_USB_HOST_ALL_CLASS_HS.Mode=ALL_Classes_HS PF1.Signal=FMC_A1 SH.FMC_D11_DA11.ConfNb=1 RCC.UART5Freq_Value=42000000 @@ -486,6 +495,7 @@ SH.FMC_D8_DA8.ConfNb=1 Dma.SPI2_TX.0.Direction=DMA_MEMORY_TO_PERIPH Dma.UART5_TX.5.Direction=DMA_MEMORY_TO_PERIPH PB12.Signal=UART5_RX +USB_HOST0.BSP.instance=PC9 PB4\ (NJTRST).Signal=GPXTI4 USB_OTG_HS.VirtualMode-Host_FS=Host_FS SH.FMC_D7_DA7.0=FMC_D7,sd-16b-d1 @@ -508,6 +518,7 @@ SPI5.DataSize=SPI_DATASIZE_8BIT PD3.GPIOParameters=GPIO_Label Dma.USART2_TX.7.SignalID=NONE FMC.LoadToActiveDelay1=2 +USB_HOST0.BSP.condition= Dma.SAI1_B.2.SyncSignalID=NONE PA6.GPIO_Label=ENC2_CH1 Dma.USART2_RX.6.SyncEnable=DISABLE @@ -535,6 +546,7 @@ Dma.SAI1_B.2.SyncEnable=DISABLE TIM2.IPParameters=EncoderMode,Period PD4.Signal=GPIO_Output SH.FMC_D10_DA10.ConfNb=1 +USB_HOST0.BSP.component= PB6.Mode=SdramChipSelect2_1 RCC.DIVQ3Freq_Value=50390625 Dma.USART2_RX.6.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber @@ -605,6 +617,7 @@ VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC.Mode=SAI_A_BASIC ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,master,ContinuousConvMode,ClockPrescaler,Resolution,Overrun,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,OffsetNumber-1\#ChannelRegularConversion,NbrOfConversion,EOCSelection,ConversionDataManagement PG9.Locked=true PG9.Signal=GPIO_Output +USB_HOST.USBH_HandleTypeDef-ALL_Classes_HS=hUsbHostHS RCC.SWPMI1Freq_Value=120000000 FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 PB11.GPIO_Label=OLED_CS @@ -622,6 +635,7 @@ Dma.USART2_RX.6.PeriphInc=DMA_PINC_DISABLE PG10.Signal=GPIO_Output PG10.Locked=true VP_TIM6_VS_ClockSourceINT.Signal=TIM6_VS_ClockSourceINT +USB_HOST0.BSP.STBoard=false SH.FMC_A3.0=FMC_A3,12b-sda1 Dma.SAI1_A.1.Polarity=HAL_DMAMUX_REQ_GEN_RISING RCC.USART234578Freq_Value=120000000 @@ -631,6 +645,7 @@ SH.FMC_D15_DA15.0=FMC_D15,sd-16b-d1 Dma.SAI1_B.2.PeriphDataAlignment=DMA_PDATAALIGN_WORD PC3_C.GPIOParameters=GPIO_Label Dma.UART5_RX.4.SignalID=NONE +USB_HOST.VirtualModeHS=All_Classes PA9.Signal=USB_OTG_FS_VBUS SH.S_TIM2_CH2.ConfNb=1 RCC.DIVN2=12 @@ -660,6 +675,7 @@ SH.FMC_D7_DA7.ConfNb=1 PA4.Signal=COMP_DAC11_group ADC1.SamplingTime-1\#ChannelRegularConversion=ADC_SAMPLETIME_64CYCLES_5 PB5.Signal=FMC_SDCKE1 +USB_HOST.USBH_MAX_NUM_CONFIGURATION-ALL_Classes_HS=5 SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX SH.FMC_A10.ConfNb=1 Dma.SAI1_A.1.SyncRequestNumber=1 @@ -684,6 +700,7 @@ SH.FMC_D12_DA12.ConfNb=1 RCC.HCLK3ClockFreq_Value=240000000 RCC.I2C2Freq_Value=42000000 SPI5.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,DataSize,VirtualType,Direction +USB_HOST0.BSP.mode=Output PA7.GPIOParameters=GPIO_PuPd,GPIO_Label PC1.Signal=SPI2_MOSI PB12.GPIOParameters=GPIO_Speed @@ -704,7 +721,7 @@ PC10.Signal=GPXTI10 SPI4.Direction=SPI_DIRECTION_2LINES_TXONLY SH.FMC_NBL0.0=FMC_NBL0,Sd2ByteEnable1 TIM3.EncoderMode=TIM_ENCODERMODE_TI12 -ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI2_Init-SPI2-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-MX_SPI5_Init-SPI5-false-HAL-true,9-MX_TIM2_Init-TIM2-false-HAL-true,10-MX_TIM3_Init-TIM3-false-HAL-true,11-MX_TIM6_Init-TIM6-false-HAL-true,12-MX_USART2_UART_Init-USART2-false-HAL-true,13-MX_ADC1_Init-ADC1-false-HAL-true,14-MX_DAC1_Init-DAC1-false-HAL-true,15-MX_UART5_Init-UART5-false-HAL-true,16-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-false-HAL-true,17-MX_USB_OTG_HS_HCD_Init-USB_OTG_HS-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI2_Init-SPI2-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-MX_SPI5_Init-SPI5-false-HAL-true,9-MX_TIM2_Init-TIM2-false-HAL-true,10-MX_TIM3_Init-TIM3-false-HAL-true,11-MX_TIM6_Init-TIM6-false-HAL-true,12-MX_USART2_UART_Init-USART2-false-HAL-true,13-MX_ADC1_Init-ADC1-false-HAL-true,14-MX_DAC1_Init-DAC1-false-HAL-true,15-MX_UART5_Init-UART5-false-HAL-true,16-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-false-HAL-true,17-MX_USB_HOST_Init-USB_HOST-false-HAL-false,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true SH.FMC_D6_DA6.0=FMC_D6,sd-16b-d1 PC9.Locked=true RCC.PLLI2SRCLKFreq_Value=96000000 @@ -732,7 +749,7 @@ Mcu.ThirdPartyNb=0 Dma.SPI2_TX.0.SyncSignalID=NONE Dma.USART2_TX.7.PeriphInc=DMA_PINC_DISABLE RCC.HCLKFreq_Value=240000000 -Mcu.IPNb=21 +Mcu.IPNb=22 RCC.PLLI2SRoutputFreq_Value=96000000 RCC.SPDIFRXFreq_Value=48000000 Dma.ADC1.3.PeriphInc=DMA_PINC_DISABLE @@ -775,6 +792,7 @@ PE4.Mode=SAI_A_AsyncSlave TIM6.Period=8 SH.FMC_SDNRAS.0=FMC_SDNRAS,12b-sda1 Dma.SPI2_TX.0.RequestNumber=1 +USB_HOST0.BSP.i2creg= PE4.Signal=SAI1_FS_A PE6.GPIOParameters=GPIO_Label Dma.RequestsNb=8 @@ -783,6 +801,7 @@ SPI4.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_32 PC2_C.Locked=true ProjectManager.ProjectName=Genius RCC.APB3Freq_Value=120000000 +USB_HOST0.BSP.i2caddr=0 SPI5.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128 SH.FMC_D0_DA0.0=FMC_D0,sd-16b-d1 RCC.D1PPRE=RCC_APB3_DIV2 @@ -816,6 +835,7 @@ ProjectManager.NoMain=false PG1.Signal=FMC_A11 RCC.SAI4BFreq_Value=48000000 SH.FMC_SDCLK.ConfNb=1 +USB_HOST.BSP.number=1 RCC.D2PPRE2=RCC_APB2_DIV2 RCC.D2PPRE1=RCC_APB1_DIV2 Dma.UART5_RX.4.EventEnable=DISABLE @@ -855,6 +875,7 @@ SAI1.IPParameters=Instance-SAI_A_AsyncSlave,VirtualMode-SAI_A_AsyncSlave,Instanc RCC.VCOInput1Freq_Value=5000000 NVIC.SavedSystickIrqHandlerGenerated=true RCC.APB2Freq_Value=120000000 +USB_HOST0.BSP.api=Unknown Dma.UART5_TX.5.SyncRequestNumber=1 Dma.USART2_TX.7.RequestNumber=1 SH.FMC_D13_DA13.ConfNb=1 diff --git a/Genius/Inc/usbh_conf.h b/Genius/Inc/usbh_conf.h index 2fa26bdb..066c9c49 100644 --- a/Genius/Inc/usbh_conf.h +++ b/Genius/Inc/usbh_conf.h @@ -7,7 +7,7 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2020 STMicroelectronics. + *

© Copyright (c) 2019 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under Ultimate Liberty license @@ -36,7 +36,11 @@ #include "stm32h7xx_hal.h" /* USER CODE BEGIN INCLUDE */ - +#ifdef DEBUG +#define DEBUG_LEVEL 3 +#else +#define DEBUG_LEVEL 0 +#endif /* USER CODE END INCLUDE */ /** @addtogroup STM32_USB_HOST_LIBRARY @@ -69,13 +73,13 @@ #define USBH_MAX_NUM_INTERFACES 10U /*---------- -----------*/ -#define USBH_MAX_NUM_CONFIGURATION 1U +#define USBH_MAX_NUM_CONFIGURATION 5U /*---------- -----------*/ #define USBH_KEEP_CFG_DESCRIPTOR 1U /*---------- -----------*/ -#define USBH_MAX_NUM_SUPPORTED_CLASS 1U +#define USBH_MAX_NUM_SUPPORTED_CLASS 5U /*---------- -----------*/ #define USBH_MAX_SIZE_CONFIGURATION 256U @@ -84,7 +88,7 @@ #define USBH_MAX_DATA_BUFFER 512U /*---------- -----------*/ -#define USBH_DEBUG_LEVEL 0U +#define USBH_DEBUG_LEVEL DEBUG_LEVEL /*---------- -----------*/ #define USBH_USE_OS 0U diff --git a/Genius/Src/main.c b/Genius/Src/main.c index bae8a0ce..9fe37656 100644 --- a/Genius/Src/main.c +++ b/Genius/Src/main.c @@ -20,6 +20,7 @@ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "cmsis_os.h" +#include "usb_host.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ @@ -71,7 +72,6 @@ DMA_HandleTypeDef hdma_usart2_rx; DMA_HandleTypeDef hdma_usart2_tx; PCD_HandleTypeDef hpcd_USB_OTG_FS; -HCD_HandleTypeDef hhcd_USB_OTG_HS; SDRAM_HandleTypeDef hsdram1; @@ -97,7 +97,6 @@ static void MX_ADC1_Init(void); static void MX_DAC1_Init(void); static void MX_UART5_Init(void); static void MX_USB_OTG_FS_PCD_Init(void); -static void MX_USB_OTG_HS_HCD_Init(void); void StartDefaultTask(void const * argument); /* USER CODE BEGIN PFP */ @@ -185,7 +184,6 @@ int main(void) MX_DAC1_Init(); MX_UART5_Init(); MX_USB_OTG_FS_PCD_Init(); - MX_USB_OTG_HS_HCD_Init(); /* USER CODE BEGIN 2 */ HAL_SAI_DeInit(&hsai_BlockA1); HAL_SAI_DeInit(&hsai_BlockB1); @@ -894,39 +892,6 @@ static void MX_USB_OTG_FS_PCD_Init(void) } -/** - * @brief USB_OTG_HS Initialization Function - * @param None - * @retval None - */ -static void MX_USB_OTG_HS_HCD_Init(void) -{ - - /* USER CODE BEGIN USB_OTG_HS_Init 0 */ - - /* USER CODE END USB_OTG_HS_Init 0 */ - - /* USER CODE BEGIN USB_OTG_HS_Init 1 */ - - /* USER CODE END USB_OTG_HS_Init 1 */ - hhcd_USB_OTG_HS.Instance = USB_OTG_HS; - hhcd_USB_OTG_HS.Init.Host_channels = 16; - hhcd_USB_OTG_HS.Init.speed = HCD_SPEED_FULL; - hhcd_USB_OTG_HS.Init.dma_enable = DISABLE; - hhcd_USB_OTG_HS.Init.phy_itface = USB_OTG_EMBEDDED_PHY; - hhcd_USB_OTG_HS.Init.Sof_enable = DISABLE; - hhcd_USB_OTG_HS.Init.low_power_enable = DISABLE; - hhcd_USB_OTG_HS.Init.use_external_vbus = DISABLE; - if (HAL_HCD_Init(&hhcd_USB_OTG_HS) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN USB_OTG_HS_Init 2 */ - - /* USER CODE END USB_OTG_HS_Init 2 */ - -} - /** * Enable DMA controller clock */ @@ -1172,6 +1137,7 @@ static void MX_GPIO_Init(void) /* USER CODE END 4 */ /* USER CODE BEGIN Header_StartDefaultTask */ +#if 0 /** * @brief Function implementing the defaultTask thread. * @param argument: Not used @@ -1180,7 +1146,11 @@ static void MX_GPIO_Init(void) /* USER CODE END Header_StartDefaultTask */ void StartDefaultTask(void const * argument) { + /* init code for USB_HOST */ + MX_USB_HOST_Init(); /* USER CODE BEGIN 5 */ +#endif + void StartDefaultTask(void const * argument) { /* init code for USB_DEVICE */ /* NOTE: we get frequent boot failures if host is called first */ MX_USB_DEVICE_Init(); diff --git a/Genius/Src/stm32h7xx_hal_msp.c b/Genius/Src/stm32h7xx_hal_msp.c index b2da2c60..289abc73 100644 --- a/Genius/Src/stm32h7xx_hal_msp.c +++ b/Genius/Src/stm32h7xx_hal_msp.c @@ -909,58 +909,6 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd) } -/** -* @brief HCD MSP Initialization -* This function configures the hardware resources used in this example -* @param hhcd: HCD handle pointer -* @retval None -*/ -void HAL_HCD_MspInit(HCD_HandleTypeDef* hhcd) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; - if(hhcd->Instance==USB_OTG_HS) - { - /* USER CODE BEGIN USB_OTG_HS_MspInit 0 */ - - /* USER CODE END USB_OTG_HS_MspInit 0 */ - - /** Initializes the peripherals clock - */ - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB; - PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLL; - if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) - { - Error_Handler(); - } - /** Enable USB Voltage detector - */ - HAL_PWREx_EnableUSBVoltageDetector(); - - __HAL_RCC_GPIOB_CLK_ENABLE(); - /**USB_OTG_HS GPIO Configuration - PB14 ------> USB_OTG_HS_DM - PB15 ------> USB_OTG_HS_DP - */ - GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF12_OTG2_FS; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /* Peripheral clock enable */ - __HAL_RCC_USB_OTG_HS_CLK_ENABLE(); - /* USB_OTG_HS interrupt Init */ - HAL_NVIC_SetPriority(OTG_HS_IRQn, 10, 0); - HAL_NVIC_EnableIRQ(OTG_HS_IRQn); - /* USER CODE BEGIN USB_OTG_HS_MspInit 1 */ - - /* USER CODE END USB_OTG_HS_MspInit 1 */ - } - -} - /** * @brief PCD MSP De-Initialization * This function freeze the hardware resources used in this example @@ -993,37 +941,6 @@ void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd) } -/** -* @brief HCD MSP De-Initialization -* This function freeze the hardware resources used in this example -* @param hhcd: HCD handle pointer -* @retval None -*/ -void HAL_HCD_MspDeInit(HCD_HandleTypeDef* hhcd) -{ - if(hhcd->Instance==USB_OTG_HS) - { - /* USER CODE BEGIN USB_OTG_HS_MspDeInit 0 */ - - /* USER CODE END USB_OTG_HS_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_USB_OTG_HS_CLK_DISABLE(); - - /**USB_OTG_HS GPIO Configuration - PB14 ------> USB_OTG_HS_DM - PB15 ------> USB_OTG_HS_DP - */ - HAL_GPIO_DeInit(GPIOB, GPIO_PIN_14|GPIO_PIN_15); - - /* USB_OTG_HS interrupt DeInit */ - HAL_NVIC_DisableIRQ(OTG_HS_IRQn); - /* USER CODE BEGIN USB_OTG_HS_MspDeInit 1 */ - - /* USER CODE END USB_OTG_HS_MspDeInit 1 */ - } - -} - static uint32_t FMC_Initialized = 0; static void HAL_FMC_MspInit(void){ diff --git a/Genius/Src/stm32h7xx_it.c b/Genius/Src/stm32h7xx_it.c index b91c1301..6aa96e18 100644 --- a/Genius/Src/stm32h7xx_it.c +++ b/Genius/Src/stm32h7xx_it.c @@ -58,6 +58,7 @@ /* USER CODE END 0 */ /* External variables --------------------------------------------------------*/ +extern HCD_HandleTypeDef hhcd_USB_OTG_HS; extern DMA_HandleTypeDef hdma_adc1; extern ADC_HandleTypeDef hadc1; extern DMA_HandleTypeDef hdma_sai1_a; @@ -73,7 +74,6 @@ extern DMA_HandleTypeDef hdma_usart2_tx; extern UART_HandleTypeDef huart5; extern UART_HandleTypeDef huart2; extern PCD_HandleTypeDef hpcd_USB_OTG_FS; -extern HCD_HandleTypeDef hhcd_USB_OTG_HS; /* USER CODE BEGIN EV */ /* USER CODE END EV */ diff --git a/Genius/Src/usbd_conf.c b/Genius/Src/usbd_conf.c index ebe07ef9..e989bde2 100644 --- a/Genius/Src/usbd_conf.c +++ b/Genius/Src/usbd_conf.c @@ -280,8 +280,8 @@ USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) hpcd_USB_OTG_FS.Init.Sof_enable = ENABLE; hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; - hpcd_USB_OTG_FS.Init.battery_charging_enable = ENABLE; - hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE; + hpcd_USB_OTG_FS.Init.battery_charging_enable = DISABLE; + hpcd_USB_OTG_FS.Init.vbus_sensing_enable = DISABLE; hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE; hpcd_USB_OTG_FS.Init.use_external_vbus = DISABLE; if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) diff --git a/Genius/Src/usbh_conf.c b/Genius/Src/usbh_conf.c index 1f61f845..d907b549 100644 --- a/Genius/Src/usbh_conf.c +++ b/Genius/Src/usbh_conf.c @@ -36,7 +36,7 @@ /* USER CODE END PV */ -extern HCD_HandleTypeDef hhcd_USB_OTG_HS; +HCD_HandleTypeDef hhcd_USB_OTG_HS; void Error_Handler(void); /* USER CODE BEGIN 0 */ @@ -61,6 +61,76 @@ void USBH_MIDI_NotifyURBChange(USBH_HandleTypeDef *phost, uint8_t chnum, HCD_URB *******************************************************************************/ /* MSP Init */ +void HAL_HCD_MspInit(HCD_HandleTypeDef* hcdHandle) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + if(hcdHandle->Instance==USB_OTG_HS) + { + /* USER CODE BEGIN USB_OTG_HS_MspInit 0 */ + + /* USER CODE END USB_OTG_HS_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB; + PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLL; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + /** Enable USB Voltage detector + */ + HAL_PWREx_EnableUSBVoltageDetector(); + + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**USB_OTG_HS GPIO Configuration + PB14 ------> USB_OTG_HS_DM + PB15 ------> USB_OTG_HS_DP + */ + GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_OTG2_FS; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* Peripheral clock enable */ + __HAL_RCC_USB_OTG_HS_CLK_ENABLE(); + + /* Peripheral interrupt init */ + HAL_NVIC_SetPriority(OTG_HS_IRQn, 10, 0); + HAL_NVIC_EnableIRQ(OTG_HS_IRQn); + /* USER CODE BEGIN USB_OTG_HS_MspInit 1 */ + + /* USER CODE END USB_OTG_HS_MspInit 1 */ + } +} + +void HAL_HCD_MspDeInit(HCD_HandleTypeDef* hcdHandle) +{ + if(hcdHandle->Instance==USB_OTG_HS) + { + /* USER CODE BEGIN USB_OTG_HS_MspDeInit 0 */ + + /* USER CODE END USB_OTG_HS_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_USB_OTG_HS_CLK_DISABLE(); + + /**USB_OTG_HS GPIO Configuration + PB14 ------> USB_OTG_HS_DM + PB15 ------> USB_OTG_HS_DP + */ + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_14|GPIO_PIN_15); + + /* Peripheral interrupt Deinit*/ + HAL_NVIC_DisableIRQ(OTG_HS_IRQn); + + /* USER CODE BEGIN USB_OTG_HS_MspDeInit 1 */ + + /* USER CODE END USB_OTG_HS_MspDeInit 1 */ + } +} + /** * @brief SOF callback. * @param hhcd: HCD handle @@ -78,6 +148,7 @@ void HAL_HCD_SOF_Callback(HCD_HandleTypeDef *hhcd) */ void HAL_HCD_Connect_Callback(HCD_HandleTypeDef *hhcd) { + debugMessage("USBH Connect"); USBH_LL_Connect(hhcd->pData); } @@ -88,6 +159,7 @@ void HAL_HCD_Connect_Callback(HCD_HandleTypeDef *hhcd) */ void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd) { + debugMessage("USBH Disconnect"); USBH_LL_Disconnect(hhcd->pData); } @@ -147,8 +219,10 @@ USBH_StatusTypeDef USBH_LL_Init(USBH_HandleTypeDef *phost) hhcd_USB_OTG_HS.Init.Host_channels = 16; hhcd_USB_OTG_HS.Init.speed = HCD_SPEED_FULL; hhcd_USB_OTG_HS.Init.dma_enable = DISABLE; - hhcd_USB_OTG_HS.Init.phy_itface = HCD_PHY_EMBEDDED; + hhcd_USB_OTG_HS.Init.phy_itface = USB_OTG_EMBEDDED_PHY; hhcd_USB_OTG_HS.Init.Sof_enable = DISABLE; + hhcd_USB_OTG_HS.Init.low_power_enable = DISABLE; + hhcd_USB_OTG_HS.Init.use_external_vbus = DISABLE; if (HAL_HCD_Init(&hhcd_USB_OTG_HS) != HAL_OK) { Error_Handler( ); @@ -388,7 +462,6 @@ USBH_StatusTypeDef USBH_LL_DriverVBUS(USBH_HandleTypeDef *phost, uint8_t state) } /* USER CODE BEGIN 0 */ - /* USER CODE END 0*/ HAL_Delay(200); diff --git a/Genius/Src/usbh_platform.c b/Genius/Src/usbh_platform.c index 33001136..3c2e63db 100644 --- a/Genius/Src/usbh_platform.c +++ b/Genius/Src/usbh_platform.c @@ -31,8 +31,8 @@ * @brief Drive VBUS. * @param state : VBUS state * This parameter can be one of the these values: - * - 1 : VBUS Active - * - 0 : VBUS Inactive + * - 1 : VBUS Active + * - 0 : VBUS Inactive */ void MX_DriverVbusHS(uint8_t state) { @@ -49,7 +49,7 @@ void MX_DriverVbusHS(uint8_t state) data = GPIO_PIN_RESET; } /* USER CODE END PREPARE_GPIO_DATA_VBUS_HS */ - HAL_GPIO_WritePin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin, (GPIO_PinState)data); + HAL_GPIO_WritePin(GPIOC,GPIO_PIN_9,(GPIO_PinState)data); } /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ From da61afb0ac4bcdf8cddecac481111e7908a80551 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 18 Oct 2021 12:54:00 +0200 Subject: [PATCH 112/286] changed URB callback --- Source/usbh_midi.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Source/usbh_midi.cpp b/Source/usbh_midi.cpp index 3fa7532e..820e6dbe 100644 --- a/Source/usbh_midi.cpp +++ b/Source/usbh_midi.cpp @@ -164,14 +164,23 @@ USBH_StatusTypeDef USBH_MIDI_Stop(USBH_HandleTypeDef *phost){ return USBH_OK; } -void USBH_MIDI_NotifyURBChange(USBH_HandleTypeDef *phost, uint8_t chnum, HCD_URBStateTypeDef urb_state){ +extern "C"{ + void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state){ + // USBH_MIDI_NotifyURBChange((USBH_HandleTypeDef*)hhcd->pData, chnum, urb_state); + // USBH_HandleTypeDef* phost = (USBH_HandleTypeDef*)hhcd->pData; +// } +// } +// void USBH_MIDI_NotifyURBChange(USBH_HandleTypeDef *phost, uint8_t chnum, HCD_URBStateTypeDef urb_state){ MIDI_HandleTypeDef *MIDI_Handle = &staticMidiHandle; if(urb_state == URB_DONE && chnum == MIDI_Handle->InPipe && MIDI_Handle->state == MIDI_TRANSFER_DATA){ - size_t len = USBH_LL_GetLastXferSize(phost, MIDI_Handle->InPipe); - USBH_MIDI_ReceiveCallback(phost, MIDI_Handle->pRxData, len); + // size_t len = USBH_LL_GetLastXferSize(phost, MIDI_Handle->InPipe); + // USBH_MIDI_ReceiveCallback(phost, MIDI_Handle->pRxData, len); + size_t len = USBH_LL_GetLastXferSize((USBH_HandleTypeDef*)hhcd->pData, MIDI_Handle->InPipe); + USBH_MIDI_ReceiveCallback((USBH_HandleTypeDef*)hhcd->pData, MIDI_Handle->pRxData, len); } } +} /** * @brief USBH_MIDI_Process From 9417aecec271a678ac3067d541aac8d591d19b07 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 18 Oct 2021 12:54:10 +0200 Subject: [PATCH 113/286] config and usbh changes --- Genius/Inc/hardware.h | 12 +++-- Genius/Src/Genius.cpp | 12 +++-- Genius/Src/usb_host.c | 108 +++++++++++++++++++++++++++++++++-------- Genius/Src/usbh_conf.c | 20 ++++---- 4 files changed, 113 insertions(+), 39 deletions(-) diff --git a/Genius/Inc/hardware.h b/Genius/Inc/hardware.h index 84b5308e..535a2547 100644 --- a/Genius/Inc/hardware.h +++ b/Genius/Inc/hardware.h @@ -5,13 +5,15 @@ #define HARDWARE_ID GENIUS_HARDWARE #define HARDWARE_VERSION "Genius" +/* #define USE_SPI_FLASH */ + /* #define NO_EXTERNAL_RAM */ /* #define NO_CCM_RAM */ #define DMA_RAM __attribute__ ((section (".dmadata"))) #define USE_PLUS_RAM -#define USE_ICACHE -#define USE_DCACHE +/* #define USE_ICACHE */ +/* #define USE_DCACHE */ #define MAX_SYSEX_PROGRAM_SIZE (512*1024) @@ -41,9 +43,9 @@ #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) #define USE_USBD_AUDIO -#define USE_USBD_RX_FB -#define USE_USBD_AUDIO_FEATURES -#define USE_USBD_AUDIO_RX // speaker +/* #define USE_USBD_RX_FB */ +/* #define USE_USBD_AUDIO_FEATURES */ +/* #define USE_USBD_AUDIO_RX // speaker */ #define USE_USBD_AUDIO_TX // microphone #define USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS diff --git a/Genius/Src/Genius.cpp b/Genius/Src/Genius.cpp index db9ad8ed..043391a0 100644 --- a/Genius/Src/Genius.cpp +++ b/Genius/Src/Genius.cpp @@ -153,10 +153,16 @@ extern "C"{ void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc){ error(CONFIG_ERROR, "ADC error"); } -} -// void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* adc_values, size_t adc_len){ -// } + void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* adc_values, size_t adc_len){ + // graphics.params.parameters + graphics.params.setValue(0, adc_values[0]); + graphics.params.setValue(1, adc_values[1]); + // parameter_values[0] = adc_values[0]; // todo: sum with user / encoder setting + // parameter_values[1] = adc_values[1]; + } + +} void updateEncoders(){ static int16_t encoder_values[2] = {INT16_MAX/2, INT16_MAX/2}; diff --git a/Genius/Src/usb_host.c b/Genius/Src/usb_host.c index 02c1c118..b58e3e7d 100644 --- a/Genius/Src/usb_host.c +++ b/Genius/Src/usb_host.c @@ -7,7 +7,7 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2020 STMicroelectronics. + *

© Copyright (c) 2019 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under Ultimate Liberty license @@ -23,15 +23,23 @@ #include "usb_host.h" #include "usbh_core.h" -#include "usbh_midi.h" /* USER CODE BEGIN Includes */ - +#include "device.h" +#include "message.h" +#include "errorhandlers.h" +#ifdef USE_USBH_MIDI +#include "usbh_midi.h" +#endif +#ifdef USE_USBH_HID +#include "usbh_hid.h" +#endif /* USER CODE END Includes */ /* USER CODE BEGIN PV */ /* Private variables ---------------------------------------------------------*/ - +#define HUSB_HOST hUsbHostHS +#define HUSB_HOST_HSFS HOST_HS /* USER CODE END PV */ /* USER CODE BEGIN PFP */ @@ -40,7 +48,7 @@ /* USER CODE END PFP */ /* USB Host core handle declaration */ -USBH_HandleTypeDef hUsbHostHS; +USBH_HandleTypeDef HUSB_HOST; ApplicationTypeDef Appli_state = APPLICATION_IDLE; /* @@ -59,11 +67,41 @@ static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id); * -- Insert your external function declaration here -- */ /* USER CODE BEGIN 1 */ + +void USBH_HID_EventCallback(USBH_HandleTypeDef *phost){ + debugMessage("HID"); +} + +/* + * Background task +*/ void MX_USB_HOST_Process() { /* USB Host Background task */ - USBH_Process(&hUsbHostHS); + USBH_Process(&HUSB_HOST); + /* if(Appli_state == APPLICATION_DISCONNECT){ */ + /* USBH_Stop(&HUSB_HOST); */ + /* USBH_DeInit(&HUSB_HOST); */ + /* Appli_state = APPLICATION_DISCONNECTED; */ + /* }else if(Appli_state == APPLICATION_DISCONNECTED){ */ + /* MX_USB_HOST_Init(); */ + /* Appli_state = APPLICATION_IDLE; */ + /* } */ + USBH_HandleTypeDef *phost = &HUSB_HOST; + /* if(USBH_HID_GetDeviceType(phost) == HID_KEYBOARD){ */ + /* HID_KEYBD_Info_TypeDef* pinfo = USBH_HID_GetKeybdInfo(phost); */ + /* if(pinfo != NULL){ */ + /* uint8_t c = USBH_HID_GetASCIICode(pinfo); */ + /* // or c = pinfo->keys[0]; */ + /* if(c >= 32 && c <= 126) { // readable ascii */ + /* char* msg = "char[ ]"; */ + /* msg[5] = c; */ + /* debugMessage(msg); */ + /* } */ + /* } */ + /* } */ } + /* USER CODE END 1 */ /** @@ -73,24 +111,34 @@ void MX_USB_HOST_Process() void MX_USB_HOST_Init(void) { /* USER CODE BEGIN USB_HOST_Init_PreTreatment */ - + /* USER CODE END USB_HOST_Init_PreTreatment */ - + /* Init host Library, add supported class and start the library. */ - if (USBH_Init(&hUsbHostHS, USBH_UserProcess, HOST_HS) != USBH_OK) + if (USBH_Init(&HUSB_HOST, USBH_UserProcess, HUSB_HOST_HSFS) != USBH_OK) + { + Error_Handler(); + } +#ifdef USE_USBH_MIDI + if (USBH_RegisterClass(&HUSB_HOST, USBH_MIDI_CLASS) != USBH_OK) { Error_Handler(); } - if (USBH_RegisterClass(&hUsbHostHS, USBH_MIDI_CLASS) != USBH_OK) +#endif +#ifdef USE_USBH_HID + if (USBH_RegisterClass(&HUSB_HOST, USBH_HID_CLASS) != USBH_OK) { Error_Handler(); } - if (USBH_Start(&hUsbHostHS) != USBH_OK) +#endif + if (USBH_Start(&HUSB_HOST) != USBH_OK) { Error_Handler(); } /* USER CODE BEGIN USB_HOST_Init_PostTreatment */ + HAL_PWREx_EnableUSBVoltageDetector(); + /* USER CODE END USB_HOST_Init_PostTreatment */ } @@ -100,25 +148,43 @@ void MX_USB_HOST_Init(void) static void USBH_UserProcess (USBH_HandleTypeDef *phost, uint8_t id) { /* USER CODE BEGIN CALL_BACK_1 */ + USBH_UsrLog("USBH UserProcess %d %d %d", phost->EnumState, phost->gState, id); switch(id) { case HOST_USER_SELECT_CONFIGURATION: - break; + break; - case HOST_USER_DISCONNECTION: - Appli_state = APPLICATION_DISCONNECT; - break; + case HOST_USER_CONNECTION: + Appli_state = APPLICATION_START; + break; case HOST_USER_CLASS_ACTIVE: - Appli_state = APPLICATION_READY; - break; + if(Appli_state == APPLICATION_START){ +#ifdef USE_USBH_MIDI + usbh_midi_begin(); +#endif + Appli_state = APPLICATION_READY; + } + break; - case HOST_USER_CONNECTION: - Appli_state = APPLICATION_START; - break; + case HOST_USER_DISCONNECTION: + Appli_state = APPLICATION_DISCONNECT; +#ifdef USE_USBH_MIDI + usbh_midi_reset(); +#endif + break; + + case HOST_USER_UNRECOVERED_ERROR: + /* phost->Control.state = CTRL_SETUP; */ + /* phost->RequestState = CMD_SEND; */ + Appli_state = APPLICATION_DISCONNECT; + /* usbh_midi_reset(); // reset and hope for the best */ + /* USBH_LL_ResetPort(&USBH_HANDLE); */ + error(USB_ERROR, "USB Host error"); + break; default: - break; + break; } /* USER CODE END CALL_BACK_1 */ } diff --git a/Genius/Src/usbh_conf.c b/Genius/Src/usbh_conf.c index d907b549..b96127ac 100644 --- a/Genius/Src/usbh_conf.c +++ b/Genius/Src/usbh_conf.c @@ -24,7 +24,7 @@ #include "usbh_platform.h" /* USER CODE BEGIN Includes */ - +#include "message.h" /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -46,7 +46,6 @@ void Error_Handler(void); /* Private function prototypes -----------------------------------------------*/ USBH_StatusTypeDef USBH_Get_USB_Status(HAL_StatusTypeDef hal_status); -void USBH_MIDI_NotifyURBChange(USBH_HandleTypeDef *phost, uint8_t chnum, HCD_URBStateTypeDef urb_state); /* USER CODE END PFP */ @@ -170,14 +169,15 @@ void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd) * @param urb_state: state * @retval None */ -void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) -{ - USBH_MIDI_NotifyURBChange(hhcd->pData, chnum, urb_state); - /* To be used with OS to sync URB state with the global state machine */ -#if (USBH_USE_OS == 1) - USBH_LL_NotifyURBChange(hhcd->pData); -#endif -} +/* void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) */ +/* { */ +/* USBH_MIDI_NotifyURBChange((USBH_HandleTypeDef*)hhcd->pData, chnum, urb_state); */ +/* /\* To be used with OS to sync URB state with the global state machine *\/ */ +/* #if (USBH_USE_OS == 1) */ +/* // calls (void)osMessagePut(phost->os_event, phost->os_msg, 0U); */ +/* USBH_LL_NotifyURBChange(hhcd->pData); */ +/* #endif */ +/* } */ /** * @brief Port Port Enabled callback. * @param hhcd: HCD handle From 20a875968271d9cfdabbf46e8ad88f18bc095469 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 18 Oct 2021 15:39:10 +0200 Subject: [PATCH 114/286] enable spi (not storing patches) --- Genius/Genius.ioc | 219 ++++++++++++++++++--------------- Genius/Inc/hardware.h | 3 +- Genius/Inc/main.h | 20 +-- Genius/Src/main.c | 42 +++---- Genius/Src/stm32h7xx_hal_msp.c | 6 +- 5 files changed, 155 insertions(+), 135 deletions(-) diff --git a/Genius/Genius.ioc b/Genius/Genius.ioc index 5f62c997..822bf358 100644 --- a/Genius/Genius.ioc +++ b/Genius/Genius.ioc @@ -75,6 +75,7 @@ Dma.UART5_RX.4.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT NVIC.TIM2_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true RCC.USART16Freq_Value=120000000 PE4.GPIO_Label=CS_LRCK +PF10.Locked=true Dma.SPI2_TX.0.EventEnable=DISABLE SH.FMC_D1_DA1.0=FMC_D1,sd-16b-d1 Dma.UART5_TX.5.EventEnable=DISABLE @@ -93,7 +94,7 @@ SH.FMC_A11.ConfNb=1 PA10.Signal=GPIO_Input FREERTOS.FootprintOK=true FMC.WriteRecoveryTime1=2 -SPI5.CalculateBaudRate=937.5 KBits/s +SPI5.CalculateBaudRate=30.0 MBits/s RCC.APB2CLKDivider=RCC_HCLK_DIV2 NVIC.EXTI2_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true Dma.UART5_RX.4.Polarity=HAL_DMAMUX_REQ_GEN_RISING @@ -111,44 +112,46 @@ SH.FMC_D3_DA3.ConfNb=1 PA6.GPIOParameters=GPIO_PuPd,GPIO_Label SH.GPXTI10.0=GPIO_EXTI10 PD6.GPIOParameters=GPIO_Label -Mcu.Pin80=PB3 (JTDO/TRACESWO) -Mcu.Pin81=PB4 (NJTRST) +Mcu.Pin80=PG14 +Mcu.Pin81=PG15 SH.FMC_A4.0=FMC_A4,12b-sda1 ProjectManager.ProjectFileName=Genius.ioc SH.FMC_A5.ConfNb=1 FREERTOS.Tasks01=defaultTask,0,1024,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL -Mcu.Pin79=PG15 -Mcu.PinsNb=92 +Mcu.Pin79=PG10 +Mcu.PinsNb=94 PC11.Locked=true -Mcu.Pin73=PD3 -Mcu.Pin74=PD4 -Mcu.Pin71=PD1 -Mcu.Pin72=PD2 -Mcu.Pin77=PG10 +Mcu.Pin73=PD1 +Mcu.Pin74=PD2 +Mcu.Pin71=PC12 +Mcu.Pin72=PD0 +Mcu.Pin77=PD6 +PC13.Locked=true PG5.Signal=FMC_A15_BA1 -Mcu.Pin78=PG14 +Mcu.Pin78=PG9 ADC1.OffsetNumber-0\#ChannelRegularConversion=ADC_OFFSET_NONE -Mcu.Pin75=PD6 +Mcu.Pin75=PD3 SH.FMC_D10_DA10.0=FMC_D10,sd-16b-d1 -Mcu.Pin76=PG9 +PC13.Signal=GPIO_Output +Mcu.Pin76=PD4 FREERTOS.INCLUDE_vTaskDelayUntil=1 PD3.Signal=GPIO_Output Dma.ADC1.3.Priority=DMA_PRIORITY_LOW -Mcu.Pin70=PD0 -Mcu.Pin68=PC11 -Mcu.Pin69=PC12 +Mcu.Pin70=PC11 +Mcu.Pin68=PA15 (JTDI) +Mcu.Pin69=PC10 PD6.Mode=SAI_A_AsyncSlave PG14.Locked=true -Mcu.Pin62=PA11 -Mcu.Pin63=PA12 -Mcu.Pin60=PA9 -Mcu.Pin61=PA10 -Mcu.Pin66=PA15 (JTDI) -Mcu.Pin67=PC10 -Mcu.Pin64=PA13 (JTMS/SWDIO) -Mcu.Pin65=PA14 (JTCK/SWCLK) +Mcu.Pin62=PA9 +Mcu.Pin63=PA10 +Mcu.Pin60=PG8 +Mcu.Pin61=PC9 +Mcu.Pin66=PA13 (JTMS/SWDIO) +Mcu.Pin67=PA14 (JTCK/SWCLK) +Mcu.Pin64=PA11 +Mcu.Pin65=PA12 Dma.SAI1_B.2.PeriphInc=DMA_PINC_DISABLE -PF8.GPIO_Label=Flash_MISO +PF8.GPIO_Label=FLASH_MISO USB_HOST0.BSP.semaphore= Dma.USART2_RX.6.FIFOMode=DMA_FIFOMODE_DISABLE PD10.Signal=FMC_D15_DA15 @@ -157,37 +160,39 @@ PA3.Mode=Asynchronous Dma.USART2_RX.6.MemInc=DMA_MINC_ENABLE Dma.USART2_RX.6.Mode=DMA_NORMAL RCC.Tim1OutputFreq_Value=240000000 -Mcu.Pin59=PC9 +Mcu.Pin59=PG5 +Mcu.Pin57=PD15 SH.GPXTI2.ConfNb=1 -Mcu.Pin57=PG5 -Mcu.Pin58=PG8 +Mcu.Pin58=PG4 Dma.SPI2_TX.0.SyncRequestNumber=1 -Mcu.Pin51=PD8 +TIM3.IC2Filter=8 +Mcu.Pin51=PB14 RCC.USART6Freq_Value=84000000 -Mcu.Pin52=PD9 +Mcu.Pin52=PB15 SH.COMP_DAC11_group.0=DAC1_OUT1,DAC_OUT1 -Mcu.Pin50=PB15 -Mcu.Pin55=PD15 -Mcu.Pin56=PG4 -Mcu.Pin53=PD10 -Mcu.Pin54=PD14 +Mcu.Pin50=PB13 +Mcu.Pin55=PD10 +Mcu.Pin56=PD14 +Mcu.Pin53=PD8 +Mcu.Pin54=PD9 PB13.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM PB11.GPIOParameters=GPIO_Label Dma.SPI2_TX.0.SyncEnable=DISABLE -Mcu.Pin48=PB13 +Mcu.Pin48=PB11 SPI4.NSSPMode=SPI_NSS_PULSE_DISABLE -Mcu.Pin49=PB14 -Mcu.Pin46=PB11 -Mcu.Pin47=PB12 +Mcu.Pin49=PB12 +Mcu.Pin46=PE15 +Mcu.Pin47=PB10 VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC.Mode=SAI_B_BASIC PB14.Signal=USB_OTG_HS_DM PA5.Signal=COMP_DAC12_group -Mcu.Pin40=PE11 -Mcu.Pin41=PE12 -Mcu.Pin44=PE15 -Mcu.Pin45=PB10 -Mcu.Pin42=PE13 -Mcu.Pin43=PE14 +Mcu.Pin40=PE9 +Mcu.Pin41=PE10 +TIM3.IC1Filter=8 +Mcu.Pin44=PE13 +Mcu.Pin45=PE14 +Mcu.Pin42=PE11 +Mcu.Pin43=PE12 NVIC.TIM3_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true FMC.ReadBurst1=FMC_SDRAM_RBURST_ENABLE PC2_C.GPIO_Label=OLED_RST @@ -195,24 +200,24 @@ SH.FMC_A6.0=FMC_A6,12b-sda1 RCC.AHB12Freq_Value=240000000 PE14.Signal=FMC_D11_DA11 PE6.Mode=TX_Only_Simplex_Unidirect_Master -Mcu.Pin37=PE8 -Mcu.Pin38=PE9 -Mcu.Pin35=PG1 +Mcu.Pin37=PG1 +Mcu.Pin38=PE7 +Mcu.Pin35=PF15 RCC.I2C1Freq_Value=42000000 -Mcu.Pin36=PE7 +Mcu.Pin36=PG0 RCC.PLLI2SPCLKFreq_Value=96000000 SH.FMC_D14_DA14.ConfNb=1 -Mcu.Pin39=PE10 +Mcu.Pin39=PE8 SAI1.TriState-SAI_A_AsyncSlave=SAI_OUTPUT_NOTRELEASED Dma.ADC1.3.SyncSignalID=NONE -Mcu.Pin30=PF12 +Mcu.Pin30=PA7 PA1.GPIO_Label=ADC1 -Mcu.Pin33=PF15 -Mcu.Pin34=PG0 -Mcu.Pin31=PF13 +Mcu.Pin33=PF13 +Mcu.Pin34=PF14 +Mcu.Pin31=PF11 PA15\ (JTDI).GPIO_PuPd=GPIO_PULLUP Dma.ADC1.3.Polarity=HAL_DMAMUX_REQ_GEN_RISING -Mcu.Pin32=PF14 +Mcu.Pin32=PF12 NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false FREERTOS.configUSE_MUTEXES=0 PF13.Signal=FMC_A7 @@ -223,18 +228,18 @@ PG14.GPIO_PuPd=GPIO_PULLUP PC9.GPIOParameters=GPIO_Label PF9.GPIOParameters=GPIO_Label RCC.PLLI2SQCLKFreq_Value=96000000 -Mcu.Pin26=PA5 -Mcu.Pin27=PA6 +Mcu.Pin26=PA3 +Mcu.Pin27=PA4 NVIC.DMA2_Stream4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -Mcu.Pin24=PA3 -Mcu.Pin25=PA4 -Mcu.Pin28=PA7 -Mcu.Pin29=PF11 -Mcu.Pin22=PA1 -Mcu.Pin23=PA2 -Mcu.Pin20=PC3_C +Mcu.Pin24=PA1 +Mcu.Pin25=PA2 +Mcu.Pin28=PA5 +Mcu.Pin29=PA6 +Mcu.Pin22=PC3_C +Mcu.Pin23=PA0 +Mcu.Pin20=PC1 ADC1.master=1 -Mcu.Pin21=PA0 +Mcu.Pin21=PC2_C PA10.Locked=true NVIC.ForceEnableDMAVector=true Dma.UART5_RX.4.Priority=DMA_PRIORITY_LOW @@ -244,21 +249,22 @@ PE5.GPIO_Label=CS_SCK Dma.ADC1.3.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber SH.FMC_SDNRAS.ConfNb=1 ProjectManager.HeapSize=0x400 -Mcu.Pin15=PH0-OSC_IN (PH0) +Mcu.Pin15=PF9 PA0.GPIOParameters=GPIO_Label NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -Mcu.Pin16=PH1-OSC_OUT (PH1) -Mcu.Pin13=PF8 -Mcu.Pin14=PF9 -Mcu.Pin19=PC2_C -Mcu.Pin17=PC0 -Mcu.Pin18=PC1 +Mcu.Pin16=PF10 +Mcu.Pin13=PF7 +Mcu.Pin14=PF8 +Mcu.Pin19=PC0 +PF10.GPIOParameters=GPIO_Label +Mcu.Pin17=PH0-OSC_IN (PH0) +Mcu.Pin18=PH1-OSC_OUT (PH1) Dma.USART2_TX.7.MemDataAlignment=DMA_MDATAALIGN_BYTE SAI1.VirtualProtocol-SAI_B_BASIC=VM_BASIC_PROTOCOL NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 -Mcu.Pin11=PF6 -Mcu.Pin12=PF7 -Mcu.Pin10=PF5 +Mcu.Pin11=PF5 +Mcu.Pin12=PF6 +Mcu.Pin10=PF4 SH.GPXTI10.ConfNb=1 ADC1.ConversionDataManagement=ADC_CONVERSIONDATA_DMA_CIRCULAR PE3.Signal=SAI1_SD_B @@ -267,6 +273,7 @@ PF4.Signal=FMC_A4 PD2.Signal=GPXTI2 PB4\ (NJTRST).GPIO_PuPd=GPIO_PULLUP PC1.Mode=TX_Only_Simplex_Unidirect_Master +TIM2.IC2Filter=8 Mcu.Family=STM32H7 FMC.IPParameters=ReadBurst1,ReadPipeDelay1,LoadToActiveDelay1,ExitSelfRefreshDelay1,SelfRefreshTime1,RowCycleDelay1,WriteRecoveryTime1,RPDelay1,RCDDelay1,SDClockPeriod1,CASLatency1 NVIC.OTG_HS_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true @@ -283,7 +290,9 @@ PH0-OSC_IN\ (PH0).Signal=RCC_OSC_IN SH.COMP_DAC12_group.0=DAC1_OUT2,DAC_OUT2 Dma.UART5_TX.5.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber PA0.GPIO_Label=ADC0 +PA12.GPIOParameters=GPIO_Speed SAI1.VirtualProtocol-SAI_A_BASIC=VM_BASIC_PROTOCOL +PA11.GPIOParameters=GPIO_Speed PA11.Mode=Device_Only VP_USB_HOST_VS_USB_HOST_ALL_CLASS_HS.Signal=USB_HOST_VS_USB_HOST_ALL_CLASS_HS PD6.Locked=true @@ -364,36 +373,39 @@ ProjectManager.ToolChainLocation= PF8.Signal=SPI5_MISO UART5.IPParameters=BaudRate,DMADisableonRxErrorParam,OverrunDisableParam RCC.DIVR1Freq_Value=480000000 +Mcu.Pin93=VP_USB_HOST_VS_USB_HOST_ALL_CLASS_HS USB_HOST0.BSP.name=Drive_VBUS_HS Dma.Request2=SAI1_B Dma.Request1=SAI1_A Dma.Request4=UART5_RX Dma.Request3=ADC1 -Mcu.Pin91=VP_USB_HOST_VS_USB_HOST_ALL_CLASS_HS +Mcu.Pin91=VP_SYS_VS_Systick Dma.Request6=USART2_RX +Mcu.Pin92=VP_TIM6_VS_ClockSourceINT Dma.Request5=UART5_TX NVIC.DMA1_Stream0_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true PD3.GPIO_Label=TR_OUT_B -Mcu.Pin90=VP_TIM6_VS_ClockSourceINT +Mcu.Pin90=VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC Dma.Request7=USART2_TX Dma.SAI1_A.1.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT PE7.Signal=FMC_D4_DA4 PD6.Signal=SAI1_SD_A Dma.Request0=SPI2_TX PE2.GPIO_Label=CS_SCK -Mcu.Pin84=PE0 -Mcu.Pin85=PE1 -Mcu.Pin82=PB5 -Mcu.Pin83=PB6 -Mcu.Pin88=VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC +PA12.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +Mcu.Pin84=PB5 +Mcu.Pin85=PB6 +Mcu.Pin82=PB3 (JTDO/TRACESWO) +Mcu.Pin83=PB4 (NJTRST) +Mcu.Pin88=VP_FREERTOS_VS_CMSIS_V1 PA3.Signal=USART2_RX -Mcu.Pin89=VP_SYS_VS_Systick -Mcu.Pin86=VP_FREERTOS_VS_CMSIS_V1 -Mcu.Pin87=VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC +Mcu.Pin89=VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC +Mcu.Pin86=PE0 +Mcu.Pin87=PE1 SH.FMC_A3.ConfNb=1 PB3\ (JTDO/TRACESWO).GPIO_Label=ENC1_CH2 RCC.I2SFreq_Value=96000000 -USB_HOST.IPParameters=USBH_HandleTypeDef-ALL_Classes_HS,VirtualModeHS,USBH_MAX_NUM_CONFIGURATION-ALL_Classes_HS +USB_HOST.IPParameters=USBH_HandleTypeDef-ALL_Classes_HS,VirtualModeHS Dma.UART5_RX.4.SyncEnable=DISABLE Dma.UART5_TX.5.Mode=DMA_NORMAL SH.S_TIM2_CH1.0=TIM2_CH1,Encoder_Interface @@ -434,7 +446,7 @@ SPI2.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,DataSize,VirtualType, PE2.GPIOParameters=GPIO_Label PG10.GPIOParameters=GPIO_Label RCC.USBFreq_Value=48000000 -PF9.GPIO_Label=Flash_MOSI +PF9.GPIO_Label=FLASH_MOSI PA1.Signal=SharedAnalog_PA1 PA7.GPIO_PuPd=GPIO_PULLUP Dma.USART2_TX.7.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT @@ -497,6 +509,7 @@ Dma.UART5_TX.5.Direction=DMA_MEMORY_TO_PERIPH PB12.Signal=UART5_RX USB_HOST0.BSP.instance=PC9 PB4\ (NJTRST).Signal=GPXTI4 +PA11.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH USB_OTG_HS.VirtualMode-Host_FS=Host_FS SH.FMC_D7_DA7.0=FMC_D7,sd-16b-d1 Dma.USART2_RX.6.RequestNumber=1 @@ -530,8 +543,8 @@ PD6.GPIO_Label=CS_SDIN Dma.SAI1_B.2.Mode=DMA_CIRCULAR Dma.SPI2_TX.0.Instance=DMA1_Stream4 PinOutPanel.RotationAngle=0 +PF6.GPIO_Label=FLASH_nCS PE6.GPIO_Label=CS_SDA -PF6.GPIO_Label=Flash_CS RCC.MCO1PinFreq_Value=16000000 RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK RCC.AHB4Freq_Value=240000000 @@ -543,7 +556,7 @@ PA14\ (JTCK/SWCLK).Signal=DEBUG_JTCK-SWCLK Dma.SPI2_TX.0.SignalID=NONE PE2.Mode=TX_Only_Simplex_Unidirect_Master Dma.SAI1_B.2.SyncEnable=DISABLE -TIM2.IPParameters=EncoderMode,Period +TIM2.IPParameters=EncoderMode,Period,IC1Filter,IC2Filter PD4.Signal=GPIO_Output SH.FMC_D10_DA10.ConfNb=1 USB_HOST0.BSP.component= @@ -552,6 +565,7 @@ RCC.DIVQ3Freq_Value=50390625 Dma.USART2_RX.6.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber RCC.SAI2Freq_Value=50000000 PE5.Signal=SAI1_SCK_A +PF10.GPIO_Label=FLASH_HOLD PB13.Locked=true Dma.SAI1_A.1.MemInc=DMA_MINC_ENABLE PD2.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING @@ -582,6 +596,7 @@ PF8.GPIOParameters=GPIO_Label SH.GPXTI11.0=GPIO_EXTI11 Dma.SAI1_A.1.Direction=DMA_MEMORY_TO_PERIPH RCC.DFSDMFreq_Value=120000000 +PB14.GPIOParameters=GPIO_Speed SH.FMC_A1.0=FMC_A1,12b-sda1 SH.GPXTI14.ConfNb=1 Dma.SPI2_TX.0.PeriphInc=DMA_PINC_DISABLE @@ -615,6 +630,7 @@ Dma.USART2_RX.6.SyncSignalID=NONE PD2.GPIO_PuPd=GPIO_PULLUP VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC.Mode=SAI_A_BASIC ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,master,ContinuousConvMode,ClockPrescaler,Resolution,Overrun,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,OffsetNumber-1\#ChannelRegularConversion,NbrOfConversion,EOCSelection,ConversionDataManagement +TIM2.IC1Filter=8 PG9.Locked=true PG9.Signal=GPIO_Output USB_HOST.USBH_HandleTypeDef-ALL_Classes_HS=hUsbHostHS @@ -641,6 +657,7 @@ Dma.SAI1_A.1.Polarity=HAL_DMAMUX_REQ_GEN_RISING RCC.USART234578Freq_Value=120000000 FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_3 RCC.SPI123Freq_Value=48000000 +PB14.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH SH.FMC_D15_DA15.0=FMC_D15,sd-16b-d1 Dma.SAI1_B.2.PeriphDataAlignment=DMA_PDATAALIGN_WORD PC3_C.GPIOParameters=GPIO_Label @@ -660,7 +677,7 @@ PC11.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING PE8.Signal=FMC_D5_DA5 RCC.RNGFreq_Value=48000000 RCC.EthernetFreq_Value=168000000 -TIM3.IPParameters=EncoderMode,Period +TIM3.IPParameters=EncoderMode,Period,IC1Filter,IC2Filter Dma.USART2_TX.7.Direction=DMA_MEMORY_TO_PERIPH Dma.SAI1_A.1.EventEnable=DISABLE PG14.GPIO_Label=ENC1_SW @@ -675,7 +692,6 @@ SH.FMC_D7_DA7.ConfNb=1 PA4.Signal=COMP_DAC11_group ADC1.SamplingTime-1\#ChannelRegularConversion=ADC_SAMPLETIME_64CYCLES_5 PB5.Signal=FMC_SDCKE1 -USB_HOST.USBH_MAX_NUM_CONFIGURATION-ALL_Classes_HS=5 SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX SH.FMC_A10.ConfNb=1 Dma.SAI1_A.1.SyncRequestNumber=1 @@ -721,13 +737,14 @@ PC10.Signal=GPXTI10 SPI4.Direction=SPI_DIRECTION_2LINES_TXONLY SH.FMC_NBL0.0=FMC_NBL0,Sd2ByteEnable1 TIM3.EncoderMode=TIM_ENCODERMODE_TI12 -ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI2_Init-SPI2-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-MX_SPI5_Init-SPI5-false-HAL-true,9-MX_TIM2_Init-TIM2-false-HAL-true,10-MX_TIM3_Init-TIM3-false-HAL-true,11-MX_TIM6_Init-TIM6-false-HAL-true,12-MX_USART2_UART_Init-USART2-false-HAL-true,13-MX_ADC1_Init-ADC1-false-HAL-true,14-MX_DAC1_Init-DAC1-false-HAL-true,15-MX_UART5_Init-UART5-false-HAL-true,16-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-false-HAL-true,17-MX_USB_HOST_Init-USB_HOST-false-HAL-false,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI2_Init-SPI2-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-MX_SPI5_Init-SPI5-false-HAL-true,9-MX_TIM2_Init-TIM2-false-HAL-true,10-MX_TIM3_Init-TIM3-false-HAL-true,11-MX_TIM6_Init-TIM6-false-HAL-true,12-MX_USART2_UART_Init-USART2-false-HAL-true,13-MX_ADC1_Init-ADC1-false-HAL-true,14-MX_DAC1_Init-DAC1-false-HAL-true,15-MX_UART5_Init-UART5-false-HAL-true,16-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-false-HAL-true,17-MX_USB_OTG_HS_HCD_Init-USB_OTG_HS-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true SH.FMC_D6_DA6.0=FMC_D6,sd-16b-d1 PC9.Locked=true RCC.PLLI2SRCLKFreq_Value=96000000 TIM2.EncoderMode=TIM_ENCODERMODE_TI12 RCC.USART2Freq_Value=42000000 Dma.SPI2_TX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +PC13.GPIO_Label=FLASH_WP Dma.ADC1.3.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD PB11.Signal=GPIO_Output NVIC.DMA1_Stream4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true @@ -756,10 +773,10 @@ Dma.ADC1.3.PeriphInc=DMA_PINC_DISABLE SH.SharedAnalog_PA1.ConfNb=2 PF12.Signal=FMC_A6 FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 -Mcu.Pin6=PF1 -Mcu.Pin7=PF2 -Mcu.Pin8=PF3 -Mcu.Pin9=PF4 +Mcu.Pin6=PF0 +Mcu.Pin7=PF1 +Mcu.Pin8=PF2 +Mcu.Pin9=PF3 RCC.VCOSAIOutputFreq_Value=100000000 Dma.SPI2_TX.0.Mode=DMA_NORMAL PC2_C.Signal=GPIO_Output @@ -772,14 +789,14 @@ GPIO.groupedBy=Group By Peripherals Mcu.Pin2=PE4 Mcu.Pin3=PE5 Mcu.Pin4=PE6 -Mcu.Pin5=PF0 +Mcu.Pin5=PC13 Dma.USART2_TX.7.SyncEnable=DISABLE SH.FMC_D8_DA8.0=FMC_D8,sd-16b-d1 USART2.VirtualMode-Asynchronous=VM_ASYNC FMC.RPDelay1=2 SH.FMC_D2_DA2.0=FMC_D2,sd-16b-d1 PE13.Signal=FMC_D10_DA10 -PF7.GPIO_Label=Flash_CLK +PF7.GPIO_Label=FLASH_CLK Dma.UART5_TX.5.PeriphInc=DMA_PINC_DISABLE File.Version=6 PA10.GPIO_Label=USB_HOST_PWR_FAULT @@ -802,7 +819,7 @@ PC2_C.Locked=true ProjectManager.ProjectName=Genius RCC.APB3Freq_Value=120000000 USB_HOST0.BSP.i2caddr=0 -SPI5.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128 +SPI5.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_4 SH.FMC_D0_DA0.0=FMC_D0,sd-16b-d1 RCC.D1PPRE=RCC_APB3_DIV2 RCC.LSI_VALUE=32000 @@ -880,13 +897,17 @@ Dma.UART5_TX.5.SyncRequestNumber=1 Dma.USART2_TX.7.RequestNumber=1 SH.FMC_D13_DA13.ConfNb=1 PD4.GPIO_Label=TR_OUT_A +PC13.GPIOParameters=GPIO_Label Dma.SPI2_TX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +PF10.Signal=GPIO_Output Dma.SAI1_B.2.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +PB15.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH PF15.Signal=FMC_A9 SPI4.CalculateBaudRate=3.75 MBits/s Dma.SAI1_B.2.Priority=DMA_PRIORITY_HIGH Dma.UART5_RX.4.Instance=DMA1_Stream1 PE6.Signal=SPI4_MOSI +PB15.GPIOParameters=GPIO_Speed Mcu.Name=STM32H743ZGTx Dma.SAI1_B.2.Direction=DMA_PERIPH_TO_MEMORY PA2.Signal=USART2_TX diff --git a/Genius/Inc/hardware.h b/Genius/Inc/hardware.h index 535a2547..2292c149 100644 --- a/Genius/Inc/hardware.h +++ b/Genius/Inc/hardware.h @@ -5,7 +5,8 @@ #define HARDWARE_ID GENIUS_HARDWARE #define HARDWARE_VERSION "Genius" -/* #define USE_SPI_FLASH */ +#define USE_SPI_FLASH +#define SPI_FLASH_HSPI hspi5 /* #define NO_EXTERNAL_RAM */ /* #define NO_CCM_RAM */ diff --git a/Genius/Inc/main.h b/Genius/Inc/main.h index c72410f0..f3a5e5a3 100644 --- a/Genius/Inc/main.h +++ b/Genius/Inc/main.h @@ -68,14 +68,18 @@ void Error_Handler(void); #define CS_SCKE5_GPIO_Port GPIOE #define CS_SDA_Pin GPIO_PIN_6 #define CS_SDA_GPIO_Port GPIOE -#define Flash_CS_Pin GPIO_PIN_6 -#define Flash_CS_GPIO_Port GPIOF -#define Flash_CLK_Pin GPIO_PIN_7 -#define Flash_CLK_GPIO_Port GPIOF -#define Flash_MISO_Pin GPIO_PIN_8 -#define Flash_MISO_GPIO_Port GPIOF -#define Flash_MOSI_Pin GPIO_PIN_9 -#define Flash_MOSI_GPIO_Port GPIOF +#define FLASH_WP_Pin GPIO_PIN_13 +#define FLASH_WP_GPIO_Port GPIOC +#define FLASH_nCS_Pin GPIO_PIN_6 +#define FLASH_nCS_GPIO_Port GPIOF +#define FLASH_CLK_Pin GPIO_PIN_7 +#define FLASH_CLK_GPIO_Port GPIOF +#define FLASH_MISO_Pin GPIO_PIN_8 +#define FLASH_MISO_GPIO_Port GPIOF +#define FLASH_MOSI_Pin GPIO_PIN_9 +#define FLASH_MOSI_GPIO_Port GPIOF +#define FLASH_HOLD_Pin GPIO_PIN_10 +#define FLASH_HOLD_GPIO_Port GPIOF #define OLED_MOSI_Pin GPIO_PIN_1 #define OLED_MOSI_GPIO_Port GPIOC #define OLED_RST_Pin GPIO_PIN_2 diff --git a/Genius/Src/main.c b/Genius/Src/main.c index 9fe37656..3cd5ca52 100644 --- a/Genius/Src/main.c +++ b/Genius/Src/main.c @@ -595,7 +595,7 @@ static void MX_SPI5_Init(void) hspi5.Init.CLKPolarity = SPI_POLARITY_LOW; hspi5.Init.CLKPhase = SPI_PHASE_1EDGE; hspi5.Init.NSS = SPI_NSS_SOFT; - hspi5.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_128; + hspi5.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4; hspi5.Init.FirstBit = SPI_FIRSTBIT_MSB; hspi5.Init.TIMode = SPI_TIMODE_DISABLE; hspi5.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; @@ -648,11 +648,11 @@ static void MX_TIM2_Init(void) sConfig.IC1Polarity = TIM_ICPOLARITY_RISING; sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI; sConfig.IC1Prescaler = TIM_ICPSC_DIV1; - sConfig.IC1Filter = 0; + sConfig.IC1Filter = 8; sConfig.IC2Polarity = TIM_ICPOLARITY_RISING; sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI; sConfig.IC2Prescaler = TIM_ICPSC_DIV1; - sConfig.IC2Filter = 0; + sConfig.IC2Filter = 8; if (HAL_TIM_Encoder_Init(&htim2, &sConfig) != HAL_OK) { Error_Handler(); @@ -697,11 +697,11 @@ static void MX_TIM3_Init(void) sConfig.IC1Polarity = TIM_ICPOLARITY_RISING; sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI; sConfig.IC1Prescaler = TIM_ICPSC_DIV1; - sConfig.IC1Filter = 0; + sConfig.IC1Filter = 8; sConfig.IC2Polarity = TIM_ICPOLARITY_RISING; sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI; sConfig.IC2Prescaler = TIM_ICPSC_DIV1; - sConfig.IC2Filter = 0; + sConfig.IC2Filter = 8; if (HAL_TIM_Encoder_Init(&htim3, &sConfig) != HAL_OK) { Error_Handler(); @@ -997,10 +997,10 @@ static void MX_GPIO_Init(void) __HAL_RCC_GPIOD_CLK_ENABLE(); /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(Flash_CS_GPIO_Port, Flash_CS_Pin, GPIO_PIN_RESET); + HAL_GPIO_WritePin(GPIOC, FLASH_WP_Pin|OLED_RST_Pin|OLED_DC_Pin|USB_HOST_PWR_EN_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOC, OLED_RST_Pin|OLED_DC_Pin|USB_HOST_PWR_EN_Pin, GPIO_PIN_RESET); + HAL_GPIO_WritePin(GPIOF, FLASH_nCS_Pin|FLASH_HOLD_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(OLED_CS_GPIO_Port, OLED_CS_Pin, GPIO_PIN_RESET); @@ -1011,33 +1011,27 @@ static void MX_GPIO_Init(void) /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOG, CS_CS_Pin|CS_RST_Pin, GPIO_PIN_RESET); - /*Configure GPIO pins : PC13 PC14 PC15 PC4 - PC5 PC6 PC7 PC8 */ - GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_4 - |GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8; - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /*Configure GPIO pin : Flash_CS_Pin */ - GPIO_InitStruct.Pin = Flash_CS_Pin; + /*Configure GPIO pins : FLASH_WP_Pin OLED_RST_Pin OLED_DC_Pin USB_HOST_PWR_EN_Pin */ + GPIO_InitStruct.Pin = FLASH_WP_Pin|OLED_RST_Pin|OLED_DC_Pin|USB_HOST_PWR_EN_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(Flash_CS_GPIO_Port, &GPIO_InitStruct); + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - /*Configure GPIO pin : PF10 */ - GPIO_InitStruct.Pin = GPIO_PIN_10; + /*Configure GPIO pins : PC14 PC15 PC4 PC5 + PC6 PC7 PC8 */ + GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_4|GPIO_PIN_5 + |GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - /*Configure GPIO pins : OLED_RST_Pin OLED_DC_Pin USB_HOST_PWR_EN_Pin */ - GPIO_InitStruct.Pin = OLED_RST_Pin|OLED_DC_Pin|USB_HOST_PWR_EN_Pin; + /*Configure GPIO pins : FLASH_nCS_Pin FLASH_HOLD_Pin */ + GPIO_InitStruct.Pin = FLASH_nCS_Pin|FLASH_HOLD_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); /*Configure GPIO pins : PB0 PB1 PB2 PB7 PB8 PB9 */ diff --git a/Genius/Src/stm32h7xx_hal_msp.c b/Genius/Src/stm32h7xx_hal_msp.c index 289abc73..eaead0c5 100644 --- a/Genius/Src/stm32h7xx_hal_msp.c +++ b/Genius/Src/stm32h7xx_hal_msp.c @@ -375,7 +375,7 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) PF8 ------> SPI5_MISO PF9 ------> SPI5_MOSI */ - GPIO_InitStruct.Pin = Flash_CLK_Pin|Flash_MISO_Pin|Flash_MOSI_Pin; + GPIO_InitStruct.Pin = FLASH_CLK_Pin|FLASH_MISO_Pin|FLASH_MOSI_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; @@ -453,7 +453,7 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) PF8 ------> SPI5_MISO PF9 ------> SPI5_MOSI */ - HAL_GPIO_DeInit(GPIOF, Flash_CLK_Pin|Flash_MISO_Pin|Flash_MOSI_Pin); + HAL_GPIO_DeInit(GPIOF, FLASH_CLK_Pin|FLASH_MISO_Pin|FLASH_MOSI_Pin); /* USER CODE BEGIN SPI5_MspDeInit 1 */ @@ -893,7 +893,7 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd) GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG1_FS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); From d7d775714a59905dc6ace0c7b9404d8a4376b49d Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 18 Oct 2021 15:39:25 +0200 Subject: [PATCH 115/286] removed redundant debug code --- Source/errorhandlers.c | 168 ----------------------------------------- 1 file changed, 168 deletions(-) diff --git a/Source/errorhandlers.c b/Source/errorhandlers.c index 8c532f78..6d8400f8 100644 --- a/Source/errorhandlers.c +++ b/Source/errorhandlers.c @@ -51,44 +51,16 @@ void NMI_Handler(void){ void MemManage_Handler(void){ errorcode = MEM_ERROR; -#ifdef DEBUG - volatile unsigned int hfsr = SCB->MMFAR; - volatile unsigned int cfsr = SCB->CFSR; - volatile unsigned int msp = __get_MSP(); - volatile unsigned int psp = __get_PSP(); - (void)hfsr; - (void)cfsr; - (void)msp; - (void)psp; -#endif assert_failed(0, 0); } void BusFault_Handler(void){ errorcode = BUS_ERROR; -#ifdef DEBUG - volatile unsigned int hfsr = SCB->BFAR; - volatile unsigned int cfsr = SCB->CFSR; - volatile unsigned int msp = __get_MSP(); - volatile unsigned int psp = __get_PSP(); - (void)hfsr; - (void)cfsr; - (void)msp; - (void)psp; -#endif assert_failed(0, 0); } void UsageFault_Handler(void){ errorcode = USAGE_ERROR; -#ifdef DEBUG - volatile unsigned int cfsr = SCB->CFSR; - volatile unsigned int msp = __get_MSP(); - volatile unsigned int psp = __get_PSP(); - (void)cfsr; - (void)msp; - (void)psp; -#endif assert_failed(0, 0); } @@ -96,107 +68,8 @@ void DebugMon_Handler(void){ for(;;); } -/** - * @see http://www.freertos.org/Debugging-Hard-Faults-On-Cortex-M-Microcontrollers.html - */ -#if 0 -void prvGetRegistersFromStack(uint32_t *pulFaultStackAddress) { -/* These are volatile to try and prevent the compiler/linker optimising them -away as the variables never actually get used. If the debugger won't show the -values of the variables, make them global my moving their declaration outside -of this function. */ - volatile uint32_t r0; - volatile uint32_t r1; - volatile uint32_t r2; - volatile uint32_t r3; - volatile uint32_t r12; - volatile uint32_t lr; /* Link register. */ - volatile uint32_t pc; /* Program counter. */ - volatile uint32_t psr;/* Program status register. */ - - r0 = pulFaultStackAddress[0]; - r1 = pulFaultStackAddress[1]; - r2 = pulFaultStackAddress[2]; - r3 = pulFaultStackAddress[3]; - - r12 = pulFaultStackAddress[4]; - lr = pulFaultStackAddress[5]; - pc = pulFaultStackAddress[6]; - psr = pulFaultStackAddress[7]; - - /* When the following line is hit, the variables contain the register values. */ - for (;;); -} - -The fault handler implementation calls a function called - prvGetRegistersFromStack(). -static void HardFault_Handler(void) { - __asm volatile ( - " tst lr, #4 \n" - " ite eq \n" - " mrseq r0, msp \n" - " mrsne r0, psp \n" - " ldr r1, [r0, #24] \n" - " ldr r2, handler2_address_const \n" - " bx r2 \n" - " handler2_address_const: .word prvGetRegistersFromStack \n" - ); -} -#endif - -/* - HardFault_Handler from http://blog.frankvh.com/2011/12/07/cortex-m3-m4-hard-fault-handler/ -*/ -#if 0 -void HardFault_Handler(void) __attribute__((naked)); - -void HardFault_Handler(void) { -/* HardFault_Handler: */ - __asm("TST LR, #4"); - __asm("ITE EQ"); - __asm("MRSEQ R0, MSP"); - __asm("MRSNE R0, PSP"); - __asm("B hard_fault_handler_c"); -} - -void hard_fault_handler_c (unsigned int * hardfault_args){ - volatile unsigned int stacked_r0; - volatile unsigned int stacked_r1; - volatile unsigned int stacked_r2; - volatile unsigned int stacked_r3; - volatile unsigned int stacked_r12; - volatile unsigned int stacked_lr; - volatile unsigned int stacked_pc; - volatile unsigned int stacked_psr; - - stacked_r0 = ((unsigned long) hardfault_args[0]); - stacked_r1 = ((unsigned long) hardfault_args[1]); - stacked_r2 = ((unsigned long) hardfault_args[2]); - stacked_r3 = ((unsigned long) hardfault_args[3]); - - stacked_r12 = ((unsigned long) hardfault_args[4]); - stacked_lr = ((unsigned long) hardfault_args[5]); - stacked_pc = ((unsigned long) hardfault_args[6]); - stacked_psr = ((unsigned long) hardfault_args[7]); -} -#endif - -/* -see -https://blog.feabhas.com/2013/02/developing-a-generic-hard-fault-handler-for-arm-cortex-m3cortex-m4/ -*/ void HardFault_Handler(void){ errorcode = HARDFAULT_ERROR; -#ifdef DEBUG - volatile unsigned int hfsr = SCB->HFSR; - volatile unsigned int cfsr = SCB->CFSR; - volatile unsigned int msp = __get_MSP(); - volatile unsigned int psp = __get_PSP(); - (void)hfsr; - (void)cfsr; - (void)msp; - (void)psp; -#endif assert_failed(0, 0); } @@ -221,44 +94,3 @@ void PVD_IRQHandler(void) { void FPU_IRQHandler(void){ assert_failed(0, 0); } - -/* - -void UART4_IRQHandler(void){ - assert_failed(0, 0); -} - -void UART5_IRQHandler(void){ - assert_failed(0, 0); -} - -void USART6_IRQHandler(void){ - assert_failed(0, 0); -} - -void USART3_IRQHandler(void){ - assert_failed(0, 0); -} -void USART2_IRQHandler(void){ - assert_failed(0, 0); -} -void USART1_IRQHandler(void){ - assert_failed(0, 0); -} - -void FLASH_IRQHandler(void){ - assert_failed(0, 0); -} - -void TIM8_UP_TIM13_IRQHandler(void){ - assert_failed(0, 0); -} - -void TIM8_TRG_COM_TIM14_IRQHandler(void){ - assert_failed(0, 0); -} - -void TIM8_CC_IRQHandler(void){ - assert_failed(0, 0); -} -*/ From fd43010d0d384228b5a4411f498189af76126c5b Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 18 Oct 2021 15:39:50 +0200 Subject: [PATCH 116/286] allow flash spi config override --- Source/device.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/device.h b/Source/device.h index aca8ddca..06f30f5f 100644 --- a/Source/device.h +++ b/Source/device.h @@ -8,7 +8,9 @@ #ifdef USE_SPI_FLASH #define MAX_SPI_FLASH_HEADERS 32 #define FLASH_DEFAULT_FLAGS RESOURCE_PORT_MAPPED +#ifndef SPI_FLASH_HSPI #define SPI_FLASH_HSPI hspi1 +#endif #define EXTERNAL_STORAGE_SIZE (8*1024*1024) #else #define MAX_SPI_FLASH_HEADERS 0 From e69af0a0055f87b73211407d11d343e22a1a2cca Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 18 Oct 2021 16:00:23 +0200 Subject: [PATCH 117/286] changed usbh NotifyURBChange_Callback --- Lich/Src/usbh_conf.c | 16 +++++++--------- Magus/Src/usbh_conf.c | 16 +++++++--------- Magus3/Src/usbh_conf.c | 16 +++++++--------- Mussol/Src/usbh_conf.c | 14 +++++++------- Noctua/Src/usbh_conf.c | 14 +++++++------- Source/usbh_midi.cpp | 21 ++++++--------------- Witch/Src/usbh_conf.c | 24 ++++++++---------------- Wizard/usbd-fs/usbh_conf.c | 16 +++++++--------- Wizard/usbd-hs/usbh_conf.c | 16 +++++++--------- 9 files changed, 63 insertions(+), 90 deletions(-) diff --git a/Lich/Src/usbh_conf.c b/Lich/Src/usbh_conf.c index 622a3a73..238743bf 100644 --- a/Lich/Src/usbh_conf.c +++ b/Lich/Src/usbh_conf.c @@ -39,7 +39,6 @@ HCD_HandleTypeDef hhcd_USB_OTG_HS; void Error_Handler(void); /* USER CODE BEGIN 0 */ -void USBH_MIDI_NotifyURBChange(USBH_HandleTypeDef *phost, uint8_t chnum, HCD_URBStateTypeDef urb_state); /* USER CODE END 0 */ @@ -155,14 +154,13 @@ void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd) * @param urb_state: state * @retval None */ -void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) -{ - USBH_MIDI_NotifyURBChange(hhcd->pData, chnum, urb_state); -/* To be used with OS to sync URB state with the global state machine */ -#if (USBH_USE_OS == 1) - USBH_LL_NotifyURBChange(hhcd->pData); -#endif -} +/* void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) */ +/* { */ +/* /\* To be used with OS to sync URB state with the global state machine *\/ */ +/* #if (USBH_USE_OS == 1) */ +/* USBH_LL_NotifyURBChange(hhcd->pData); */ +/* #endif */ +/* } */ /** * @brief Port Port Enabled callback. * @param hhcd: HCD handle diff --git a/Magus/Src/usbh_conf.c b/Magus/Src/usbh_conf.c index 3c105db3..1b95f814 100644 --- a/Magus/Src/usbh_conf.c +++ b/Magus/Src/usbh_conf.c @@ -48,7 +48,6 @@ void Error_Handler(void); /* Private function prototypes -----------------------------------------------*/ USBH_StatusTypeDef USBH_Get_USB_Status(HAL_StatusTypeDef hal_status); -void USBH_MIDI_NotifyURBChange(USBH_HandleTypeDef *phost, uint8_t chnum, HCD_URBStateTypeDef urb_state); /* USER CODE END PFP */ @@ -167,14 +166,13 @@ void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd) * @param urb_state: state * @retval None */ -void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) -{ - USBH_MIDI_NotifyURBChange(hhcd->pData, chnum, urb_state); - /* To be used with OS to sync URB state with the global state machine */ -#if (USBH_USE_OS == 1) - USBH_LL_NotifyURBChange(hhcd->pData); -#endif -} +/* void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) */ +/* { */ +/* /\* To be used with OS to sync URB state with the global state machine *\/ */ +/* #if (USBH_USE_OS == 1) */ +/* USBH_LL_NotifyURBChange(hhcd->pData); */ +/* #endif */ +/* } */ /** * @brief Port Port Enabled callback. * @param hhcd: HCD handle diff --git a/Magus3/Src/usbh_conf.c b/Magus3/Src/usbh_conf.c index dffac0ea..3e039c1e 100644 --- a/Magus3/Src/usbh_conf.c +++ b/Magus3/Src/usbh_conf.c @@ -46,7 +46,6 @@ void Error_Handler(void); /* Private function prototypes -----------------------------------------------*/ USBH_StatusTypeDef USBH_Get_USB_Status(HAL_StatusTypeDef hal_status); -void USBH_MIDI_NotifyURBChange(USBH_HandleTypeDef *phost, uint8_t chnum, HCD_URBStateTypeDef urb_state); /* USER CODE END PFP */ @@ -175,14 +174,13 @@ void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd) * @param urb_state: state * @retval None */ -void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) -{ - USBH_MIDI_NotifyURBChange(hhcd->pData, chnum, urb_state); - /* To be used with OS to sync URB state with the global state machine */ -#if (USBH_USE_OS == 1) - USBH_LL_NotifyURBChange(hhcd->pData); -#endif -} +/* void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) */ +/* { */ +/* /\* To be used with OS to sync URB state with the global state machine *\/ */ +/* #if (USBH_USE_OS == 1) */ +/* USBH_LL_NotifyURBChange(hhcd->pData); */ +/* #endif */ +/* } */ /** * @brief Port Port Enabled callback. * @param hhcd: HCD handle diff --git a/Mussol/Src/usbh_conf.c b/Mussol/Src/usbh_conf.c index 59f3b20a..55fca072 100644 --- a/Mussol/Src/usbh_conf.c +++ b/Mussol/Src/usbh_conf.c @@ -154,13 +154,13 @@ void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd) * @param urb_state: state * @retval None */ -void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) -{ - /* To be used with OS to sync URB state with the global state machine */ -#if (USBH_USE_OS == 1) - USBH_LL_NotifyURBChange(hhcd->pData); -#endif -} +/* void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) */ +/* { */ +/* /\* To be used with OS to sync URB state with the global state machine *\/ */ +/* #if (USBH_USE_OS == 1) */ +/* USBH_LL_NotifyURBChange(hhcd->pData); */ +/* #endif */ +/* } */ /** * @brief Port Port Enabled callback. * @param hhcd: HCD handle diff --git a/Noctua/Src/usbh_conf.c b/Noctua/Src/usbh_conf.c index b5aa0c15..2b161533 100644 --- a/Noctua/Src/usbh_conf.c +++ b/Noctua/Src/usbh_conf.c @@ -149,13 +149,13 @@ void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd) * @param urb_state: state * @retval None */ -void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) -{ - /* To be used with OS to sync URB state with the global state machine */ -#if (USBH_USE_OS == 1) - USBH_LL_NotifyURBChange(hhcd->pData); -#endif -} +/* void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) */ +/* { */ +/* /\* To be used with OS to sync URB state with the global state machine *\/ */ +/* #if (USBH_USE_OS == 1) */ +/* USBH_LL_NotifyURBChange(hhcd->pData); */ +/* #endif */ +/* } */ /** * @brief Port Port Enabled callback. * @param hhcd: HCD handle diff --git a/Source/usbh_midi.cpp b/Source/usbh_midi.cpp index 820e6dbe..55dc0e6a 100644 --- a/Source/usbh_midi.cpp +++ b/Source/usbh_midi.cpp @@ -29,8 +29,6 @@ extern "C" { }; void usbh_midi_push(); - - void USBH_MIDI_NotifyURBChange(USBH_HandleTypeDef *phost, uint8_t chnum, HCD_URBStateTypeDef urb_state); } static SerialBuffer rxbuffer; @@ -166,21 +164,14 @@ USBH_StatusTypeDef USBH_MIDI_Stop(USBH_HandleTypeDef *phost){ extern "C"{ void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state){ - // USBH_MIDI_NotifyURBChange((USBH_HandleTypeDef*)hhcd->pData, chnum, urb_state); - // USBH_HandleTypeDef* phost = (USBH_HandleTypeDef*)hhcd->pData; -// } -// } -// void USBH_MIDI_NotifyURBChange(USBH_HandleTypeDef *phost, uint8_t chnum, HCD_URBStateTypeDef urb_state){ - MIDI_HandleTypeDef *MIDI_Handle = &staticMidiHandle; - if(urb_state == URB_DONE && chnum == MIDI_Handle->InPipe && - MIDI_Handle->state == MIDI_TRANSFER_DATA){ - // size_t len = USBH_LL_GetLastXferSize(phost, MIDI_Handle->InPipe); - // USBH_MIDI_ReceiveCallback(phost, MIDI_Handle->pRxData, len); - size_t len = USBH_LL_GetLastXferSize((USBH_HandleTypeDef*)hhcd->pData, MIDI_Handle->InPipe); - USBH_MIDI_ReceiveCallback((USBH_HandleTypeDef*)hhcd->pData, MIDI_Handle->pRxData, len); + MIDI_HandleTypeDef *MIDI_Handle = &staticMidiHandle; + if(urb_state == URB_DONE && chnum == MIDI_Handle->InPipe && + MIDI_Handle->state == MIDI_TRANSFER_DATA){ + size_t len = USBH_LL_GetLastXferSize((USBH_HandleTypeDef*)hhcd->pData, MIDI_Handle->InPipe); + USBH_MIDI_ReceiveCallback((USBH_HandleTypeDef*)hhcd->pData, MIDI_Handle->pRxData, len); + } } } -} /** * @brief USBH_MIDI_Process diff --git a/Witch/Src/usbh_conf.c b/Witch/Src/usbh_conf.c index 06cfc8b1..0981749f 100644 --- a/Witch/Src/usbh_conf.c +++ b/Witch/Src/usbh_conf.c @@ -39,7 +39,6 @@ HCD_HandleTypeDef hhcd_USB_OTG_HS; void Error_Handler(void); /* USER CODE BEGIN 0 */ -void USBH_MIDI_NotifyURBChange(USBH_HandleTypeDef *phost, uint8_t chnum, HCD_URBStateTypeDef urb_state); /* USER CODE END 0 */ @@ -155,14 +154,13 @@ void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd) * @param urb_state: state * @retval None */ -void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) -{ - USBH_MIDI_NotifyURBChange(hhcd->pData, chnum, urb_state); - /* To be used with OS to sync URB state with the global state machine */ -#if (USBH_USE_OS == 1) - USBH_LL_NotifyURBChange(hhcd->pData); -#endif -} +/* void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) */ +/* { */ +/* /\* To be used with OS to sync URB state with the global state machine *\/ */ +/* #if (USBH_USE_OS == 1) */ +/* USBH_LL_NotifyURBChange(hhcd->pData); */ +/* #endif */ +/* } */ /** * @brief Port Port Enabled callback. * @param hhcd: HCD handle @@ -450,12 +448,6 @@ USBH_URBStateTypeDef USBH_LL_GetURBState(USBH_HandleTypeDef *phost, uint8_t pipe */ USBH_StatusTypeDef USBH_LL_DriverVBUS(USBH_HandleTypeDef *phost, uint8_t state) { - - /* USER CODE BEGIN 0 */ -void USBH_MIDI_NotifyURBChange(USBH_HandleTypeDef *phost, uint8_t chnum, HCD_URBStateTypeDef urb_state); - - /* USER CODE END 0*/ - if (phost->id == HOST_HS) { if (state == 0) @@ -475,7 +467,7 @@ void USBH_MIDI_NotifyURBChange(USBH_HandleTypeDef *phost, uint8_t chnum, HCD_URB /* USER CODE END DRIVE_LOW_CHARGE_FOR_HS */ } } - HAL_Delay(200); + /* HAL_Delay(200); */ return USBH_OK; } diff --git a/Wizard/usbd-fs/usbh_conf.c b/Wizard/usbd-fs/usbh_conf.c index e25ce68c..5f98c60b 100644 --- a/Wizard/usbd-fs/usbh_conf.c +++ b/Wizard/usbd-fs/usbh_conf.c @@ -46,7 +46,6 @@ void Error_Handler(void); /* Private function prototypes -----------------------------------------------*/ USBH_StatusTypeDef USBH_Get_USB_Status(HAL_StatusTypeDef hal_status); -void USBH_MIDI_NotifyURBChange(USBH_HandleTypeDef *phost, uint8_t chnum, HCD_URBStateTypeDef urb_state); /* USER CODE END PFP */ @@ -156,14 +155,13 @@ void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd) * @param urb_state: state * @retval None */ -void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) -{ - USBH_MIDI_NotifyURBChange(hhcd->pData, chnum, urb_state); - /* To be used with OS to sync URB state with the global state machine */ -#if (USBH_USE_OS == 1) - USBH_LL_NotifyURBChange(hhcd->pData); -#endif -} +/* void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) */ +/* { */ +/* /\* To be used with OS to sync URB state with the global state machine *\/ */ +/* #if (USBH_USE_OS == 1) */ +/* USBH_LL_NotifyURBChange(hhcd->pData); */ +/* #endif */ +/* } */ /** * @brief Port Port Enabled callback. * @param hhcd: HCD handle diff --git a/Wizard/usbd-hs/usbh_conf.c b/Wizard/usbd-hs/usbh_conf.c index 4cf9fe87..8959765d 100644 --- a/Wizard/usbd-hs/usbh_conf.c +++ b/Wizard/usbd-hs/usbh_conf.c @@ -46,7 +46,6 @@ void Error_Handler(void); /* Private function prototypes -----------------------------------------------*/ USBH_StatusTypeDef USBH_Get_USB_Status(HAL_StatusTypeDef hal_status); -void USBH_MIDI_NotifyURBChange(USBH_HandleTypeDef *phost, uint8_t chnum, HCD_URBStateTypeDef urb_state); /* USER CODE END PFP */ @@ -156,14 +155,13 @@ void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd) * @param urb_state: state * @retval None */ -void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) -{ - USBH_MIDI_NotifyURBChange(hhcd->pData, chnum, urb_state); - /* To be used with OS to sync URB state with the global state machine */ -#if (USBH_USE_OS == 1) - USBH_LL_NotifyURBChange(hhcd->pData); -#endif -} +/* void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum, HCD_URBStateTypeDef urb_state) */ +/* { */ +/* /\* To be used with OS to sync URB state with the global state machine *\/ */ +/* #if (USBH_USE_OS == 1) */ +/* USBH_LL_NotifyURBChange(hhcd->pData); */ +/* #endif */ +/* } */ /** * @brief Port Port Enabled callback. * @param hhcd: HCD handle From 0d25687d2d783428c2190335119ff1c8eccd2ebd Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 18 Oct 2021 16:37:25 +0200 Subject: [PATCH 118/286] nor flash enabled --- Magus3/Inc/hardware.h | 10 ++++++---- Magus3/Inc/main.h | 4 ++-- Magus3/Magus3.ioc | 17 ++++++++++------- Magus3/Src/main.c | 6 +++--- Magus3/Src/stm32h7xx_hal_msp.c | 4 ++-- 5 files changed, 23 insertions(+), 18 deletions(-) diff --git a/Magus3/Inc/hardware.h b/Magus3/Inc/hardware.h index dc460e88..301e5ab7 100644 --- a/Magus3/Inc/hardware.h +++ b/Magus3/Inc/hardware.h @@ -5,12 +5,14 @@ #define HARDWARE_ID MAGUS_HARDWARE #define HARDWARE_VERSION "Magus3" +#define USE_SPI_FLASH + /* #define NO_EXTERNAL_RAM */ /* #define NO_CCM_RAM */ #define DMA_RAM __attribute__ ((section (".dmadata"))) #define USE_PLUS_RAM -#define USE_ICACHE -#define USE_DCACHE +/* #define USE_ICACHE */ +/* #define USE_DCACHE */ #define MAX_SYSEX_PROGRAM_SIZE (512*1024) @@ -37,8 +39,8 @@ #define ARM_CYCLES_PER_SAMPLE (480000000/AUDIO_SAMPLINGRATE) /* 480MHz / 48kHz */ #define USE_USBD_AUDIO -/* #define USE_USBD_AUDIO_TX // microphone */ -/* #define USE_USBD_AUDIO_RX // speaker */ +#define USE_USBD_AUDIO_TX // microphone +#define USE_USBD_AUDIO_RX // speaker #define USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS #define USBH_HANDLE hUsbHostHS diff --git a/Magus3/Inc/main.h b/Magus3/Inc/main.h index 518785df..a97c6ed8 100644 --- a/Magus3/Inc/main.h +++ b/Magus3/Inc/main.h @@ -132,8 +132,8 @@ void Error_Handler(void); #define FLASH_HOLD_GPIO_Port GPIOC #define FLASH_nCS_Pin GPIO_PIN_5 #define FLASH_nCS_GPIO_Port GPIOC -#define FLASH_nWP_Pin GPIO_PIN_0 -#define FLASH_nWP_GPIO_Port GPIOB +#define FLASH_WP_Pin GPIO_PIN_0 +#define FLASH_WP_GPIO_Port GPIOB #define TLC_GSCLK_Pin GPIO_PIN_1 #define TLC_GSCLK_GPIO_Port GPIOB #define ENC_CHGRDY_Pin GPIO_PIN_2 diff --git a/Magus3/Magus3.ioc b/Magus3/Magus3.ioc index 7db39f0f..bad39aee 100644 --- a/Magus3/Magus3.ioc +++ b/Magus3/Magus3.ioc @@ -23,8 +23,9 @@ RCC.CpuClockFreq_Value=480000000 SH.FMC_SDNWE.ConfNb=1 PG14.GPIOParameters=GPIO_Label SH.FMC_D5_DA5.0=FMC_D5,sd-16b-d1 -PB3\ (JTDO/TRACESWO).GPIOParameters=GPIO_Label +PB3\ (JTDO/TRACESWO).GPIOParameters=GPIO_Speed,GPIO_Label Dma.SPI5_TX.2.EventEnable=DISABLE +PB3\ (JTDO/TRACESWO).GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH PA2.GPIOParameters=GPIO_Speed,GPIO_Label SH.FMC_D9_DA9.0=FMC_D9,sd-16b-d1 RCC.LPTIM1Freq_Value=120000000 @@ -104,7 +105,7 @@ RCC.PLLSAIQCLKFreq_Value=50000000 RCC.VCO3OutputFreq_Value=100781250 SH.FMC_D3_DA3.ConfNb=1 Dma.SAI1_B.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -PA6.GPIOParameters=GPIO_Label +PA6.GPIOParameters=GPIO_Speed,GPIO_Label USB_DEVICE.VID-AUDIO_FS=0x1209 PD6.GPIOParameters=GPIO_Label Mcu.Pin80=PE1 @@ -418,7 +419,7 @@ RCC.VCOOutputFreq_Value=336000000 PB15.Mode=Host_FS RCC.UART4Freq_Value=54000000 Dma.SPI5_TX.2.SignalID=NONE -MxCube.Version=6.2.0 +MxCube.Version=6.2.1 RCC.FDCANFreq_Value=48000000 PE5.Mode=SAI_A_AsyncSlave RCC.ADCFreq_Value=30000000 @@ -489,8 +490,8 @@ PA6.GPIO_Label=FLASH_MISO Dma.USART2_RX.4.PeriphDataAlignment=DMA_PDATAALIGN_BYTE PA3.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM PB13.Signal=USB_OTG_HS_VBUS -PD6.GPIO_Label=CS_SDIN PG13.Signal=SPI6_SCK +PD6.GPIO_Label=CS_SDIN Dma.USART2_RX.4.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber PinOutPanel.RotationAngle=0 TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4 @@ -515,7 +516,7 @@ PA4.Locked=true RCC.DIVM2=2 Bdma.SPI6_TX.0.PeriphInc=DMA_PINC_DISABLE RCC.DIVM1=5 -MxDb.Version=DB.6.0.20 +MxDb.Version=DB.6.0.21 PB0.GPIOParameters=GPIO_Label PA1.GPIOParameters=GPIO_Label SH.FMC_D15_DA15.ConfNb=1 @@ -545,6 +546,7 @@ PF14.Signal=FMC_A8 NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false Dma.SPI5_TX.2.RequestNumber=1 PB10.GPIOParameters=GPIO_Label +PA6.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH PH0-OSC_IN\ (PH0).Mode=HSE-External-Oscillator SH.FMC_D3_DA3.0=FMC_D3,sd-16b-d1 SPI5.VirtualType=VM_MASTER @@ -594,6 +596,7 @@ Bdma.SPI6_TX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE FREERTOS.MEMORY_ALLOCATION=2 PA15\ (JTDI).GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH ProjectManager.LastFirmware=true +PA7.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH Dma.SAI1_A.0.PeriphInc=DMA_PINC_DISABLE PE15.Signal=FMC_D12_DA12 PE8.Signal=FMC_D5_DA5 @@ -639,7 +642,7 @@ Dma.SPI5_TX.2.Mode=DMA_NORMAL Dma.USART2_RX.4.Polarity=HAL_DMAMUX_REQ_GEN_RISING Dma.SAI1_A.0.FIFOMode=DMA_FIFOMODE_DISABLE USB_HOST0.BSP.mode=Output -PA7.GPIOParameters=GPIO_Label +PA7.GPIOParameters=GPIO_Speed,GPIO_Label Dma.SAI1_A.0.Instance=DMA2_Stream1 Dma.SAI1_A.0.PeriphDataAlignment=DMA_PDATAALIGN_WORD PA13\ (JTMS/SWDIO).Signal=DEBUG_JTMS-SWDIO @@ -659,7 +662,7 @@ SH.FMC_NBL0.0=FMC_NBL0,Sd2ByteEnable1 ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_BDMA_Init-BDMA-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI4_Init-SPI4-false-HAL-true,7-SystemClock_Config-RCC-false-HAL-true,8-MX_SPI1_Init-SPI1-false-HAL-true,9-MX_SPI5_Init-SPI5-false-HAL-true,10-MX_TIM3_Init-TIM3-false-HAL-true,11-MX_USART2_UART_Init-USART2-false-HAL-true,12-MX_SPI6_Init-SPI6-false-HAL-true,13-MX_USB_HOST_Init-USB_HOST-false-HAL-false,14-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,15-MX_TIM2_Init-TIM2-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true PA2.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM SH.FMC_D6_DA6.0=FMC_D6,sd-16b-d1 -PB0.GPIO_Label=FLASH_nWP +PB0.GPIO_Label=FLASH_WP RCC.PLLI2SRCLKFreq_Value=96000000 RCC.USART2Freq_Value=54000000 Dma.USART2_TX.3.Direction=DMA_MEMORY_TO_PERIPH diff --git a/Magus3/Src/main.c b/Magus3/Src/main.c index 009bb069..dd25cfdc 100644 --- a/Magus3/Src/main.c +++ b/Magus3/Src/main.c @@ -861,7 +861,7 @@ static void MX_GPIO_Init(void) HAL_GPIO_WritePin(GPIOC, FLASH_HOLD_Pin|FLASH_nCS_Pin|ENC_NRST_Pin|TLC_XLAT_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOB, FLASH_nWP_Pin|CS_CS_Pin|CS_RST_Pin, GPIO_PIN_RESET); + HAL_GPIO_WritePin(GPIOB, FLASH_WP_Pin|CS_CS_Pin|CS_RST_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin, GPIO_PIN_SET); @@ -899,8 +899,8 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - /*Configure GPIO pins : FLASH_nWP_Pin CS_CS_Pin CS_RST_Pin */ - GPIO_InitStruct.Pin = FLASH_nWP_Pin|CS_CS_Pin|CS_RST_Pin; + /*Configure GPIO pins : FLASH_WP_Pin CS_CS_Pin CS_RST_Pin */ + GPIO_InitStruct.Pin = FLASH_WP_Pin|CS_CS_Pin|CS_RST_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; diff --git a/Magus3/Src/stm32h7xx_hal_msp.c b/Magus3/Src/stm32h7xx_hal_msp.c index 89dfb0a9..8edfe3d7 100644 --- a/Magus3/Src/stm32h7xx_hal_msp.c +++ b/Magus3/Src/stm32h7xx_hal_msp.c @@ -124,14 +124,14 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) GPIO_InitStruct.Pin = FLASH_MISO_Pin|FLASH_MOSI_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); GPIO_InitStruct.Pin = FLASH_SCK_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; HAL_GPIO_Init(FLASH_SCK_GPIO_Port, &GPIO_InitStruct); From 482902a3bdde93d6d6fdc880f8ea760d655161fe Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 20 Oct 2021 00:55:50 +0200 Subject: [PATCH 119/286] added MIDI program message rx callback --- Source/MidiHandler.cpp | 9 +++++++++ Source/MidiHandler.h | 1 + Source/Owl.cpp | 9 +++++++++ Source/Owl.h | 3 +++ Source/ProgramManager.cpp | 3 ++- Source/ServiceCall.cpp | 7 +++++++ Source/ServiceCall.h | 1 + Source/device.h | 1 + 8 files changed, 33 insertions(+), 1 deletion(-) diff --git a/Source/MidiHandler.cpp b/Source/MidiHandler.cpp index 93132ac2..2380a95e 100644 --- a/Source/MidiHandler.cpp +++ b/Source/MidiHandler.cpp @@ -179,6 +179,12 @@ void MidiHandler::updateCodecSettings(){ #define HEXCODE(x) ((uint16_t)(((x)[1]<<8)|(x)[0])) +void MidiHandler::handleProgramMessage(uint8_t* data, uint16_t size){ + // we've received a message destined for the patch + data[size] = '\0'; // terminate string, overwriting 0xf7 + owl.handleMessage((const char*)data, size); +} + void MidiHandler::handleConfigurationCommand(uint8_t* data, uint16_t size){ if(size < 3) // size may be 3 or more depending on number of digits in value return; @@ -401,6 +407,9 @@ void MidiHandler::handleSysEx(uint8_t* data, uint16_t size){ case SYSEX_BOOTLOADER_COMMAND: jump_to_bootloader(); break; + case SYSEX_PROGRAM_MESSAGE: + handleProgramMessage(data+4, size-5); + break; case SYSEX_FIRMWARE_UPLOAD: handleFirmwareUploadCommand(data+1, size-2); break; diff --git a/Source/MidiHandler.h b/Source/MidiHandler.h index 1e54ab61..2fd60196 100644 --- a/Source/MidiHandler.h +++ b/Source/MidiHandler.h @@ -38,6 +38,7 @@ class MidiHandler { void handleSettingsResetCommand(uint8_t* data, uint16_t size); void handleSettingsStoreCommand(uint8_t* data, uint16_t size); void handleDeviceResetCommand(uint8_t* data, uint16_t size); + void handleProgramMessage(uint8_t* data, uint16_t size); void runProgram(); }; diff --git a/Source/Owl.cpp b/Source/Owl.cpp index 6d458e0a..dc5826e7 100644 --- a/Source/Owl.cpp +++ b/Source/Owl.cpp @@ -323,3 +323,12 @@ const char* getDeviceName(){ } return ptr; } + +void Owl::setMessageCallback(void* callback){ + messageCallback = (void (*)(const char* msg, size_t len))callback; +} + +void Owl::handleMessage(const char* msg, size_t len){ + if(messageCallback != NULL) + messageCallback(msg, len); +} diff --git a/Source/Owl.h b/Source/Owl.h index b6b950f6..f07210af 100644 --- a/Source/Owl.h +++ b/Source/Owl.h @@ -74,6 +74,7 @@ class Owl { private: volatile OperationMode operationMode = STARTUP_MODE; BackgroundTask* backgroundTask = NULL; + void (*messageCallback)(const char* msg, size_t len) = NULL; public: void setup(); @@ -81,6 +82,8 @@ class Owl { OperationMode getOperationMode(); void setOperationMode(OperationMode mode); void setBackgroundTask(BackgroundTask* bt); + void setMessageCallback(void* callback); + void handleMessage(const char* msg, size_t len); }; extern Owl owl; diff --git a/Source/ProgramManager.cpp b/Source/ProgramManager.cpp index b758b862..712fe52c 100644 --- a/Source/ProgramManager.cpp +++ b/Source/ProgramManager.cpp @@ -588,6 +588,7 @@ void runManagerTask(void* p){ graphics.setCallback(NULL); #endif /* USE_SCREEN */ midi_rx.setCallback(NULL); + owl.setMessageCallback(NULL); vTaskDelete(audioTask); audioTask = NULL; #ifdef USE_CODEC @@ -759,8 +760,8 @@ uint8_t ProgramManager::getProgramIndex(){ extern "C" { void vApplicationMallocFailedHook(void) { - program.exitProgram(false); error(PROGRAM_ERROR, "malloc failed"); + program.exitProgram(false); } void vApplicationIdleHook(void) { } diff --git a/Source/ServiceCall.cpp b/Source/ServiceCall.cpp index 27204e8b..429327ef 100644 --- a/Source/ServiceCall.cpp +++ b/Source/ServiceCall.cpp @@ -223,6 +223,13 @@ static int handleRegisterCallback(void** params, int len){ ret = OWL_SERVICE_OK; } #endif /* USE_MIDI_CALLBACK */ +#ifdef USE_MESSAGE_CALLBACK + if(strncmp(SYSTEM_FUNCTION_MESSAGE, name, 3) == 0){ + // void (*messageCallback)(const char* msg, size_t len); + owl.setMessageCallback(callback); + ret = OWL_SERVICE_OK; + } +#endif /* USE_MESSAGE_CALLBACK */ } return ret; } diff --git a/Source/ServiceCall.h b/Source/ServiceCall.h index a272fbed..c3342e4e 100644 --- a/Source/ServiceCall.h +++ b/Source/ServiceCall.h @@ -13,6 +13,7 @@ #define SYSTEM_TABLE_POW "SPW" #define SYSTEM_FUNCTION_DRAW "DRW" #define SYSTEM_FUNCTION_MIDI "MDI" +#define SYSTEM_FUNCTION_MESSAGE "MSG" #define OWL_SERVICE_VERSION OWL_SERVICE_VERSION_V1 diff --git a/Source/device.h b/Source/device.h index 06f30f5f..85553477 100644 --- a/Source/device.h +++ b/Source/device.h @@ -43,6 +43,7 @@ #define MIDI_OUTPUT_BUFFER_SIZE 1024 #define MIDI_INPUT_BUFFER_SIZE 64 #define MIDI_SYSEX_BUFFER_SIZE 256 +#define USE_MESSAGE_CALLBACK #ifndef USBD_MAX_POWER #define USBD_MAX_POWER 100 // 200mA From 35b4e8333e2d96c7bcc9549e0e1b6d0471588ff4 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 20 Oct 2021 22:36:59 +0200 Subject: [PATCH 120/286] use pvPortMalloc and free --- Genius/Inc/usbh_conf.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Genius/Inc/usbh_conf.h b/Genius/Inc/usbh_conf.h index 066c9c49..9d02b5b1 100644 --- a/Genius/Inc/usbh_conf.h +++ b/Genius/Inc/usbh_conf.h @@ -116,10 +116,10 @@ /* Memory management macros */ /** Alias for memory allocation. */ -#define USBH_malloc malloc +#define USBH_malloc pvPortMalloc /** Alias for memory release. */ -#define USBH_free free +#define USBH_free vPortFree /** Alias for memory set. */ #define USBH_memset memset From a8c400db21048ae88ccb78c920faac56588e7f76 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 20 Oct 2021 22:40:17 +0200 Subject: [PATCH 121/286] fix typo --- Source/message.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/message.h b/Source/message.h index 614594cf..d6c207a7 100644 --- a/Source/message.h +++ b/Source/message.h @@ -62,4 +62,4 @@ void assert_failed(const char* msg, const char* location, int line); #endif -#endif /* __MESSAG£_H */ +#endif /* __MESSAGE_H */ From a9832738035ac84cb7d5cc5c3a7b682b0f69441b Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 20 Oct 2021 22:40:30 +0200 Subject: [PATCH 122/286] added memory barriers --- Source/ProgramManager.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/ProgramManager.cpp b/Source/ProgramManager.cpp index 712fe52c..3d56d0c9 100644 --- a/Source/ProgramManager.cpp +++ b/Source/ProgramManager.cpp @@ -525,6 +525,9 @@ void runAudioTask(void* p){ // zero-fill heap memory for(size_t i=0; i<5 && pv->heapSegments[i].location != NULL; ++i) memset(pv->heapSegments[i].location, 0, pv->heapSegments[i].size); + // memory barriers for dynamically loaded code + __DSB(); + __ISB(); // run program def->run(); } From e06617cfb2623179aa105d5e9160844ab444efde Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 20 Oct 2021 22:44:33 +0200 Subject: [PATCH 123/286] added usbh HID sources --- Hardware/h7-libs.mk | 1 + Hardware/h7.mk | 1 + 2 files changed, 2 insertions(+) diff --git a/Hardware/h7-libs.mk b/Hardware/h7-libs.mk index 51ce0a41..d97c173a 100644 --- a/Hardware/h7-libs.mk +++ b/Hardware/h7-libs.mk @@ -66,6 +66,7 @@ C_SRC_USBH += $(USB_HOST_FILE)/Core/Src/usbh_core.c C_SRC_USBH += $(USB_HOST_FILE)/Core/Src/usbh_pipes.c C_SRC_USBH += $(USB_HOST_FILE)/Core/Src/usbh_ioreq.c C_SRC_USBH += $(USB_HOST_FILE)/Core/Src/usbh_ctlreq.c +C_SRC_USBH_HID = $(wildcard $(USB_HOST_FILE)/Class/HID/Src/*.c) ### CMSIS DSP Library #### C_SRC_DSP = $(DSPLIB)/FastMathFunctions/arm_sin_f32.c diff --git a/Hardware/h7.mk b/Hardware/h7.mk index 1eee4af8..c73d52c4 100644 --- a/Hardware/h7.mk +++ b/Hardware/h7.mk @@ -23,6 +23,7 @@ INC_FLAGS += -I$(BUILDROOT)/Core/Inc INC_FLAGS += -I$(BUILDROOT)/USB_DEVICE/App -I$(BUILDROOT)/USB_DEVICE/Target INC_FLAGS += -I$(BUILDROOT)/USB_HOST/App -I$(BUILDROOT)/USB_HOST/Target INC_FLAGS += -I$(USB_HOST_FILE)/Core/Inc +INC_FLAGS += -I$(USB_HOST_FILE)/Class/HID/Inc INC_FLAGS += -I$(USB_DEVICE_FILE)/Core/Inc INC_FLAGS += -I$(USB_OTG_FILE)/inc INC_FLAGS += -I$(FREERTOS_DIR)/include From b41838172b73a1bd0bd0958c2d0eea782b042c0f Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 20 Oct 2021 22:46:30 +0200 Subject: [PATCH 124/286] added usbh HID sources --- Hardware/f4-libs.mk | 1 + Hardware/f4.mk | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Hardware/f4-libs.mk b/Hardware/f4-libs.mk index 469c0de1..a77620e1 100644 --- a/Hardware/f4-libs.mk +++ b/Hardware/f4-libs.mk @@ -63,6 +63,7 @@ C_SRC_USBH += $(USB_HOST_FILE)/Core/Src/usbh_core.c C_SRC_USBH += $(USB_HOST_FILE)/Core/Src/usbh_pipes.c C_SRC_USBH += $(USB_HOST_FILE)/Core/Src/usbh_ioreq.c C_SRC_USBH += $(USB_HOST_FILE)/Core/Src/usbh_ctlreq.c +C_SRC_USBH_HID = $(wildcard $(USB_HOST_FILE)/Class/HID/Src/*.c) ### CMSIS DSP Library #### C_SRC_DSP = $(DSPLIB)/FastMathFunctions/arm_sin_f32.c diff --git a/Hardware/f4.mk b/Hardware/f4.mk index 5b2fb97e..ac49b038 100644 --- a/Hardware/f4.mk +++ b/Hardware/f4.mk @@ -14,14 +14,13 @@ CMSIS_CORE=$(LIBROOT)/CMSIS/Include DSPLIB=$(LIBROOT)/CMSIS/DSP/Source USB_DEVICE_FILE=$(OPENWARE)/Libraries/Middlewares/ST/STM32_USB_Device_Library USB_HOST_FILE=$(OPENWARE)/Libraries/Middlewares/ST/STM32_USB_Host_Library -USB_OTG_FILE=$(LIBROOT)/STM32_USB_OTG_Driver FREERTOS_DIR=$(OPENWARE)/Libraries/Middlewares/Third_Party/FreeRTOS/Source INC_FLAGS = -I$(CMSIS_CORE) -I$(CMSIS_DEVICE)/Include -I$(DRIVERS)/Inc INC_FLAGS += -I$(OPENWARE)/Source -I$(BUILDROOT)/Inc INC_FLAGS += -I$(USB_HOST_FILE)/Core/Inc +INC_FLAGS += -I$(USB_HOST_FILE)/Class/HID/Inc INC_FLAGS += -I$(USB_DEVICE_FILE)/Core/Inc -INC_FLAGS += -I$(USB_OTG_FILE)/inc INC_FLAGS += -I$(FREERTOS_DIR)/include INC_FLAGS += -I$(FREERTOS_DIR)/portable/GCC/ARM_CM4F/ INC_FLAGS += -I$(FREERTOS_DIR)/CMSIS_RTOS From 9a59ce7ec5baf0c8b2ad1bf4dd3645e628b51e36 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 20 Oct 2021 22:52:21 +0200 Subject: [PATCH 125/286] nor flash spi config change --- Genius/Src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Genius/Src/main.c b/Genius/Src/main.c index 3cd5ca52..e9f2d849 100644 --- a/Genius/Src/main.c +++ b/Genius/Src/main.c @@ -600,7 +600,7 @@ static void MX_SPI5_Init(void) hspi5.Init.TIMode = SPI_TIMODE_DISABLE; hspi5.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; hspi5.Init.CRCPolynomial = 0x0; - hspi5.Init.NSSPMode = SPI_NSS_PULSE_ENABLE; + hspi5.Init.NSSPMode = SPI_NSS_PULSE_DISABLE; hspi5.Init.NSSPolarity = SPI_NSS_POLARITY_LOW; hspi5.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA; hspi5.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; From 9bf8a33e12ae181c3a2f453ddcc5e997573ca6d0 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 20 Oct 2021 22:52:44 +0200 Subject: [PATCH 126/286] hid wip --- Genius/Inc/hardware.h | 9 +++++++-- Genius/Makefile | 2 ++ Genius/Src/usb_host.c | 28 ++++++++++++++++------------ 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/Genius/Inc/hardware.h b/Genius/Inc/hardware.h index 2292c149..42de77d3 100644 --- a/Genius/Inc/hardware.h +++ b/Genius/Inc/hardware.h @@ -8,13 +8,18 @@ #define USE_SPI_FLASH #define SPI_FLASH_HSPI hspi5 +#define USE_USBH_HID + /* #define NO_EXTERNAL_RAM */ /* #define NO_CCM_RAM */ #define DMA_RAM __attribute__ ((section (".dmadata"))) #define USE_PLUS_RAM -/* #define USE_ICACHE */ -/* #define USE_DCACHE */ + +#ifndef DEBUG +#define USE_ICACHE +#define USE_DCACHE +#endif #define MAX_SYSEX_PROGRAM_SIZE (512*1024) diff --git a/Genius/Makefile b/Genius/Makefile index 2c6d8984..0eaf9434 100644 --- a/Genius/Makefile +++ b/Genius/Makefile @@ -33,4 +33,6 @@ C_SRC += $(C_SRC_DSP) C_SRC += $(C_SRC_OS) C_SRC += $(C_SRC_UART) +C_SRC += $(C_SRC_USBH_HID) + include $(OPENWARE)/Hardware/h7.mk diff --git a/Genius/Src/usb_host.c b/Genius/Src/usb_host.c index b58e3e7d..15afa143 100644 --- a/Genius/Src/usb_host.c +++ b/Genius/Src/usb_host.c @@ -68,9 +68,11 @@ static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id); */ /* USER CODE BEGIN 1 */ +#ifdef USE_USBH_HID void USBH_HID_EventCallback(USBH_HandleTypeDef *phost){ debugMessage("HID"); } +#endif /* * Background task @@ -88,18 +90,20 @@ void MX_USB_HOST_Process() /* Appli_state = APPLICATION_IDLE; */ /* } */ USBH_HandleTypeDef *phost = &HUSB_HOST; - /* if(USBH_HID_GetDeviceType(phost) == HID_KEYBOARD){ */ - /* HID_KEYBD_Info_TypeDef* pinfo = USBH_HID_GetKeybdInfo(phost); */ - /* if(pinfo != NULL){ */ - /* uint8_t c = USBH_HID_GetASCIICode(pinfo); */ - /* // or c = pinfo->keys[0]; */ - /* if(c >= 32 && c <= 126) { // readable ascii */ - /* char* msg = "char[ ]"; */ - /* msg[5] = c; */ - /* debugMessage(msg); */ - /* } */ - /* } */ - /* } */ +#ifdef USE_USBH_HID + if(USBH_HID_GetDeviceType(phost) == HID_KEYBOARD){ + HID_KEYBD_Info_TypeDef* pinfo = USBH_HID_GetKeybdInfo(phost); + if(pinfo != NULL){ + uint8_t c = USBH_HID_GetASCIICode(pinfo); + // or c = pinfo->keys[0]; + if(c >= 32 && c <= 126) { // readable ascii + char* msg = "char[ ]"; + msg[5] = c; + debugMessage(msg); + } + } + } +#endif } /* USER CODE END 1 */ From a83d12ecfc563c5f38e1538a78dd91a3721819cd Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 21 Oct 2021 17:49:21 +0200 Subject: [PATCH 127/286] added Magus configuration --- MidiBoot3/Inc/hardware.h | 4 ++ MidiBoot3/Makefile | 3 + MidiBoot3/Src/usb_device.c | 111 +++++++++++++++++-------------------- 3 files changed, 57 insertions(+), 61 deletions(-) diff --git a/MidiBoot3/Inc/hardware.h b/MidiBoot3/Inc/hardware.h index 5cd776ee..5467f7f2 100644 --- a/MidiBoot3/Inc/hardware.h +++ b/MidiBoot3/Inc/hardware.h @@ -14,6 +14,10 @@ #define HARDWARE_VERSION "OWL Genius Boot" #define HARDWARE_ID GENIUS_HARDWARE #define APPLICATION_ADDRESS 0x08020000 +#elif defined OWL_MAGUS + #define HARDWARE_VERSION "OWL Magus Boot" + #define HARDWARE_ID MAGUS_HARDWARE + #define APPLICATION_ADDRESS 0x08020000 #else #error Invalid configuration #endif diff --git a/MidiBoot3/Makefile b/MidiBoot3/Makefile index 12b4255e..1ce9b420 100644 --- a/MidiBoot3/Makefile +++ b/MidiBoot3/Makefile @@ -27,6 +27,9 @@ PROJECT = MidiBoot-$(PLATFORM) ifeq ($(PLATFORM),Genius) CPPFLAGS += -Iusbd-fs -DOWL_GENIUS -DUSE_USBD_FS vpath %.c usbd-fs +else ifeq ($(PLATFORM),Magus) + CPPFLAGS += -Iusbd-fs -DOWL_MAGUS -DUSE_USBD_FS + vpath %.c usbd-fs endif CPP_SRC += $(OPENWARE)/Source/MidiController.cpp diff --git a/MidiBoot3/Src/usb_device.c b/MidiBoot3/Src/usb_device.c index 3c01e804..4b8646e6 100644 --- a/MidiBoot3/Src/usb_device.c +++ b/MidiBoot3/Src/usb_device.c @@ -1,96 +1,85 @@ -/* USER CODE BEGIN Header */ /** ****************************************************************************** - * @file : usb_device.c + * @file : USB_DEVICE * @version : v1.0_Cube - * @brief : This file implements the USB Device + * @brief : This file implements the USB Device ****************************************************************************** - * @attention * - *

© Copyright (c) 2021 STMicroelectronics. - * All rights reserved.

+ * Copyright (c) 2017 STMicroelectronics International N.V. + * All rights reserved. * - * This software component is licensed by ST under Ultimate Liberty license - * SLA0044, the "License"; You may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * www.st.com/SLA0044 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions are met: + * + * 1. Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of other + * contributors to this software may be used to endorse or promote products + * derived from this software without specific written permission. + * 4. This software, including modifications and/or derivative works of this + * software, must execute solely and exclusively on microcontroller or + * microprocessor devices manufactured by or for STMicroelectronics. + * 5. Redistribution and use of this software other than as permitted under + * this license is void and will automatically terminate your rights under + * this license. + * + * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY + * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT + * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** - */ -/* USER CODE END Header */ +*/ /* Includes ------------------------------------------------------------------*/ +#include "device.h" #include "usb_device.h" #include "usbd_core.h" #include "usbd_desc.h" #include "usbd_midi.h" -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN PV */ -/* Private variables ---------------------------------------------------------*/ - -/* USER CODE END PV */ - -/* USER CODE BEGIN PFP */ -/* Private function prototypes -----------------------------------------------*/ - -/* USER CODE END PFP */ - -/* USB Device Core handle declaration. */ -USBD_HandleTypeDef hUsbDeviceFS; - -/* - * -- Insert your variables declaration here -- - */ -/* USER CODE BEGIN 0 */ +/* USB Device Core handle declaration */ +USBD_HandleTypeDef USBD_HANDLE; -/* USER CODE END 0 */ - -/* - * -- Insert your external function declaration here -- - */ -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ - -/** - * Init USB device Library, add supported class and start the library - * @retval None - */ +/* init function */ void MX_USB_DEVICE_Init(void) { - /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */ - - /* USER CODE END USB_DEVICE_Init_PreTreatment */ - - /* Init Device Library, add supported class and start the library. */ - if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK) + /* Init Device Library,Add Supported Class and Start the library*/ +#if defined USE_USBD_FS + if (USBD_Init(&USBD_HANDLE, &FS_Desc, DEVICE_FS) != USBD_OK) +#elif defined USE_USBD_HS + if (USBD_Init(&USBD_HANDLE, &HS_Desc, DEVICE_HS) != USBD_OK) +#else +#error Invalid USB configuration +#endif { Error_Handler(); } - if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_AUDIO) != USBD_OK) + if (USBD_RegisterClass(&USBD_HANDLE, &USBD_AUDIO) != USBD_OK) { Error_Handler(); } - if (USBD_AUDIO_RegisterInterface(&hUsbDeviceFS, NULL) != USBD_OK) + if (USBD_AUDIO_RegisterInterface(&USBD_HANDLE, NULL) != USBD_OK) { Error_Handler(); } - if (USBD_Start(&hUsbDeviceFS) != USBD_OK) + if (USBD_Start(&USBD_HANDLE) != USBD_OK) { Error_Handler(); } - - /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */ - HAL_PWREx_EnableUSBVoltageDetector(); - - /* USER CODE END USB_DEVICE_Init_PostTreatment */ } - /** * @} */ From 3fbc3876398a64d48c33dd5280811561707a7b6d Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 21 Oct 2021 17:49:59 +0200 Subject: [PATCH 128/286] removed unused references --- Hardware/h7.mk | 2 -- 1 file changed, 2 deletions(-) diff --git a/Hardware/h7.mk b/Hardware/h7.mk index c73d52c4..871c3826 100644 --- a/Hardware/h7.mk +++ b/Hardware/h7.mk @@ -14,7 +14,6 @@ CMSIS_CORE=$(LIBROOT)/CMSIS/Include DSPLIB=$(LIBROOT)/CMSIS/DSP/Source USB_DEVICE_FILE=$(OPENWARE)/Libraries/Middlewares/ST/STM32_USB_Device_Library USB_HOST_FILE=$(OPENWARE)/Libraries/Middlewares/ST/STM32_USB_Host_Library -USB_OTG_FILE=$(LIBROOT)/STM32_USB_OTG_Driver FREERTOS_DIR=$(OPENWARE)/Libraries/Middlewares/Third_Party/FreeRTOS/Source INC_FLAGS = -I$(CMSIS_CORE) -I$(CMSIS_DEVICE)/Include -I$(DRIVERS)/Inc @@ -25,7 +24,6 @@ INC_FLAGS += -I$(BUILDROOT)/USB_HOST/App -I$(BUILDROOT)/USB_HOST/Target INC_FLAGS += -I$(USB_HOST_FILE)/Core/Inc INC_FLAGS += -I$(USB_HOST_FILE)/Class/HID/Inc INC_FLAGS += -I$(USB_DEVICE_FILE)/Core/Inc -INC_FLAGS += -I$(USB_OTG_FILE)/inc INC_FLAGS += -I$(FREERTOS_DIR)/include INC_FLAGS += -I$(FREERTOS_DIR)/portable/GCC/ARM_CM7/r0p1 INC_FLAGS += -I$(FREERTOS_DIR)/CMSIS_RTOS From 3930c335628f5a708841705f323ef1d1b2238f0c Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 21 Oct 2021 17:50:19 +0200 Subject: [PATCH 129/286] enabled bootload sector allocation for owl3 --- Hardware/owl3.ld | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Hardware/owl3.ld b/Hardware/owl3.ld index f86ed448..72f1160d 100644 --- a/Hardware/owl3.ld +++ b/Hardware/owl3.ld @@ -20,13 +20,13 @@ PLUSRAM (xrw) : ORIGIN = 0x24000000, LENGTH = 512K /* D1 RAM */ HEAP_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 256K DMA_D2 (xrw) : ORIGIN = 0x30040000, LENGTH = 32K RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K -ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 2K -CCMRAM (xrw) : ORIGIN = 0x00000800, LENGTH = 62K +ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 4K +CCMRAM (xrw) : ORIGIN = 0x00001000, LENGTH = 60K EXTRAM (rwx) : ORIGIN = 0xD0000000, LENGTH = 8M -BOOTLOADER (rx) : ORIGIN = 0x08000000, LENGTH = 0K -FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K -/* BOOTLOADER (rx) : ORIGIN = 0x08000000, LENGTH = 128K */ -/* FLASH (rx) : ORIGIN = 0x08020000, LENGTH = 384K */ +/* BOOTLOADER (rx) : ORIGIN = 0x08000000, LENGTH = 0K */ +/* FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K */ +BOOTLOADER (rx) : ORIGIN = 0x08000000, LENGTH = 128K +FLASH (rx) : ORIGIN = 0x08020000, LENGTH = 384K STORAGE (rx) : ORIGIN = 0x08080000, LENGTH = 512K /* Assuming 1Mb FLASH */ /* STORAGE (rx) : ORIGIN = 0x08080000, LENGTH = 1536K /\* Assuming 2Mb FLASH *\/ */ } From 314f241c5087921f2ef0278f66e093b35f429a42 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 21 Oct 2021 17:54:11 +0200 Subject: [PATCH 130/286] removed effectsbox from 'all' target --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d89a38b6..606e4887 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ endif export OPENWARE CONFIG -all: alchemist wizard magus lich witch owlpedal noctua effectsbox biosignals midiboot midibootowl midiboot3 genius # tesseract prism player quadfm ## build most targets +all: alchemist wizard magus lich witch owlpedal noctua biosignals midiboot midibootowl midiboot3 genius # effectsbox tesseract prism player quadfm ## build most targets midiboot: ## build MidiBoot project @$(MAKE) -C MidiBoot all From 0a45b2c7b501e7ce7b5142c548ebe5da197ac74a Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 21 Oct 2021 17:54:35 +0200 Subject: [PATCH 131/286] started refactor screen/graphics --- Genius/Inc/GeniusParameterController.hpp | 84 +- Genius/Inc/hardware.h | 6 +- Genius/Inc/usbh_conf.h | 3 + Genius/Src/Genius.cpp | 36 +- Magus/Src/Magus.cpp | 24 +- Magus3/Inc/FreeRTOSConfig.h | 97 +- Magus3/Inc/hardware.h | 10 +- Magus3/Magus3.ioc | 1582 +++++++++++----------- Magus3/Src/Magus.cpp | 22 +- Source/Graphics.cpp | 40 +- Source/Graphics.h | 25 +- Source/HAL_Encoders.c | 7 + Source/HAL_Encoders.h | 1 + Source/MagusParameterController.hpp | 99 +- Source/Owl.cpp | 3 + Source/Owl.h | 9 - Source/ParameterController.hpp | 56 + Source/ProgramManager.cpp | 9 +- Source/callbacks.h | 9 +- 19 files changed, 1095 insertions(+), 1027 deletions(-) diff --git a/Genius/Inc/GeniusParameterController.hpp b/Genius/Inc/GeniusParameterController.hpp index a691442f..614fd8a4 100644 --- a/Genius/Inc/GeniusParameterController.hpp +++ b/Genius/Inc/GeniusParameterController.hpp @@ -1,5 +1,5 @@ -#ifndef __ParameterController_hpp__ -#define __ParameterController_hpp__ +#ifndef __GeniusParameterController_hpp__ +#define __GeniusParameterController_hpp__ #include #include @@ -26,36 +26,31 @@ extern DigitalBusReader bus; extern VersionToken* bootloader_token; -void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height); +#define NOF_ENCODERS 2 -/* shows a single parameter selected and controlled with a single encoder +/** + *shows a single parameter selected and controlled with a single encoder */ -template -class ParameterController { +class GeniusParameterController : public ParameterController { public: - char title[11] = "Genius"; - int16_t parameters[SIZE]; - char names[SIZE][12]; + char names[NOF_PARAMETERS][12]; int8_t selected = 0; - ParameterController(){ + int16_t encoders[NOF_ENCODERS]; // last seen encoder values + int16_t user[NOF_PARAMETERS]; // user set values (ie by encoder or MIDI) + GeniusParameterController(){ + encoders[0] = INT16_MAX/2; + encoders[1] = INT16_MAX/2; reset(); } - void setTitle(const char* str){ - strncpy(title, str, 10); - } void reset(){ - drawCallback = defaultDrawCallback; - for(int i=0; i 1) - selected = min(SIZE-1, selected+1); + selected = min(NOF_PARAMETERS-1, selected+1); else if(delta < 1) selected = max(0, selected-1); }else{ - parameters[selected] += delta*10; + // single clicks have delta +/- 2 + // parameters[selected] += delta*4095/200; + if(delta > 0) + parameters[selected] += 20 << (delta/2); + else + parameters[selected] -= 20 << (-delta/2); parameters[selected] = min(4095, max(0, parameters[selected])); } } // todo: change patch with enc1/sw1 } void setName(uint8_t pid, const char* name){ - if(pid < SIZE) + if(pid < NOF_PARAMETERS) strncpy(names[pid], name, 11); } - uint8_t getSize(){ - return SIZE; - } void setValue(uint8_t ch, int16_t value){ parameters[ch] = value; } @@ -178,15 +186,17 @@ class ParameterController { screen.print(1, 17, title); } - void setCallback(void *callback){ - if(callback == NULL) - drawCallback = defaultDrawCallback; - else - drawCallback = (void (*)(uint8_t*, uint16_t, uint16_t))callback; + // @param value is the modulation ADC value + void updateValue(uint8_t pid, int16_t value){ + // smoothing at apprx 50Hz + parameters[pid] = max(0, min(4095, (parameters[pid] + user[pid] + value)>>1)); } - + + int16_t getValue(uint8_t pid){ + return parameters[pid]; + } + private: - void (*drawCallback)(uint8_t*, uint16_t, uint16_t); bool sw1(){ return HAL_GPIO_ReadPin(ENC1_SW_GPIO_Port, ENC1_SW_Pin) != GPIO_PIN_SET; } @@ -195,4 +205,4 @@ class ParameterController { } }; -#endif // __ParameterController_hpp__ +#endif // __GeniusParameterController_hpp__ diff --git a/Genius/Inc/hardware.h b/Genius/Inc/hardware.h index 42de77d3..835d6960 100644 --- a/Genius/Inc/hardware.h +++ b/Genius/Inc/hardware.h @@ -21,6 +21,8 @@ #define USE_DCACHE #endif +/* #define USE_BKPSRAM */ + #define MAX_SYSEX_PROGRAM_SIZE (512*1024) #define hdac hdac1 @@ -28,8 +30,8 @@ #define USE_SCREEN #define SSD1309 -#define ENCODER_TIM1 htim2 -#define ENCODER_TIM2 htim3 +#define ENCODER_TIM1 htim3 +#define ENCODER_TIM2 htim2 /* #define OLED_DMA */ #define OLED_SOFT_CS diff --git a/Genius/Inc/usbh_conf.h b/Genius/Inc/usbh_conf.h index 9d02b5b1..4a6c551d 100644 --- a/Genius/Inc/usbh_conf.h +++ b/Genius/Inc/usbh_conf.h @@ -41,6 +41,9 @@ #else #define DEBUG_LEVEL 0 #endif + void *pvPortMalloc( size_t xSize ); + void vPortFree( void *pv ); + /* USER CODE END INCLUDE */ /** @addtogroup STM32_USB_HOST_LIBRARY diff --git a/Genius/Src/Genius.cpp b/Genius/Src/Genius.cpp index 043391a0..13dbff13 100644 --- a/Genius/Src/Genius.cpp +++ b/Genius/Src/Genius.cpp @@ -3,6 +3,7 @@ #include "OpenWareMidiControl.h" #include "Graphics.h" #include "Pin.h" +#include "GeniusParameterController.hpp" #ifdef DEBUG_USBD_AUDIO void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height){ @@ -66,11 +67,12 @@ extern "C"{ extern TIM_HandleTypeDef ENCODER_TIM1; extern TIM_HandleTypeDef ENCODER_TIM2; -Graphics graphics; - Pin tr_out_a_pin(GPIOD, GPIO_PIN_3); Pin tr_out_b_pin(GPIOD, GPIO_PIN_4); +static GeniusParameterController params; +Graphics graphics(params); + void setup(){ tr_out_a_pin.outputMode(); tr_out_b_pin.outputMode(); @@ -156,26 +158,28 @@ extern "C"{ void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* adc_values, size_t adc_len){ // graphics.params.parameters - graphics.params.setValue(0, adc_values[0]); - graphics.params.setValue(1, adc_values[1]); + graphics.params.updateValue(0, adc_values[0]); + graphics.params.updateValue(1, adc_values[1]); // parameter_values[0] = adc_values[0]; // todo: sum with user / encoder setting // parameter_values[1] = adc_values[1]; } - } void updateEncoders(){ - static int16_t encoder_values[2] = {INT16_MAX/2, INT16_MAX/2}; - int16_t value = __HAL_TIM_GET_COUNTER(&ENCODER_TIM1); - int16_t delta = value - encoder_values[0]; - if(delta) - graphics.params.encoderChanged(0, delta); - encoder_values[0] = value; - value = __HAL_TIM_GET_COUNTER(&ENCODER_TIM2); - delta = value - encoder_values[1]; - if(delta) - graphics.params.encoderChanged(1, delta); - encoder_values[1] = value; + int16_t encoder_values[2] = {(int16_t)__HAL_TIM_GET_COUNTER(&ENCODER_TIM1), + (int16_t)__HAL_TIM_GET_COUNTER(&ENCODER_TIM2)}; + params.updateEncoders(encoder_values, 2); + // static int16_t encoder_values[2] = {INT16_MAX/2, INT16_MAX/2}; + // int16_t value = __HAL_TIM_GET_COUNTER(&ENCODER_TIM1); + // int16_t delta = value - encoder_values[0]; + // if(delta) + // graphics.params.encoderChanged(0, delta); + // encoder_values[0] = value; + // value = __HAL_TIM_GET_COUNTER(&ENCODER_TIM2); + // delta = value - encoder_values[1]; + // if(delta) + // graphics.params.encoderChanged(1, delta); + // encoder_values[1] = value; } void loop(void){ diff --git a/Magus/Src/Magus.cpp b/Magus/Src/Magus.cpp index d360e361..87346b4b 100644 --- a/Magus/Src/Magus.cpp +++ b/Magus/Src/Magus.cpp @@ -9,15 +9,27 @@ #include "HAL_Encoders.h" #include "Pin.h" #include "ApplicationSettings.h" +#include "Storage.h" +#include "MagusParameterController.hpp" // 63, 19, 60 // TODO: balance levels const uint32_t* dyn_rainbowinputs = rainbowinputs; const uint32_t* dyn_rainbowoutputs = rainbowoutputs; -Graphics graphics; + +static MagusParameterController params; +Graphics graphics(params); extern "C" void onResourceUpdate(void); +char* progress_message = NULL; +uint16_t progress_counter = 0; + +void setProgress(uint16_t value, const char* reason){ + progress_message = (char*)reason; + progress_counter = value; +} + static bool updateMAX11300 = false; static uint8_t portMode[20]; void setPortMode(uint8_t index, uint8_t mode){ @@ -174,7 +186,7 @@ void loop(void){ for(int i=0; i<16; ++i){ if(getPortMode(i) == PORT_UNI_INPUT){ graphics.params.updateValue(i, MAX11300_getADCValue(i+1)); - uint16_t val = graphics.params.parameters[i]>>2; + uint16_t val = graphics.params.getValue(i)>>2; setLed(i, dyn_rainbowinputs[val&0x3ff]); }else{ // DACs @@ -182,9 +194,9 @@ void loop(void){ // graphics.params.updateOutput(i, getOutputValue(i)); // MAX11300_setDACValue(i+1, graphics.params.parameters[i]); graphics.params.updateValue(i, 0); - uint16_t val = graphics.params.parameters[i]>>2; + uint16_t val = graphics.params.getValue(i)>>2; setLed(i, dyn_rainbowoutputs[val&0x3ff]); - MAX11300_setDAC(i+1, graphics.params.parameters[i]); + MAX11300_setDAC(i+1, graphics.params.getValue(i)); } } for(int i=16; i<20; ++i){ @@ -192,10 +204,10 @@ void loop(void){ graphics.params.updateValue(i, MAX11300_getADCValue(i+1)); }else{ graphics.params.updateValue(i, 0); - MAX11300_setDAC(i+1, graphics.params.parameters[i]); + MAX11300_setDAC(i+1, graphics.params.getValue(i)); } } - for(int i=20; i < 40; i++) { + for(int i=20; i < NOF_PARAMETERS; i++) { graphics.params.updateValue(i, 0); } // MAX11300_bulkwriteDAC(); diff --git a/Magus3/Inc/FreeRTOSConfig.h b/Magus3/Inc/FreeRTOSConfig.h index 25e7cb9c..e4702a11 100644 --- a/Magus3/Inc/FreeRTOSConfig.h +++ b/Magus3/Inc/FreeRTOSConfig.h @@ -1,72 +1,31 @@ /* USER CODE BEGIN Header */ /* - FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS 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. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ + * FreeRTOS Kernel V10.2.1 + * Portion Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Portion Copyright (C) 2019 StMicroelectronics, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ /* USER CODE END Header */ #ifndef FREERTOS_CONFIG_H @@ -85,7 +44,7 @@ *----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ - +/* Section where include file can be added */ #include "device.h" #ifdef DEBUG_STACK #define configUSE_TRACE_FACILITY 1 @@ -168,7 +127,7 @@ See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ /* Normal assert() semantics without relying on the provision of an assert.h header file. */ /* USER CODE BEGIN 1 */ -#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );} +#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );} /* USER CODE END 1 */ /* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS diff --git a/Magus3/Inc/hardware.h b/Magus3/Inc/hardware.h index 301e5ab7..f8f72f89 100644 --- a/Magus3/Inc/hardware.h +++ b/Magus3/Inc/hardware.h @@ -5,14 +5,14 @@ #define HARDWARE_ID MAGUS_HARDWARE #define HARDWARE_VERSION "Magus3" -#define USE_SPI_FLASH +/* #define USE_SPI_FLASH */ -/* #define NO_EXTERNAL_RAM */ -/* #define NO_CCM_RAM */ #define DMA_RAM __attribute__ ((section (".dmadata"))) #define USE_PLUS_RAM -/* #define USE_ICACHE */ -/* #define USE_DCACHE */ +#define USE_ICACHE +#define USE_DCACHE + +/* #define USE_BKPSRAM */ #define MAX_SYSEX_PROGRAM_SIZE (512*1024) diff --git a/Magus3/Magus3.ioc b/Magus3/Magus3.ioc index bad39aee..77e65bc5 100644 --- a/Magus3/Magus3.ioc +++ b/Magus3/Magus3.ioc @@ -1,845 +1,845 @@ #MicroXplorer Configuration settings - do not modify -PF7.GPIOParameters=GPIO_Label -PA15\ (JTDI).GPIOParameters=GPIO_Speed,GPIO_Label -SH.FMC_D0_DA0.ConfNb=1 Bdma.Request0=SPI6_TX -USART2.IPParameters=VirtualMode,BaudRate,Mode,VirtualMode-Asynchronous -SH.FMC_A8.ConfNb=1 -SH.FMC_D6_DA6.ConfNb=1 -SH.FMC_A0.ConfNb=1 -PC10.GPIO_PuPd=GPIO_PULLUP -FMC.SDClockPeriod2=FMC_SDRAM_CLOCK_PERIOD_2 -SH.FMC_D9_DA9.ConfNb=1 -FMC.SDClockPeriod1=FMC_SDRAM_CLOCK_PERIOD_2 -SH.FMC_A0.0=FMC_A0,12b-sda1 -Dma.USART2_TX.3.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -PG8.Signal=FMC_SDCLK -Dma.SPI5_TX.2.MemInc=DMA_MINC_ENABLE -RCC.PLLQCLKFreq_Value=48000000 -PG0.Signal=FMC_A10 -RCC.RTCFreq_Value=32000 -PA15\ (JTDI).Signal=S_TIM2_CH1 -RCC.CpuClockFreq_Value=480000000 -SH.FMC_SDNWE.ConfNb=1 -PG14.GPIOParameters=GPIO_Label -SH.FMC_D5_DA5.0=FMC_D5,sd-16b-d1 -PB3\ (JTDO/TRACESWO).GPIOParameters=GPIO_Speed,GPIO_Label -Dma.SPI5_TX.2.EventEnable=DISABLE -PB3\ (JTDO/TRACESWO).GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH -PA2.GPIOParameters=GPIO_Speed,GPIO_Label -SH.FMC_D9_DA9.0=FMC_D9,sd-16b-d1 -RCC.LPTIM1Freq_Value=120000000 -USB_DEVICE.PID_AUDIO_FS=0xDADA -NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -Dma.SPI5_TX.2.Direction=DMA_MEMORY_TO_PERIPH -PF7.Signal=SPI5_SCK -SH.FMC_SDNWE.0=FMC_SDNWE,12b-sda1 -SPI1.Direction=SPI_DIRECTION_2LINES -SH.FMC_D11_DA11.0=FMC_D11,sd-16b-d1 -RCC.I2C4Freq_Value=120000000 -RCC.APB2TimFreq_Value=168000000 -PB6.Signal=FMC_SDNE1 -VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC.Signal=SAI1_VP_$IpInstance_SAIB_SAI_BASIC -SPI1.CalculateBaudRate=3.0 MBits/s -PD0.Signal=FMC_D2_DA2 -PD8.Signal=FMC_D13_DA13 -Bdma.SPI6_TX.0.RequestNumber=1 -PE1.Signal=FMC_NBL1 +Bdma.RequestsNb=1 +Bdma.SPI6_TX.0.Direction=DMA_MEMORY_TO_PERIPH +Bdma.SPI6_TX.0.EventEnable=DISABLE +Bdma.SPI6_TX.0.Instance=BDMA_Channel0 +Bdma.SPI6_TX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE +Bdma.SPI6_TX.0.MemInc=DMA_MINC_ENABLE +Bdma.SPI6_TX.0.Mode=DMA_NORMAL +Bdma.SPI6_TX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +Bdma.SPI6_TX.0.PeriphInc=DMA_PINC_DISABLE Bdma.SPI6_TX.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING -RCC.USART3Freq_Value=54000000 -RCC.PLLSAIRCLKFreq_Value=50000000 -ProjectManager.ProjectBuild=false -NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -PA0.Locked=true -VP_USB_HOST_VS_USB_HOST_AUDIO_HS.Mode=AUDIO_HS -PG14.Mode=TX_Only_Simplex_Unidirect_Master -FMC.SelfRefreshTime1=4 -SPI6.NSSPMode=SPI_NSS_PULSE_DISABLE -ProjectManager.FirmwarePackage=STM32Cube FW_H7 V1.9.0 -USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology -ProjectManager.BackupPrevious=false -RCC.FMCFreq_Value=240000000 -PC4.GPIO_Label=FLASH_HOLD -RCC.SAI1CLockSelection=RCC_SAI1CLKSOURCE_PLL2 -PB1.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH -PE9.Signal=FMC_D6_DA6 -Dma.SAI1_A.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING -SH.FMC_A2.0=FMC_A2,12b-sda1 -PB14.Mode=Host_FS -PB1.GPIO_Label=TLC_GSCLK -RCC.USART16Freq_Value=120000000 -SPI1.DataSize=SPI_DATASIZE_8BIT -PE4.GPIO_Label=CS_LRCK -VP_USB_HOST_VS_USB_HOST_AUDIO_HS.Signal=USB_HOST_VS_USB_HOST_AUDIO_HS +Bdma.SPI6_TX.0.Priority=DMA_PRIORITY_LOW +Bdma.SPI6_TX.0.RequestNumber=1 +Bdma.SPI6_TX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Bdma.SPI6_TX.0.SignalID=NONE Bdma.SPI6_TX.0.SyncEnable=DISABLE -SH.FMC_D1_DA1.0=FMC_D1,sd-16b-d1 -USB_OTG_HS.IPParameters=VirtualMode-Host_FS -VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 -ProjectManager.HalAssertFull=true -RCC.DIVP2Freq_Value=30000000 -PA0.Signal=GPIO_Output -Mcu.Package=LQFP144 -TIM2.Prescaler=4095 -PB1.Signal=S_TIM3_CH4 -PA5.Locked=true -SH.FMC_SDNCAS.ConfNb=1 -VP_SYS_VS_Systick.Signal=SYS_VS_Systick -SH.FMC_A11.ConfNb=1 -FREERTOS.FootprintOK=true -FMC.WriteRecoveryTime1=2 +Bdma.SPI6_TX.0.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Bdma.SPI6_TX.0.SyncRequestNumber=1 +Bdma.SPI6_TX.0.SyncSignalID=NONE +Dma.Request0=SAI1_A +Dma.Request1=SAI1_B +Dma.Request2=SPI5_TX +Dma.Request3=USART2_TX +Dma.Request4=USART2_RX +Dma.RequestsNb=5 +Dma.SAI1_A.0.Direction=DMA_MEMORY_TO_PERIPH +Dma.SAI1_A.0.EventEnable=DISABLE +Dma.SAI1_A.0.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SAI1_A.0.Instance=DMA2_Stream1 +Dma.SAI1_A.0.MemDataAlignment=DMA_MDATAALIGN_WORD +Dma.SAI1_A.0.MemInc=DMA_MINC_ENABLE +Dma.SAI1_A.0.Mode=DMA_CIRCULAR +Dma.SAI1_A.0.PeriphDataAlignment=DMA_PDATAALIGN_WORD +Dma.SAI1_A.0.PeriphInc=DMA_PINC_DISABLE +Dma.SAI1_A.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.SAI1_A.0.Priority=DMA_PRIORITY_VERY_HIGH +Dma.SAI1_A.0.RequestNumber=1 +Dma.SAI1_A.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.SAI1_A.0.SignalID=NONE +Dma.SAI1_A.0.SyncEnable=DISABLE +Dma.SAI1_A.0.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.SAI1_A.0.SyncRequestNumber=1 Dma.SAI1_A.0.SyncSignalID=NONE -SPI5.CalculateBaudRate=1.875 MBits/s -RCC.APB2CLKDivider=RCC_HCLK_DIV2 -NVIC.EXTI2_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -RCC.APB1TimFreq_Value=84000000 -RCC.LPUART1Freq_Value=120000000 -FMC.RowCycleDelay2=6 -FMC.RowCycleDelay1=6 -USB_OTG_FS.IPParameters=VirtualMode -PB13.Mode=Activate_VBUS_FS -Dma.USART2_TX.3.SyncSignalID=NONE -NVIC.DMA1_Stream6_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true -PA4.GPIO_Label=OLED_CS -PD15.Signal=FMC_D1_DA1 -RCC.PLLSAIQCLKFreq_Value=50000000 -RCC.VCO3OutputFreq_Value=100781250 -SH.FMC_D3_DA3.ConfNb=1 -Dma.SAI1_B.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -PA6.GPIOParameters=GPIO_Speed,GPIO_Label -USB_DEVICE.VID-AUDIO_FS=0x1209 -PD6.GPIOParameters=GPIO_Label -Mcu.Pin80=PE1 -Mcu.Pin81=VP_FREERTOS_VS_CMSIS_V1 -SH.FMC_A4.0=FMC_A4,12b-sda1 -ProjectManager.ProjectFileName=Magus3.ioc -SH.FMC_A5.ConfNb=1 -FREERTOS.Tasks01=defaultTask,0,1024,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL -Mcu.Pin79=PE0 -USB_DEVICE.VirtualMode-AUDIO_FS=Audio -Mcu.PinsNb=87 -PC11.Locked=true -Mcu.Pin73=PG13 -Mcu.Pin74=PG14 +Dma.SAI1_B.1.Direction=DMA_PERIPH_TO_MEMORY +Dma.SAI1_B.1.EventEnable=DISABLE +Dma.SAI1_B.1.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SAI1_B.1.Instance=DMA2_Stream4 +Dma.SAI1_B.1.MemDataAlignment=DMA_MDATAALIGN_WORD Dma.SAI1_B.1.MemInc=DMA_MINC_ENABLE -Mcu.Pin71=PG9 -Mcu.Pin72=PG11 -Mcu.Pin77=PB5 -PG5.Signal=FMC_A15_BA1 -Mcu.Pin78=PB6 -Mcu.Pin75=PG15 -SH.FMC_D10_DA10.0=FMC_D10,sd-16b-d1 -Mcu.Pin76=PB3 (JTDO/TRACESWO) -FREERTOS.INCLUDE_vTaskDelayUntil=1 -Mcu.Pin70=PD6 -RCC.VCOSAIOutputFreq_ValueQ=25000000 -Mcu.Pin68=PD0 -Mcu.Pin69=PD1 -PD6.Mode=SAI_A_AsyncSlave -Mcu.Pin62=PA12 -Mcu.Pin63=PA13 (JTMS/SWDIO) -Mcu.Pin60=PC8 -USART2.BaudRate=31250 -Mcu.Pin61=PA11 -Mcu.Pin66=PC10 -RCC.PWR_Regulator_Voltage_Scale=PWR_REGULATOR_VOLTAGE_SCALE0 -Mcu.Pin67=PC11 -Mcu.Pin64=PA14 (JTCK/SWCLK) -Mcu.Pin65=PA15 (JTDI) -PF8.GPIO_Label=SPI_A_MISO -USB_HOST0.BSP.semaphore= -PD10.Signal=FMC_D15_DA15 -RCC.D1CPREFreq_Value=480000000 -PA3.Mode=Asynchronous -RCC.Tim1OutputFreq_Value=240000000 -Mcu.Pin59=PC6 -Mcu.Pin57=PG5 -SH.GPXTI2.ConfNb=1 -Mcu.Pin58=PG8 -Mcu.Pin51=PD8 -RCC.USART6Freq_Value=108000000 -Mcu.Pin52=PD9 -Mcu.Pin50=PB15 -Mcu.Pin55=PD15 -Mcu.Pin56=PG4 -Mcu.Pin53=PD10 -Mcu.Pin54=PD14 -PB11.GPIOParameters=GPIO_Label -NVIC.DMA2_Stream6_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true -Mcu.Pin48=PB13 -SPI4.NSSPMode=SPI_NSS_PULSE_DISABLE -Mcu.Pin49=PB14 -Mcu.Pin46=PB10 -Mcu.Pin47=PB11 -VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC.Mode=SAI_B_BASIC -PB14.Signal=USB_OTG_HS_DM -Mcu.Pin40=PE10 -PA5.Signal=GPIO_Output -Mcu.Pin41=PE11 -Mcu.Pin44=PE14 -Mcu.Pin45=PE15 -Mcu.Pin42=PE12 -Mcu.Pin43=PE13 -FMC.ReadBurst1=FMC_SDRAM_RBURST_ENABLE -SH.FMC_A6.0=FMC_A6,12b-sda1 -FMC.ReadBurst2=FMC_SDRAM_RBURST_ENABLE -RCC.AHB12Freq_Value=240000000 -PE14.Signal=FMC_D11_DA11 -PE6.Mode=TX_Only_Simplex_Unidirect_Master -Mcu.Pin37=PE7 -Mcu.Pin38=PE8 -Mcu.Pin35=PG0 -RCC.I2C1Freq_Value=54000000 -Mcu.Pin36=PG1 -RCC.PLLI2SPCLKFreq_Value=96000000 -SPI1.Mode=SPI_MODE_MASTER -SH.FMC_D14_DA14.ConfNb=1 -Mcu.Pin39=PE9 -Dma.USART2_TX.3.Mode=DMA_NORMAL -Mcu.Pin30=PF11 -PA1.GPIO_Label=OLED_RST -Mcu.Pin33=PF14 -Mcu.Pin34=PF15 -Mcu.Pin31=PF12 -Mcu.Pin32=PF13 -Dma.SAI1_A.0.SyncRequestNumber=1 -NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -FREERTOS.configUSE_MUTEXES=0 -PF13.Signal=FMC_A7 -PC10.GPIOParameters=GPIO_PuPd,GPIO_Label -TIM2.Period=200 -PF9.GPIOParameters=GPIO_Label -RCC.PLLI2SQCLKFreq_Value=96000000 -Mcu.Pin26=PC5 -NVIC.DMA2_Stream4_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -Mcu.Pin27=PB0 -SPI1.NSSPMode=SPI_NSS_PULSE_DISABLE -Mcu.Pin24=PA7 -Mcu.Pin25=PC4 -Mcu.Pin28=PB1 -Mcu.Pin29=PB2 -PC8.GPIO_PuPd=GPIO_PULLUP -Mcu.Pin22=PA5 -Mcu.Pin23=PA6 -Mcu.Pin20=PA3 -Mcu.Pin21=PA4 -PA5.GPIO_Label=PIXI_nCS -NVIC.ForceEnableDMAVector=true -NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -PE5.GPIO_Label=CS_SCK +Dma.SAI1_B.1.Mode=DMA_CIRCULAR +Dma.SAI1_B.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD +Dma.SAI1_B.1.PeriphInc=DMA_PINC_DISABLE +Dma.SAI1_B.1.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.SAI1_B.1.Priority=DMA_PRIORITY_VERY_HIGH +Dma.SAI1_B.1.RequestNumber=1 +Dma.SAI1_B.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.SAI1_B.1.SignalID=NONE +Dma.SAI1_B.1.SyncEnable=DISABLE +Dma.SAI1_B.1.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.SAI1_B.1.SyncRequestNumber=1 +Dma.SAI1_B.1.SyncSignalID=NONE +Dma.SPI5_TX.2.Direction=DMA_MEMORY_TO_PERIPH +Dma.SPI5_TX.2.EventEnable=DISABLE +Dma.SPI5_TX.2.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SPI5_TX.2.Instance=DMA2_Stream6 +Dma.SPI5_TX.2.MemDataAlignment=DMA_MDATAALIGN_BYTE +Dma.SPI5_TX.2.MemInc=DMA_MINC_ENABLE +Dma.SPI5_TX.2.Mode=DMA_NORMAL +Dma.SPI5_TX.2.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +Dma.SPI5_TX.2.PeriphInc=DMA_PINC_DISABLE +Dma.SPI5_TX.2.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.SPI5_TX.2.Priority=DMA_PRIORITY_LOW +Dma.SPI5_TX.2.RequestNumber=1 +Dma.SPI5_TX.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.SPI5_TX.2.SignalID=NONE +Dma.SPI5_TX.2.SyncEnable=DISABLE +Dma.SPI5_TX.2.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.SPI5_TX.2.SyncRequestNumber=1 +Dma.SPI5_TX.2.SyncSignalID=NONE +Dma.USART2_RX.4.Direction=DMA_PERIPH_TO_MEMORY +Dma.USART2_RX.4.EventEnable=DISABLE +Dma.USART2_RX.4.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.USART2_RX.4.Instance=DMA1_Stream5 +Dma.USART2_RX.4.MemDataAlignment=DMA_MDATAALIGN_BYTE +Dma.USART2_RX.4.MemInc=DMA_MINC_ENABLE +Dma.USART2_RX.4.Mode=DMA_NORMAL +Dma.USART2_RX.4.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +Dma.USART2_RX.4.PeriphInc=DMA_PINC_DISABLE +Dma.USART2_RX.4.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.USART2_RX.4.Priority=DMA_PRIORITY_LOW +Dma.USART2_RX.4.RequestNumber=1 +Dma.USART2_RX.4.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.USART2_RX.4.SignalID=NONE +Dma.USART2_RX.4.SyncEnable=DISABLE +Dma.USART2_RX.4.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.USART2_RX.4.SyncRequestNumber=1 +Dma.USART2_RX.4.SyncSignalID=NONE +Dma.USART2_TX.3.Direction=DMA_MEMORY_TO_PERIPH +Dma.USART2_TX.3.EventEnable=DISABLE +Dma.USART2_TX.3.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.USART2_TX.3.Instance=DMA1_Stream6 +Dma.USART2_TX.3.MemDataAlignment=DMA_MDATAALIGN_BYTE +Dma.USART2_TX.3.MemInc=DMA_MINC_ENABLE +Dma.USART2_TX.3.Mode=DMA_NORMAL +Dma.USART2_TX.3.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +Dma.USART2_TX.3.PeriphInc=DMA_PINC_DISABLE +Dma.USART2_TX.3.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.USART2_TX.3.Priority=DMA_PRIORITY_LOW +Dma.USART2_TX.3.RequestNumber=1 +Dma.USART2_TX.3.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber Dma.USART2_TX.3.SignalID=NONE -SH.FMC_SDNRAS.ConfNb=1 -ProjectManager.HeapSize=0x200 -Mcu.Pin15=PH1-OSC_OUT (PH1) -PA0.GPIOParameters=GPIO_Label -NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -Mcu.Pin16=PC0 -Mcu.Pin13=PF9 -Mcu.Pin14=PH0-OSC_IN (PH0) -Mcu.Pin19=PA2 -Mcu.Pin17=PA0 -Mcu.Pin18=PA1 -SPI6.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_16 -SAI1.VirtualProtocol-SAI_B_BASIC=VM_BASIC_PROTOCOL -NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 -Mcu.Pin11=PF7 -Mcu.Pin12=PF8 -Mcu.Pin10=PF5 -PE3.Signal=SAI1_SD_B -PF4.Signal=FMC_A4 -Bdma.SPI6_TX.0.Direction=DMA_MEMORY_TO_PERIPH +Dma.USART2_TX.3.SyncEnable=DISABLE +Dma.USART2_TX.3.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT Dma.USART2_TX.3.SyncRequestNumber=1 -Mcu.Family=STM32H7 +Dma.USART2_TX.3.SyncSignalID=NONE +FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_3 +FMC.ExitSelfRefreshDelay1=6 FMC.IPParameters=ReadPipeDelay1,ReadBurst1,ReadBurst2,SDClockPeriod1,SDClockPeriod2,CASLatency1,LoadToActiveDelay1,ExitSelfRefreshDelay1,SelfRefreshTime1,RowCycleDelay1,RowCycleDelay2,WriteRecoveryTime1,RPDelay1,RPDelay2,RCDDelay1 -NVIC.OTG_HS_IRQn=true\:10\:0\:true\:false\:true\:true\:true\:true -ProjectManager.MainLocation=Src -SH.FMC_A6.ConfNb=1 -PA6.Mode=Full_Duplex_Master -USB_DEVICE.CLASS_NAME_FS=AUDIO -NVIC.SPI6_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -SH.FMC_A8.0=FMC_A8,12b-sda1 -PG9.GPIOParameters=GPIO_Label -ProjectManager.KeepUserCode=true -Dma.SPI5_TX.2.SyncSignalID=NONE -SH.FMC_D14_DA14.0=FMC_D14,sd-16b-d1 -PH0-OSC_IN\ (PH0).Signal=RCC_OSC_IN -PC5.Locked=true -PA0.GPIO_Label=OLED_DC -SAI1.VirtualProtocol-SAI_A_BASIC=VM_BASIC_PROTOCOL -PA11.Mode=Device_Only -SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 -RCC.VCO2OutputFreq_Value=150000000 -SH.FMC_A11.0=FMC_A11,12b-sda1 -PB15.Signal=USB_OTG_HS_DP -Bdma.SPI6_TX.0.SyncSignalID=NONE -PG11.Signal=GPIO_Output -PG15.Signal=FMC_SDNCAS -SH.GPXTI2.0=GPIO_EXTI2 -SAI1.Instance-SAI_A_AsyncSlave=SAI$Index_Block_A -Mcu.IP4=FMC -Mcu.IP5=FREERTOS -RCC.FCLKCortexFreq_Value=168000000 -Mcu.IP2=DEBUG -Mcu.IP3=DMA -NVIC.BDMA_Channel0_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true -Mcu.IP0=BDMA -Mcu.IP1=CORTEX_M7 -PE4.GPIOParameters=GPIO_Label -SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE -Dma.SAI1_B.1.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -RCC.DIVP3Freq_Value=50390625 -RCC.SDMMCFreq_Value=48000000 -ProjectManager.PreviousToolchain= -TIM3.Period=100 -RCC.VcooutputI2S=96000000 -SH.FMC_NBL1.0=FMC_NBL1,Sd2ByteEnable1 -TIM2.ClockDivision=TIM_CLOCKDIVISION_DIV2 -Dma.SPI5_TX.2.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,VirtualType,Direction,DataSize,NSSPMode +FMC.LoadToActiveDelay1=2 +FMC.RCDDelay1=2 +FMC.RPDelay1=2 +FMC.RPDelay2=2 +FMC.ReadBurst1=FMC_SDRAM_RBURST_ENABLE +FMC.ReadBurst2=FMC_SDRAM_RBURST_ENABLE +FMC.ReadPipeDelay1=FMC_SDRAM_RPIPE_DELAY_0 +FMC.RowCycleDelay1=6 +FMC.RowCycleDelay2=6 +FMC.SDClockPeriod1=FMC_SDRAM_CLOCK_PERIOD_2 +FMC.SDClockPeriod2=FMC_SDRAM_CLOCK_PERIOD_2 +FMC.SelfRefreshTime1=4 +FMC.WriteRecoveryTime1=2 +FREERTOS.FootprintOK=true +FREERTOS.INCLUDE_vTaskDelayUntil=1 FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,MEMORY_ALLOCATION,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,configUSE_MUTEXES,FootprintOK,INCLUDE_vTaskDelayUntil -USB_HOST0.BSP.ip=GPIO -Dma.SAI1_B.1.Instance=DMA2_Stream4 -Dma.SAI1_B.1.FIFOMode=DMA_FIFOMODE_DISABLE +FREERTOS.MEMORY_ALLOCATION=2 +FREERTOS.Tasks01=defaultTask,0,1024,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL +FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 +FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 +FREERTOS.configUSE_MUTEXES=0 FREERTOS.configUSE_PREEMPTION=0 -RCC.HRTIMFreq_Value=240000000 -PH1-OSC_OUT\ (PH1).Mode=HSE-External-Oscillator -RCC.DIVR3Freq_Value=50390625 -RCC.HSE_VALUE=25000000 -NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -SH.FMC_A14_BA0.ConfNb=1 -Dma.USART2_TX.3.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -FMC.ExitSelfRefreshDelay1=6 +File.Version=6 +GPIO.groupedBy=Group By Peripherals +KeepUserPlacement=false +Mcu.Family=STM32H7 +Mcu.IP0=BDMA +Mcu.IP1=CORTEX_M7 Mcu.IP10=SPI4 -NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:true\:true -Mcu.IP12=SPI6 Mcu.IP11=SPI5 -Bdma.SPI6_TX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE -Mcu.IP18=USB_HOST -Bdma.SPI6_TX.0.MemInc=DMA_MINC_ENABLE -Mcu.IP17=USB_DEVICE -Mcu.IP19=USB_OTG_FS -RCC.DIVP1Freq_Value=480000000 -Mcu.IP14=TIM2 -PF9.Mode=Full_Duplex_Master +Mcu.IP12=SPI6 Mcu.IP13=SYS -Mcu.IP16=USART2 +Mcu.IP14=TIM2 Mcu.IP15=TIM3 -RCC.VCOInputFreq_Value=1000000 -Dma.SPI5_TX.2.SyncRequestNumber=1 -PF11.Signal=FMC_SDNRAS -PC11.GPIO_Label=TLC_XLAT -PB5.Mode=SdramChipSelect2_1 -PE3.GPIOParameters=GPIO_Label -Dma.USART2_RX.4.SyncSignalID=NONE +Mcu.IP16=USART2 +Mcu.IP17=USB_DEVICE +Mcu.IP18=USB_HOST +Mcu.IP19=USB_OTG_FS +Mcu.IP2=DEBUG Mcu.IP20=USB_OTG_HS -TIM2.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 -PB0.Locked=true -Dma.USART2_RX.4.Priority=DMA_PRIORITY_LOW -USB_DEVICE.PRODUCT_STRING_AUDIO_FS=OWL-MAGUS -PA6.Signal=SPI1_MISO -PG11.Locked=true -Dma.SAI1_A.0.MemDataAlignment=DMA_MDATAALIGN_WORD -SH.FMC_D4_DA4.ConfNb=1 -NVIC.OTG_FS_IRQn=true\:10\:0\:true\:false\:true\:true\:true\:true -ProjectManager.ToolChainLocation= -Dma.USART2_RX.4.MemInc=DMA_MINC_ENABLE -Bdma.SPI6_TX.0.Mode=DMA_NORMAL -PF8.Signal=SPI5_MISO -RCC.DIVR1Freq_Value=480000000 -USB_HOST0.BSP.name=Drive_VBUS_HS -Dma.Request2=SPI5_TX -Dma.Request1=SAI1_B -Dma.SAI1_B.1.PeriphInc=DMA_PINC_DISABLE -Dma.Request4=USART2_RX -Bdma.SPI6_TX.0.SignalID=NONE -Dma.Request3=USART2_TX -PG11.GPIO_Label=TLC_MODE -PC5.Signal=GPIO_Output -PE7.Signal=FMC_D4_DA4 -PD6.Signal=SAI1_SD_A -Dma.Request0=SAI1_A -Dma.SAI1_B.1.Priority=DMA_PRIORITY_VERY_HIGH -PE2.GPIO_Label=CS_SCK -Mcu.Pin84=VP_SYS_VS_Systick -Mcu.Pin85=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS +Mcu.IP3=DMA +Mcu.IP4=FMC +Mcu.IP5=FREERTOS +Mcu.IP6=NVIC +Mcu.IP7=RCC +Mcu.IP8=SAI1 +Mcu.IP9=SPI1 +Mcu.IPNb=21 +Mcu.Name=STM32H743ZGTx +Mcu.Package=LQFP144 +Mcu.Pin0=PE2 +Mcu.Pin1=PE3 +Mcu.Pin10=PF5 +Mcu.Pin11=PF7 +Mcu.Pin12=PF8 +Mcu.Pin13=PF9 +Mcu.Pin14=PH0-OSC_IN (PH0) +Mcu.Pin15=PH1-OSC_OUT (PH1) +Mcu.Pin16=PC0 +Mcu.Pin17=PA0 +Mcu.Pin18=PA1 +Mcu.Pin19=PA2 +Mcu.Pin2=PE4 +Mcu.Pin20=PA3 +Mcu.Pin21=PA4 +Mcu.Pin22=PA5 +Mcu.Pin23=PA6 +Mcu.Pin24=PA7 +Mcu.Pin25=PC4 +Mcu.Pin26=PC5 +Mcu.Pin27=PB0 +Mcu.Pin28=PB1 +Mcu.Pin29=PB2 +Mcu.Pin3=PE5 +Mcu.Pin30=PF11 +Mcu.Pin31=PF12 +Mcu.Pin32=PF13 +Mcu.Pin33=PF14 +Mcu.Pin34=PF15 +Mcu.Pin35=PG0 +Mcu.Pin36=PG1 +Mcu.Pin37=PE7 +Mcu.Pin38=PE8 +Mcu.Pin39=PE9 +Mcu.Pin4=PE6 +Mcu.Pin40=PE10 +Mcu.Pin41=PE11 +Mcu.Pin42=PE12 +Mcu.Pin43=PE13 +Mcu.Pin44=PE14 +Mcu.Pin45=PE15 +Mcu.Pin46=PB10 +Mcu.Pin47=PB11 +Mcu.Pin48=PB13 +Mcu.Pin49=PB14 +Mcu.Pin5=PF0 +Mcu.Pin50=PB15 +Mcu.Pin51=PD8 +Mcu.Pin52=PD9 +Mcu.Pin53=PD10 +Mcu.Pin54=PD14 +Mcu.Pin55=PD15 +Mcu.Pin56=PG4 +Mcu.Pin57=PG5 +Mcu.Pin58=PG8 +Mcu.Pin59=PC6 +Mcu.Pin6=PF1 +Mcu.Pin60=PC8 +Mcu.Pin61=PA11 +Mcu.Pin62=PA12 +Mcu.Pin63=PA13 (JTMS/SWDIO) +Mcu.Pin64=PA14 (JTCK/SWCLK) +Mcu.Pin65=PA15 (JTDI) +Mcu.Pin66=PC10 +Mcu.Pin67=PC11 +Mcu.Pin68=PD0 +Mcu.Pin69=PD1 +Mcu.Pin7=PF2 +Mcu.Pin70=PD6 +Mcu.Pin71=PG9 +Mcu.Pin72=PG11 +Mcu.Pin73=PG13 +Mcu.Pin74=PG14 +Mcu.Pin75=PG15 +Mcu.Pin76=PB3 (JTDO/TRACESWO) +Mcu.Pin77=PB5 +Mcu.Pin78=PB6 +Mcu.Pin79=PE0 +Mcu.Pin8=PF3 +Mcu.Pin80=PE1 +Mcu.Pin81=VP_FREERTOS_VS_CMSIS_V1 Mcu.Pin82=VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC Mcu.Pin83=VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC -PA3.Signal=USART2_RX -PH1-OSC_OUT\ (PH1).GPIO_Label=OSC2 +Mcu.Pin84=VP_SYS_VS_Systick +Mcu.Pin85=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS Mcu.Pin86=VP_USB_HOST_VS_USB_HOST_AUDIO_HS -SH.FMC_A3.ConfNb=1 -PB3\ (JTDO/TRACESWO).GPIO_Label=FLASH_SCK -Dma.USART2_TX.3.MemDataAlignment=DMA_MDATAALIGN_BYTE -RCC.I2SFreq_Value=96000000 -USB_HOST.IPParameters=VirtualModeHS,USBH_HandleTypeDef-AUDIO_HS,USBH_MAX_NUM_ENDPOINTS-AUDIO_HS,USBH_MAX_SIZE_CONFIGURATION-AUDIO_HS -SH.S_TIM2_CH1.0=TIM2_CH1,PWM Generation1 CH1 -Dma.SAI1_B.1.Mode=DMA_CIRCULAR -RCC.UART7Freq_Value=54000000 -Dma.USART2_TX.3.Instance=DMA1_Stream6 -SPI4.DataSize=SPI_DATASIZE_8BIT -Dma.SAI1_B.1.RequestNumber=1 +Mcu.Pin9=PF4 +Mcu.PinsNb=87 +Mcu.ThirdPartyNb=0 +Mcu.UserConstants= +Mcu.UserName=STM32H743ZGTx +MxCube.Version=6.3.0 +MxDb.Version=DB.6.0.30 +NVIC.BDMA_Channel0_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.DMA1_Stream5_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.DMA1_Stream6_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.DMA2_Stream1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true +NVIC.DMA2_Stream4_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true +NVIC.DMA2_Stream6_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.EXTI2_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.ForceEnableDMAVector=true +NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.OTG_FS_IRQn=true\:10\:0\:true\:false\:true\:true\:true\:true +NVIC.OTG_HS_IRQn=true\:10\:0\:true\:false\:true\:true\:true\:true +NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false +NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 +NVIC.SPI5_IRQn=true\:10\:0\:true\:false\:true\:true\:true\:true +NVIC.SPI6_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.SavedPendsvIrqHandlerGenerated=true NVIC.SavedSvcallIrqHandlerGenerated=true -Dma.SAI1_A.0.Direction=DMA_MEMORY_TO_PERIPH -PC11.Signal=GPIO_Output -Dma.SAI1_A.0.SignalID=NONE -PC8.Signal=GPIO_Input -USB_HOST0.BSP.solution=PC6 -ProjectManager.DefaultFWLocation=true -PD9.Signal=FMC_D14_DA14 -ProjectManager.DeletePrevious=true -PB10.Locked=true -RCC.LCDTFToutputFreq_Value=25000000 -USB_DEVICE.IPParameters=VirtualMode-AUDIO_FS,VirtualModeFS,CLASS_NAME_FS,VID-AUDIO_FS,MANUFACTURER_STRING-AUDIO_FS,PID_AUDIO_FS,PRODUCT_STRING_AUDIO_FS,SERIALNUMBER_STRING_AUDIO_FS -SPI5.Mode=SPI_MODE_MASTER -RCC.FamilyName=M -PH1-OSC_OUT\ (PH1).Signal=RCC_OSC_OUT -Dma.SPI5_TX.2.PeriphInc=DMA_PINC_DISABLE -Dma.USART2_RX.4.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 -SH.FMC_A15_BA1.ConfNb=1 -PH1-OSC_OUT\ (PH1).GPIOParameters=GPIO_Label -PB10.GPIO_Label=CS_CS -Dma.SAI1_A.0.Mode=DMA_CIRCULAR -RCC.VCO1OutputFreq_Value=960000000 -SH.FMC_D13_DA13.0=FMC_D13,sd-16b-d1 -SAI1.BasicDataSize-SAI_B_SyncSlave=SAI_PROTOCOL_DATASIZE_24BIT -PC5.GPIOParameters=GPIO_Label -RCC.AXIClockFreq_Value=240000000 -PE2.GPIOParameters=GPIO_Label -RCC.USBFreq_Value=48000000 -PF9.GPIO_Label=SPI_A_MOSI -Dma.SAI1_B.1.SyncEnable=DISABLE +NVIC.SavedSystickIrqHandlerGenerated=true +NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:true\:true +NVIC.USART2_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +PA0.GPIOParameters=GPIO_Label +PA0.GPIO_Label=OLED_DC +PA0.Locked=true +PA0.Signal=GPIO_Output +PA1.GPIOParameters=GPIO_Label +PA1.GPIO_Label=OLED_RST +PA1.Locked=true PA1.Signal=GPIO_Output -RCC.CKPERFreq_Value=16000000 -Dma.USART2_RX.4.PeriphInc=DMA_PINC_DISABLE -RCC.VCOI2SOutputFreq_Value=192000000 -Dma.USART2_TX.3.FIFOMode=DMA_FIFOMODE_DISABLE -RCC.PLLSAIPCLKFreq_Value=50000000 -board=Magus -RCC.VCOOutputFreq_Value=336000000 -PB15.Mode=Host_FS -RCC.UART4Freq_Value=54000000 -Dma.SPI5_TX.2.SignalID=NONE -MxCube.Version=6.2.1 -RCC.FDCANFreq_Value=48000000 -PE5.Mode=SAI_A_AsyncSlave -RCC.ADCFreq_Value=30000000 -VP_SYS_VS_Systick.Mode=SysTick -SH.FMC_D12_DA12.0=FMC_D12,sd-16b-d1 -PF1.Signal=FMC_A1 -VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_FS -VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Mode=AUDIO_FS -SH.FMC_D11_DA11.ConfNb=1 -RCC.UART5Freq_Value=54000000 +PA11.Mode=Device_Only +PA11.Signal=USB_OTG_FS_DM +PA12.Mode=Device_Only +PA12.Signal=USB_OTG_FS_DP +PA13\ (JTMS/SWDIO).Mode=Serial_Wire +PA13\ (JTMS/SWDIO).Signal=DEBUG_JTMS-SWDIO +PA14\ (JTCK/SWCLK).Mode=Serial_Wire +PA14\ (JTCK/SWCLK).Signal=DEBUG_JTCK-SWCLK +PA15\ (JTDI).GPIOParameters=GPIO_Speed,GPIO_Label PA15\ (JTDI).GPIO_Label=TLC_BLANK -RCC.IPParameters=48MHZClocksFreq_Value,ADCFreq_Value,AHB12Freq_Value,AHB4Freq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,APB3Freq_Value,APB4Freq_Value,AXIClockFreq_Value,CECFreq_Value,CKPERFreq_Value,CortexFreq_Value,CpuClockFreq_Value,D1CPREFreq_Value,D1PPRE,D2PPRE1,D2PPRE2,D3PPRE,DFSDMACLkFreq_Value,DFSDMFreq_Value,DIVM1,DIVM2,DIVN1,DIVN2,DIVP1Freq_Value,DIVP2,DIVP2Freq_Value,DIVP3Freq_Value,DIVQ1,DIVQ1Freq_Value,DIVQ2Freq_Value,DIVQ3Freq_Value,DIVR1Freq_Value,DIVR2Freq_Value,DIVR3Freq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FDCANFreq_Value,FMCFreq_Value,FamilyName,HCLK3ClockFreq_Value,HCLKFreq_Value,HPRE,HRTIMFreq_Value,HSE_VALUE,HSI_VALUE,I2C123Freq_Value,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SClocksFreq_Value,I2SFreq_Value,LCDTFToutputFreq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPTIM345Freq_Value,LPUART1Freq_Value,LSE_VALUE,LSI_VALUE,LTDCFreq_Value,MCO1PinFreq_Value,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLI2SPCLKFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLI2SRoutputFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLQoutputFreq_Value,PLLSAIN,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIRCLKFreq_Value,PLLSAIoutputFreq_Value,PWR_Regulator_Voltage_Scale,ProductRev,QSPIFreq_Value,RNGFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SAI1CLockSelection,SAI1Freq_Value,SAI23Freq_Value,SAI2Freq_Value,SAI4AFreq_Value,SAI4BFreq_Value,SAI_AClocksFreq_Value,SAI_BClocksFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SPI123Freq_Value,SPI45Freq_Value,SPI6Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,Tim1OutputFreq_Value,Tim2OutputFreq_Value,TraceFreq_Value,UART4Freq_Value,UART5Freq_Value,UART7Freq_Value,UART8Freq_Value,USART16Freq_Value,USART1Freq_Value,USART234578Freq_Value,USART2Freq_Value,USART3Freq_Value,USART6Freq_Value,USBFreq_Value,VCO1OutputFreq_Value,VCO2OutputFreq_Value,VCO3OutputFreq_Value,VCOI2SOutputFreq_Value,VCOInput1Freq_Value,VCOInput2Freq_Value,VCOInput3Freq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value,VCOSAIOutputFreq_ValueQ,VcooutputI2S,VcooutputI2SQ -ProjectManager.AskForMigrate=true -PE0.Signal=FMC_NBL0 -Dma.SAI1_B.1.SyncSignalID=NONE -PE12.Signal=FMC_D9_DA9 -NVIC.SavedPendsvIrqHandlerGenerated=true -PB2.Locked=true -Mcu.IP8=SAI1 -Mcu.IP9=SPI1 -Mcu.IP6=NVIC -Mcu.IP7=RCC -ProjectManager.CoupleFile=false -RCC.48MHZClocksFreq_Value=48000000 -RCC.SYSCLKFreq_VALUE=480000000 -RCC.I2C123Freq_Value=120000000 -PA1.Locked=true -KeepUserPlacement=false -USB_HOST.USBH_MAX_SIZE_CONFIGURATION-AUDIO_HS=256 -PB2.GPIO_Label=ENC_CHGRDY -PC6.GPIOParameters=PinState,GPIO_Label -RCC.HSI_VALUE=16000000 -RCC.PLLQ=7 -SH.S_TIM3_CH4.ConfNb=1 -PH0-OSC_IN\ (PH0).GPIO_Label=OSC1 -RCC.PLLM=25 -RCC.PLLN=336 +PA15\ (JTDI).GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PA15\ (JTDI).Signal=S_TIM2_CH1 +PA2.GPIOParameters=GPIO_Speed,GPIO_Label +PA2.GPIO_Label=UART_MOSI +PA2.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM +PA2.Locked=true PA2.Mode=Asynchronous -PC8.Locked=true -Dma.SPI5_TX.2.Polarity=HAL_DMAMUX_REQ_GEN_RISING -SH.FMC_D8_DA8.ConfNb=1 -SPI5.NSSPMode=SPI_NSS_PULSE_DISABLE -Dma.SAI1_A.0.SyncEnable=DISABLE -PG11.GPIOParameters=GPIO_Label +PA2.Signal=USART2_TX +PA3.GPIOParameters=GPIO_Speed,GPIO_Label PA3.GPIO_Label=UART_MISO -PH0-OSC_IN\ (PH0).GPIOParameters=GPIO_Label -USB_HOST0.BSP.instance=PC6 -SPI6.Mode=SPI_MODE_MASTER -USB_OTG_HS.VirtualMode-Host_FS=Host_FS -SH.FMC_D7_DA7.0=FMC_D7,sd-16b-d1 -RCC.USART1Freq_Value=108000000 -SH.FMC_A4.ConfNb=1 -SPI4.VirtualType=VM_MASTER -Dma.SPI5_TX.2.SyncEnable=DISABLE -SAI1.VirtualMode-SAI_A_AsyncSlave=VM_SLAVE -USB_HOST.USBH_MAX_NUM_ENDPOINTS-AUDIO_HS=10 -FMC.RCDDelay1=2 -SPI1.VirtualType=VM_MASTER -Dma.USART2_TX.3.MemInc=DMA_MINC_ENABLE -PG4.Signal=FMC_A14_BA0 -RCC.PLLCLKFreq_Value=168000000 -SPI5.DataSize=SPI_DATASIZE_8BIT -FMC.LoadToActiveDelay1=2 -USB_HOST0.BSP.condition= +PA3.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM +PA3.Mode=Asynchronous +PA3.Signal=USART2_RX +PA4.GPIOParameters=GPIO_Label +PA4.GPIO_Label=OLED_CS +PA4.Locked=true +PA4.Signal=GPIO_Output +PA5.GPIOParameters=GPIO_Label +PA5.GPIO_Label=PIXI_nCS +PA5.Locked=true +PA5.Signal=GPIO_Output +PA6.GPIOParameters=GPIO_Speed,GPIO_Label +PA6.GPIO_Label=FLASH_MISO +PA6.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PA6.Mode=Full_Duplex_Master +PA6.Signal=SPI1_MISO +PA7.GPIOParameters=GPIO_Speed,GPIO_Label +PA7.GPIO_Label=FLASH_MOSI +PA7.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PA7.Mode=Full_Duplex_Master +PA7.Signal=SPI1_MOSI +PB0.GPIOParameters=GPIO_Label +PB0.GPIO_Label=FLASH_WP +PB0.Locked=true +PB0.Signal=GPIO_Output +PB1.GPIOParameters=GPIO_Speed,GPIO_Label +PB1.GPIO_Label=TLC_GSCLK +PB1.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PB1.Locked=true +PB1.Signal=S_TIM3_CH4 +PB10.GPIOParameters=GPIO_Label +PB10.GPIO_Label=CS_CS +PB10.Locked=true +PB10.Signal=GPIO_Output +PB11.GPIOParameters=GPIO_Label +PB11.GPIO_Label=CS_RST +PB11.Locked=true +PB11.Signal=GPIO_Output +PB13.Mode=Activate_VBUS_FS +PB13.Signal=USB_OTG_HS_VBUS +PB14.Mode=Host_FS +PB14.Signal=USB_OTG_HS_DM +PB15.Mode=Host_FS +PB15.Signal=USB_OTG_HS_DP +PB2.GPIOParameters=GPIO_Label +PB2.GPIO_Label=ENC_CHGRDY +PB2.Locked=true +PB2.Signal=GPXTI2 +PB3\ (JTDO/TRACESWO).GPIOParameters=GPIO_Speed,GPIO_Label +PB3\ (JTDO/TRACESWO).GPIO_Label=FLASH_SCK +PB3\ (JTDO/TRACESWO).GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PB3\ (JTDO/TRACESWO).Locked=true +PB3\ (JTDO/TRACESWO).Mode=Full_Duplex_Master +PB3\ (JTDO/TRACESWO).Signal=SPI1_SCK +PB5.Mode=SdramChipSelect2_1 +PB5.Signal=FMC_SDCKE1 +PB6.Mode=SdramChipSelect2_1 +PB6.Signal=FMC_SDNE1 +PC0.Signal=FMC_SDNWE +PC10.GPIOParameters=GPIO_PuPd,GPIO_Label +PC10.GPIO_Label=ENC_NRST +PC10.GPIO_PuPd=GPIO_PULLUP +PC10.Locked=true +PC10.Signal=GPIO_Output +PC11.GPIOParameters=GPIO_Label +PC11.GPIO_Label=TLC_XLAT +PC11.Locked=true +PC11.Signal=GPIO_Output +PC4.GPIOParameters=GPIO_Label +PC4.GPIO_Label=FLASH_HOLD +PC4.Locked=true +PC4.Signal=GPIO_Output +PC5.GPIOParameters=GPIO_Label +PC5.GPIO_Label=FLASH_nCS +PC5.Locked=true +PC5.Signal=GPIO_Output +PC6.GPIOParameters=PinState,GPIO_Label PC6.GPIO_Label=USB_HOST_PWR_EN -PA3.GPIOParameters=GPIO_Speed,GPIO_Label -PA6.GPIO_Label=FLASH_MISO -Dma.USART2_RX.4.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -PA3.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM -PB13.Signal=USB_OTG_HS_VBUS -PG13.Signal=SPI6_SCK +PC6.Locked=true +PC6.PinState=GPIO_PIN_SET +PC6.Signal=GPIO_Output +PC8.GPIOParameters=GPIO_PuPd,GPIO_Label +PC8.GPIO_Label=USB_HOST_PWR_FAULT +PC8.GPIO_PuPd=GPIO_PULLUP +PC8.Locked=true +PC8.Signal=GPIO_Input +PD0.Signal=FMC_D2_DA2 +PD1.Signal=FMC_D3_DA3 +PD10.Signal=FMC_D15_DA15 +PD14.Signal=FMC_D0_DA0 +PD15.Signal=FMC_D1_DA1 +PD6.GPIOParameters=GPIO_Label PD6.GPIO_Label=CS_SDIN -Dma.USART2_RX.4.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -PinOutPanel.RotationAngle=0 -TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4 -PE6.GPIO_Label=CS_MOSI -RCC.MCO1PinFreq_Value=16000000 -RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK -Dma.USART2_TX.3.EventEnable=DISABLE -RCC.AHB4Freq_Value=240000000 -SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 -PA14\ (JTCK/SWCLK).Signal=DEBUG_JTCK-SWCLK +PD6.Mode=SAI_A_AsyncSlave +PD6.Signal=SAI1_SD_A +PD8.Signal=FMC_D13_DA13 +PD9.Signal=FMC_D14_DA14 +PE0.Signal=FMC_NBL0 +PE1.Signal=FMC_NBL1 +PE10.Signal=FMC_D7_DA7 +PE11.Signal=FMC_D8_DA8 +PE12.Signal=FMC_D9_DA9 +PE13.Signal=FMC_D10_DA10 +PE14.Signal=FMC_D11_DA11 +PE15.Signal=FMC_D12_DA12 +PE2.GPIOParameters=GPIO_Label +PE2.GPIO_Label=CS_SCK PE2.Mode=TX_Only_Simplex_Unidirect_Master -TIM2.IPParameters=Channel-PWM Generation1 CH1,Prescaler,ClockDivision,Period,Pulse-PWM Generation1 CH1 -SH.FMC_D10_DA10.ConfNb=1 -USB_HOST0.BSP.component= -RCC.DIVQ3Freq_Value=50390625 -PB6.Mode=SdramChipSelect2_1 -RCC.SAI2Freq_Value=50000000 -PE5.Signal=SAI1_SCK_A -Dma.SAI1_B.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD -PB2.Signal=GPXTI2 -PA4.Locked=true -RCC.DIVM2=2 -Bdma.SPI6_TX.0.PeriphInc=DMA_PINC_DISABLE -RCC.DIVM1=5 -MxDb.Version=DB.6.0.21 -PB0.GPIOParameters=GPIO_Label -PA1.GPIOParameters=GPIO_Label -SH.FMC_D15_DA15.ConfNb=1 -Dma.USART2_RX.4.EventEnable=DISABLE PE2.Signal=SPI4_SCK -PF8.Mode=Full_Duplex_Master -PA14\ (JTCK/SWCLK).Mode=Serial_Wire -NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false +PE3.GPIOParameters=GPIO_Label +PE3.GPIO_Label=CS_SDOUT +PE3.Mode=SAI_B_SyncSlave +PE3.Signal=SAI1_SD_B +PE4.GPIOParameters=GPIO_Label +PE4.GPIO_Label=CS_LRCK +PE4.Mode=SAI_A_AsyncSlave +PE4.Signal=SAI1_FS_A +PE5.GPIOParameters=GPIO_Label +PE5.GPIO_Label=CS_SCK +PE5.Mode=SAI_A_AsyncSlave +PE5.Signal=SAI1_SCK_A +PE6.GPIOParameters=GPIO_Label +PE6.GPIO_Label=CS_MOSI +PE6.Mode=TX_Only_Simplex_Unidirect_Master +PE6.Signal=SPI4_MOSI +PE7.Signal=FMC_D4_DA4 +PE8.Signal=FMC_D5_DA5 +PE9.Signal=FMC_D6_DA6 +PF0.Signal=FMC_A0 +PF1.Signal=FMC_A1 +PF11.Signal=FMC_SDNRAS +PF12.Signal=FMC_A6 +PF13.Signal=FMC_A7 +PF14.Signal=FMC_A8 +PF15.Signal=FMC_A9 +PF2.Signal=FMC_A2 PF3.Signal=FMC_A3 -RCC.DIVR2Freq_Value=75000000 -PE10.Signal=FMC_D7_DA7 -Dma.USART2_TX.3.SyncEnable=DISABLE -RCC.MCO2PinFreq_Value=480000000 -PC8.GPIOParameters=GPIO_PuPd,GPIO_Label +PF4.Signal=FMC_A4 +PF5.Signal=FMC_A5 +PF7.GPIOParameters=GPIO_Label +PF7.GPIO_Label=SPI_A_SCK +PF7.Mode=Full_Duplex_Master +PF7.Signal=SPI5_SCK PF8.GPIOParameters=GPIO_Label +PF8.GPIO_Label=SPI_A_MISO +PF8.Mode=Full_Duplex_Master +PF8.Signal=SPI5_MISO +PF9.GPIOParameters=GPIO_Label +PF9.GPIO_Label=SPI_A_MOSI +PF9.Mode=Full_Duplex_Master +PF9.Signal=SPI5_MOSI +PG0.Signal=FMC_A10 +PG1.Signal=FMC_A11 +PG11.GPIOParameters=GPIO_Label +PG11.GPIO_Label=TLC_MODE +PG11.Locked=true +PG11.Signal=GPIO_Output PG13.GPIOParameters=GPIO_Label -RCC.DFSDMFreq_Value=120000000 -PA5.GPIOParameters=GPIO_Label -SH.FMC_A1.0=FMC_A1,12b-sda1 -Bdma.SPI6_TX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -SH.FMC_SDCLK.0=FMC_SDCLK,12b-sda1 -RCC.TraceFreq_Value=480000000 -RCC.APB4Freq_Value=120000000 -RCC.CECFreq_Value=32000 -RCC.SAI23Freq_Value=48000000 -PF14.Signal=FMC_A8 -NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -Dma.SPI5_TX.2.RequestNumber=1 -PB10.GPIOParameters=GPIO_Label -PA6.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH -PH0-OSC_IN\ (PH0).Mode=HSE-External-Oscillator -SH.FMC_D3_DA3.0=FMC_D3,sd-16b-d1 -SPI5.VirtualType=VM_MASTER -ProjectManager.CustomerFirmwarePackage= -PC4.GPIOParameters=GPIO_Label -RCC.SAI_AClocksFreq_Value=25000000 -Dma.SAI1_B.1.EventEnable=DISABLE -SH.FMC_A7.ConfNb=1 -RCC.PLLQoutputFreq_Value=48000000 -SH.FMC_A1.ConfNb=1 -RCC.DIVQ1=20 -VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC.Mode=SAI_A_BASIC +PG13.GPIO_Label=SPI_B_CLK +PG13.Mode=TX_Only_Simplex_Unidirect_Master +PG13.Signal=SPI6_SCK +PG14.GPIOParameters=GPIO_Label +PG14.GPIO_Label=SPI_B_MOSI +PG14.Mode=TX_Only_Simplex_Unidirect_Master +PG14.Signal=SPI6_MOSI +PG15.Signal=FMC_SDNCAS +PG4.Signal=FMC_A14_BA0 +PG5.Signal=FMC_A15_BA1 +PG8.Signal=FMC_SDCLK +PG9.GPIOParameters=GPIO_Label +PG9.GPIO_Label=ENC_nCS PG9.Locked=true PG9.Signal=GPIO_Output -RCC.SWPMI1Freq_Value=120000000 -FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 -PC6.Signal=GPIO_Output -PB11.GPIO_Label=CS_RST -PD1.Signal=FMC_D3_DA3 -VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC.Signal=SAI1_VP_$IpInstance_SAIA_SAI_BASIC -RCC.DIVP2=5 -Dma.USART2_TX.3.PeriphInc=DMA_PINC_DISABLE -NVIC.DMA2_Stream1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -RCC.UART8Freq_Value=54000000 -PC0.Signal=FMC_SDNWE -Dma.USART2_RX.4.RequestNumber=1 +PH0-OSC_IN\ (PH0).GPIOParameters=GPIO_Label +PH0-OSC_IN\ (PH0).GPIO_Label=OSC1 +PH0-OSC_IN\ (PH0).Mode=HSE-External-Oscillator +PH0-OSC_IN\ (PH0).Signal=RCC_OSC_IN +PH1-OSC_OUT\ (PH1).GPIOParameters=GPIO_Label +PH1-OSC_OUT\ (PH1).GPIO_Label=OSC2 +PH1-OSC_OUT\ (PH1).Mode=HSE-External-Oscillator +PH1-OSC_OUT\ (PH1).Signal=RCC_OSC_OUT +PinOutPanel.RotationAngle=0 +ProjectManager.AskForMigrate=true +ProjectManager.BackupPrevious=false +ProjectManager.CompilerOptimize=6 +ProjectManager.ComputerToolchain=false +ProjectManager.CoupleFile=false +ProjectManager.CustomerFirmwarePackage= +ProjectManager.DefaultFWLocation=true +ProjectManager.DeletePrevious=true +ProjectManager.DeviceId=STM32H743ZGTx +ProjectManager.FirmwarePackage=STM32Cube FW_H7 V1.9.0 +ProjectManager.FreePins=true +ProjectManager.HalAssertFull=true +ProjectManager.HeapSize=0x200 +ProjectManager.KeepUserCode=true +ProjectManager.LastFirmware=true +ProjectManager.LibraryCopy=2 +ProjectManager.MainLocation=Src +ProjectManager.NoMain=false +ProjectManager.PreviousToolchain= +ProjectManager.ProjectBuild=false +ProjectManager.ProjectFileName=Magus3.ioc +ProjectManager.ProjectName=Magus3 +ProjectManager.RegisterCallBack= +ProjectManager.StackSize=0x400 +ProjectManager.TargetToolchain=Other Toolchains (GPDSC) +ProjectManager.ToolChainLocation= +ProjectManager.UnderRoot=false +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_BDMA_Init-BDMA-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI4_Init-SPI4-false-HAL-true,7-SystemClock_Config-RCC-false-HAL-true,8-MX_SPI1_Init-SPI1-false-HAL-true,9-MX_SPI5_Init-SPI5-false-HAL-true,10-MX_TIM3_Init-TIM3-false-HAL-true,11-MX_USART2_UART_Init-USART2-false-HAL-true,12-MX_SPI6_Init-SPI6-false-HAL-true,13-MX_USB_HOST_Init-USB_HOST-false-HAL-false,14-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,15-MX_TIM2_Init-TIM2-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true +RCC.48MHZClocksFreq_Value=48000000 +RCC.ADCFreq_Value=30000000 +RCC.AHB12Freq_Value=240000000 +RCC.AHB4Freq_Value=240000000 +RCC.AHBFreq_Value=168000000 RCC.APB1CLKDivider=RCC_HCLK_DIV4 -PC11.GPIOParameters=GPIO_Label -RCC.QSPIFreq_Value=240000000 -PG13.GPIO_Label=SPI_B_CLK -USB_HOST0.BSP.STBoard=false -SH.FMC_A3.0=FMC_A3,12b-sda1 -RCC.USART234578Freq_Value=120000000 -Bdma.SPI6_TX.0.Instance=BDMA_Channel0 -FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_3 -SPI6.CalculateBaudRate=7.5 MBits/s -RCC.SPI123Freq_Value=48000000 -Dma.SAI1_A.0.RequestNumber=1 -SH.FMC_D15_DA15.0=FMC_D15,sd-16b-d1 -USB_HOST.VirtualModeHS=Audio -PC6.Locked=true -RCC.DIVN2=12 +RCC.APB1Freq_Value=120000000 +RCC.APB1TimFreq_Value=84000000 +RCC.APB2CLKDivider=RCC_HCLK_DIV2 +RCC.APB2Freq_Value=120000000 +RCC.APB2TimFreq_Value=168000000 +RCC.APB3Freq_Value=120000000 +RCC.APB4Freq_Value=120000000 +RCC.AXIClockFreq_Value=240000000 +RCC.CECFreq_Value=32000 +RCC.CKPERFreq_Value=16000000 +RCC.CortexFreq_Value=480000000 +RCC.CpuClockFreq_Value=480000000 +RCC.D1CPREFreq_Value=480000000 +RCC.D1PPRE=RCC_APB3_DIV2 +RCC.D2PPRE1=RCC_APB1_DIV2 +RCC.D2PPRE2=RCC_APB2_DIV2 +RCC.D3PPRE=RCC_APB4_DIV2 +RCC.DFSDMACLkFreq_Value=30000000 +RCC.DFSDMFreq_Value=120000000 +RCC.DIVM1=5 +RCC.DIVM2=2 RCC.DIVN1=192 -PB10.Signal=GPIO_Output -PC6.PinState=GPIO_PIN_SET -Bdma.SPI6_TX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -FREERTOS.MEMORY_ALLOCATION=2 -PA15\ (JTDI).GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH -ProjectManager.LastFirmware=true -PA7.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH -Dma.SAI1_A.0.PeriphInc=DMA_PINC_DISABLE -PE15.Signal=FMC_D12_DA12 -PE8.Signal=FMC_D5_DA5 -RCC.RNGFreq_Value=48000000 +RCC.DIVN2=12 +RCC.DIVP1Freq_Value=480000000 +RCC.DIVP2=5 +RCC.DIVP2Freq_Value=30000000 +RCC.DIVP3Freq_Value=50390625 +RCC.DIVQ1=20 +RCC.DIVQ1Freq_Value=48000000 +RCC.DIVQ2Freq_Value=75000000 +RCC.DIVQ3Freq_Value=50390625 +RCC.DIVR1Freq_Value=480000000 +RCC.DIVR2Freq_Value=75000000 +RCC.DIVR3Freq_Value=50390625 RCC.EthernetFreq_Value=168000000 -TIM3.IPParameters=Channel-PWM Generation4 CH4,Pulse-PWM Generation4 CH4,Period,OCFastMode_PWM-PWM Generation4 CH4,ClockDivision -Bdma.SPI6_TX.0.SyncRequestNumber=1 -PG14.GPIO_Label=SPI_B_MOSI -SH.FMC_SDNCAS.0=FMC_SDNCAS,12b-sda1 -RCC.ProductRev=revV -ProjectManager.FreePins=true -RCC.LPTIM2Freq_Value=120000000 -SH.FMC_NBL1.ConfNb=1 -RCC.RTCHSEDivFreq_Value=12500000 -ProjectManager.UnderRoot=false -SH.FMC_D7_DA7.ConfNb=1 -Dma.SAI1_B.1.MemDataAlignment=DMA_MDATAALIGN_WORD -PA4.Signal=GPIO_Output -Bdma.SPI6_TX.0.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -PB5.Signal=FMC_SDCKE1 -Dma.USART2_RX.4.MemDataAlignment=DMA_MDATAALIGN_BYTE -SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX -SH.FMC_A10.ConfNb=1 -ProjectManager.CompilerOptimize=6 -SH.FMC_A5.0=FMC_A5,12b-sda1 -PA11.Signal=USB_OTG_FS_DM -RCC.LPTIM345Freq_Value=120000000 -ProjectManager.ComputerToolchain=false -PF9.Signal=SPI5_MOSI -SAI1.InitProtocol-SAI_A_AsyncSlave=Enable -Dma.USART2_TX.3.Priority=DMA_PRIORITY_LOW -RCC.LTDCFreq_Value=50390625 -Dma.SPI5_TX.2.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -PB3\ (JTDO/TRACESWO).Mode=Full_Duplex_Master -Dma.USART2_RX.4.Mode=DMA_NORMAL -SH.FMC_D12_DA12.ConfNb=1 -Bdma.SPI6_TX.0.EventEnable=DISABLE +RCC.FCLKCortexFreq_Value=168000000 +RCC.FDCANFreq_Value=48000000 +RCC.FMCFreq_Value=240000000 +RCC.FamilyName=M RCC.HCLK3ClockFreq_Value=240000000 -RCC.I2C2Freq_Value=54000000 -SPI5.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,DataSize,NSSPMode -PB0.Signal=GPIO_Output -Dma.SPI5_TX.2.Mode=DMA_NORMAL -Dma.USART2_RX.4.Polarity=HAL_DMAMUX_REQ_GEN_RISING -Dma.SAI1_A.0.FIFOMode=DMA_FIFOMODE_DISABLE -USB_HOST0.BSP.mode=Output -PA7.GPIOParameters=GPIO_Speed,GPIO_Label -Dma.SAI1_A.0.Instance=DMA2_Stream1 -Dma.SAI1_A.0.PeriphDataAlignment=DMA_PDATAALIGN_WORD -PA13\ (JTMS/SWDIO).Signal=DEBUG_JTMS-SWDIO -SPI6.VirtualType=VM_MASTER -Dma.SAI1_A.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -RCC.DIVQ2Freq_Value=75000000 -RCC.SAI1Freq_Value=30000000 -RCC.CortexFreq_Value=480000000 -SH.FMC_A2.ConfNb=1 -Mcu.UserName=STM32H743ZGTx +RCC.HCLKFreq_Value=240000000 RCC.HPRE=RCC_HCLK_DIV2 -Dma.USART2_TX.3.Polarity=HAL_DMAMUX_REQ_GEN_RISING -PC10.Locked=true -PC10.Signal=GPIO_Output -SPI4.Direction=SPI_DIRECTION_2LINES_TXONLY -SH.FMC_NBL0.0=FMC_NBL0,Sd2ByteEnable1 -ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_BDMA_Init-BDMA-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI4_Init-SPI4-false-HAL-true,7-SystemClock_Config-RCC-false-HAL-true,8-MX_SPI1_Init-SPI1-false-HAL-true,9-MX_SPI5_Init-SPI5-false-HAL-true,10-MX_TIM3_Init-TIM3-false-HAL-true,11-MX_USART2_UART_Init-USART2-false-HAL-true,12-MX_SPI6_Init-SPI6-false-HAL-true,13-MX_USB_HOST_Init-USB_HOST-false-HAL-false,14-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,15-MX_TIM2_Init-TIM2-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true -PA2.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM -SH.FMC_D6_DA6.0=FMC_D6,sd-16b-d1 -PB0.GPIO_Label=FLASH_WP -RCC.PLLI2SRCLKFreq_Value=96000000 -RCC.USART2Freq_Value=54000000 -Dma.USART2_TX.3.Direction=DMA_MEMORY_TO_PERIPH -Dma.USART2_RX.4.Instance=DMA1_Stream5 -PB11.Signal=GPIO_Output -PE5.GPIOParameters=GPIO_Label -ProjectManager.StackSize=0x400 -RCC.SAI_BClocksFreq_Value=25000000 -RCC.VCOInput3Freq_Value=781250 +RCC.HRTIMFreq_Value=240000000 +RCC.HSE_VALUE=25000000 +RCC.HSI_VALUE=16000000 +RCC.I2C123Freq_Value=120000000 +RCC.I2C1Freq_Value=54000000 +RCC.I2C2Freq_Value=54000000 RCC.I2C3Freq_Value=54000000 -USB_HOST.USBH_HandleTypeDef-AUDIO_HS=hUsbHostHS -SH.FMC_A7.0=FMC_A7,12b-sda1 -PA12.Signal=USB_OTG_FS_DP -Mcu.UserConstants= -SPI4.Mode=SPI_MODE_MASTER -Mcu.ThirdPartyNb=0 -RCC.HCLKFreq_Value=240000000 -Mcu.IPNb=21 +RCC.I2C4Freq_Value=120000000 RCC.I2SClocksFreq_Value=96000000 +RCC.I2SFreq_Value=96000000 +RCC.IPParameters=48MHZClocksFreq_Value,ADCFreq_Value,AHB12Freq_Value,AHB4Freq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,APB3Freq_Value,APB4Freq_Value,AXIClockFreq_Value,CECFreq_Value,CKPERFreq_Value,CortexFreq_Value,CpuClockFreq_Value,D1CPREFreq_Value,D1PPRE,D2PPRE1,D2PPRE2,D3PPRE,DFSDMACLkFreq_Value,DFSDMFreq_Value,DIVM1,DIVM2,DIVN1,DIVN2,DIVP1Freq_Value,DIVP2,DIVP2Freq_Value,DIVP3Freq_Value,DIVQ1,DIVQ1Freq_Value,DIVQ2Freq_Value,DIVQ3Freq_Value,DIVR1Freq_Value,DIVR2Freq_Value,DIVR3Freq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FDCANFreq_Value,FMCFreq_Value,FamilyName,HCLK3ClockFreq_Value,HCLKFreq_Value,HPRE,HRTIMFreq_Value,HSE_VALUE,HSI_VALUE,I2C123Freq_Value,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SClocksFreq_Value,I2SFreq_Value,LCDTFToutputFreq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPTIM345Freq_Value,LPUART1Freq_Value,LSE_VALUE,LSI_VALUE,LTDCFreq_Value,MCO1PinFreq_Value,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLI2SPCLKFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLI2SRoutputFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLQoutputFreq_Value,PLLSAIN,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIRCLKFreq_Value,PLLSAIoutputFreq_Value,PWR_Regulator_Voltage_Scale,ProductRev,QSPIFreq_Value,RNGFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SAI1CLockSelection,SAI1Freq_Value,SAI23Freq_Value,SAI2Freq_Value,SAI4AFreq_Value,SAI4BFreq_Value,SAI_AClocksFreq_Value,SAI_BClocksFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SPI123Freq_Value,SPI45Freq_Value,SPI6Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,Tim1OutputFreq_Value,Tim2OutputFreq_Value,TraceFreq_Value,UART4Freq_Value,UART5Freq_Value,UART7Freq_Value,UART8Freq_Value,USART16Freq_Value,USART1Freq_Value,USART234578Freq_Value,USART2Freq_Value,USART3Freq_Value,USART6Freq_Value,USBFreq_Value,VCO1OutputFreq_Value,VCO2OutputFreq_Value,VCO3OutputFreq_Value,VCOI2SOutputFreq_Value,VCOInput1Freq_Value,VCOInput2Freq_Value,VCOInput3Freq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value,VCOSAIOutputFreq_ValueQ,VcooutputI2S,VcooutputI2SQ +RCC.LCDTFToutputFreq_Value=25000000 +RCC.LPTIM1Freq_Value=120000000 +RCC.LPTIM2Freq_Value=120000000 +RCC.LPTIM345Freq_Value=120000000 +RCC.LPUART1Freq_Value=120000000 +RCC.LSE_VALUE=32768 +RCC.LSI_VALUE=32000 +RCC.LTDCFreq_Value=50390625 +RCC.MCO1PinFreq_Value=16000000 +RCC.MCO2PinFreq_Value=480000000 +RCC.PLLCLKFreq_Value=168000000 +RCC.PLLI2SPCLKFreq_Value=96000000 +RCC.PLLI2SQCLKFreq_Value=96000000 +RCC.PLLI2SRCLKFreq_Value=96000000 RCC.PLLI2SRoutputFreq_Value=96000000 -Dma.USART2_RX.4.SignalID=NONE -Dma.USART2_TX.3.RequestNumber=1 +RCC.PLLM=25 +RCC.PLLN=336 +RCC.PLLQ=7 +RCC.PLLQCLKFreq_Value=48000000 +RCC.PLLQoutputFreq_Value=48000000 +RCC.PLLSAIN=100 +RCC.PLLSAIPCLKFreq_Value=50000000 +RCC.PLLSAIQCLKFreq_Value=50000000 +RCC.PLLSAIRCLKFreq_Value=50000000 +RCC.PLLSAIoutputFreq_Value=50000000 +RCC.PWR_Regulator_Voltage_Scale=PWR_REGULATOR_VOLTAGE_SCALE0 +RCC.ProductRev=revV +RCC.QSPIFreq_Value=240000000 +RCC.RNGFreq_Value=48000000 +RCC.RTCFreq_Value=32000 +RCC.RTCHSEDivFreq_Value=12500000 +RCC.SAI1CLockSelection=RCC_SAI1CLKSOURCE_PLL2 +RCC.SAI1Freq_Value=30000000 +RCC.SAI23Freq_Value=48000000 +RCC.SAI2Freq_Value=50000000 +RCC.SAI4AFreq_Value=48000000 +RCC.SAI4BFreq_Value=48000000 +RCC.SAI_AClocksFreq_Value=25000000 +RCC.SAI_BClocksFreq_Value=25000000 +RCC.SDMMCFreq_Value=48000000 RCC.SPDIFRXFreq_Value=48000000 -SPI6.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,DataSize,NSSPMode -PF12.Signal=FMC_A6 -FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 -Mcu.Pin6=PF1 -Mcu.Pin7=PF2 -Mcu.Pin8=PF3 -Mcu.Pin9=PF4 -Dma.SAI1_A.0.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +RCC.SPI123Freq_Value=48000000 +RCC.SPI45Freq_Value=120000000 +RCC.SPI6Freq_Value=120000000 +RCC.SWPMI1Freq_Value=120000000 +RCC.SYSCLKFreq_VALUE=480000000 +RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK +RCC.Tim1OutputFreq_Value=240000000 +RCC.Tim2OutputFreq_Value=240000000 +RCC.TraceFreq_Value=480000000 +RCC.UART4Freq_Value=54000000 +RCC.UART5Freq_Value=54000000 +RCC.UART7Freq_Value=54000000 +RCC.UART8Freq_Value=54000000 +RCC.USART16Freq_Value=120000000 +RCC.USART1Freq_Value=108000000 +RCC.USART234578Freq_Value=120000000 +RCC.USART2Freq_Value=54000000 +RCC.USART3Freq_Value=54000000 +RCC.USART6Freq_Value=108000000 +RCC.USBFreq_Value=48000000 +RCC.VCO1OutputFreq_Value=960000000 +RCC.VCO2OutputFreq_Value=150000000 +RCC.VCO3OutputFreq_Value=100781250 +RCC.VCOI2SOutputFreq_Value=192000000 +RCC.VCOInput1Freq_Value=5000000 +RCC.VCOInput2Freq_Value=12500000 +RCC.VCOInput3Freq_Value=781250 +RCC.VCOInputFreq_Value=1000000 +RCC.VCOOutputFreq_Value=336000000 RCC.VCOSAIOutputFreq_Value=100000000 +RCC.VCOSAIOutputFreq_ValueQ=25000000 +RCC.VcooutputI2S=96000000 +RCC.VcooutputI2SQ=96000000 +SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX +SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_RX +SAI1.BasicDataSize-SAI_A_AsyncSlave=SAI_PROTOCOL_DATASIZE_24BIT +SAI1.BasicDataSize-SAI_B_SyncSlave=SAI_PROTOCOL_DATASIZE_24BIT +SAI1.IPParameters=Instance-SAI_A_AsyncSlave,VirtualMode-SAI_A_AsyncSlave,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,AudioMode-SAI_B_SyncSlave,AudioMode-SAI_A_AsyncSlave,Synchro_A,Synchro_B,InitProtocol-SAI_A_AsyncSlave,VirtualProtocol-SAI_A_BASIC,InitProtocol-SAI_B_SyncSlave,VirtualProtocol-SAI_B_BASIC,BasicDataSize-SAI_A_AsyncSlave,BasicDataSize-SAI_B_SyncSlave +SAI1.InitProtocol-SAI_A_AsyncSlave=Enable +SAI1.InitProtocol-SAI_B_SyncSlave=Enable +SAI1.Instance-SAI_A_AsyncSlave=SAI$Index_Block_A +SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B +SAI1.Synchro_A=SAI_ASYNCHRONOUS +SAI1.Synchro_B=SAI_SYNCHRONOUS +SAI1.VirtualMode-SAI_A_AsyncSlave=VM_SLAVE +SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE +SAI1.VirtualProtocol-SAI_A_BASIC=VM_BASIC_PROTOCOL +SAI1.VirtualProtocol-SAI_B_BASIC=VM_BASIC_PROTOCOL +SH.FMC_A0.0=FMC_A0,12b-sda1 +SH.FMC_A0.ConfNb=1 +SH.FMC_A1.0=FMC_A1,12b-sda1 +SH.FMC_A1.ConfNb=1 SH.FMC_A10.0=FMC_A10,12b-sda1 -RCC.AHBFreq_Value=168000000 -Mcu.Pin0=PE2 -Mcu.Pin1=PE3 -GPIO.groupedBy=Group By Peripherals -Mcu.Pin2=PE4 -Mcu.Pin3=PE5 -TIM3.ClockDivision=TIM_CLOCKDIVISION_DIV2 -Mcu.Pin4=PE6 -Mcu.Pin5=PF0 -SH.FMC_D8_DA8.0=FMC_D8,sd-16b-d1 -FMC.RPDelay2=2 -USART2.VirtualMode-Asynchronous=VM_ASYNC -FMC.RPDelay1=2 +SH.FMC_A10.ConfNb=1 +SH.FMC_A11.0=FMC_A11,12b-sda1 +SH.FMC_A11.ConfNb=1 +SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 +SH.FMC_A14_BA0.ConfNb=1 +SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 +SH.FMC_A15_BA1.ConfNb=1 +SH.FMC_A2.0=FMC_A2,12b-sda1 +SH.FMC_A2.ConfNb=1 +SH.FMC_A3.0=FMC_A3,12b-sda1 +SH.FMC_A3.ConfNb=1 +SH.FMC_A4.0=FMC_A4,12b-sda1 +SH.FMC_A4.ConfNb=1 +SH.FMC_A5.0=FMC_A5,12b-sda1 +SH.FMC_A5.ConfNb=1 +SH.FMC_A6.0=FMC_A6,12b-sda1 +SH.FMC_A6.ConfNb=1 +SH.FMC_A7.0=FMC_A7,12b-sda1 +SH.FMC_A7.ConfNb=1 +SH.FMC_A8.0=FMC_A8,12b-sda1 +SH.FMC_A8.ConfNb=1 +SH.FMC_A9.0=FMC_A9,12b-sda1 +SH.FMC_A9.ConfNb=1 +SH.FMC_D0_DA0.0=FMC_D0,sd-16b-d1 +SH.FMC_D0_DA0.ConfNb=1 +SH.FMC_D10_DA10.0=FMC_D10,sd-16b-d1 +SH.FMC_D10_DA10.ConfNb=1 +SH.FMC_D11_DA11.0=FMC_D11,sd-16b-d1 +SH.FMC_D11_DA11.ConfNb=1 +SH.FMC_D12_DA12.0=FMC_D12,sd-16b-d1 +SH.FMC_D12_DA12.ConfNb=1 +SH.FMC_D13_DA13.0=FMC_D13,sd-16b-d1 +SH.FMC_D13_DA13.ConfNb=1 +SH.FMC_D14_DA14.0=FMC_D14,sd-16b-d1 +SH.FMC_D14_DA14.ConfNb=1 +SH.FMC_D15_DA15.0=FMC_D15,sd-16b-d1 +SH.FMC_D15_DA15.ConfNb=1 +SH.FMC_D1_DA1.0=FMC_D1,sd-16b-d1 +SH.FMC_D1_DA1.ConfNb=1 SH.FMC_D2_DA2.0=FMC_D2,sd-16b-d1 -Dma.SPI5_TX.2.MemDataAlignment=DMA_MDATAALIGN_BYTE -PE13.Signal=FMC_D10_DA10 -Dma.USART2_RX.4.FIFOMode=DMA_FIFOMODE_DISABLE -PF7.GPIO_Label=SPI_A_SCK -Dma.SPI5_TX.2.Priority=DMA_PRIORITY_LOW -File.Version=6 -Dma.USART2_RX.4.SyncRequestNumber=1 -Dma.SAI1_A.0.EventEnable=DISABLE -SH.FMC_D5_DA5.ConfNb=1 -SH.S_TIM2_CH1.ConfNb=1 SH.FMC_D2_DA2.ConfNb=1 -PG13.Mode=TX_Only_Simplex_Unidirect_Master -FMC.ReadPipeDelay1=FMC_SDRAM_RPIPE_DELAY_0 -PE4.Mode=SAI_A_AsyncSlave -SH.FMC_SDNRAS.0=FMC_SDNRAS,12b-sda1 -USB_HOST0.BSP.i2creg= -PE4.Signal=SAI1_FS_A -PE6.GPIOParameters=GPIO_Label -Dma.RequestsNb=5 -SPI4.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_32 -ProjectManager.ProjectName=Magus3 -RCC.APB3Freq_Value=120000000 -USB_HOST0.BSP.i2caddr=0 -SPI5.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_64 -SH.FMC_D0_DA0.0=FMC_D0,sd-16b-d1 -RCC.D1PPRE=RCC_APB3_DIV2 -USART2.VirtualMode=VM_ASYNC -PA2.GPIO_Label=UART_MOSI -RCC.LSI_VALUE=32000 -Bdma.SPI6_TX.0.Priority=DMA_PRIORITY_LOW -USB_OTG_FS.VirtualMode=Device_Only -SH.FMC_A9.0=FMC_A9,12b-sda1 +SH.FMC_D3_DA3.0=FMC_D3,sd-16b-d1 +SH.FMC_D3_DA3.ConfNb=1 SH.FMC_D4_DA4.0=FMC_D4,sd-16b-d1 -RCC.PLLSAIN=100 -PF5.Signal=FMC_A5 -Dma.SPI5_TX.2.Instance=DMA2_Stream6 -Dma.SAI1_B.1.SignalID=NONE -PC4.Locked=true -PF0.Signal=FMC_A0 +SH.FMC_D4_DA4.ConfNb=1 +SH.FMC_D5_DA5.0=FMC_D5,sd-16b-d1 +SH.FMC_D5_DA5.ConfNb=1 +SH.FMC_D6_DA6.0=FMC_D6,sd-16b-d1 +SH.FMC_D6_DA6.ConfNb=1 +SH.FMC_D7_DA7.0=FMC_D7,sd-16b-d1 +SH.FMC_D7_DA7.ConfNb=1 +SH.FMC_D8_DA8.0=FMC_D8,sd-16b-d1 +SH.FMC_D8_DA8.ConfNb=1 +SH.FMC_D9_DA9.0=FMC_D9,sd-16b-d1 +SH.FMC_D9_DA9.ConfNb=1 +SH.FMC_NBL0.0=FMC_NBL0,Sd2ByteEnable1 SH.FMC_NBL0.ConfNb=1 +SH.FMC_NBL1.0=FMC_NBL1,Sd2ByteEnable1 +SH.FMC_NBL1.ConfNb=1 +SH.FMC_SDCLK.0=FMC_SDCLK,12b-sda1 +SH.FMC_SDCLK.ConfNb=1 +SH.FMC_SDNCAS.0=FMC_SDNCAS,12b-sda1 +SH.FMC_SDNCAS.ConfNb=1 +SH.FMC_SDNRAS.0=FMC_SDNRAS,12b-sda1 +SH.FMC_SDNRAS.ConfNb=1 +SH.FMC_SDNWE.0=FMC_SDNWE,12b-sda1 +SH.FMC_SDNWE.ConfNb=1 +SH.GPXTI2.0=GPIO_EXTI2 +SH.GPXTI2.ConfNb=1 +SH.S_TIM2_CH1.0=TIM2_CH1,PWM Generation1 CH1 +SH.S_TIM2_CH1.ConfNb=1 +SH.S_TIM3_CH4.0=TIM3_CH4,PWM Generation4 CH4 +SH.S_TIM3_CH4.ConfNb=1 SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_16 -PE3.Mode=SAI_B_SyncSlave -Dma.SPI5_TX.2.FIFOMode=DMA_FIFOMODE_DISABLE -RCC.Tim2OutputFreq_Value=240000000 -RCC.DFSDMACLkFreq_Value=30000000 -PA2.Locked=true -SAI1.Synchro_A=SAI_ASYNCHRONOUS -SH.FMC_A9.ConfNb=1 -SAI1.Synchro_B=SAI_SYNCHRONOUS -PA7.Mode=Full_Duplex_Master -PA13\ (JTMS/SWDIO).Mode=Serial_Wire -PC10.GPIO_Label=ENC_NRST -Dma.SAI1_B.1.Polarity=HAL_DMAMUX_REQ_GEN_RISING -ProjectManager.NoMain=false +SPI1.CalculateBaudRate=3.0 MBits/s +SPI1.DataSize=SPI_DATASIZE_8BIT +SPI1.Direction=SPI_DIRECTION_2LINES SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,DataSize,NSSPMode,BaudRatePrescaler -USB_DEVICE.VirtualModeFS=Audio_FS -PG1.Signal=FMC_A11 -RCC.SAI4BFreq_Value=48000000 -SH.FMC_SDCLK.ConfNb=1 -PC4.Signal=GPIO_Output -USB_HOST.BSP.number=1 -RCC.D2PPRE2=RCC_APB2_DIV2 -RCC.D2PPRE1=RCC_APB1_DIV2 -Dma.SPI5_TX.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -Dma.SAI1_A.0.MemInc=DMA_MINC_ENABLE -NVIC.USART2_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -NVIC.SPI5_IRQn=true\:10\:0\:true\:false\:true\:true\:true\:true -TIM2.Pulse-PWM\ Generation1\ CH1=100 -RCC.SPI6Freq_Value=120000000 -PC8.GPIO_Label=USB_HOST_PWR_FAULT -PF7.Mode=Full_Duplex_Master -RCC.SPI45Freq_Value=120000000 -SAI1.BasicDataSize-SAI_A_AsyncSlave=SAI_PROTOCOL_DATASIZE_24BIT +SPI1.Mode=SPI_MODE_MASTER +SPI1.NSSPMode=SPI_NSS_PULSE_DISABLE +SPI1.VirtualType=VM_MASTER +SPI4.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_32 +SPI4.CalculateBaudRate=3.75 MBits/s +SPI4.DataSize=SPI_DATASIZE_8BIT +SPI4.Direction=SPI_DIRECTION_2LINES_TXONLY +SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,VirtualType,Direction,DataSize,NSSPMode +SPI4.Mode=SPI_MODE_MASTER +SPI4.NSSPMode=SPI_NSS_PULSE_DISABLE +SPI4.VirtualType=VM_MASTER +SPI5.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_64 +SPI5.CalculateBaudRate=1.875 MBits/s +SPI5.DataSize=SPI_DATASIZE_8BIT +SPI5.Direction=SPI_DIRECTION_2LINES +SPI5.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,DataSize,NSSPMode +SPI5.Mode=SPI_MODE_MASTER +SPI5.NSSPMode=SPI_NSS_PULSE_DISABLE +SPI5.VirtualType=VM_MASTER +SPI6.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_16 +SPI6.CalculateBaudRate=7.5 MBits/s SPI6.DataSize=SPI_DATASIZE_8BIT -PB3\ (JTDO/TRACESWO).Locked=true -PB3\ (JTDO/TRACESWO).Signal=SPI1_SCK -ProjectManager.TargetToolchain=Other Toolchains (GPDSC) -NVIC.DMA1_Stream5_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true -SH.FMC_D1_DA1.ConfNb=1 -Bdma.RequestsNb=1 -PB2.GPIOParameters=GPIO_Label -RCC.VcooutputI2SQ=96000000 -PF2.Signal=FMC_A2 -Dma.USART2_TX.3.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -ProjectManager.RegisterCallBack= -RCC.PLLSAIoutputFreq_Value=50000000 -USB_DEVICE.SERIALNUMBER_STRING_AUDIO_FS=00000000010D -PE11.Signal=FMC_D8_DA8 -RCC.LSE_VALUE=32768 -PB1.Locked=true -SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_RX -Dma.SAI1_A.0.Priority=DMA_PRIORITY_VERY_HIGH -PG9.GPIO_Label=ENC_nCS -PG14.Signal=SPI6_MOSI -SAI1.IPParameters=Instance-SAI_A_AsyncSlave,VirtualMode-SAI_A_AsyncSlave,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,AudioMode-SAI_B_SyncSlave,AudioMode-SAI_A_AsyncSlave,Synchro_A,Synchro_B,InitProtocol-SAI_A_AsyncSlave,VirtualProtocol-SAI_A_BASIC,InitProtocol-SAI_B_SyncSlave,VirtualProtocol-SAI_B_BASIC,BasicDataSize-SAI_A_AsyncSlave,BasicDataSize-SAI_B_SyncSlave -RCC.VCOInput1Freq_Value=5000000 -Dma.USART2_RX.4.SyncEnable=DISABLE -Dma.USART2_RX.4.Direction=DMA_PERIPH_TO_MEMORY -NVIC.SavedSystickIrqHandlerGenerated=true -RCC.APB2Freq_Value=120000000 -USB_HOST0.BSP.api=Unknown -SH.FMC_D13_DA13.ConfNb=1 SPI6.Direction=SPI_DIRECTION_2LINES_TXONLY -PF15.Signal=FMC_A9 -SPI4.CalculateBaudRate=3.75 MBits/s -PA4.GPIOParameters=GPIO_Label -PE6.Signal=SPI4_MOSI -Mcu.Name=STM32H743ZGTx -PA2.Signal=USART2_TX -PD14.Signal=FMC_D0_DA0 +SPI6.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,DataSize,NSSPMode +SPI6.Mode=SPI_MODE_MASTER +SPI6.NSSPMode=SPI_NSS_PULSE_DISABLE +SPI6.VirtualType=VM_MASTER +TIM2.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 +TIM2.ClockDivision=TIM_CLOCKDIVISION_DIV2 +TIM2.IPParameters=Channel-PWM Generation1 CH1,Prescaler,ClockDivision,Period,Pulse-PWM Generation1 CH1 +TIM2.Period=200 +TIM2.Prescaler=4095 +TIM2.Pulse-PWM\ Generation1\ CH1=100 +TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4 +TIM3.ClockDivision=TIM_CLOCKDIVISION_DIV2 +TIM3.IPParameters=Channel-PWM Generation4 CH4,Pulse-PWM Generation4 CH4,Period,OCFastMode_PWM-PWM Generation4 CH4,ClockDivision TIM3.OCFastMode_PWM-PWM\ Generation4\ CH4=TIM_OCFAST_DISABLE -PA7.GPIO_Label=FLASH_MOSI -PA12.Mode=Device_Only -Dma.SAI1_B.1.Direction=DMA_PERIPH_TO_MEMORY -PC5.GPIO_Label=FLASH_nCS -SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B -RCC.SAI4AFreq_Value=48000000 -RCC.DIVQ1Freq_Value=48000000 -PE3.GPIO_Label=CS_SDOUT -Dma.SAI1_B.1.SyncRequestNumber=1 -RCC.D3PPRE=RCC_APB4_DIV2 -RCC.VCOInput2Freq_Value=12500000 -RCC.APB1Freq_Value=120000000 -USART2.Mode=MODE_TX_RX -SAI1.InitProtocol-SAI_B_SyncSlave=Enable +TIM3.Period=100 TIM3.Pulse-PWM\ Generation4\ CH4=50 -PB11.Locked=true -ProjectManager.DeviceId=STM32H743ZGTx -ProjectManager.LibraryCopy=2 -SPI5.Direction=SPI_DIRECTION_2LINES -SH.S_TIM3_CH4.0=TIM3_CH4,PWM Generation4 CH4 -PB1.GPIOParameters=GPIO_Speed,GPIO_Label -PA7.Signal=SPI1_MOSI +USART2.BaudRate=31250 +USART2.IPParameters=VirtualMode,BaudRate,Mode,VirtualMode-Asynchronous +USART2.Mode=MODE_TX_RX +USART2.VirtualMode=VM_ASYNC +USART2.VirtualMode-Asynchronous=VM_ASYNC +USB_DEVICE.CLASS_NAME_FS=AUDIO +USB_DEVICE.IPParameters=VirtualMode-AUDIO_FS,VirtualModeFS,CLASS_NAME_FS,VID-AUDIO_FS,MANUFACTURER_STRING-AUDIO_FS,PID_AUDIO_FS,PRODUCT_STRING_AUDIO_FS,SERIALNUMBER_STRING_AUDIO_FS +USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology +USB_DEVICE.PID_AUDIO_FS=0xDADA +USB_DEVICE.PRODUCT_STRING_AUDIO_FS=OWL-MAGUS +USB_DEVICE.SERIALNUMBER_STRING_AUDIO_FS=00000000010D +USB_DEVICE.VID-AUDIO_FS=0x1209 +USB_DEVICE.VirtualMode-AUDIO_FS=Audio +USB_DEVICE.VirtualModeFS=Audio_FS +USB_HOST.BSP.number=1 +USB_HOST.IPParameters=VirtualModeHS,USBH_HandleTypeDef-AUDIO_HS,USBH_MAX_NUM_ENDPOINTS-AUDIO_HS,USBH_MAX_SIZE_CONFIGURATION-AUDIO_HS +USB_HOST.USBH_HandleTypeDef-AUDIO_HS=hUsbHostHS +USB_HOST.USBH_MAX_NUM_ENDPOINTS-AUDIO_HS=10 +USB_HOST.USBH_MAX_SIZE_CONFIGURATION-AUDIO_HS=256 +USB_HOST.VirtualModeHS=Audio +USB_HOST0.BSP.STBoard=false +USB_HOST0.BSP.api=Unknown +USB_HOST0.BSP.component= +USB_HOST0.BSP.condition= +USB_HOST0.BSP.i2caddr=0 +USB_HOST0.BSP.i2creg= +USB_HOST0.BSP.instance=PC6 +USB_HOST0.BSP.ip=GPIO +USB_HOST0.BSP.mode=Output +USB_HOST0.BSP.name=Drive_VBUS_HS +USB_HOST0.BSP.semaphore= +USB_HOST0.BSP.solution=PC6 +USB_OTG_FS.IPParameters=VirtualMode +USB_OTG_FS.VirtualMode=Device_Only +USB_OTG_HS.IPParameters=VirtualMode-Host_FS +USB_OTG_HS.VirtualMode-Host_FS=Host_FS +VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 +VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 +VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC.Mode=SAI_A_BASIC +VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC.Signal=SAI1_VP_$IpInstance_SAIA_SAI_BASIC +VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC.Mode=SAI_B_BASIC +VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC.Signal=SAI1_VP_$IpInstance_SAIB_SAI_BASIC +VP_SYS_VS_Systick.Mode=SysTick +VP_SYS_VS_Systick.Signal=SYS_VS_Systick +VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Mode=AUDIO_FS +VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_FS +VP_USB_HOST_VS_USB_HOST_AUDIO_HS.Mode=AUDIO_HS +VP_USB_HOST_VS_USB_HOST_AUDIO_HS.Signal=USB_HOST_VS_USB_HOST_AUDIO_HS +board=Magus diff --git a/Magus3/Src/Magus.cpp b/Magus3/Src/Magus.cpp index e3aac9c2..57cfb776 100644 --- a/Magus3/Src/Magus.cpp +++ b/Magus3/Src/Magus.cpp @@ -9,15 +9,27 @@ #include "HAL_Encoders.h" #include "Pin.h" #include "ApplicationSettings.h" +#include "Storage.h" +#include "MagusParameterController.hpp" // 63, 19, 60 // TODO: balance levels const uint32_t* dyn_rainbowinputs = rainbowinputs; const uint32_t* dyn_rainbowoutputs = rainbowoutputs; -Graphics graphics; + +static MagusParameterController params; +Graphics graphics(params); extern "C" void onResourceUpdate(void); +char* progress_message = NULL; +uint16_t progress_counter = 0; + +void setProgress(uint16_t value, const char* reason){ + progress_message = (char*)reason; + progress_counter = value; +} + static bool updateMAX11300 = false; static uint8_t portMode[20]; void setPortMode(uint8_t index, uint8_t mode){ @@ -174,7 +186,7 @@ void loop(void){ for(int i=0; i<16; ++i){ if(getPortMode(i) == PORT_UNI_INPUT){ graphics.params.updateValue(i, MAX11300_getADCValue(i+1)); - uint16_t val = graphics.params.parameters[i]>>2; + uint16_t val = graphics.params.getValue(i)>>2; setLed(i, dyn_rainbowinputs[val&0x3ff]); }else{ // DACs @@ -182,9 +194,9 @@ void loop(void){ // graphics.params.updateOutput(i, getOutputValue(i)); // MAX11300_setDACValue(i+1, graphics.params.parameters[i]); graphics.params.updateValue(i, 0); - uint16_t val = graphics.params.parameters[i]>>2; + uint16_t val = graphics.params.getValue(i)>>2; setLed(i, dyn_rainbowoutputs[val&0x3ff]); - MAX11300_setDAC(i+1, graphics.params.parameters[i]); + MAX11300_setDAC(i+1, graphics.params.getValue(i)); } } for(int i=16; i<20; ++i){ @@ -192,7 +204,7 @@ void loop(void){ graphics.params.updateValue(i, MAX11300_getADCValue(i+1)); }else{ graphics.params.updateValue(i, 0); - MAX11300_setDAC(i+1, graphics.params.parameters[i]); + MAX11300_setDAC(i+1, graphics.params.getValue(i)); } } // MAX11300_bulkwriteDAC(); diff --git a/Source/Graphics.cpp b/Source/Graphics.cpp index 446d36ba..08137f79 100644 --- a/Source/Graphics.cpp +++ b/Source/Graphics.cpp @@ -2,6 +2,8 @@ #include "Graphics.h" #include "errorhandlers.h" #include "oled.h" +#include "callbacks.h" +#include "ProgramVector.h" void Graphics::begin(SPI_HandleTypeDef *spi) { oled_init(spi); @@ -26,21 +28,37 @@ void Graphics::draw(){ // graphics.params.draw(graphics.screen); // } +void Graphics::reset(){ + drawCallback = defaultDrawCallback; + params.reset(); +} + void Graphics::setCallback(void *callback){ - params.setCallback(callback); - // if(callback == NULL) - // drawCallback = defaultDrawCallback; - // else - // drawCallback = (void (*)(uint8_t*, uint16_t, uint16_t))callback; + if(callback == NULL) + drawCallback = defaultDrawCallback; + else + drawCallback = (void (*)(uint8_t*, uint16_t, uint16_t))callback; } -Graphics::Graphics() : - screen(OLED_WIDTH, OLED_HEIGHT) - // drawCallback(defaultDrawCallback) -{ +Graphics::Graphics(ParameterController& params) : + screen(OLED_WIDTH, OLED_HEIGHT), params(params), + drawCallback(defaultDrawCallback) { + screen.clear(); } __weak void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height){ - graphics.params.drawTitle(graphics.screen); - graphics.params.drawMessage(26, graphics.screen); + ScreenBuffer screen = graphics.screen; + + // draw title + screen.setTextSize(2); + screen.print(0, 16, graphics.params.getTitle()); + + // draw program message, if set + ProgramVector* pv = getProgramVector(); + if(pv != NULL && pv->message != NULL){ + screen.setTextSize(1); + screen.setTextWrap(true); + screen.print(0, 26, pv->message); + screen.setTextWrap(false); + } } diff --git a/Source/Graphics.h b/Source/Graphics.h index 698553b8..11e76060 100644 --- a/Source/Graphics.h +++ b/Source/Graphics.h @@ -4,32 +4,19 @@ #include #include "device.h" #include "ScreenBuffer.h" - -#if defined OWL_RACK -#include "BollardsParameterController.hpp" -#elif defined OWL_MAGUS -#include "MagusParameterController.hpp" -#elif defined OWL_PRISM -#include "PrismParameterController.hpp" -#elif defined OWL_EFFECTSBOX -#include "EffectsBoxParameterController.hpp" -#elif defined OWL_GENIUS -#include "GeniusParameterController.hpp" -#elif defined OWL_XIBECA -#include "XibecaParameterController.hpp" -#else #include "ParameterController.hpp" -#endif class Graphics { public: - Graphics(); - void begin(SPI_HandleTypeDef *spi); + Graphics(ParameterController& params); + void begin(SPI_HandleTypeDef* spi); void display(); void draw(); - void setCallback(void *callback); - ParameterController params; + void reset(); + void setCallback(void* callback); ScreenBuffer screen; + ParameterController& params; + void (*drawCallback)(uint8_t* pixels, uint16_t width, uint16_t height); private: uint8_t pixelbuffer[OLED_BUFFER_SIZE]; }; diff --git a/Source/HAL_Encoders.c b/Source/HAL_Encoders.c index 81480512..9a26f7cf 100644 --- a/Source/HAL_Encoders.c +++ b/Source/HAL_Encoders.c @@ -52,3 +52,10 @@ void Encoders_init (SPI_HandleTypeDef *spiconfig) pbarRST(1); } +void Encoders_reset(void){ + pbarRST(0); + volatile uint16_t x = NOP_CNT; + while(--x){__NOP();} + pbarRST(1); +} + diff --git a/Source/HAL_Encoders.h b/Source/HAL_Encoders.h index d675cdd5..04454b27 100644 --- a/Source/HAL_Encoders.h +++ b/Source/HAL_Encoders.h @@ -13,6 +13,7 @@ void Encoders_readAll(void); void Encoders_readSwitches(void); void Encoders_init (SPI_HandleTypeDef *spiconfig); int16_t* Encoders_get(); +void Encoders_reset(void); #ifdef __cplusplus } diff --git a/Source/MagusParameterController.hpp b/Source/MagusParameterController.hpp index e62778f2..b8ae86e7 100644 --- a/Source/MagusParameterController.hpp +++ b/Source/MagusParameterController.hpp @@ -1,10 +1,10 @@ -#ifndef __ParameterController_hpp__ -#define __ParameterController_hpp__ +#ifndef __MagusParameterController_hpp__ +#define __MagusParameterController_hpp__ #include "device.h" #include "errorhandlers.h" #include "ProgramVector.h" -// #include "HAL_Encoders.h" +#include "HAL_Encoders.h" #include "Owl.h" #include "OpenWareMidiControl.h" #include "PatchRegistry.h" @@ -17,8 +17,6 @@ #include "ScreenBuffer.h" #include "HAL_TLC5946.h" -void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height); - #define NOF_ENCODERS 6 #define ENC_MULTIPLIER 6 // shift left by this many steps #define SHOW_CALIBRATION_INFO // This flag renders current values in calibration menu @@ -38,6 +36,14 @@ void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height); extern VersionToken* bootloader_token; + +#define PORT_UNI_INPUT 1 +#define PORT_UNI_OUTPUT 2 +#define PORT_BI_INPUT 3 +#define PORT_BI_OUTPUT 4 +void setPortMode(uint8_t index, uint8_t mode); +uint8_t getPortMode(uint8_t index); + /* screen 128 x 64, font 5x7 4 blocks, 32px per each, 3-4 letters each @@ -54,11 +60,8 @@ press again to select parameter: select > update - select global parameter - select preset mode */ -template -class ParameterController { +class MagusParameterController : public ParameterController { public: - char title[11] = "Magus"; - enum EncoderSensitivity { SENS_SUPER_FINE = 0, SENS_FINE = (ENC_MULTIPLIER / 2), @@ -70,11 +73,10 @@ class ParameterController { // Sensitivity is currently not stored in settings, but it's not reset either. bool sensitivitySelected; - int16_t parameters[SIZE]; int16_t encoders[NOF_ENCODERS]; // last seen encoder values int16_t offsets[NOF_ENCODERS]; // last seen encoder values - int16_t user[SIZE]; // user set values (ie by encoder or MIDI) - char names[SIZE][12]; + int16_t user[NOF_PARAMETERS]; // user set values (ie by encoder or MIDI) + char names[NOF_PARAMETERS][12]; // char blocknames[4][NOF_ENCODERS] = {"OSC", "FLT", "ENV", "LFO"} ; // 4 times up to 5 letters/32px uint8_t selectedBlock; uint8_t selectedPid[NOF_ENCODERS]; @@ -110,14 +112,15 @@ class ParameterController { "< LEDs >", "< V/Oct " }; - ParameterController(){ + MagusParameterController(){ reset(); } void reset(){ + setTitle("Magus"); + Encoders_reset(); saveSettings = false; resourceDelete = false; - drawCallback = defaultDrawCallback; - for(int i=0; i> encoderSensitivity); } - void draw(uint8_t* pixels, uint16_t width, uint16_t height){ - ScreenBuffer screen(width, height); - screen.setBuffer(pixels); - draw(screen); - } - - void drawLoadProgress(uint8_t progress, ScreenBuffer &screen){ - // progress should be 0 - 127 - screen.drawRectangle(0, 30, 128, 20, WHITE); - screen.setCursor(32, 40); - screen.setTextSize(1); - screen.print("Uploading..."); - screen.fillRectangle(0, 44, progress, 5, WHITE); + void drawLoadProgress(ScreenBuffer &screen){ + extern char* progress_message; + extern uint16_t progress_counter; + // uint16_t progress_counter = user[LOAD_INDICATOR_PARAMETER]; + if(progress_message != NULL && progress_counter != 4095){ + // if(progress_counter && progress_counter != 4095){ + screen.drawRectangle(0, 30, 128, 20, WHITE); + screen.setCursor(32, 40); + screen.setTextSize(1); + screen.print(progress_message); + screen.fillRectangle(0, 44, progress_counter * 127 / 4095, 5, WHITE); + } } void drawParameter(int pid, int y, ScreenBuffer& screen){ @@ -202,7 +204,7 @@ class ParameterController { if(selectedPid[0] > 0) screen.print(1, 24, names[selectedPid[0]-1]); screen.print(1, 24+10, names[selectedPid[0]]); - if(selectedPid[0] < SIZE-1) + if(selectedPid[0] < NOF_PARAMETERS-1) screen.print(1, 24+20, names[selectedPid[0]+1]); screen.invert(0, 25, 64, 10); } @@ -388,7 +390,7 @@ class ParameterController { void drawPresetNames(uint8_t selected, ScreenBuffer& screen){ screen.setTextSize(1); - selected = min(selected, registry.getNumberOfPatches()-1); + selected = min(selected, (int)registry.getNumberOfPatches()-1); if(selected > 1) { screen.setCursor(1, 24); screen.print((int)selected - 1); @@ -411,9 +413,9 @@ class ParameterController { void drawResourceNames(int selected, ScreenBuffer &screen) { screen.setTextSize(1); if (resourceDelete) - selected = min(selected, registry.getNumberOfResources()); + selected = min(selected, (int)registry.getNumberOfResources()); else - selected = min(selected, registry.getNumberOfResources() - 1); + selected = min(selected, (int)registry.getNumberOfResources() - 1); if (resourceDelete && selected == 0) screen.print(18, 24, "Delete:"); if (selected > 0 && registry.getNumberOfResources() > 0) { @@ -616,13 +618,13 @@ class ParameterController { // draw most recently changed parameter // drawParameter(selectedPid[selectedBlock], 44, screen); if (owl.getOperationMode() == LOAD_MODE){ - drawLoadProgress(user[LOAD_INDICATOR_PARAMETER] * 127 / 4095, screen); + drawLoadProgress(screen); } else { drawParameter(selectedPid[selectedBlock], 54, screen); } // use callback to draw title and message - drawCallback(screen.getBuffer(), screen.getWidth(), screen.getHeight()); + graphics.drawCallback(screen.getBuffer(), screen.getWidth(), screen.getHeight()); break; case SELECTBLOCKPARAMETER: drawTitle(screen); @@ -645,7 +647,7 @@ class ParameterController { } void setName(uint8_t pid, const char* name){ - if(pid < SIZE){ + if(pid < NOF_PARAMETERS){ strncpy(names[pid], name, 11); #ifdef OWL_MAGUS if(names[pid][strnlen(names[pid], 11)-1] == '>') @@ -661,7 +663,7 @@ class ParameterController { } uint8_t getSize(){ - return SIZE; + return NOF_PARAMETERS; } void selectBlockParameter(uint8_t enc, int8_t pid){ @@ -675,7 +677,7 @@ class ParameterController { } void selectGlobalParameter(int8_t pid){ - selectedPid[0] = max(0, min(SIZE-1, pid)); + selectedPid[0] = max(0, min(NOF_PARAMETERS-1, pid)); setEncoderValue(0, user[selectedPid[0]]); } @@ -1052,6 +1054,10 @@ class ParameterController { parameters[pid] = max(0, min(4095, (parameters[pid] + user[pid] + value)>>1)); } + int16_t getValue(uint8_t pid){ + return parameters[pid]; + } + void updateOutput(uint8_t pid, int16_t value){ parameters[pid] = max(0, min(4095, (((parameters[pid] + (user[pid]*value))>>12)>>1))); } @@ -1061,17 +1067,14 @@ class ParameterController { // parameters[selectedPid[i]] = encoders[i] + data[i]; // } - void encoderChanged(uint8_t encoder, int32_t delta){ - } - + // void encoderChanged(uint8_t encoder, int32_t delta){ + // } - void setCallback(void *callback){ - if(callback == NULL) - drawCallback = defaultDrawCallback; - else - drawCallback = (void (*)(uint8_t*, uint16_t, uint16_t))callback; - } - void (*drawCallback)(uint8_t*, uint16_t, uint16_t); + // void draw(uint8_t* pixels, uint16_t width, uint16_t height){ + // ScreenBuffer screen(width, height); + // screen.setBuffer(pixels); + // draw(screen); + // } }; -#endif // __ParameterController_hpp__ +#endif // __MagusParameterController_hpp__ diff --git a/Source/Owl.cpp b/Source/Owl.cpp index dc5826e7..d555e352 100644 --- a/Source/Owl.cpp +++ b/Source/Owl.cpp @@ -328,6 +328,9 @@ void Owl::setMessageCallback(void* callback){ messageCallback = (void (*)(const char* msg, size_t len))callback; } +/** + * This method should not be called from an irq handler + */ void Owl::handleMessage(const char* msg, size_t len){ if(messageCallback != NULL) messageCallback(msg, len); diff --git a/Source/Owl.h b/Source/Owl.h index f07210af..e934ccea 100644 --- a/Source/Owl.h +++ b/Source/Owl.h @@ -38,15 +38,6 @@ extern "C" { void midiSetInputChannel(int8_t channel); void midiSetOutputChannel(int8_t channel); - -#ifdef OWL_MAGUS -#define PORT_UNI_INPUT 1 -#define PORT_UNI_OUTPUT 2 -#define PORT_BI_INPUT 3 -#define PORT_BI_OUTPUT 4 - void setPortMode(uint8_t index, uint8_t mode); - uint8_t getPortMode(uint8_t index); -#endif /* OWL_MAGUS */ int16_t getParameterValue(uint8_t index); void setParameterValue(uint8_t ch, int16_t value); diff --git a/Source/ParameterController.hpp b/Source/ParameterController.hpp index 61e55409..44502344 100644 --- a/Source/ParameterController.hpp +++ b/Source/ParameterController.hpp @@ -5,6 +5,61 @@ #include "errorhandlers.h" #include "ProgramVector.h" +class ParameterController { +protected: + char title[11]; + int16_t parameters[NOF_PARAMETERS]; +public: + // ParameterController(); + virtual void reset(){} + virtual void draw(ScreenBuffer& screen) = 0; + virtual void updateEncoders(int16_t* data, uint8_t size) = 0; + virtual void updateValue(uint8_t pid, int16_t value) = 0; + virtual void setValue(uint8_t pid, int16_t value) = 0; + virtual void setName(uint8_t pid, const char* name) = 0; + int16_t getValue(uint8_t pid){ + return parameters[pid]; + } + int16_t* getParameters(){ + return parameters; + } + size_t getSize(){ + return NOF_PARAMETERS; + } + void setTitle(const char* str){ + strncpy(title, str, sizeof(title)-1); + } + const char* getTitle(){ + return title; + } +}; + + +#if 0 +class Page { +public: + virtual void draw(ScreenBuffer& screen){} + void updateEncoders(int16_t* data, uint8_t size); + void enter(); + void exit(); +}; + +class SensitivityPage : public Page { +public: + void draw(ScreenBuffer& screen){ + } +}; + +class PageManager { +private: + Page* page; +public: + virtual void draw(ScreenBuffer& screen){} + void updateEncoders(int16_t* data, uint8_t size); +}; +#endif + +#if 0 void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height); /* shows a single parameter selected and controlled with a single encoder @@ -137,5 +192,6 @@ class ParameterController { return HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_4) != GPIO_PIN_SET; } }; +#endif #endif // __ParameterController_hpp__ diff --git a/Source/ProgramManager.cpp b/Source/ProgramManager.cpp index 3d56d0c9..3d1f15de 100644 --- a/Source/ProgramManager.cpp +++ b/Source/ProgramManager.cpp @@ -223,7 +223,7 @@ void onProgramStatus(ProgramVectorAudioStatus status){ __weak int16_t getParameterValue(uint8_t pid){ if(pid < NOF_PARAMETERS) #ifdef USE_SCREEN - return graphics.params.parameters[pid]; + return graphics.params.getValue(pid); #else return parameter_values[pid]; #endif @@ -235,7 +235,6 @@ __weak void setParameterValue(uint8_t pid, int16_t value){ if(pid < NOF_PARAMETERS) #ifdef USE_SCREEN graphics.params.setValue(pid, value); - // graphics.params.parameters[pid] = value; #else parameter_values[pid] = value; #endif @@ -283,7 +282,7 @@ void onProgramReady(){ #endif #ifdef USE_ADC #ifdef USE_SCREEN - updateParameters(graphics.params.parameters, NOF_PARAMETERS, adc_values, NOF_ADC_VALUES); + updateParameters(graphics.params.getParameters(), graphics.params.getSize(), adc_values, NOF_ADC_VALUES); #else updateParameters(parameter_values, NOF_PARAMETERS, adc_values, NOF_ADC_VALUES); #endif @@ -342,7 +341,7 @@ void updateProgramVector(ProgramVector* pv, PatchDefinition* def){ pv->checksum = PROGRAM_VECTOR_CHECKSUM; #ifdef USE_SCREEN pv->parameters_size = graphics.params.getSize(); - pv->parameters = graphics.params.parameters; + pv->parameters = graphics.params.getParameters(); #else pv->parameters_size = NOF_PARAMETERS; pv->parameters = parameter_values; @@ -502,7 +501,7 @@ void sendResourceTask(void* p){ __weak void onStartProgram(){ #ifdef USE_SCREEN - graphics.params.reset(); + graphics.reset(); #endif #ifndef USE_SCREEN memset(parameter_values, 0, sizeof(parameter_values)); diff --git a/Source/callbacks.h b/Source/callbacks.h index b92a3189..8e11d473 100644 --- a/Source/callbacks.h +++ b/Source/callbacks.h @@ -1,5 +1,6 @@ #ifndef __CALLBACKS_H__ #define __CALLBACKS_H__ + #include #ifdef __cplusplus @@ -26,15 +27,15 @@ extern "C" { void setGateValue(uint8_t bid, int16_t value); void onChangePin(uint16_t pin); void onChangeMode(OperationMode new_mode, OperationMode old_mode); + void onStartProgram(); // sets a progress bar (if available) to a value from 0 to 4095 void setProgress(uint16_t value, const char* reason); void onResourceUpdate(void); void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* adc_values, size_t adc_len); - int16_t getParameterValue(uint8_t pid); - void setParameterValue(uint8_t pid, int16_t value); - - void onStartProgram(); +#ifdef USE_SCREEN + void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height); +#endif #ifdef __cplusplus } /* extern C */ From e5e31a9a089cdcc31d80a2f59919ec92f2d626ad Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 22 Oct 2021 22:24:41 +0200 Subject: [PATCH 132/286] Genius screen refactor with pages --- Genius/Inc/GeniusParameterController.hpp | 347 ++++++++++++++++------- Genius/Src/Genius.cpp | 103 ++++--- Magus/Src/Magus.cpp | 30 +- Source/Graphics.cpp | 25 +- Source/Graphics.h | 6 +- Source/Owl.cpp | 4 +- Source/ParameterController.hpp | 29 +- Source/ProgramManager.cpp | 26 +- Source/ServiceCall.cpp | 2 + 9 files changed, 378 insertions(+), 194 deletions(-) diff --git a/Genius/Inc/GeniusParameterController.hpp b/Genius/Inc/GeniusParameterController.hpp index 614fd8a4..6bea704d 100644 --- a/Genius/Inc/GeniusParameterController.hpp +++ b/Genius/Inc/GeniusParameterController.hpp @@ -28,73 +28,204 @@ extern VersionToken* bootloader_token; #define NOF_ENCODERS 2 -/** - *shows a single parameter selected and controlled with a single encoder - */ +enum DisplayMode { + STANDARD_DISPLAY_MODE, CONFIGURATION_DISPLAY_MODE, PROGRESS_DISPLAY_MODE, SELECT_ONE_DISPLAY_MODE, SELECT_TWO_DISPLAY_MODE, ERROR_DISPLAY_MODE +}; +// DisplayMode displayMode; +void setDisplayMode(DisplayMode mode); + +class Page { +public: + virtual void draw(ScreenBuffer& screen){} + // virtual void updateEncoders(int16_t* data, uint8_t size){} + virtual void enter(){} + virtual void exit(){} + virtual void encoderChanged(uint8_t encoder, int32_t delta){} +}; + class GeniusParameterController : public ParameterController { +private: public: - char names[NOF_PARAMETERS][12]; - int8_t selected = 0; + Page* page; int16_t encoders[NOF_ENCODERS]; // last seen encoder values - int16_t user[NOF_PARAMETERS]; // user set values (ie by encoder or MIDI) - GeniusParameterController(){ + int16_t user[NOF_ADC_VALUES]; // user set values (ie by encoder or MIDI) + // for assignable CV / modulations + // int16_t user[NOF_PARAMETERS]; // user set values (ie by encoder or MIDI) + GeniusParameterController() { encoders[0] = INT16_MAX/2; encoders[1] = INT16_MAX/2; reset(); + setDisplayMode(PROGRESS_DISPLAY_MODE); } void reset(){ setTitle("Genius"); - for(int i=0; idraw(screen); + } + void updateEncoders(int16_t* data, uint8_t size){ + if(data[0] != encoders[0]){ + encoderChanged(0, data[0] - encoders[0]); + encoders[0] = data[0]; + } + if(data[1] != encoders[1]){ + encoderChanged(1, data[1] - encoders[1]); + encoders[1] = data[1]; + } + } + void encoderChanged(uint8_t encoder, int32_t delta){ + page->encoderChanged(encoder, delta); + } + // update value with encoder + void setUserValue(uint8_t ch, int16_t value){ + if(ch < NOF_ADC_VALUES){ + user[ch] = value; }else{ - graphics.drawCallback(screen.getBuffer(), screen.getWidth(), screen.getHeight()); - screen.setTextSize(1); - screen.print(2, 56, names[selected]); - screen.print(": "); - screen.print((int)parameters[selected]/41); + parameters[ch] = value; } } + // @param value is the modulation ADC value + void updateValues(int16_t* values, size_t len){ + for(size_t pid=0; pid>1)); + // parameters[pid] = max(0, min(4095, (2*parameters[pid] + user[pid] + values[pid])>>2)); + } + // void updateValue(uint8_t pid, int16_t value){ + // // smoothing at apprx 50Hz + // parameters[pid] = max(0, min(4095, (parameters[pid] + user[pid] + value)>>1)); + // } + // update value from patch or MIDI + // void setValue(uint8_t ch, int16_t value){ + // parameters[ch] = value; + // } + // int16_t getValue(uint8_t pid){ + // return parameters[pid]; + // } +private: +}; + +static bool sw1(){ + return HAL_GPIO_ReadPin(ENC1_SW_GPIO_Port, ENC1_SW_Pin) != GPIO_PIN_SET; +} +static bool sw2(){ + return HAL_GPIO_ReadPin(ENC2_SW_GPIO_Port, ENC2_SW_Pin) != GPIO_PIN_SET; +} +static bool sw(uint8_t ctrl){ + return ctrl == 0 ? sw1() : sw2(); +} - void drawParameterNames(int y, int pid, const char names[][12], int size, ScreenBuffer& screen){ +extern GeniusParameterController params; + +class SelectControlPage : public Page { + const uint8_t ctrl; + size_t counter; // ticks since switch was pressed down + static constexpr size_t TOGGLE_LIMIT = (600/MAIN_LOOP_SLEEP_MS); +public: + int8_t select; + SelectControlPage(uint8_t ctrl, int8_t select): ctrl(ctrl), select(select){} + void enter(){ + counter = 0; + } + void encoderChanged(uint8_t encoder, int32_t delta){ + if(encoder == ctrl){ + // select = max(0, min(NOF_PARAMETERS-1, select+delta)); + if(delta > 0) + select = min(NOF_PARAMETERS-1, select+1); + else if(delta < 0) + select = max(0, select-1); + } + } + void draw(ScreenBuffer& screen){ + if(!sw(ctrl)){ + // encoder switch released + if(counter < TOGGLE_LIMIT){ + setDisplayMode(CONFIGURATION_DISPLAY_MODE); + }else{ + setDisplayMode(STANDARD_DISPLAY_MODE); + } + }else{ + counter++; + } + drawGlobalParameterNames(42, screen); + } + + void drawParameterNames(int y, int pid, int size, ScreenBuffer& screen){ screen.setTextSize(1); - // int selected = selectedPid[pid]; - if(selected > 2) - screen.print(1, y-30, names[selected-3]); - if(selected > 1) - screen.print(1, y-20, names[selected-2]); - if(selected > 0) - screen.print(1, y-10, names[selected-1]); - screen.print(1, y, names[selected]); - if(selected < size-1) - screen.print(1, y+10, names[selected+1]); - if(selected < size-2) - screen.print(1, y+20, names[selected+2]); - if(selected < size-3) - screen.print(1, y+30, names[selected+3]); + // int select = selectPid[pid]; + if(select > 2) + screen.print(1, y-30, params.getName(select-3)); + if(select > 1) + screen.print(1, y-20, params.getName(select-2)); + if(select > 0) + screen.print(1, y-10, params.getName(select-1)); + screen.print(1, y, params.getName(select)); + if(select < size-1) + screen.print(1, y+10, params.getName(select+1)); + if(select < size-2) + screen.print(1, y+20, params.getName(select+2)); + if(select < size-3) + screen.print(1, y+30, params.getName(select+3)); screen.invert(0, y-9, screen.getWidth(), 10); } - void drawGlobalParameterNames(int y, ScreenBuffer& screen){ - drawParameterNames(y, 0, names, NOF_PARAMETERS, screen); + void drawGlobalParameterNames(int y, ScreenBuffer& screen){ + drawParameterNames(y, 0, NOF_PARAMETERS, screen); + } +}; + +class ProgressPage : public Page { + void draw(ScreenBuffer& screen){ + drawLoadProgress(screen); + } + void drawLoadProgress(ScreenBuffer &screen){ + extern char* progress_message; + extern uint16_t progress_counter; + // uint16_t progress_counter = user[LOAD_INDICATOR_PARAMETER]; + screen.drawRectangle(0, 30, 128, 20, WHITE); + // if(progress_counter != 4095) + screen.fillRectangle(0, 44, progress_counter * 127 / 4095, 5, WHITE); + screen.setCursor(33, 40); + screen.setTextSize(1); + if(progress_message == NULL) + screen.print("Loading"); + else + screen.print(progress_message); + } +}; + +class ErrorPage : public Page { + void draw(ScreenBuffer& screen){ + if(sw1()) + setErrorStatus(0); + if(getErrorStatus() == NO_ERROR){ + setDisplayMode(STANDARD_DISPLAY_MODE); + }else{ + screen.setTextSize(2); + screen.print(1, 17, "ERROR"); + if(getErrorMessage() != NULL){ + screen.setTextSize(1); + screen.print(2, 25, getErrorMessage()); + } + } } +}; +class StatsPage : public Page { +public: + void encoderChanged(uint8_t encoder, int32_t delta){} + void draw(ScreenBuffer& screen){ + if(sw1() || sw2()){ + setDisplayMode(STANDARD_DISPLAY_MODE); + }else{ + drawStats(screen); + } + } void drawStats(ScreenBuffer& screen){ screen.setTextSize(1); ProgramVector* pv = getProgramVector(); @@ -106,7 +237,6 @@ class GeniusParameterController : public ParameterController { screen.print("% "); screen.print((int)(pv->heap_bytes_used)/1024); screen.print("kB"); - // draw firmware version screen.print(1, 36, getFirmwareVersion()); if (bootloader_token->magic == BOOTLOADER_MAGIC){ @@ -128,81 +258,78 @@ class GeniusParameterController : public ParameterController { } #endif } +}; - void updateEncoders(int16_t* data, uint8_t size){ - if(data[0] != encoders[0]){ - encoderChanged(0, data[0] - encoders[0]); - encoders[0] = data[0]; - } - if(data[1] != encoders[1]){ - encoderChanged(1, data[1] - encoders[1]); - encoders[1] = data[1]; - } - } +SelectControlPage selectOnePage(0, 0); +SelectControlPage selectTwoPage(1, 1); +class StandardPage : public Page { +public: void encoderChanged(uint8_t encoder, int32_t delta){ - if(encoder == 1){ - if(sw2()){ - if(delta > 1) - selected = min(NOF_PARAMETERS-1, selected+1); - else if(delta < 1) - selected = max(0, selected-1); - }else{ - // single clicks have delta +/- 2 - // parameters[selected] += delta*4095/200; - if(delta > 0) - parameters[selected] += 20 << (delta/2); - else - parameters[selected] -= 20 << (-delta/2); - parameters[selected] = min(4095, max(0, parameters[selected])); - } - } // todo: change patch with enc1/sw1 - } - void setName(uint8_t pid, const char* name){ - if(pid < NOF_PARAMETERS) - strncpy(names[pid], name, 11); + int select = encoder == 0 ? selectOnePage.select : selectTwoPage.select; + if(delta > 0) + delta = 20 << (delta/2); + else + delta = -20 << (-delta/2); + delta = min(802, max(-802, delta)); // max rate of change +/- 20% + params.setUserValue(select, min(4095, max(0, params.getValue(select) + delta))); } - void setValue(uint8_t ch, int16_t value){ - parameters[ch] = value; - } - - void drawMessage(int16_t y, ScreenBuffer& screen){ - ProgramVector* pv = getProgramVector(); - if(pv->message != NULL){ + void draw(ScreenBuffer& screen){ + if(sw1()){ + setDisplayMode(SELECT_ONE_DISPLAY_MODE); + }else if(sw2()){ + setDisplayMode(SELECT_TWO_DISPLAY_MODE); + }else{ + int s1 = selectOnePage.select; + int s2 = selectTwoPage.select; screen.setTextSize(1); - screen.setTextWrap(true); - screen.print(0, y, pv->message); - screen.setTextWrap(false); - } - } - - void drawTitle(ScreenBuffer& screen){ - drawTitle(title, screen); - } - - void drawTitle(const char* title, ScreenBuffer& screen){ - // draw title - screen.setTextSize(2); - screen.print(1, 17, title); + screen.print(2, 56, params.getName(s1)); + screen.print(": "); + screen.print((int)params.getValue(s1)/41); + screen.print(2, 64, params.getName(s2)); + screen.print(": "); + screen.print((int)params.getValue(s2)/41); + graphics.drawCallback(screen.getBuffer(), screen.getWidth(), screen.getHeight()); + } } +}; - // @param value is the modulation ADC value - void updateValue(uint8_t pid, int16_t value){ - // smoothing at apprx 50Hz - parameters[pid] = max(0, min(4095, (parameters[pid] + user[pid] + value)>>1)); - } +StandardPage standardPage; +ProgressPage progressPage; +ErrorPage errorPage; +StatsPage configurationPage; - int16_t getValue(uint8_t pid){ - return parameters[pid]; +void changePage(Page* page){ + if(params.page != page){ + if(params.page != NULL) + params.page->exit(); + params.page = page; + if(page != NULL) + page->enter(); } +} -private: - bool sw1(){ - return HAL_GPIO_ReadPin(ENC1_SW_GPIO_Port, ENC1_SW_Pin) != GPIO_PIN_SET; - } - bool sw2(){ - return HAL_GPIO_ReadPin(ENC2_SW_GPIO_Port, ENC2_SW_Pin) != GPIO_PIN_SET; +void setDisplayMode(DisplayMode mode){ + switch(mode){ + case STANDARD_DISPLAY_MODE: + changePage(&standardPage); + break; + case CONFIGURATION_DISPLAY_MODE: + changePage(&configurationPage); + break; + case PROGRESS_DISPLAY_MODE: + changePage(&progressPage); + break; + case SELECT_ONE_DISPLAY_MODE: + changePage(&selectOnePage); + break; + case SELECT_TWO_DISPLAY_MODE: + changePage(&selectTwoPage); + break; + case ERROR_DISPLAY_MODE: + changePage(&errorPage); + break; } -}; +} #endif // __GeniusParameterController_hpp__ diff --git a/Genius/Src/Genius.cpp b/Genius/Src/Genius.cpp index 13dbff13..b4bc5adb 100644 --- a/Genius/Src/Genius.cpp +++ b/Genius/Src/Genius.cpp @@ -5,37 +5,6 @@ #include "Pin.h" #include "GeniusParameterController.hpp" -#ifdef DEBUG_USBD_AUDIO -void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height){ - extern int usbd_tx_flow; - extern int usbd_rx_flow; - extern int usbd_tx_capacity; - extern int usbd_rx_capacity; - ScreenBuffer& screen = graphics.screen; - graphics.params.drawTitle(screen); - graphics.params.drawMessage(26, screen); - - screen.setTextSize(1); - screen.print(2, 36, "rx "); - screen.print(usbd_rx_flow); - screen.print(" / "); - screen.print(usbd_rx_capacity); - screen.print(2, 46, "tx "); - screen.print(usbd_tx_flow); - screen.print(" / "); - screen.print(usbd_tx_capacity); -} -// #else -// void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height){ -// ScreenBuffer& screen = graphics.screen; -// graphics.params.drawTitle(screen); -// graphics.params.drawMessage(26, screen); - -// screen.setTextSize(1); -// encoder_values -// } -#endif - extern "C"{ #if 0 void eeprom_unlock(){} @@ -70,10 +39,36 @@ extern TIM_HandleTypeDef ENCODER_TIM2; Pin tr_out_a_pin(GPIOD, GPIO_PIN_3); Pin tr_out_b_pin(GPIOD, GPIO_PIN_4); -static GeniusParameterController params; -Graphics graphics(params); +GeniusParameterController params; +Graphics graphics; + +char* progress_message = NULL; +uint16_t progress_counter = 0; + +void setProgress(uint16_t value, const char* reason){ + progress_message = (char*)reason; + progress_counter = value; +} + +void onChangeMode(OperationMode new_mode, OperationMode old_mode){ + switch(new_mode){ + case STARTUP_MODE: + case STREAM_MODE: + case LOAD_MODE: + case CONFIGURE_MODE: + setDisplayMode(PROGRESS_DISPLAY_MODE); + break; + case RUN_MODE: + setDisplayMode(STANDARD_DISPLAY_MODE); + break; + case ERROR_MODE: + setDisplayMode(ERROR_DISPLAY_MODE); + break; + } +} void setup(){ + progress_counter = 100; tr_out_a_pin.outputMode(); tr_out_b_pin.outputMode(); tr_out_a_pin.high(); @@ -81,7 +76,9 @@ void setup(){ HAL_GPIO_WritePin(OLED_RST_GPIO_Port, OLED_RST_Pin, GPIO_PIN_RESET); // OLED off extern SPI_HandleTypeDef OLED_SPI; - graphics.begin(&OLED_SPI); + graphics.begin(¶ms, &OLED_SPI); + + progress_counter = 1000; #ifdef USE_USB_HOST // enable USB Host power @@ -93,7 +90,9 @@ void setup(){ HAL_TIM_Encoder_Start_IT(&ENCODER_TIM1, TIM_CHANNEL_ALL); HAL_TIM_Encoder_Start_IT(&ENCODER_TIM2, TIM_CHANNEL_ALL); + progress_counter = 2000; owl.setup(); + progress_counter = 4000; } void setGateValue(uint8_t ch, int16_t value){ @@ -158,8 +157,9 @@ extern "C"{ void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* adc_values, size_t adc_len){ // graphics.params.parameters - graphics.params.updateValue(0, adc_values[0]); - graphics.params.updateValue(1, adc_values[1]); + params.updateValues((int16_t*)adc_values, adc_len); + // graphics.params.updateValue(0, adc_values[0]); + // graphics.params.updateValue(1, adc_values[1]); // parameter_values[0] = adc_values[0]; // todo: sum with user / encoder setting // parameter_values[1] = adc_values[1]; } @@ -206,3 +206,34 @@ void loop(void){ owl.loop(); } + +#ifdef DEBUG_USBD_AUDIO +void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height){ + extern int usbd_tx_flow; + extern int usbd_rx_flow; + extern int usbd_tx_capacity; + extern int usbd_rx_capacity; + ScreenBuffer& screen = graphics.screen; + params.drawTitle(screen); + params.drawMessage(26, screen); + + screen.setTextSize(1); + screen.print(2, 36, "rx "); + screen.print(usbd_rx_flow); + screen.print(" / "); + screen.print(usbd_rx_capacity); + screen.print(2, 46, "tx "); + screen.print(usbd_tx_flow); + screen.print(" / "); + screen.print(usbd_tx_capacity); +} +// #else +// void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height){ +// ScreenBuffer& screen = graphics.screen; +// params.drawTitle(screen); +// params.drawMessage(26, screen); + +// screen.setTextSize(1); +// encoder_values +// } +#endif diff --git a/Magus/Src/Magus.cpp b/Magus/Src/Magus.cpp index 87346b4b..c6dceb2c 100644 --- a/Magus/Src/Magus.cpp +++ b/Magus/Src/Magus.cpp @@ -17,8 +17,8 @@ const uint32_t* dyn_rainbowinputs = rainbowinputs; const uint32_t* dyn_rainbowoutputs = rainbowoutputs; -static MagusParameterController params; -Graphics graphics(params); +MagusParameterController params; +Graphics graphics; extern "C" void onResourceUpdate(void); @@ -120,7 +120,7 @@ void setup(){ HAL_GPIO_WritePin(OLED_RST_GPIO_Port, OLED_RST_Pin, GPIO_PIN_RESET); // OLED off extern SPI_HandleTypeDef OLED_SPI; - graphics.begin(&OLED_SPI); + graphics.begin(¶ms, &OLED_SPI); #ifdef USE_USB_HOST // enable USB Host power @@ -181,34 +181,34 @@ void loop(void){ TLC5946_Refresh_GS(); #endif Encoders_readAll(); - graphics.params.updateEncoders(Encoders_get(), 7); + params.updateEncoders(Encoders_get(), 7); MAX11300_bulkreadADC(); for(int i=0; i<16; ++i){ if(getPortMode(i) == PORT_UNI_INPUT){ - graphics.params.updateValue(i, MAX11300_getADCValue(i+1)); - uint16_t val = graphics.params.getValue(i)>>2; + params.updateValue(i, MAX11300_getADCValue(i+1)); + uint16_t val = params.getValue(i)>>2; setLed(i, dyn_rainbowinputs[val&0x3ff]); }else{ // DACs // TODO: store values set from patch somewhere and multiply with user[] value for outputs - // graphics.params.updateOutput(i, getOutputValue(i)); - // MAX11300_setDACValue(i+1, graphics.params.parameters[i]); - graphics.params.updateValue(i, 0); - uint16_t val = graphics.params.getValue(i)>>2; + // params.updateOutput(i, getOutputValue(i)); + // MAX11300_setDACValue(i+1, params.parameters[i]); + params.updateValue(i, 0); + uint16_t val = params.getValue(i)>>2; setLed(i, dyn_rainbowoutputs[val&0x3ff]); - MAX11300_setDAC(i+1, graphics.params.getValue(i)); + MAX11300_setDAC(i+1, params.getValue(i)); } } for(int i=16; i<20; ++i){ if(getPortMode(i) == PORT_UNI_INPUT){ - graphics.params.updateValue(i, MAX11300_getADCValue(i+1)); + params.updateValue(i, MAX11300_getADCValue(i+1)); }else{ - graphics.params.updateValue(i, 0); - MAX11300_setDAC(i+1, graphics.params.getValue(i)); + params.updateValue(i, 0); + MAX11300_setDAC(i+1, params.getValue(i)); } } for(int i=20; i < NOF_PARAMETERS; i++) { - graphics.params.updateValue(i, 0); + params.updateValue(i, 0); } // MAX11300_bulkwriteDAC(); } diff --git a/Source/Graphics.cpp b/Source/Graphics.cpp index 08137f79..289e1f13 100644 --- a/Source/Graphics.cpp +++ b/Source/Graphics.cpp @@ -5,7 +5,14 @@ #include "callbacks.h" #include "ProgramVector.h" -void Graphics::begin(SPI_HandleTypeDef *spi) { +Graphics::Graphics() : + screen(OLED_WIDTH, OLED_HEIGHT), + drawCallback(defaultDrawCallback) { + screen.clear(); +} + +void Graphics::begin(ParameterController* pc, SPI_HandleTypeDef *spi) { + params = pc; oled_init(spi); screen.setBuffer(pixelbuffer); screen.clear(); @@ -18,19 +25,19 @@ void Graphics::display(){ void Graphics::draw(){ // drawCallback(pixelbuffer, OLED_WIDTH, OLED_HEIGHT); - // // params.draw(pixelbuffer, OLED_WIDTH, OLED_HEIGHT); - params.draw(screen); + // // params->draw(pixelbuffer, OLED_WIDTH, OLED_HEIGHT); + params->draw(screen); } // static void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height){ // graphics.screen.setBuffer(pixels); // graphics.screen.clear(); -// graphics.params.draw(graphics.screen); +// graphics.params->draw(graphics.screen); // } void Graphics::reset(){ drawCallback = defaultDrawCallback; - params.reset(); + params->reset(); } void Graphics::setCallback(void *callback){ @@ -40,18 +47,12 @@ void Graphics::setCallback(void *callback){ drawCallback = (void (*)(uint8_t*, uint16_t, uint16_t))callback; } -Graphics::Graphics(ParameterController& params) : - screen(OLED_WIDTH, OLED_HEIGHT), params(params), - drawCallback(defaultDrawCallback) { - screen.clear(); -} - __weak void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height){ ScreenBuffer screen = graphics.screen; // draw title screen.setTextSize(2); - screen.print(0, 16, graphics.params.getTitle()); + screen.print(0, 16, graphics.params->getTitle()); // draw program message, if set ProgramVector* pv = getProgramVector(); diff --git a/Source/Graphics.h b/Source/Graphics.h index 11e76060..7d0113a2 100644 --- a/Source/Graphics.h +++ b/Source/Graphics.h @@ -8,14 +8,14 @@ class Graphics { public: - Graphics(ParameterController& params); - void begin(SPI_HandleTypeDef* spi); + Graphics(); + void begin(ParameterController* params, SPI_HandleTypeDef* spi); void display(); void draw(); void reset(); void setCallback(void* callback); ScreenBuffer screen; - ParameterController& params; + ParameterController* params; void (*drawCallback)(uint8_t* pixels, uint16_t width, uint16_t height); private: uint8_t pixelbuffer[OLED_BUFFER_SIZE]; diff --git a/Source/Owl.cpp b/Source/Owl.cpp index d555e352..a5b4fc16 100644 --- a/Source/Owl.cpp +++ b/Source/Owl.cpp @@ -151,8 +151,6 @@ void Owl::setup(void){ codec.setOutputGain(settings.audio_output_gain); #endif /* USE_CODEC */ - program.startManager(); - #ifdef USE_DAC HAL_DAC_Start(&hdac, DAC_CHANNEL_1); HAL_DAC_Start(&hdac, DAC_CHANNEL_2); @@ -178,6 +176,8 @@ void Owl::setup(void){ bus_setup(); bus_set_input_channel(settings.midi_input_channel); #endif /* USE_DIGITALBUS */ + + program.startManager(); // calls bootstrap, loads patch } #ifdef USE_DIGITALBUS diff --git a/Source/ParameterController.hpp b/Source/ParameterController.hpp index 44502344..a7cdaecc 100644 --- a/Source/ParameterController.hpp +++ b/Source/ParameterController.hpp @@ -9,14 +9,33 @@ class ParameterController { protected: char title[11]; int16_t parameters[NOF_PARAMETERS]; + char names[NOF_PARAMETERS][12]; public: // ParameterController(); - virtual void reset(){} + virtual void reset(){ + for(int i=0; igetValue(pid); #else return parameter_values[pid]; #endif @@ -234,7 +234,7 @@ __weak int16_t getParameterValue(uint8_t pid){ __weak void setParameterValue(uint8_t pid, int16_t value){ if(pid < NOF_PARAMETERS) #ifdef USE_SCREEN - graphics.params.setValue(pid, value); + graphics.params->setValue(pid, value); #else parameter_values[pid] = value; #endif @@ -282,7 +282,7 @@ void onProgramReady(){ #endif #ifdef USE_ADC #ifdef USE_SCREEN - updateParameters(graphics.params.getParameters(), graphics.params.getSize(), adc_values, NOF_ADC_VALUES); + updateParameters(graphics.params->getParameters(), graphics.params->getSize(), adc_values, NOF_ADC_VALUES); #else updateParameters(parameter_values, NOF_PARAMETERS, adc_values, NOF_ADC_VALUES); #endif @@ -302,7 +302,7 @@ void onProgramReady(){ // called from program void onSetPatchParameter(uint8_t pid, int16_t value){ // #ifdef USE_SCREEN -// graphics.params.setDynamicValue(ch, value); +// graphics.params->setDynamicValue(ch, value); // #else // parameter_values[ch] = value; // #endif @@ -324,7 +324,7 @@ void onSetButton(uint8_t bid, uint16_t state, uint16_t samples){ // called from program void onRegisterPatchParameter(uint8_t id, const char* name){ #ifdef USE_SCREEN - graphics.params.setName(id, name); + graphics.params->setName(id, name); #endif /* USE_SCREEN */ midi_tx.sendPatchParameterName((PatchParameterId)id, name); } @@ -332,7 +332,7 @@ void onRegisterPatchParameter(uint8_t id, const char* name){ // called from program void onRegisterPatch(const char* name, uint8_t inputChannels, uint8_t outputChannels){ #if defined USE_SCREEN - graphics.params.setTitle(name); + graphics.params->setTitle(name); #endif /* OWL_MAGUS */ } @@ -340,8 +340,8 @@ void updateProgramVector(ProgramVector* pv, PatchDefinition* def){ pv->hardware_version = HARDWARE_ID; pv->checksum = PROGRAM_VECTOR_CHECKSUM; #ifdef USE_SCREEN - pv->parameters_size = graphics.params.getSize(); - pv->parameters = graphics.params.getParameters(); + pv->parameters_size = graphics.params->getSize(); + pv->parameters = graphics.params->getParameters(); #else pv->parameters_size = NOF_PARAMETERS; pv->parameters = parameter_values; @@ -711,11 +711,17 @@ void ProgramManager::updateProgramIndex(uint8_t index){ void ProgramManager::loadDynamicProgram(void* address, uint32_t length){ if(registry.loadProgram(address, length)) updateProgramIndex(0); + else + error(PROGRAM_ERROR, "Failed load"); } void ProgramManager::loadProgram(uint8_t pid){ - if(patchindex != pid && registry.loadProgram(pid)) - updateProgramIndex(pid); + if(patchindex != pid && registry.hasPatch(pid)){ + if(registry.loadProgram(pid)) + updateProgramIndex(pid); + else + error(PROGRAM_ERROR, "Failed load"); + } } #ifdef DEBUG_STACK diff --git a/Source/ServiceCall.cpp b/Source/ServiceCall.cpp index 429327ef..991f5343 100644 --- a/Source/ServiceCall.cpp +++ b/Source/ServiceCall.cpp @@ -7,6 +7,8 @@ #include "Storage.h" #include "Owl.h" +#include "cmsis_os.h" + #ifdef USE_FFT_TABLES #include "arm_const_structs.h" #endif /* USE_FFT_TABLES */ From b2b6cfa01aeee48d0b6e27ec0a7f6e2496aab3f4 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 25 Oct 2021 10:30:30 +0200 Subject: [PATCH 133/286] factored out BioSignals code --- BioSignals/Src/BioSignals.cpp | 94 +++++++++++++++++++++++++++++++++++ Source/Owl.cpp | 41 --------------- Source/callbacks.cpp | 75 +++++++--------------------- 3 files changed, 111 insertions(+), 99 deletions(-) create mode 100644 BioSignals/Src/BioSignals.cpp diff --git a/BioSignals/Src/BioSignals.cpp b/BioSignals/Src/BioSignals.cpp new file mode 100644 index 00000000..89708a36 --- /dev/null +++ b/BioSignals/Src/BioSignals.cpp @@ -0,0 +1,94 @@ +#include +#include +#include "device.h" +#include "Owl.h" + +#include "ads.h" +#ifdef USE_KX122 +#include "kx122.h" +#endif +#include "ble_midi.h" + +void setup(){ + ble_init(); + setLed(1, NO_COLOUR); + owl.setup(); +} + +void initLed(){ + // Initialise RGB LED PWM timers +#ifdef USE_LED_PWM + extern TIM_HandleTypeDef htim1; + HAL_TIM_Base_Start(&htim1); + HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1); + HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_2); + HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_3); +#else + /*Configure GPIO pin : LED_GREEN_Pin, LED_RED_Pin */ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + GPIO_InitStruct.Pin = LED_GREEN_Pin | LED_RED_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(LED_GREEN_GPIO_Port, &GPIO_InitStruct); +#endif +} + +void setLed(uint8_t led, uint32_t rgb){ + // rgb should be a 3x 10 bit value + if(led == 0){ +#ifdef USE_LED_PWM + rgb &= COLOUR_LEVEL5; // turn down intensity + TIM1->CCR1 = 1023 - ((rgb>>20)&0x3ff); // red + TIM1->CCR3 = 1023 - ((rgb>>10)&0x3ff); // green + TIM1->CCR2 = 1023 - ((rgb>>00)&0x3ff); // blue +#else + switch(rgb){ // sinking current + case RED_COLOUR: + HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_RESET); + HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_SET); + break; + case GREEN_COLOUR: + HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_SET); + HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_RESET); + break; + case YELLOW_COLOUR: + HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_RESET); + HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_RESET); + break; + case NO_COLOUR: + HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_SET); + HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_SET); + break; + } +#endif + }else if(led == 1){ + if(rgb == NO_COLOUR) + HAL_GPIO_WritePin(LED_BLUE_GPIO_Port, LED_BLUE_Pin, GPIO_PIN_RESET); + else + HAL_GPIO_WritePin(LED_BLUE_GPIO_Port, LED_BLUE_Pin, GPIO_PIN_SET); + } +} + +void onChangePin(uint16_t pin){ + switch(pin){ + case ADC_DRDY_Pin: { + ads_drdy(); + break; + } +#ifdef USE_KX122 + case ACC_INT1_Pin: { + kx122_drdy(); + break; + } +#endif +#ifdef PUSHBUTTON_Pin + case PUSHBUTTON_Pin: { + bool isSet = !(PUSHBUTTON_GPIO_Port->IDR & PUSHBUTTON_Pin); + setButtonValue(PUSHBUTTON, isSet); + midi_tx.sendCc(PUSHBUTTON, isSet ? 127 : 0); + break; + } +#endif + } +} diff --git a/Source/Owl.cpp b/Source/Owl.cpp index a5b4fc16..7a529811 100644 --- a/Source/Owl.cpp +++ b/Source/Owl.cpp @@ -19,14 +19,6 @@ #include "Storage.h" #include "PatchRegistry.h" -#ifdef OWL_BIOSIGNALS -#include "ads.h" -#ifdef USE_KX122 -#include "kx122.h" -#endif -#include "ble_midi.h" -#endif - #if defined USE_RGB_LED #include "rainbow.h" #endif /* USE_RGB_LED */ @@ -76,39 +68,6 @@ void midiSetOutputChannel(int8_t channel){ midi_tx.setOutputChannel(channel); } -__weak void initLed(){ - // Initialise RGB LED PWM timers -#if defined OWL_TESSERACT - extern TIM_HandleTypeDef htim2; - extern TIM_HandleTypeDef htim3; - // Red - HAL_TIM_Base_Start(&htim2); - HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1); - // Green - HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2); - // Blue - HAL_TIM_Base_Start(&htim3); - HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_4); -#elif defined OWL_BIOSIGNALS -#ifdef USE_LED_PWM - extern TIM_HandleTypeDef htim1; - HAL_TIM_Base_Start(&htim1); - HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1); - HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_2); - HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_3); -#else - /*Configure GPIO pin : LED_GREEN_Pin, LED_RED_Pin */ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - GPIO_InitStruct.Pin = LED_GREEN_Pin | LED_RED_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(LED_GREEN_GPIO_Port, &GPIO_InitStruct); -#endif -#endif -} - - extern "C" { void HAL_GPIO_EXTI_Callback(uint16_t pin){ diff --git a/Source/callbacks.cpp b/Source/callbacks.cpp index b8e08c2f..c634f2f1 100644 --- a/Source/callbacks.cpp +++ b/Source/callbacks.cpp @@ -21,13 +21,6 @@ #ifdef USE_CODEC #include "Codec.h" #endif -#ifdef OWL_BIOSIGNALS -#include "ads.h" -#ifdef USE_KX122 -#include "kx122.h" -#endif -#include "ble_midi.h" -#endif #if defined USE_RGB_LED #include "rainbow.h" @@ -78,6 +71,22 @@ int getPatchSelectionValue(){ return adc_values[MODE_BUTTON_PATCH]*(registry.getNumberOfPatches()-1)*4/4095; } +__weak void initLed(){ + // Initialise RGB LED PWM timers +#if defined OWL_TESSERACT + extern TIM_HandleTypeDef htim2; + extern TIM_HandleTypeDef htim3; + // Red + HAL_TIM_Base_Start(&htim2); + HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1); + // Green + HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2); + // Blue + HAL_TIM_Base_Start(&htim3); + HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_4); +#endif +} + void owl_mode_button(void){ static int patchselect = 0; static int gainselect = 0; @@ -135,11 +144,6 @@ void owl_mode_button(void){ #endif /* USE_MODE_BUTTON */ __weak void setup(){ -#ifdef OWL_BIOSIGNALS - ble_init(); - setLed(1, NO_COLOUR); -#endif - #ifdef USE_ENCODERS __HAL_TIM_SET_COUNTER(&ENCODER_TIM1, INT16_MAX/2); __HAL_TIM_SET_COUNTER(&ENCODER_TIM2, INT16_MAX/2); @@ -242,57 +246,12 @@ __weak void setLed(uint8_t led, uint32_t rgb){ TIM2->CCR1 = 1023 - ((rgb>>20)&0x3ff); TIM3->CCR4 = 1023 - ((rgb>>10)&0x3ff); TIM2->CCR2 = 1023 - ((rgb>>00)&0x3ff); -#elif defined OWL_BIOSIGNALS - if(led == 0){ -#ifdef USE_LED_PWM - rgb &= COLOUR_LEVEL5; // turn down intensity - TIM1->CCR1 = 1023 - ((rgb>>20)&0x3ff); // red - TIM1->CCR3 = 1023 - ((rgb>>10)&0x3ff); // green - TIM1->CCR2 = 1023 - ((rgb>>00)&0x3ff); // blue -#else - switch(rgb){ // sinking current - case RED_COLOUR: - HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_RESET); - HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_SET); - break; - case GREEN_COLOUR: - HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_SET); - HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_RESET); - break; - case YELLOW_COLOUR: - HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_RESET); - HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_RESET); - break; - case NO_COLOUR: - HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_SET); - HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_SET); - break; - } -#endif - }else if(led == 1){ - if(rgb == NO_COLOUR) - HAL_GPIO_WritePin(LED_BLUE_GPIO_Port, LED_BLUE_Pin, GPIO_PIN_RESET); - else - HAL_GPIO_WritePin(LED_BLUE_GPIO_Port, LED_BLUE_Pin, GPIO_PIN_SET); - } -#endif // OWL_BIOSIGNALS +#endif // OWL_TESSERACT } __weak void onChangePin(uint16_t pin){ switch(pin){ -#ifdef OWL_BIOSIGNALS - case ADC_DRDY_Pin: { - ads_drdy(); - break; - } -#ifdef USE_KX122 - case ACC_INT1_Pin: { - kx122_drdy(); - break; - } -#endif -#endif #ifdef PUSHBUTTON_Pin case PUSHBUTTON_Pin: { bool isSet = !(PUSHBUTTON_GPIO_Port->IDR & PUSHBUTTON_Pin); From 6ae821c81944e77a764b518e6e5ca4a74c83f8e1 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 25 Oct 2021 12:12:39 +0200 Subject: [PATCH 134/286] disable re-initialising USB FS --- Genius/Src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Genius/Src/main.c b/Genius/Src/main.c index e9f2d849..958c432b 100644 --- a/Genius/Src/main.c +++ b/Genius/Src/main.c @@ -183,7 +183,7 @@ int main(void) MX_ADC1_Init(); MX_DAC1_Init(); MX_UART5_Init(); - MX_USB_OTG_FS_PCD_Init(); + /* MX_USB_OTG_FS_PCD_Init(); hangs if bootloader has run */ /* USER CODE BEGIN 2 */ HAL_SAI_DeInit(&hsai_BlockA1); HAL_SAI_DeInit(&hsai_BlockB1); From 81fdf1d0caf2bd6f051f5055fd5853b85685a951 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 25 Oct 2021 12:36:43 +0200 Subject: [PATCH 135/286] change enter/exit status page --- Genius/Inc/GeniusParameterController.hpp | 41 ++++++++++++++++++------ 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/Genius/Inc/GeniusParameterController.hpp b/Genius/Inc/GeniusParameterController.hpp index 6bea704d..73a5ee12 100644 --- a/Genius/Inc/GeniusParameterController.hpp +++ b/Genius/Inc/GeniusParameterController.hpp @@ -29,7 +29,7 @@ extern VersionToken* bootloader_token; #define NOF_ENCODERS 2 enum DisplayMode { - STANDARD_DISPLAY_MODE, CONFIGURATION_DISPLAY_MODE, PROGRESS_DISPLAY_MODE, SELECT_ONE_DISPLAY_MODE, SELECT_TWO_DISPLAY_MODE, ERROR_DISPLAY_MODE + STANDARD_DISPLAY_MODE, CONFIGURATION_DISPLAY_MODE, PROGRESS_DISPLAY_MODE, SELECT_ONE_DISPLAY_MODE, SELECT_TWO_DISPLAY_MODE, EXIT_DISPLAY_MODE, ERROR_DISPLAY_MODE }; // DisplayMode displayMode; void setDisplayMode(DisplayMode mode); @@ -90,11 +90,16 @@ class GeniusParameterController : public ParameterController { parameters[ch] = value; } } - // @param value is the modulation ADC value + int16_t getUserValue(uint8_t ch){ + if(ch < NOF_ADC_VALUES) + return user[ch]; + return parameters[ch]; + } + // @param values the modulation ADC values void updateValues(int16_t* values, size_t len){ for(size_t pid=0; pid>1)); - // parameters[pid] = max(0, min(4095, (2*parameters[pid] + user[pid] + values[pid])>>2)); + parameters[pid] = max(0, min(4095, user[pid] + values[pid])); + // parameters[pid] = max(0, min(4095, (parameters[pid] + user[pid] + values[pid])>>1)); } // void updateValue(uint8_t pid, int16_t value){ // // smoothing at apprx 50Hz @@ -125,7 +130,7 @@ extern GeniusParameterController params; class SelectControlPage : public Page { const uint8_t ctrl; size_t counter; // ticks since switch was pressed down - static constexpr size_t TOGGLE_LIMIT = (600/MAIN_LOOP_SLEEP_MS); + static constexpr size_t TOGGLE_LIMIT = (400/MAIN_LOOP_SLEEP_MS); public: int8_t select; SelectControlPage(uint8_t ctrl, int8_t select): ctrl(ctrl), select(select){} @@ -144,7 +149,7 @@ class SelectControlPage : public Page { void draw(ScreenBuffer& screen){ if(!sw(ctrl)){ // encoder switch released - if(counter < TOGGLE_LIMIT){ + if(ctrl == 0 && counter < TOGGLE_LIMIT){ setDisplayMode(CONFIGURATION_DISPLAY_MODE); }else{ setDisplayMode(STANDARD_DISPLAY_MODE); @@ -189,7 +194,7 @@ class ProgressPage : public Page { // uint16_t progress_counter = user[LOAD_INDICATOR_PARAMETER]; screen.drawRectangle(0, 30, 128, 20, WHITE); // if(progress_counter != 4095) - screen.fillRectangle(0, 44, progress_counter * 127 / 4095, 5, WHITE); + screen.fillRectangle(0, 44, progress_counter * 128 / 4095, 5, WHITE); screen.setCursor(33, 40); screen.setTextSize(1); if(progress_message == NULL) @@ -207,7 +212,7 @@ class ErrorPage : public Page { setDisplayMode(STANDARD_DISPLAY_MODE); }else{ screen.setTextSize(2); - screen.print(1, 17, "ERROR"); + screen.print(1, 16, "ERROR"); if(getErrorMessage() != NULL){ screen.setTextSize(1); screen.print(2, 25, getErrorMessage()); @@ -216,12 +221,24 @@ class ErrorPage : public Page { } }; +class ExitPage : public Page { +public: + void draw(ScreenBuffer& screen){ + if(!(sw1() || sw2())){ // leave configuration mode on release + setDisplayMode(STANDARD_DISPLAY_MODE); + }else{ + screen.setTextSize(2); + screen.print(40, 26, "exit"); + } + } +}; + class StatsPage : public Page { public: void encoderChanged(uint8_t encoder, int32_t delta){} void draw(ScreenBuffer& screen){ if(sw1() || sw2()){ - setDisplayMode(STANDARD_DISPLAY_MODE); + setDisplayMode(EXIT_DISPLAY_MODE); }else{ drawStats(screen); } @@ -272,7 +289,7 @@ class StandardPage : public Page { else delta = -20 << (-delta/2); delta = min(802, max(-802, delta)); // max rate of change +/- 20% - params.setUserValue(select, min(4095, max(0, params.getValue(select) + delta))); + params.setUserValue(select, min(4095, max(0, params.getUserValue(select) + delta))); } void draw(ScreenBuffer& screen){ if(sw1()){ @@ -297,6 +314,7 @@ class StandardPage : public Page { StandardPage standardPage; ProgressPage progressPage; ErrorPage errorPage; +ExitPage exitPage; StatsPage configurationPage; void changePage(Page* page){ @@ -326,6 +344,9 @@ void setDisplayMode(DisplayMode mode){ case SELECT_TWO_DISPLAY_MODE: changePage(&selectTwoPage); break; + case EXIT_DISPLAY_MODE: + changePage(&exitPage); + break; case ERROR_DISPLAY_MODE: changePage(&errorPage); break; From 705ff7dd8a527f9ac06fa97615b47e5fd2de4c1c Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 25 Oct 2021 16:06:14 +0200 Subject: [PATCH 136/286] added onSetup() and onLoop() as preferred callbacks --- Source/callbacks.cpp | 103 +++++++++++++++++++++++++------------------ Source/callbacks.h | 10 +++-- 2 files changed, 67 insertions(+), 46 deletions(-) diff --git a/Source/callbacks.cpp b/Source/callbacks.cpp index c634f2f1..f38b6488 100644 --- a/Source/callbacks.cpp +++ b/Source/callbacks.cpp @@ -38,6 +38,11 @@ extern TIM_HandleTypeDef ENCODER_TIM1; extern TIM_HandleTypeDef ENCODER_TIM2; #endif +extern "C"{ + void setup(); + void loop(); +} + #ifndef min #define min(a,b) ((a)<(b)?(a):(b)) #endif @@ -71,22 +76,6 @@ int getPatchSelectionValue(){ return adc_values[MODE_BUTTON_PATCH]*(registry.getNumberOfPatches()-1)*4/4095; } -__weak void initLed(){ - // Initialise RGB LED PWM timers -#if defined OWL_TESSERACT - extern TIM_HandleTypeDef htim2; - extern TIM_HandleTypeDef htim3; - // Red - HAL_TIM_Base_Start(&htim2); - HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1); - // Green - HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2); - // Blue - HAL_TIM_Base_Start(&htim3); - HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_4); -#endif -} - void owl_mode_button(void){ static int patchselect = 0; static int gainselect = 0; @@ -143,14 +132,7 @@ void owl_mode_button(void){ } #endif /* USE_MODE_BUTTON */ -__weak void setup(){ -#ifdef USE_ENCODERS - __HAL_TIM_SET_COUNTER(&ENCODER_TIM1, INT16_MAX/2); - __HAL_TIM_SET_COUNTER(&ENCODER_TIM2, INT16_MAX/2); - HAL_TIM_Encoder_Start_IT(&ENCODER_TIM1, TIM_CHANNEL_ALL); - HAL_TIM_Encoder_Start_IT(&ENCODER_TIM2, TIM_CHANNEL_ALL); -#endif /* OWL_PLAYERF7 */ - +__weak void onSetup(){ #ifdef OWL_WAVETABLE extern ADC_HandleTypeDef hadc1; extern ADC_HandleTypeDef hadc3; @@ -161,16 +143,34 @@ __weak void setup(){ if(ret != HAL_OK) error(CONFIG_ERROR, "ADC3 Start failed"); #endif - initLed(); +#if defined OWL_TESSERACT + // Initialise RGB LED PWM timers + extern TIM_HandleTypeDef htim2; + extern TIM_HandleTypeDef htim3; + // Red + HAL_TIM_Base_Start(&htim2); + HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1); + // Green + HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2); + // Blue + HAL_TIM_Base_Start(&htim3); + HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_4); +#endif setLed(0, NO_COLOUR); - owl.setup(); } -__weak void loop(void){ -#ifdef USE_MODE_BUTTON - owl_mode_button(); -#endif /* USE_MODE_BUTTON */ +__weak void setup(){ +#ifdef USE_ENCODERS + __HAL_TIM_SET_COUNTER(&ENCODER_TIM1, INT16_MAX/2); + __HAL_TIM_SET_COUNTER(&ENCODER_TIM2, INT16_MAX/2); + HAL_TIM_Encoder_Start_IT(&ENCODER_TIM1, TIM_CHANNEL_ALL); + HAL_TIM_Encoder_Start_IT(&ENCODER_TIM2, TIM_CHANNEL_ALL); +#endif /* USE_ENCODERS */ + onSetup(); + owl.setup(); +} +__weak void onLoop(){ #ifdef FASCINATION_MACHINE static int output_gain = 0; int gain = adc_values[ADC_D]*255/4095; @@ -190,6 +190,24 @@ __weak void loop(void){ } #endif +#ifdef OWL_PRISM + int16_t encoders[NOF_ENCODERS] = {(int16_t)__HAL_TIM_GET_COUNTER(&ENCODER_TIM1), + (int16_t)__HAL_TIM_GET_COUNTER(&ENCODER_TIM2) }; + graphics.params.updateEncoders(encoders, 2); +#ifndef OWL_RACK + for(int i=0; i +#include "device.h" #ifdef __cplusplus extern "C" { @@ -18,9 +19,8 @@ extern "C" { /** functions with weak declarations that can be defined by subprojects * to implement device specific behaviour */ - void setup(void); - void loop(void); - void initLed(); + void onSetup(); + void onLoop(); void setLed(uint8_t led, uint32_t rgb); void setButtonValue(uint8_t ch, uint8_t value); void setAnalogValue(uint8_t ch, int16_t value); @@ -28,12 +28,14 @@ extern "C" { void onChangePin(uint16_t pin); void onChangeMode(OperationMode new_mode, OperationMode old_mode); void onStartProgram(); + void onError(int8_t code, const char* msg); // sets a progress bar (if available) to a value from 0 to 4095 void setProgress(uint16_t value, const char* reason); - void onResourceUpdate(void); + void onResourceUpdate(); void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* adc_values, size_t adc_len); #ifdef USE_SCREEN + void onScreenDraw(); void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height); #endif From 784d396c088f1c44e7003368053ff53107300e25 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 25 Oct 2021 16:07:57 +0200 Subject: [PATCH 137/286] added onSetup() and onLoop() as preferred callbacks --- Alchemist/Src/Alchemist.cpp | 7 +++-- Magus/Src/Magus.cpp | 13 ++------- Magus3/Src/Magus.cpp | 55 ++++++++++++++++++------------------- Witch/Src/Witch.cpp | 6 ++-- Witch/Src/usb_host.c | 48 ++++++++++++++++++++++++++++---- Wizard/Src/Wizard.cpp | 7 ++--- 6 files changed, 81 insertions(+), 55 deletions(-) diff --git a/Alchemist/Src/Alchemist.cpp b/Alchemist/Src/Alchemist.cpp index 143babec..40935a9d 100644 --- a/Alchemist/Src/Alchemist.cpp +++ b/Alchemist/Src/Alchemist.cpp @@ -49,7 +49,10 @@ void onChangePin(uint16_t pin){ } } -void loop(void){ +void onSetup(){ + initLed(); +} + +void onLoop(){ owl_mode_button(); - owl.loop(); } diff --git a/Magus/Src/Magus.cpp b/Magus/Src/Magus.cpp index c6dceb2c..cef24f9a 100644 --- a/Magus/Src/Magus.cpp +++ b/Magus/Src/Magus.cpp @@ -74,7 +74,7 @@ void onResourceUpdate(void){ } } -void setup(){ +void onSetup(){ HAL_GPIO_WritePin(TLC_BLANK_GPIO_Port, TLC_BLANK_Pin, GPIO_PIN_SET); // LEDs off Pin enc_nrst(ENC_NRST_GPIO_Port, ENC_NRST_Pin); enc_nrst.outputMode(); @@ -127,8 +127,6 @@ void setup(){ HAL_GPIO_WritePin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin, GPIO_PIN_SET); #endif - owl.setup(); - // Update LEDs brighness from settings TLC5946_setAll_DC(settings.leds_brightness); TLC5946_Refresh_DC(); @@ -140,7 +138,7 @@ void setup(){ Encoders_readAll(); } -void loop(void){ +void onLoop(){ #ifdef USE_USB_HOST if(HAL_GPIO_ReadPin(USB_HOST_PWR_FAULT_GPIO_Port, USB_HOST_PWR_FAULT_Pin) == GPIO_PIN_RESET){ @@ -153,13 +151,6 @@ void loop(void){ } #endif -#ifdef USE_SCREEN - graphics.draw(); - graphics.display(); -#endif /* USE_SCREEN */ - - owl.loop(); - if(updateMAX11300){ MAX11300_setDeviceControl(DCR_DACCTL_ImmUpdate|DCR_DACREF_Int|DCR_ADCCTL_ContSweep /* |DCR_ADCCONV_200ksps|DCR_BRST_Contextual*/); for(int i=0; i<20; ++i){ diff --git a/Magus3/Src/Magus.cpp b/Magus3/Src/Magus.cpp index 57cfb776..ff356da6 100644 --- a/Magus3/Src/Magus.cpp +++ b/Magus3/Src/Magus.cpp @@ -18,7 +18,7 @@ const uint32_t* dyn_rainbowinputs = rainbowinputs; const uint32_t* dyn_rainbowoutputs = rainbowoutputs; static MagusParameterController params; -Graphics graphics(params); +Graphics graphics; extern "C" void onResourceUpdate(void); @@ -74,7 +74,7 @@ void onResourceUpdate(void){ } } -void setup(){ +void onSetup(){ HAL_GPIO_WritePin(TLC_BLANK_GPIO_Port, TLC_BLANK_Pin, GPIO_PIN_SET); // LEDs off Pin enc_nrst(ENC_NRST_GPIO_Port, ENC_NRST_Pin); enc_nrst.outputMode(); @@ -120,15 +120,13 @@ void setup(){ HAL_GPIO_WritePin(OLED_RST_GPIO_Port, OLED_RST_Pin, GPIO_PIN_RESET); // OLED off extern SPI_HandleTypeDef OLED_SPI; - graphics.begin(&OLED_SPI); + graphics.begin(¶ms, &OLED_SPI); #ifdef USE_USB_HOST // enable USB Host power HAL_GPIO_WritePin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin, GPIO_PIN_SET); #endif - owl.setup(); - // Update LEDs brighness from settings TLC5946_setAll_DC(settings.leds_brightness); TLC5946_Refresh_DC(); @@ -140,7 +138,17 @@ void setup(){ Encoders_readAll(); } -void loop(void){ +void onScreenDraw(){ +#ifdef USE_TLC5946 + for(int i=0; i<16; ++i){ + uint16_t val = params.getValue(i)>>2; + setLed(i, dyn_rainbowinputs[val&0x3ff]); + } + TLC5946_Refresh_GS(); +#endif +} + +void onLoop(){ #ifdef USE_USB_HOST if(HAL_GPIO_ReadPin(USB_HOST_PWR_FAULT_GPIO_Port, USB_HOST_PWR_FAULT_Pin) == GPIO_PIN_RESET){ @@ -153,13 +161,6 @@ void loop(void){ } #endif -#ifdef USE_SCREEN - graphics.draw(); - graphics.display(); -#endif /* USE_SCREEN */ - - owl.loop(); - if(updateMAX11300){ MAX11300_setDeviceControl(DCR_DACCTL_ImmUpdate|DCR_DACREF_Int|DCR_ADCCTL_ContSweep /* |DCR_ADCCONV_200ksps|DCR_BRST_Contextual*/); for(int i=0; i<20; ++i){ @@ -177,35 +178,31 @@ void loop(void){ } updateMAX11300 = false; } -#ifdef USE_TLC5946 - TLC5946_Refresh_GS(); -#endif Encoders_readAll(); - graphics.params.updateEncoders(Encoders_get(), 7); + params.updateEncoders(Encoders_get(), 7); MAX11300_bulkreadADC(); for(int i=0; i<16; ++i){ if(getPortMode(i) == PORT_UNI_INPUT){ - graphics.params.updateValue(i, MAX11300_getADCValue(i+1)); - uint16_t val = graphics.params.getValue(i)>>2; - setLed(i, dyn_rainbowinputs[val&0x3ff]); + params.updateValue(i, MAX11300_getADCValue(i+1)); }else{ // DACs // TODO: store values set from patch somewhere and multiply with user[] value for outputs - // graphics.params.updateOutput(i, getOutputValue(i)); - // MAX11300_setDACValue(i+1, graphics.params.parameters[i]); - graphics.params.updateValue(i, 0); - uint16_t val = graphics.params.getValue(i)>>2; - setLed(i, dyn_rainbowoutputs[val&0x3ff]); - MAX11300_setDAC(i+1, graphics.params.getValue(i)); + // params.updateOutput(i, getOutputValue(i)); + // MAX11300_setDACValue(i+1, params.parameters[i]); + params.updateValue(i, 0); + MAX11300_setDAC(i+1, params.getValue(i)); } } for(int i=16; i<20; ++i){ if(getPortMode(i) == PORT_UNI_INPUT){ - graphics.params.updateValue(i, MAX11300_getADCValue(i+1)); + params.updateValue(i, MAX11300_getADCValue(i+1)); }else{ - graphics.params.updateValue(i, 0); - MAX11300_setDAC(i+1, graphics.params.getValue(i)); + params.updateValue(i, 0); + MAX11300_setDAC(i+1, params.getValue(i)); } } + for(int i=20; i < NOF_PARAMETERS; i++) { + params.updateValue(i, 0); + } // MAX11300_bulkwriteDAC(); } diff --git a/Witch/Src/Witch.cpp b/Witch/Src/Witch.cpp index 4ca1baae..10f91483 100644 --- a/Witch/Src/Witch.cpp +++ b/Witch/Src/Witch.cpp @@ -465,12 +465,11 @@ void onChangeMode(OperationMode new_mode, OperationMode old_mode){ counter = 0; } -void setup(){ +void onSetup(){ initLed(); HAL_GPIO_WritePin(LEDPWM_GPIO_Port, LEDPWM_Pin, GPIO_PIN_SET); HAL_GPIO_WritePin(TR_OUT1_GPIO_Port, TR_OUT1_Pin, GPIO_PIN_SET); HAL_GPIO_WritePin(TR_OUT2_GPIO_Port, TR_OUT2_Pin, GPIO_PIN_SET); - owl.setup(); for(size_t i=5; i<9; ++i){ takeover.set(i, CV_ATTENUATION_DEFAULT); takeover.reset(i, false); @@ -480,11 +479,10 @@ void setup(){ patchselect = program.getProgramIndex(); } -void loop(void){ +void onLoop(){ MX_USB_HOST_Process(); // todo: enable PWR management static bool sw4_state = false; if(sw4_state != !sw4.get()) sw4_state = updatePin(4, sw4); update_preset(); - owl.loop(); } diff --git a/Witch/Src/usb_host.c b/Witch/Src/usb_host.c index 548b78d6..0cf7ad2b 100644 --- a/Witch/Src/usb_host.c +++ b/Witch/Src/usb_host.c @@ -25,9 +25,15 @@ #include "usbh_core.h" /* USER CODE BEGIN Includes */ -#include "usbh_midi.h" #include "device.h" +#include "message.h" #include "errorhandlers.h" +#ifdef USE_USBH_MIDI +#include "usbh_midi.h" +#endif +#ifdef USE_USBH_HID +#include "usbh_hid.h" +#endif /* USER CODE END Includes */ /* USER CODE BEGIN PV */ @@ -62,6 +68,10 @@ static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id); */ /* USER CODE BEGIN 1 */ +void USBH_HID_EventCallback(USBH_HandleTypeDef *phost){ + debugMessage("HID"); +} + /* * Background task */ @@ -77,6 +87,19 @@ void MX_USB_HOST_Process() /* MX_USB_HOST_Init(); */ /* Appli_state = APPLICATION_IDLE; */ /* } */ + USBH_HandleTypeDef *phost = &HUSB_HOST; + /* if(USBH_HID_GetDeviceType(phost) == HID_KEYBOARD){ */ + /* HID_KEYBD_Info_TypeDef* pinfo = USBH_HID_GetKeybdInfo(phost); */ + /* if(pinfo != NULL){ */ + /* uint8_t c = USBH_HID_GetASCIICode(pinfo); */ + /* // or c = pinfo->keys[0]; */ + /* if(c >= 32 && c <= 126) { // readable ascii */ + /* char* msg = "char[ ]"; */ + /* msg[5] = c; */ + /* debugMessage(msg); */ + /* } */ + /* } */ + /* } */ } /* USER CODE END 1 */ @@ -96,16 +119,27 @@ void MX_USB_HOST_Init(void) { Error_Handler(); } +#ifdef USE_USBH_MIDI if (USBH_RegisterClass(&HUSB_HOST, USBH_MIDI_CLASS) != USBH_OK) { Error_Handler(); } +#endif +#ifdef USE_USBH_HID + if (USBH_RegisterClass(&HUSB_HOST, USBH_HID_CLASS) != USBH_OK) + { + Error_Handler(); + } +#endif if (USBH_Start(&HUSB_HOST) != USBH_OK) { Error_Handler(); } /* USER CODE BEGIN USB_HOST_Init_PostTreatment */ - + +#ifdef STM32H7xx + HAL_PWREx_EnableUSBVoltageDetector(); +#endif /* USER CODE END USB_HOST_Init_PostTreatment */ } @@ -127,22 +161,26 @@ static void USBH_UserProcess (USBH_HandleTypeDef *phost, uint8_t id) case HOST_USER_CLASS_ACTIVE: if(Appli_state == APPLICATION_START){ +#ifdef USE_USBH_MIDI usbh_midi_begin(); +#endif Appli_state = APPLICATION_READY; } break; case HOST_USER_DISCONNECTION: Appli_state = APPLICATION_DISCONNECT; +#ifdef USE_USBH_MIDI usbh_midi_reset(); +#endif break; case HOST_USER_UNRECOVERED_ERROR: - phost->Control.state = CTRL_SETUP; - phost->RequestState = CMD_SEND; + /* phost->Control.state = CTRL_SETUP; */ + /* phost->RequestState = CMD_SEND; */ Appli_state = APPLICATION_DISCONNECT; /* usbh_midi_reset(); // reset and hope for the best */ - USBH_LL_ResetPort(&USBH_HANDLE); + /* USBH_LL_ResetPort(&USBH_HANDLE); */ error(USB_ERROR, "USB Host error"); break; diff --git a/Wizard/Src/Wizard.cpp b/Wizard/Src/Wizard.cpp index 04e0ad2a..287ca5ab 100644 --- a/Wizard/Src/Wizard.cpp +++ b/Wizard/Src/Wizard.cpp @@ -78,11 +78,11 @@ void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* // } } -void setup(){ + +void onSetup(){ HAL_GPIO_WritePin(TRIG_OUT_GPIO_Port, TRIG_OUT_Pin, GPIO_PIN_RESET); // Trigger out off initLed(); setLed(0, NO_COLOUR); - owl.setup(); #ifdef USE_USB_HOST // enable USB Host power @@ -90,7 +90,7 @@ void setup(){ #endif } -void loop(void){ +void onLoop(){ #ifdef USE_USB_HOST if(HAL_GPIO_ReadPin(USB_HOST_PWR_FAULT_GPIO_Port, USB_HOST_PWR_FAULT_Pin) == GPIO_PIN_RESET){ if(HAL_GPIO_ReadPin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin) == GPIO_PIN_SET){ @@ -102,5 +102,4 @@ void loop(void){ } #endif owl_mode_button(); - owl.loop(); } From dbd6964b234db28f9ab75b815c8350e394e5db78 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 25 Oct 2021 17:28:29 +0200 Subject: [PATCH 138/286] split graphics into separate task --- Genius/Inc/GeniusParameterController.hpp | 6 +- Genius/Inc/hardware.h | 9 +- Genius/Src/Genius.cpp | 24 ++-- Source/Graphics.cpp | 4 +- Source/MagusParameterController.hpp | 6 +- Source/ParameterController.hpp | 168 +---------------------- Source/ProgramManager.cpp | 53 ++++--- Source/callbacks.cpp | 5 - Source/device.h | 5 + Source/errorhandlers.c | 4 +- 10 files changed, 65 insertions(+), 219 deletions(-) diff --git a/Genius/Inc/GeniusParameterController.hpp b/Genius/Inc/GeniusParameterController.hpp index 73a5ee12..59bbfd3d 100644 --- a/Genius/Inc/GeniusParameterController.hpp +++ b/Genius/Inc/GeniusParameterController.hpp @@ -130,7 +130,7 @@ extern GeniusParameterController params; class SelectControlPage : public Page { const uint8_t ctrl; size_t counter; // ticks since switch was pressed down - static constexpr size_t TOGGLE_LIMIT = (400/MAIN_LOOP_SLEEP_MS); + static constexpr size_t TOGGLE_LIMIT = (400/SCREEN_LOOP_SLEEP_MS); public: int8_t select; SelectControlPage(uint8_t ctrl, int8_t select): ctrl(ctrl), select(select){} @@ -191,7 +191,6 @@ class ProgressPage : public Page { void drawLoadProgress(ScreenBuffer &screen){ extern char* progress_message; extern uint16_t progress_counter; - // uint16_t progress_counter = user[LOAD_INDICATOR_PARAMETER]; screen.drawRectangle(0, 30, 128, 20, WHITE); // if(progress_counter != 4095) screen.fillRectangle(0, 44, progress_counter * 128 / 4095, 5, WHITE); @@ -288,7 +287,8 @@ class StandardPage : public Page { delta = 20 << (delta/2); else delta = -20 << (-delta/2); - delta = min(802, max(-802, delta)); // max rate of change +/- 20% + // delta = min(819, max(-819, delta)); // max rate of change +/- 20% + // delta = min(1229, max(-1229, delta)); // max rate of change +/- 30% params.setUserValue(select, min(4095, max(0, params.getUserValue(select) + delta))); } void draw(ScreenBuffer& screen){ diff --git a/Genius/Inc/hardware.h b/Genius/Inc/hardware.h index 835d6960..0fd2ab93 100644 --- a/Genius/Inc/hardware.h +++ b/Genius/Inc/hardware.h @@ -8,7 +8,7 @@ #define USE_SPI_FLASH #define SPI_FLASH_HSPI hspi5 -#define USE_USBH_HID +/* #define USE_USBH_HID */ /* #define NO_EXTERNAL_RAM */ /* #define NO_CCM_RAM */ @@ -51,9 +51,9 @@ #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) #define USE_USBD_AUDIO -/* #define USE_USBD_RX_FB */ -/* #define USE_USBD_AUDIO_FEATURES */ -/* #define USE_USBD_AUDIO_RX // speaker */ +#define USE_USBD_RX_FB +#define USE_USBD_AUDIO_FEATURES +#define USE_USBD_AUDIO_RX // speaker #define USE_USBD_AUDIO_TX // microphone #define USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS @@ -62,7 +62,6 @@ #define USB_HOST_RX_BUFF_SIZE 256 /* Max Received data 64 bytes */ #define USE_USBH_MIDI -#define MAIN_LOOP_SLEEP_MS 20 #define ARM_CYCLES_PER_SAMPLE (480000000/AUDIO_SAMPLINGRATE) /* 480MHz / 48kHz */ // Serial MIDI diff --git a/Genius/Src/Genius.cpp b/Genius/Src/Genius.cpp index b4bc5adb..9f829b78 100644 --- a/Genius/Src/Genius.cpp +++ b/Genius/Src/Genius.cpp @@ -55,9 +55,11 @@ void onChangeMode(OperationMode new_mode, OperationMode old_mode){ case STARTUP_MODE: case STREAM_MODE: case LOAD_MODE: - case CONFIGURE_MODE: setDisplayMode(PROGRESS_DISPLAY_MODE); break; + case CONFIGURE_MODE: + setDisplayMode(CONFIGURATION_DISPLAY_MODE); + break; case RUN_MODE: setDisplayMode(STANDARD_DISPLAY_MODE); break; @@ -67,8 +69,8 @@ void onChangeMode(OperationMode new_mode, OperationMode old_mode){ } } -void setup(){ - progress_counter = 100; +void onSetup(){ + progress_counter = 1000; tr_out_a_pin.outputMode(); tr_out_b_pin.outputMode(); tr_out_a_pin.high(); @@ -78,7 +80,7 @@ void setup(){ extern SPI_HandleTypeDef OLED_SPI; graphics.begin(¶ms, &OLED_SPI); - progress_counter = 1000; + progress_counter = 2000; #ifdef USE_USB_HOST // enable USB Host power @@ -90,9 +92,7 @@ void setup(){ HAL_TIM_Encoder_Start_IT(&ENCODER_TIM1, TIM_CHANNEL_ALL); HAL_TIM_Encoder_Start_IT(&ENCODER_TIM2, TIM_CHANNEL_ALL); - progress_counter = 2000; - owl.setup(); - progress_counter = 4000; + progress_counter = 3000; } void setGateValue(uint8_t ch, int16_t value){ @@ -182,8 +182,7 @@ void updateEncoders(){ // encoder_values[1] = value; } -void loop(void){ - +void onLoop(void){ #ifdef USE_USB_HOST if(HAL_GPIO_ReadPin(USB_HOST_PWR_FAULT_GPIO_Port, USB_HOST_PWR_FAULT_Pin) == GPIO_PIN_RESET){ if(HAL_GPIO_ReadPin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin) == GPIO_PIN_SET){ @@ -198,13 +197,6 @@ void loop(void){ // SCB_CleanInvalidateDCache_by_Addr((uint32_t*)graphics.params.user, sizeof(graphics.params.user)); #endif updateEncoders(); - -#ifdef USE_SCREEN - graphics.draw(); - graphics.display(); -#endif /* USE_SCREEN */ - - owl.loop(); } #ifdef DEBUG_USBD_AUDIO diff --git a/Source/Graphics.cpp b/Source/Graphics.cpp index 289e1f13..5851847f 100644 --- a/Source/Graphics.cpp +++ b/Source/Graphics.cpp @@ -16,6 +16,7 @@ void Graphics::begin(ParameterController* pc, SPI_HandleTypeDef *spi) { oled_init(spi); screen.setBuffer(pixelbuffer); screen.clear(); + params->reset(); display(); } @@ -24,8 +25,6 @@ void Graphics::display(){ } void Graphics::draw(){ - // drawCallback(pixelbuffer, OLED_WIDTH, OLED_HEIGHT); - // // params->draw(pixelbuffer, OLED_WIDTH, OLED_HEIGHT); params->draw(screen); } @@ -48,6 +47,7 @@ void Graphics::setCallback(void *callback){ } __weak void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height){ + // doDefaultDrawCallback(graphics.screen); ScreenBuffer screen = graphics.screen; // draw title diff --git a/Source/MagusParameterController.hpp b/Source/MagusParameterController.hpp index b8ae86e7..ecd6daa2 100644 --- a/Source/MagusParameterController.hpp +++ b/Source/MagusParameterController.hpp @@ -117,14 +117,12 @@ class MagusParameterController : public ParameterController { } void reset(){ setTitle("Magus"); + ParameterController::reset(); Encoders_reset(); saveSettings = false; resourceDelete = false; for(int i=0; i 8) + names[i][ch++] = '@'+(i/8); + names[i][ch++] = 'A'+(i%8); + names[i][ch++] = '\0'; parameters[i] = 0; } } @@ -53,162 +55,4 @@ class ParameterController { } }; - -#if 0 -class Page { -public: - virtual void draw(ScreenBuffer& screen){} - void updateEncoders(int16_t* data, uint8_t size); - void enter(); - void exit(); -}; - -class SensitivityPage : public Page { -public: - void draw(ScreenBuffer& screen){ - } -}; - -class PageManager { -private: - Page* page; -public: - virtual void draw(ScreenBuffer& screen){} - void updateEncoders(int16_t* data, uint8_t size); -}; - -void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height); - -/* shows a single parameter selected and controlled with a single encoder - */ -template -class ParameterController { -public: - char title[11] = "Prism"; - int16_t parameters[SIZE]; - char names[SIZE][12]; - int8_t selected = 0; - ParameterController(){ - reset(); - } - void setTitle(const char* str){} - void reset(){ - drawCallback = defaultDrawCallback; - for(int i=0; imessage != NULL) - screen.print(2, 36, pv->message); - screen.print(2, 46, "cpu/mem: "); - float percent = (pv->cycles_per_block/pv->audio_blocksize) / (float)ARM_CYCLES_PER_SAMPLE; - screen.print((int)(percent*100)); - screen.print("% "); - screen.print((int)(pv->heap_bytes_used)/1024); - screen.print("kB"); - } - - void encoderChanged(uint8_t encoder, int32_t delta){ - if(encoder == 0){ - if(sw2()){ - if(delta > 1) - selected = min(SIZE-1, selected+1); - else if(delta < 1) - selected = max(0, selected-1); - }else{ - parameters[selected] += delta*10; - parameters[selected] = min(4095, max(0, parameters[selected])); - } - } // todo: change patch with enc1/sw1 - } - void setName(uint8_t pid, const char* name){ - if(pid < SIZE) - strncpy(names[pid], name, 11); - } - uint8_t getSize(){ - return SIZE; - } - void setValue(uint8_t ch, int16_t value){ - parameters[ch] = value; - } - - void drawMessage(int16_t y, ScreenBuffer& screen){ - ProgramVector* pv = getProgramVector(); - if(pv->message != NULL){ - screen.setTextSize(1); - screen.setTextWrap(true); - screen.print(0, y, pv->message); - screen.setTextWrap(false); - } - } - - void drawTitle(ScreenBuffer& screen){ - drawTitle(title, screen); - } - - void drawTitle(const char* title, ScreenBuffer& screen){ - // draw title - screen.setTextSize(2); - screen.print(1, 17, title); - } - - void setCallback(void *callback){ - if(callback == NULL) - drawCallback = defaultDrawCallback; - else - drawCallback = (void (*)(uint8_t*, uint16_t, uint16_t))callback; - } - -private: - void (*drawCallback)(uint8_t*, uint16_t, uint16_t); - bool tr1(){ - return HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_11) != GPIO_PIN_SET; - } - bool tr2(){ - return HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_10) != GPIO_PIN_SET; - } - bool sw1(){ - return HAL_GPIO_ReadPin(GPIOG, GPIO_PIN_14) != GPIO_PIN_SET; - } - bool sw2(){ - return HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_4) != GPIO_PIN_SET; - } -}; -#endif - #endif // __ParameterController_hpp__ diff --git a/Source/ProgramManager.cpp b/Source/ProgramManager.cpp index 06eb96f5..e4326a5b 100644 --- a/Source/ProgramManager.cpp +++ b/Source/ProgramManager.cpp @@ -155,6 +155,7 @@ void usbd_tx_convert(int32_t* src, size_t len){ #define MANAGER_TASK_PRIORITY (AUDIO_TASK_PRIORITY | portPRIVILEGE_BIT) // audio and manager task priority must be the same so that the program can stop itself in case of errors #define FLASH_TASK_PRIORITY 1 // allow default task to run when FLASH task yields +#define SCREEN_TASK_PRIORITY 3 // less than AUDIO_TASK_PRIORITY, more than osPriorityNormal #define PROGRAMSTACK_SIZE (PROGRAM_TASK_STACK_SIZE*sizeof(portSTACK_TYPE)) // size in bytes @@ -174,6 +175,9 @@ static TaskHandle_t managerTask = NULL; static TaskHandle_t utilityTask = NULL; static StaticTask_t audioTaskBuffer; static uint8_t PROGRAMSTACK[PROGRAMSTACK_SIZE] CCM_RAM; // use CCM if available +#ifdef USE_SCREEN +static TaskHandle_t screenTask = NULL; +#endif #ifdef USE_ADC extern uint16_t adc_values[NOF_ADC_VALUES]; @@ -201,6 +205,13 @@ void audioCallback(int32_t* rx, int32_t* tx, uint16_t size){ static float audio_envelope_lambda = 0.999995f; static float audio_envelope = 0.0; audio_envelope = audio_envelope*audio_envelope_lambda + (1.0f-audio_envelope_lambda)*abs(pv->audio_output[0])*(1.0f/INT16_MAX); +#endif +#ifdef USE_ADC +#ifdef USE_SCREEN + updateParameters(graphics.params->getParameters(), graphics.params->getSize(), adc_values, NOF_ADC_VALUES); +#else + updateParameters(parameter_values, NOF_PARAMETERS, adc_values, NOF_ADC_VALUES); +#endif #endif if(audioTask != NULL){ BaseType_t yield; @@ -273,19 +284,8 @@ void onProgramReady(){ #endif /* Block indefinitely (released by audioCallback) */ ulTaskNotifyTake(pdTRUE, portMAX_DELAY); -#ifdef USE_USBD_AUDIO_RX - // if(usbd_rx) // before patch runs: convert USBD audio rx to patch input (overwriting ADC) - // usbd_rx_convert(pv->audio_input, pv->audio_blocksize*AUDIO_CHANNELS); -#endif #ifdef DEBUG_DWT DWT->CYCCNT = 0; -#endif -#ifdef USE_ADC -#ifdef USE_SCREEN - updateParameters(graphics.params->getParameters(), graphics.params->getSize(), adc_values, NOF_ADC_VALUES); -#else - updateParameters(parameter_values, NOF_PARAMETERS, adc_values, NOF_ADC_VALUES); -#endif #endif pv->buttons = button_values; if(pv->buttonChangedCallback != NULL && stateChanged.getState()){ @@ -502,12 +502,26 @@ void sendResourceTask(void* p){ __weak void onStartProgram(){ #ifdef USE_SCREEN graphics.reset(); -#endif -#ifndef USE_SCREEN +#else memset(parameter_values, 0, sizeof(parameter_values)); #endif } +#ifdef USE_SCREEN +void runScreenTask(void* p){ + TickType_t xLastWakeTime; + TickType_t xFrequency; + xFrequency = SCREEN_LOOP_SLEEP_MS / portTICK_PERIOD_MS; // 20mS = 50Hz refresh rate + xLastWakeTime = xTaskGetTickCount(); + for(;;){ + vTaskDelayUntil(&xLastWakeTime, xFrequency); + onScreenDraw(); + graphics.draw(); + graphics.display(); + } +} +#endif // USE_SCREEN + void runAudioTask(void* p){ PatchDefinition* def = getPatchDefinition(); if(def->isValid()){ @@ -651,11 +665,10 @@ ProgramManager::ProgramManager(){ } void ProgramManager::startManager(){ - // updateProgramVector(getProgramVector(), NULL); -// #ifdef USE_SCREEN -// xTaskCreate(runScreenTask, "Screen", SCREEN_TASK_STACK_SIZE, NULL, SCREEN_TASK_PRIORITY, &screenTask); -// #endif xTaskCreate(runManagerTask, "Manager", MANAGER_TASK_STACK_SIZE, NULL, MANAGER_TASK_PRIORITY, &managerTask); +#ifdef USE_SCREEN + xTaskCreate(runScreenTask, "Screen", SCREEN_TASK_STACK_SIZE, NULL, SCREEN_TASK_PRIORITY, &screenTask); +#endif } void ProgramManager::notifyManagerFromISR(uint32_t ulValue){ @@ -712,7 +725,7 @@ void ProgramManager::loadDynamicProgram(void* address, uint32_t length){ if(registry.loadProgram(address, length)) updateProgramIndex(0); else - error(PROGRAM_ERROR, "Failed load"); + error(PROGRAM_ERROR, "Load error"); } void ProgramManager::loadProgram(uint8_t pid){ @@ -720,7 +733,9 @@ void ProgramManager::loadProgram(uint8_t pid){ if(registry.loadProgram(pid)) updateProgramIndex(pid); else - error(PROGRAM_ERROR, "Failed load"); + error(PROGRAM_ERROR, "Load error"); + }else{ + owl.setOperationMode(CONFIGURE_MODE); } } diff --git a/Source/callbacks.cpp b/Source/callbacks.cpp index f38b6488..716c69b7 100644 --- a/Source/callbacks.cpp +++ b/Source/callbacks.cpp @@ -223,11 +223,6 @@ __weak void loop(){ #endif #endif -#ifdef USE_SCREEN - graphics.draw(); - graphics.display(); -#endif /* USE_SCREEN */ - onLoop(); owl.loop(); } diff --git a/Source/device.h b/Source/device.h index 85553477..3b04c1a4 100644 --- a/Source/device.h +++ b/Source/device.h @@ -153,6 +153,10 @@ #define MAIN_LOOP_SLEEP_MS 2 #endif +#ifndef SCREEN_LOOP_SLEEP_MS +#define SCREEN_LOOP_SLEEP_MS 40 /* 40mS = 25 fps */ +#endif + #ifndef LOAD_INDICATOR_PARAMETER #define LOAD_INDICATOR_PARAMETER PARAMETER_A #endif @@ -163,6 +167,7 @@ #define PROGRAM_TASK_STACK_SIZE (4*1024/sizeof(portSTACK_TYPE)) #define MANAGER_TASK_STACK_SIZE (1*1024/sizeof(portSTACK_TYPE)) +#define SCREEN_TASK_STACK_SIZE (2*1024/sizeof(portSTACK_TYPE)) #ifndef ARM_CYCLES_PER_SAMPLE #define ARM_CYCLES_PER_SAMPLE (168000000/AUDIO_SAMPLINGRATE) /* 168MHz / 48kHz */ diff --git a/Source/errorhandlers.c b/Source/errorhandlers.c index 6d8400f8..69282a00 100644 --- a/Source/errorhandlers.c +++ b/Source/errorhandlers.c @@ -12,10 +12,8 @@ const char* errormsg = 0; void error(int8_t code, const char* reason){ setErrorMessage(code, reason); /* assert_param(0); */ -#if defined OWL_PEDAL || defined OWL_MODULAR || defined OWL_BIOSIGNALS if(code != NO_ERROR) - setLed(0, RED_COLOUR); -#endif + onError(code, reason); #ifdef DEBUG // assuming semihosting enabled if(reason != NULL) From 3c1efad0d028e442afea77665a2fe7ec6ea68305 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 26 Oct 2021 11:18:37 +0200 Subject: [PATCH 139/286] allow codec DAC phase inversion --- Source/cs4272.c | 3 +++ Source/cs4272.h | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/cs4272.c b/Source/cs4272.c index 42eddbd4..a3e8b270 100644 --- a/Source/cs4272.c +++ b/Source/cs4272.c @@ -40,6 +40,9 @@ void codec_reset(){ #else codec_write(CODEC_ADC_CTRL, 0x10 | 0x03 ); // hp filters disabled #endif +#ifdef CODEC_DAC_INVERT + codec_write(CODEC_DAC_CTRL, CODEC_DAC_CTRL_INV_POL_AB); // invert DAC signal +#endif } void codec_init(){ diff --git a/Source/cs4272.h b/Source/cs4272.h index e20c85e9..905b8fd6 100644 --- a/Source/cs4272.h +++ b/Source/cs4272.h @@ -12,13 +12,16 @@ #define CODEC_MC_SERIAL_FORMAT(x) (uint8_t)(((x) & 0x07) << 0) // Section 8.2 DAC Control -#define CODEC_DAC_CONTROL_REG (uint8_t)0x02 +#define CODEC_DAC_CTRL (uint8_t)0x02 #define CODEC_DAC_CTRL_AUTO_MUTE (uint8_t)0x80 #define CODEC_DAC_CTRL_FILTER_SEL (uint8_t)0x40 #define CODEC_DAC_CTRL_DE_EMPHASIS(x) (uint8_t)(((x) & 0x03) << 4) #define CODEC_DAC_CTRL_VOL_RAMP_UP (uint8_t)0x08 #define CODEC_DAC_CTRL_VOL_RAMP_DN (uint8_t)0x04 #define CODEC_DAC_CTRL_INV_POL(x) (uint8_t)(((x) & 0x03) << 0) +#define CODEC_DAC_CTRL_INV_POL_AB (uint8_t)(0x03) +#define CODEC_DAC_CTRL_INV_POL_A (uint8_t)(0x02) +#define CODEC_DAC_CTRL_INV_POL_B (uint8_t)(0x01) // Section 8.3 DAC Volume and Mixing #define CODEC_DAC_VOL_REG (uint8_t)0x03 From 2d128ac3d30c526e76eb2fdad41578af82bac25d Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 26 Oct 2021 11:19:11 +0200 Subject: [PATCH 140/286] disable DAC scaling and buffer (more range) --- Genius/Inc/hardware.h | 2 ++ Genius/Src/Genius.cpp | 10 ++++------ Genius/Src/main.c | 9 +++++++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Genius/Inc/hardware.h b/Genius/Inc/hardware.h index 0fd2ab93..d972fab4 100644 --- a/Genius/Inc/hardware.h +++ b/Genius/Inc/hardware.h @@ -45,6 +45,7 @@ #define AUDIO_BITS_PER_SAMPLE 16 #define AUDIO_BYTES_PER_SAMPLE (AUDIO_BITS_PER_SAMPLE/8) #define AUDIO_CHANNELS 2 +#define AUDIO_OUTPUT_GAIN 121 /* -6dB */ #define USBD_AUDIO_RX_CHANNELS AUDIO_CHANNELS #define USBD_AUDIO_TX_CHANNELS AUDIO_CHANNELS #define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) @@ -62,6 +63,7 @@ #define USB_HOST_RX_BUFF_SIZE 256 /* Max Received data 64 bytes */ #define USE_USBH_MIDI + #define ARM_CYCLES_PER_SAMPLE (480000000/AUDIO_SAMPLINGRATE) /* 480MHz / 48kHz */ // Serial MIDI diff --git a/Genius/Src/Genius.cpp b/Genius/Src/Genius.cpp index 9f829b78..eb73f5ea 100644 --- a/Genius/Src/Genius.cpp +++ b/Genius/Src/Genius.cpp @@ -75,23 +75,20 @@ void onSetup(){ tr_out_b_pin.outputMode(); tr_out_a_pin.high(); tr_out_b_pin.high(); - + setAnalogValue(PARAMETER_F, 0); + setAnalogValue(PARAMETER_G, 0); HAL_GPIO_WritePin(OLED_RST_GPIO_Port, OLED_RST_Pin, GPIO_PIN_RESET); // OLED off extern SPI_HandleTypeDef OLED_SPI; graphics.begin(¶ms, &OLED_SPI); - progress_counter = 2000; - #ifdef USE_USB_HOST // enable USB Host power HAL_GPIO_WritePin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin, GPIO_PIN_SET); #endif - __HAL_TIM_SET_COUNTER(&ENCODER_TIM1, INT16_MAX/2); __HAL_TIM_SET_COUNTER(&ENCODER_TIM2, INT16_MAX/2); HAL_TIM_Encoder_Start_IT(&ENCODER_TIM1, TIM_CHANNEL_ALL); HAL_TIM_Encoder_Start_IT(&ENCODER_TIM2, TIM_CHANNEL_ALL); - progress_counter = 3000; } @@ -110,7 +107,8 @@ void setGateValue(uint8_t ch, int16_t value){ // 12x12 bit multiplication with unsigned operands and result #define U12_MUL_U12(a,b) (__USAT(((uint32_t)(a)*(b))>>12, 12)) static uint16_t scaleForDac(int16_t value){ - return U12_MUL_U12(value + 70, 3521); + // return U12_MUL_U12(value + 70, 3521); + return value; } void setAnalogValue(uint8_t ch, int16_t value){ diff --git a/Genius/Src/main.c b/Genius/Src/main.c index 958c432b..6fd1f11c 100644 --- a/Genius/Src/main.c +++ b/Genius/Src/main.c @@ -410,7 +410,7 @@ static void MX_DAC1_Init(void) */ sConfig.DAC_SampleAndHold = DAC_SAMPLEANDHOLD_DISABLE; sConfig.DAC_Trigger = DAC_TRIGGER_NONE; - sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE; + sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_DISABLE; sConfig.DAC_ConnectOnChipPeripheral = DAC_CHIPCONNECT_DISABLE; sConfig.DAC_UserTrimming = DAC_TRIMMING_FACTORY; if (HAL_DAC_ConfigChannel(&hdac1, &sConfig, DAC_CHANNEL_1) != HAL_OK) @@ -424,7 +424,12 @@ static void MX_DAC1_Init(void) Error_Handler(); } /* USER CODE BEGIN DAC1_Init 2 */ - + /* extern DAC_HandleTypeDef hdac; */ + /* DAC_ChannelConfTypeDef *sConfig; */ + /* if (HAL_DACEx_SelfCalibrate(&hdac1, &sConfig, DAC_CHANNEL_1) != HAL_OK) */ + /* Error_Handler(); */ + /* if (HAL_DACEx_SelfCalibrate(&hdac1, &sConfig, DAC_CHANNEL_2) != HAL_OK) */ + /* Error_Handler(); */ /* USER CODE END DAC1_Init 2 */ } From c6e84305b36cc53914f06ebfbef317f4094130d9 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 26 Oct 2021 12:58:06 +0200 Subject: [PATCH 141/286] ADC changes --- Genius/Genius.ioc | 1771 +++++++++++----------- Genius/Inc/GeniusParameterController.hpp | 61 +- Genius/Inc/hardware.h | 1 + Genius/Inc/stm32h7xx_hal_conf.h | 1 + Genius/Src/Genius.cpp | 28 +- Genius/Src/main.c | 8 +- Genius/Src/stm32h7xx_hal_msp.c | 24 +- 7 files changed, 980 insertions(+), 914 deletions(-) diff --git a/Genius/Genius.ioc b/Genius/Genius.ioc index 822bf358..5c88c791 100644 --- a/Genius/Genius.ioc +++ b/Genius/Genius.ioc @@ -1,940 +1,943 @@ #MicroXplorer Configuration settings - do not modify -PF7.GPIOParameters=GPIO_Label -Dma.USART2_TX.7.MemInc=DMA_MINC_ENABLE -PB13.GPIOParameters=GPIO_Speed -Dma.USART2_TX.7.Priority=DMA_PRIORITY_LOW -SH.FMC_D0_DA0.ConfNb=1 -PA15\ (JTDI).GPIOParameters=GPIO_PuPd,GPIO_Label +ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_16 +ADC1.Channel-1\#ChannelRegularConversion=ADC_CHANNEL_17 +ADC1.ClockPrescaler=ADC_CLOCK_ASYNC_DIV64 +ADC1.ContinuousConvMode=ENABLE +ADC1.ConversionDataManagement=ADC_CONVERSIONDATA_DMA_CIRCULAR +ADC1.EOCSelection=ADC_EOC_SEQ_CONV +ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,master,ContinuousConvMode,ClockPrescaler,Resolution,Overrun,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,OffsetNumber-1\#ChannelRegularConversion,NbrOfConversion,EOCSelection,ConversionDataManagement +ADC1.NbrOfConversion=2 +ADC1.NbrOfConversionFlag=1 +ADC1.OffsetNumber-0\#ChannelRegularConversion=ADC_OFFSET_NONE +ADC1.OffsetNumber-1\#ChannelRegularConversion=ADC_OFFSET_NONE +ADC1.OffsetSignedSaturation-0\#ChannelRegularConversion=DISABLE +ADC1.Overrun=ADC_OVR_DATA_OVERWRITTEN +ADC1.Rank-0\#ChannelRegularConversion=1 +ADC1.Rank-1\#ChannelRegularConversion=2 +ADC1.Resolution=ADC_RESOLUTION_12B_OPT +ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_64CYCLES_5 +ADC1.SamplingTime-1\#ChannelRegularConversion=ADC_SAMPLETIME_64CYCLES_5 +ADC1.master=1 +DAC1.DAC1_OutputBuffer-DAC_OUT1=DAC_OUTPUTBUFFER_DISABLE +DAC1.DAC2_OutputBuffer-DAC_OUT2=DAC_OUTPUTBUFFER_DISABLE +DAC1.DAC_Channel-DAC_OUT1=DAC_CHANNEL_1 +DAC1.DAC_Channel-DAC_OUT2=DAC_CHANNEL_2 +DAC1.IPParameters=DAC_Channel-DAC_OUT2,DAC_Channel-DAC_OUT1,DAC2_OutputBuffer-DAC_OUT2,DAC1_OutputBuffer-DAC_OUT1 +Dma.ADC1.3.Direction=DMA_PERIPH_TO_MEMORY +Dma.ADC1.3.EventEnable=DISABLE +Dma.ADC1.3.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.ADC1.3.Instance=DMA1_Stream0 +Dma.ADC1.3.MemDataAlignment=DMA_MDATAALIGN_HALFWORD +Dma.ADC1.3.MemInc=DMA_MINC_ENABLE +Dma.ADC1.3.Mode=DMA_CIRCULAR +Dma.ADC1.3.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD +Dma.ADC1.3.PeriphInc=DMA_PINC_DISABLE +Dma.ADC1.3.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.ADC1.3.Priority=DMA_PRIORITY_LOW +Dma.ADC1.3.RequestNumber=1 +Dma.ADC1.3.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.ADC1.3.SignalID=NONE +Dma.ADC1.3.SyncEnable=DISABLE +Dma.ADC1.3.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.ADC1.3.SyncRequestNumber=1 +Dma.ADC1.3.SyncSignalID=NONE +Dma.Request0=SPI2_TX +Dma.Request1=SAI1_A +Dma.Request2=SAI1_B +Dma.Request3=ADC1 +Dma.Request4=UART5_RX +Dma.Request5=UART5_TX +Dma.Request6=USART2_RX +Dma.Request7=USART2_TX +Dma.RequestsNb=8 +Dma.SAI1_A.1.Direction=DMA_MEMORY_TO_PERIPH +Dma.SAI1_A.1.EventEnable=DISABLE +Dma.SAI1_A.1.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SAI1_A.1.Instance=DMA2_Stream1 +Dma.SAI1_A.1.MemDataAlignment=DMA_MDATAALIGN_WORD +Dma.SAI1_A.1.MemInc=DMA_MINC_ENABLE +Dma.SAI1_A.1.Mode=DMA_CIRCULAR +Dma.SAI1_A.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD +Dma.SAI1_A.1.PeriphInc=DMA_PINC_DISABLE +Dma.SAI1_A.1.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.SAI1_A.1.Priority=DMA_PRIORITY_HIGH +Dma.SAI1_A.1.RequestNumber=1 +Dma.SAI1_A.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber Dma.SAI1_A.1.SignalID=NONE -USART2.IPParameters=WordLength,VirtualMode-Asynchronous,OverrunDisableParam,DMADisableonRxErrorParam -SH.FMC_A8.ConfNb=1 -SH.FMC_A0.ConfNb=1 -SH.FMC_D6_DA6.ConfNb=1 -PC10.GPIO_PuPd=GPIO_PULLUP -SH.FMC_D9_DA9.ConfNb=1 -FMC.SDClockPeriod1=FMC_SDRAM_CLOCK_PERIOD_2 -SH.FMC_A0.0=FMC_A0,12b-sda1 -Dma.SAI1_B.2.MemDataAlignment=DMA_MDATAALIGN_WORD -PG8.Signal=FMC_SDCLK -SH.GPXTI14.0=GPIO_EXTI14 +Dma.SAI1_A.1.SyncEnable=DISABLE +Dma.SAI1_A.1.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.SAI1_A.1.SyncRequestNumber=1 Dma.SAI1_A.1.SyncSignalID=NONE -RCC.PLLQCLKFreq_Value=48000000 -PG0.Signal=FMC_A10 -Dma.UART5_TX.5.SignalID=NONE -RCC.PLLFRACN=0 -Dma.USART2_RX.6.MemDataAlignment=DMA_MDATAALIGN_BYTE -DAC1.IPParameters=DAC_Channel-DAC_OUT2,DAC_Channel-DAC_OUT1 -RCC.RTCFreq_Value=32000 -Dma.SAI1_A.1.Mode=DMA_CIRCULAR -PA15\ (JTDI).Signal=S_TIM2_CH1 -RCC.CpuClockFreq_Value=480000000 -PD2.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -SH.FMC_SDNWE.ConfNb=1 -PG14.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -Dma.UART5_TX.5.FIFOMode=DMA_FIFOMODE_DISABLE -SH.FMC_D5_DA5.0=FMC_D5,sd-16b-d1 -PB3\ (JTDO/TRACESWO).GPIOParameters=GPIO_PuPd,GPIO_Label -Dma.USART2_RX.6.Direction=DMA_PERIPH_TO_MEMORY -SH.FMC_D9_DA9.0=FMC_D9,sd-16b-d1 -RCC.LPTIM1Freq_Value=120000000 -NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -SH.S_TIM3_CH2.ConfNb=1 -PF7.Signal=SPI5_SCK -PB4\ (NJTRST).GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -SH.FMC_SDNWE.0=FMC_SDNWE,12b-sda1 -SH.FMC_D11_DA11.0=FMC_D11,sd-16b-d1 -Dma.SAI1_A.1.Instance=DMA2_Stream1 -RCC.I2C4Freq_Value=120000000 -RCC.APB2TimFreq_Value=168000000 -PB6.Signal=FMC_SDNE1 -VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC.Signal=SAI1_VP_$IpInstance_SAIB_SAI_BASIC -Dma.USART2_RX.6.Instance=DMA1_Stream3 -PD0.Signal=FMC_D2_DA2 -PD8.Signal=FMC_D13_DA13 -Dma.SAI1_A.1.FIFOMode=DMA_FIFOMODE_DISABLE -PE1.Signal=FMC_NBL1 -RCC.USART3Freq_Value=42000000 -NVIC.EXTI15_10_IRQn=true\:15\:0\:true\:false\:true\:false\:true\:true -RCC.PLLSAIRCLKFreq_Value=50000000 -ProjectManager.ProjectBuild=false -NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -PA0.Locked=true -Dma.ADC1.3.RequestNumber=1 -SH.GPXTI12.0=GPIO_EXTI12 +Dma.SAI1_B.2.Direction=DMA_PERIPH_TO_MEMORY +Dma.SAI1_B.2.EventEnable=DISABLE +Dma.SAI1_B.2.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SAI1_B.2.Instance=DMA2_Stream4 +Dma.SAI1_B.2.MemDataAlignment=DMA_MDATAALIGN_WORD +Dma.SAI1_B.2.MemInc=DMA_MINC_ENABLE +Dma.SAI1_B.2.Mode=DMA_CIRCULAR +Dma.SAI1_B.2.PeriphDataAlignment=DMA_PDATAALIGN_WORD +Dma.SAI1_B.2.PeriphInc=DMA_PINC_DISABLE +Dma.SAI1_B.2.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.SAI1_B.2.Priority=DMA_PRIORITY_HIGH +Dma.SAI1_B.2.RequestNumber=1 +Dma.SAI1_B.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.SAI1_B.2.SignalID=NONE +Dma.SAI1_B.2.SyncEnable=DISABLE +Dma.SAI1_B.2.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.SAI1_B.2.SyncRequestNumber=1 +Dma.SAI1_B.2.SyncSignalID=NONE +Dma.SPI2_TX.0.Direction=DMA_MEMORY_TO_PERIPH +Dma.SPI2_TX.0.EventEnable=DISABLE +Dma.SPI2_TX.0.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SPI2_TX.0.Instance=DMA1_Stream4 +Dma.SPI2_TX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE +Dma.SPI2_TX.0.MemInc=DMA_MINC_ENABLE +Dma.SPI2_TX.0.Mode=DMA_NORMAL +Dma.SPI2_TX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +Dma.SPI2_TX.0.PeriphInc=DMA_PINC_DISABLE +Dma.SPI2_TX.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.SPI2_TX.0.Priority=DMA_PRIORITY_LOW +Dma.SPI2_TX.0.RequestNumber=1 +Dma.SPI2_TX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.SPI2_TX.0.SignalID=NONE +Dma.SPI2_TX.0.SyncEnable=DISABLE Dma.SPI2_TX.0.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -FMC.SelfRefreshTime1=4 -ProjectManager.FirmwarePackage=STM32Cube FW_H7 V1.9.0 -ProjectManager.BackupPrevious=false -RCC.FMCFreq_Value=240000000 -PE9.Signal=FMC_D6_DA6 -Dma.ADC1.3.Mode=DMA_CIRCULAR -SH.FMC_A2.0=FMC_A2,12b-sda1 -PB14.Mode=Host_FS -Dma.UART5_TX.5.Instance=DMA1_Stream2 +Dma.SPI2_TX.0.SyncRequestNumber=1 +Dma.SPI2_TX.0.SyncSignalID=NONE +Dma.UART5_RX.4.Direction=DMA_PERIPH_TO_MEMORY +Dma.UART5_RX.4.EventEnable=DISABLE +Dma.UART5_RX.4.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.UART5_RX.4.Instance=DMA1_Stream1 +Dma.UART5_RX.4.MemDataAlignment=DMA_MDATAALIGN_BYTE +Dma.UART5_RX.4.MemInc=DMA_MINC_ENABLE +Dma.UART5_RX.4.Mode=DMA_NORMAL +Dma.UART5_RX.4.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +Dma.UART5_RX.4.PeriphInc=DMA_PINC_DISABLE +Dma.UART5_RX.4.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.UART5_RX.4.Priority=DMA_PRIORITY_LOW +Dma.UART5_RX.4.RequestNumber=1 +Dma.UART5_RX.4.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.UART5_RX.4.SignalID=NONE +Dma.UART5_RX.4.SyncEnable=DISABLE Dma.UART5_RX.4.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -NVIC.TIM2_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true -RCC.USART16Freq_Value=120000000 -PE4.GPIO_Label=CS_LRCK -PF10.Locked=true -Dma.SPI2_TX.0.EventEnable=DISABLE -SH.FMC_D1_DA1.0=FMC_D1,sd-16b-d1 +Dma.UART5_RX.4.SyncRequestNumber=1 +Dma.UART5_RX.4.SyncSignalID=NONE +Dma.UART5_TX.5.Direction=DMA_MEMORY_TO_PERIPH Dma.UART5_TX.5.EventEnable=DISABLE -USB_OTG_HS.IPParameters=VirtualMode-Host_FS -VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 -ProjectManager.HalAssertFull=true -RCC.DIVP2Freq_Value=30000000 -PA0.Signal=ADC1_INP16 -Mcu.Package=LQFP144 -SPI2.Mode=SPI_MODE_MASTER -Dma.SAI1_B.2.Polarity=HAL_DMAMUX_REQ_GEN_RISING -SH.FMC_SDNCAS.ConfNb=1 -VP_SYS_VS_Systick.Signal=SYS_VS_Systick -PC3_C.GPIO_Label=OLED_DC -SH.FMC_A11.ConfNb=1 -PA10.Signal=GPIO_Input -FREERTOS.FootprintOK=true -FMC.WriteRecoveryTime1=2 -SPI5.CalculateBaudRate=30.0 MBits/s -RCC.APB2CLKDivider=RCC_HCLK_DIV2 -NVIC.EXTI2_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true -Dma.UART5_RX.4.Polarity=HAL_DMAMUX_REQ_GEN_RISING -RCC.APB1TimFreq_Value=84000000 -RCC.LPUART1Freq_Value=120000000 -Dma.USART2_TX.7.SyncSignalID=NONE -FMC.RowCycleDelay1=6 -USB_OTG_FS.IPParameters=VirtualMode,Sof_enable -PB13.Mode=Asynchronous -ADC1.EOCSelection=ADC_EOC_SEQ_CONV -PD15.Signal=FMC_D1_DA1 -RCC.PLLSAIQCLKFreq_Value=50000000 -RCC.VCO3OutputFreq_Value=100781250 -SH.FMC_D3_DA3.ConfNb=1 -PA6.GPIOParameters=GPIO_PuPd,GPIO_Label -SH.GPXTI10.0=GPIO_EXTI10 -PD6.GPIOParameters=GPIO_Label -Mcu.Pin80=PG14 -Mcu.Pin81=PG15 -SH.FMC_A4.0=FMC_A4,12b-sda1 -ProjectManager.ProjectFileName=Genius.ioc -SH.FMC_A5.ConfNb=1 -FREERTOS.Tasks01=defaultTask,0,1024,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL -Mcu.Pin79=PG10 -Mcu.PinsNb=94 -PC11.Locked=true -Mcu.Pin73=PD1 -Mcu.Pin74=PD2 -Mcu.Pin71=PC12 -Mcu.Pin72=PD0 -Mcu.Pin77=PD6 -PC13.Locked=true -PG5.Signal=FMC_A15_BA1 -Mcu.Pin78=PG9 -ADC1.OffsetNumber-0\#ChannelRegularConversion=ADC_OFFSET_NONE -Mcu.Pin75=PD3 -SH.FMC_D10_DA10.0=FMC_D10,sd-16b-d1 -PC13.Signal=GPIO_Output -Mcu.Pin76=PD4 -FREERTOS.INCLUDE_vTaskDelayUntil=1 -PD3.Signal=GPIO_Output -Dma.ADC1.3.Priority=DMA_PRIORITY_LOW -Mcu.Pin70=PC11 -Mcu.Pin68=PA15 (JTDI) -Mcu.Pin69=PC10 -PD6.Mode=SAI_A_AsyncSlave -PG14.Locked=true -Mcu.Pin62=PA9 -Mcu.Pin63=PA10 -Mcu.Pin60=PG8 -Mcu.Pin61=PC9 -Mcu.Pin66=PA13 (JTMS/SWDIO) -Mcu.Pin67=PA14 (JTCK/SWCLK) -Mcu.Pin64=PA11 -Mcu.Pin65=PA12 -Dma.SAI1_B.2.PeriphInc=DMA_PINC_DISABLE -PF8.GPIO_Label=FLASH_MISO -USB_HOST0.BSP.semaphore= +Dma.UART5_TX.5.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.UART5_TX.5.Instance=DMA1_Stream2 +Dma.UART5_TX.5.MemDataAlignment=DMA_MDATAALIGN_BYTE +Dma.UART5_TX.5.MemInc=DMA_MINC_ENABLE +Dma.UART5_TX.5.Mode=DMA_NORMAL +Dma.UART5_TX.5.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +Dma.UART5_TX.5.PeriphInc=DMA_PINC_DISABLE +Dma.UART5_TX.5.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.UART5_TX.5.Priority=DMA_PRIORITY_LOW +Dma.UART5_TX.5.RequestNumber=1 +Dma.UART5_TX.5.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.UART5_TX.5.SignalID=NONE +Dma.UART5_TX.5.SyncEnable=DISABLE +Dma.UART5_TX.5.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.UART5_TX.5.SyncRequestNumber=1 +Dma.UART5_TX.5.SyncSignalID=NONE +Dma.USART2_RX.6.Direction=DMA_PERIPH_TO_MEMORY +Dma.USART2_RX.6.EventEnable=DISABLE Dma.USART2_RX.6.FIFOMode=DMA_FIFOMODE_DISABLE -PD10.Signal=FMC_D15_DA15 -RCC.D1CPREFreq_Value=480000000 -PA3.Mode=Asynchronous +Dma.USART2_RX.6.Instance=DMA1_Stream3 +Dma.USART2_RX.6.MemDataAlignment=DMA_MDATAALIGN_BYTE Dma.USART2_RX.6.MemInc=DMA_MINC_ENABLE Dma.USART2_RX.6.Mode=DMA_NORMAL -RCC.Tim1OutputFreq_Value=240000000 -Mcu.Pin59=PG5 -Mcu.Pin57=PD15 -SH.GPXTI2.ConfNb=1 -Mcu.Pin58=PG4 -Dma.SPI2_TX.0.SyncRequestNumber=1 -TIM3.IC2Filter=8 -Mcu.Pin51=PB14 -RCC.USART6Freq_Value=84000000 -Mcu.Pin52=PB15 -SH.COMP_DAC11_group.0=DAC1_OUT1,DAC_OUT1 -Mcu.Pin50=PB13 -Mcu.Pin55=PD10 -Mcu.Pin56=PD14 -Mcu.Pin53=PD8 -Mcu.Pin54=PD9 -PB13.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM -PB11.GPIOParameters=GPIO_Label -Dma.SPI2_TX.0.SyncEnable=DISABLE -Mcu.Pin48=PB11 -SPI4.NSSPMode=SPI_NSS_PULSE_DISABLE -Mcu.Pin49=PB12 -Mcu.Pin46=PE15 -Mcu.Pin47=PB10 -VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC.Mode=SAI_B_BASIC -PB14.Signal=USB_OTG_HS_DM -PA5.Signal=COMP_DAC12_group -Mcu.Pin40=PE9 -Mcu.Pin41=PE10 -TIM3.IC1Filter=8 -Mcu.Pin44=PE13 -Mcu.Pin45=PE14 -Mcu.Pin42=PE11 -Mcu.Pin43=PE12 -NVIC.TIM3_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true -FMC.ReadBurst1=FMC_SDRAM_RBURST_ENABLE -PC2_C.GPIO_Label=OLED_RST -SH.FMC_A6.0=FMC_A6,12b-sda1 -RCC.AHB12Freq_Value=240000000 -PE14.Signal=FMC_D11_DA11 -PE6.Mode=TX_Only_Simplex_Unidirect_Master -Mcu.Pin37=PG1 -Mcu.Pin38=PE7 -Mcu.Pin35=PF15 -RCC.I2C1Freq_Value=42000000 -Mcu.Pin36=PG0 -RCC.PLLI2SPCLKFreq_Value=96000000 -SH.FMC_D14_DA14.ConfNb=1 -Mcu.Pin39=PE8 -SAI1.TriState-SAI_A_AsyncSlave=SAI_OUTPUT_NOTRELEASED -Dma.ADC1.3.SyncSignalID=NONE -Mcu.Pin30=PA7 -PA1.GPIO_Label=ADC1 -Mcu.Pin33=PF13 -Mcu.Pin34=PF14 -Mcu.Pin31=PF11 -PA15\ (JTDI).GPIO_PuPd=GPIO_PULLUP -Dma.ADC1.3.Polarity=HAL_DMAMUX_REQ_GEN_RISING -Mcu.Pin32=PF12 -NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -FREERTOS.configUSE_MUTEXES=0 -PF13.Signal=FMC_A7 -PC10.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -Dma.USART2_TX.7.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -TIM2.Period=0xffff -PG14.GPIO_PuPd=GPIO_PULLUP -PC9.GPIOParameters=GPIO_Label -PF9.GPIOParameters=GPIO_Label -RCC.PLLI2SQCLKFreq_Value=96000000 -Mcu.Pin26=PA3 -Mcu.Pin27=PA4 -NVIC.DMA2_Stream4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -Mcu.Pin24=PA1 -Mcu.Pin25=PA2 -Mcu.Pin28=PA5 -Mcu.Pin29=PA6 -Mcu.Pin22=PC3_C -Mcu.Pin23=PA0 -Mcu.Pin20=PC1 -ADC1.master=1 -Mcu.Pin21=PC2_C -PA10.Locked=true -NVIC.ForceEnableDMAVector=true -Dma.UART5_RX.4.Priority=DMA_PRIORITY_LOW -NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -PC12.GPIO_Label=SW_B -PE5.GPIO_Label=CS_SCK -Dma.ADC1.3.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -SH.FMC_SDNRAS.ConfNb=1 -ProjectManager.HeapSize=0x400 -Mcu.Pin15=PF9 -PA0.GPIOParameters=GPIO_Label -NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -Mcu.Pin16=PF10 -Mcu.Pin13=PF7 -Mcu.Pin14=PF8 -Mcu.Pin19=PC0 -PF10.GPIOParameters=GPIO_Label -Mcu.Pin17=PH0-OSC_IN (PH0) -Mcu.Pin18=PH1-OSC_OUT (PH1) -Dma.USART2_TX.7.MemDataAlignment=DMA_MDATAALIGN_BYTE -SAI1.VirtualProtocol-SAI_B_BASIC=VM_BASIC_PROTOCOL -NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 -Mcu.Pin11=PF5 -Mcu.Pin12=PF6 -Mcu.Pin10=PF4 -SH.GPXTI10.ConfNb=1 -ADC1.ConversionDataManagement=ADC_CONVERSIONDATA_DMA_CIRCULAR -PE3.Signal=SAI1_SD_B -Dma.SAI1_A.1.PeriphInc=DMA_PINC_DISABLE -PF4.Signal=FMC_A4 -PD2.Signal=GPXTI2 -PB4\ (NJTRST).GPIO_PuPd=GPIO_PULLUP -PC1.Mode=TX_Only_Simplex_Unidirect_Master -TIM2.IC2Filter=8 -Mcu.Family=STM32H7 -FMC.IPParameters=ReadBurst1,ReadPipeDelay1,LoadToActiveDelay1,ExitSelfRefreshDelay1,SelfRefreshTime1,RowCycleDelay1,WriteRecoveryTime1,RPDelay1,RCDDelay1,SDClockPeriod1,CASLatency1 -NVIC.OTG_HS_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true -ProjectManager.MainLocation=Src -SH.FMC_A6.ConfNb=1 -Dma.SPI2_TX.0.MemInc=DMA_MINC_ENABLE -SH.FMC_A8.0=FMC_A8,12b-sda1 -PG9.GPIOParameters=GPIO_Label -ProjectManager.KeepUserCode=true -ADC1.Overrun=ADC_OVR_DATA_OVERWRITTEN -ADC1.ContinuousConvMode=ENABLE -SH.FMC_D14_DA14.0=FMC_D14,sd-16b-d1 -PH0-OSC_IN\ (PH0).Signal=RCC_OSC_IN -SH.COMP_DAC12_group.0=DAC1_OUT2,DAC_OUT2 -Dma.UART5_TX.5.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -PA0.GPIO_Label=ADC0 -PA12.GPIOParameters=GPIO_Speed -SAI1.VirtualProtocol-SAI_A_BASIC=VM_BASIC_PROTOCOL -PA11.GPIOParameters=GPIO_Speed -PA11.Mode=Device_Only -VP_USB_HOST_VS_USB_HOST_ALL_CLASS_HS.Signal=USB_HOST_VS_USB_HOST_ALL_CLASS_HS -PD6.Locked=true -PD2.Locked=true -SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 -RCC.VCO2OutputFreq_Value=150000000 -SH.FMC_A11.0=FMC_A11,12b-sda1 -PB15.Signal=USB_OTG_HS_DP -PG15.Signal=FMC_SDNCAS +Dma.USART2_RX.6.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +Dma.USART2_RX.6.PeriphInc=DMA_PINC_DISABLE +Dma.USART2_RX.6.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.USART2_RX.6.Priority=DMA_PRIORITY_LOW +Dma.USART2_RX.6.RequestNumber=1 +Dma.USART2_RX.6.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.USART2_RX.6.SignalID=NONE +Dma.USART2_RX.6.SyncEnable=DISABLE Dma.USART2_RX.6.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -SH.GPXTI2.0=GPIO_EXTI2 -Dma.SAI1_A.1.RequestNumber=1 -SAI1.Instance-SAI_A_AsyncSlave=SAI$Index_Block_A -Mcu.IP4=DMA -Mcu.IP5=FMC -RCC.FCLKCortexFreq_Value=168000000 -Mcu.IP2=DAC1 -Mcu.IP3=DEBUG -PC11.GPIO_PuPd=GPIO_PULLUP -Mcu.IP0=ADC1 -Mcu.IP1=CORTEX_M7 -PE4.GPIOParameters=GPIO_Label -SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE -RCC.DIVP3Freq_Value=50390625 -RCC.SDMMCFreq_Value=48000000 -Dma.ADC1.3.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -Dma.UART5_RX.4.RequestNumber=1 -ADC1.Resolution=ADC_RESOLUTION_12B -ProjectManager.PreviousToolchain=TrueSTUDIO -TIM3.Period=0xffff -SH.COMP_DAC12_group.ConfNb=1 -SH.FMC_NBL1.0=FMC_NBL1,Sd2ByteEnable1 -SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,DataSize,NSSPMode,VirtualType,Direction +Dma.USART2_RX.6.SyncRequestNumber=1 +Dma.USART2_RX.6.SyncSignalID=NONE +Dma.USART2_TX.7.Direction=DMA_MEMORY_TO_PERIPH +Dma.USART2_TX.7.EventEnable=DISABLE +Dma.USART2_TX.7.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.USART2_TX.7.Instance=DMA1_Stream5 +Dma.USART2_TX.7.MemDataAlignment=DMA_MDATAALIGN_BYTE +Dma.USART2_TX.7.MemInc=DMA_MINC_ENABLE +Dma.USART2_TX.7.Mode=DMA_NORMAL +Dma.USART2_TX.7.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +Dma.USART2_TX.7.PeriphInc=DMA_PINC_DISABLE +Dma.USART2_TX.7.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.USART2_TX.7.Priority=DMA_PRIORITY_LOW +Dma.USART2_TX.7.RequestNumber=1 +Dma.USART2_TX.7.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.USART2_TX.7.SignalID=NONE +Dma.USART2_TX.7.SyncEnable=DISABLE +Dma.USART2_TX.7.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.USART2_TX.7.SyncRequestNumber=1 +Dma.USART2_TX.7.SyncSignalID=NONE +FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_3 +FMC.ExitSelfRefreshDelay1=6 +FMC.IPParameters=ReadBurst1,ReadPipeDelay1,LoadToActiveDelay1,ExitSelfRefreshDelay1,SelfRefreshTime1,RowCycleDelay1,WriteRecoveryTime1,RPDelay1,RCDDelay1,SDClockPeriod1,CASLatency1 +FMC.LoadToActiveDelay1=2 +FMC.RCDDelay1=2 +FMC.RPDelay1=2 +FMC.ReadBurst1=FMC_SDRAM_RBURST_ENABLE +FMC.ReadPipeDelay1=FMC_SDRAM_RPIPE_DELAY_0 +FMC.RowCycleDelay1=6 +FMC.SDClockPeriod1=FMC_SDRAM_CLOCK_PERIOD_2 +FMC.SelfRefreshTime1=4 +FMC.WriteRecoveryTime1=2 +FREERTOS.FootprintOK=true +FREERTOS.INCLUDE_vTaskDelayUntil=1 FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,MEMORY_ALLOCATION,configUSE_MUTEXES,FootprintOK,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,INCLUDE_vTaskDelayUntil -USB_HOST0.BSP.ip=GPIO +FREERTOS.MEMORY_ALLOCATION=2 +FREERTOS.Tasks01=defaultTask,0,1024,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL +FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 +FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 +FREERTOS.configUSE_MUTEXES=0 FREERTOS.configUSE_PREEMPTION=0 -RCC.HRTIMFreq_Value=240000000 -ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_16 -PH1-OSC_OUT\ (PH1).Mode=HSE-External-Oscillator -Dma.SAI1_B.2.SignalID=NONE -RCC.DIVR3Freq_Value=50390625 -RCC.HSE_VALUE=25000000 -NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -SH.FMC_A14_BA0.ConfNb=1 -FMC.ExitSelfRefreshDelay1=6 +File.Version=6 +GPIO.groupedBy=Group By Peripherals +KeepUserPlacement=true +Mcu.Family=STM32H7 +Mcu.IP0=ADC1 +Mcu.IP1=CORTEX_M7 Mcu.IP10=SPI2 -NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:true\:true -Mcu.IP12=SPI5 Mcu.IP11=SPI4 -PC10.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -Mcu.IP18=USART2 -Mcu.IP17=UART5 -Mcu.IP19=USB_HOST -PA6.GPIO_PuPd=GPIO_PULLUP -RCC.DIVP1Freq_Value=480000000 -Mcu.IP14=TIM2 -PF9.Mode=Full_Duplex_Master +Mcu.IP12=SPI5 Mcu.IP13=SYS -Mcu.IP16=TIM6 +Mcu.IP14=TIM2 Mcu.IP15=TIM3 -RCC.VCOInputFreq_Value=1000000 -PF11.Signal=FMC_SDNRAS -PC11.GPIO_Label=TR_IN_A -PB5.Mode=SdramChipSelect2_1 -PE3.GPIOParameters=GPIO_Label -Mcu.IP21=USB_OTG_HS +Mcu.IP16=TIM6 +Mcu.IP17=UART5 +Mcu.IP18=USART2 +Mcu.IP19=USB_HOST +Mcu.IP2=DAC1 Mcu.IP20=USB_OTG_FS -Dma.UART5_RX.4.Mode=DMA_NORMAL -SH.S_TIM3_CH1.0=TIM3_CH1,Encoder_Interface -PB3\ (JTDO/TRACESWO).GPIO_PuPd=GPIO_PULLUP -PB4\ (NJTRST).Locked=true -PA6.Signal=S_TIM3_CH1 -PG14.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -PB12.Mode=Asynchronous -SH.FMC_D4_DA4.ConfNb=1 -NVIC.OTG_FS_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true -ProjectManager.ToolChainLocation= -PF8.Signal=SPI5_MISO -UART5.IPParameters=BaudRate,DMADisableonRxErrorParam,OverrunDisableParam -RCC.DIVR1Freq_Value=480000000 -Mcu.Pin93=VP_USB_HOST_VS_USB_HOST_ALL_CLASS_HS -USB_HOST0.BSP.name=Drive_VBUS_HS -Dma.Request2=SAI1_B -Dma.Request1=SAI1_A -Dma.Request4=UART5_RX -Dma.Request3=ADC1 -Mcu.Pin91=VP_SYS_VS_Systick -Dma.Request6=USART2_RX -Mcu.Pin92=VP_TIM6_VS_ClockSourceINT -Dma.Request5=UART5_TX -NVIC.DMA1_Stream0_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true -PD3.GPIO_Label=TR_OUT_B -Mcu.Pin90=VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC -Dma.Request7=USART2_TX -Dma.SAI1_A.1.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -PE7.Signal=FMC_D4_DA4 -PD6.Signal=SAI1_SD_A -Dma.Request0=SPI2_TX -PE2.GPIO_Label=CS_SCK -PA12.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH -Mcu.Pin84=PB5 -Mcu.Pin85=PB6 +Mcu.IP21=USB_OTG_HS +Mcu.IP3=DEBUG +Mcu.IP4=DMA +Mcu.IP5=FMC +Mcu.IP6=FREERTOS +Mcu.IP7=NVIC +Mcu.IP8=RCC +Mcu.IP9=SAI1 +Mcu.IPNb=22 +Mcu.Name=STM32H743ZGTx +Mcu.Package=LQFP144 +Mcu.Pin0=PE2 +Mcu.Pin1=PE3 +Mcu.Pin10=PF4 +Mcu.Pin11=PF5 +Mcu.Pin12=PF6 +Mcu.Pin13=PF7 +Mcu.Pin14=PF8 +Mcu.Pin15=PF9 +Mcu.Pin16=PF10 +Mcu.Pin17=PH0-OSC_IN (PH0) +Mcu.Pin18=PH1-OSC_OUT (PH1) +Mcu.Pin19=PC0 +Mcu.Pin2=PE4 +Mcu.Pin20=PC1 +Mcu.Pin21=PC2_C +Mcu.Pin22=PC3_C +Mcu.Pin23=PA0 +Mcu.Pin24=PA1 +Mcu.Pin25=PA2 +Mcu.Pin26=PA3 +Mcu.Pin27=PA4 +Mcu.Pin28=PA5 +Mcu.Pin29=PA6 +Mcu.Pin3=PE5 +Mcu.Pin30=PA7 +Mcu.Pin31=PF11 +Mcu.Pin32=PF12 +Mcu.Pin33=PF13 +Mcu.Pin34=PF14 +Mcu.Pin35=PF15 +Mcu.Pin36=PG0 +Mcu.Pin37=PG1 +Mcu.Pin38=PE7 +Mcu.Pin39=PE8 +Mcu.Pin4=PE6 +Mcu.Pin40=PE9 +Mcu.Pin41=PE10 +Mcu.Pin42=PE11 +Mcu.Pin43=PE12 +Mcu.Pin44=PE13 +Mcu.Pin45=PE14 +Mcu.Pin46=PE15 +Mcu.Pin47=PB10 +Mcu.Pin48=PB11 +Mcu.Pin49=PB12 +Mcu.Pin5=PC13 +Mcu.Pin50=PB13 +Mcu.Pin51=PB14 +Mcu.Pin52=PB15 +Mcu.Pin53=PD8 +Mcu.Pin54=PD9 +Mcu.Pin55=PD10 +Mcu.Pin56=PD14 +Mcu.Pin57=PD15 +Mcu.Pin58=PG4 +Mcu.Pin59=PG5 +Mcu.Pin6=PF0 +Mcu.Pin60=PG8 +Mcu.Pin61=PC9 +Mcu.Pin62=PA9 +Mcu.Pin63=PA10 +Mcu.Pin64=PA11 +Mcu.Pin65=PA12 +Mcu.Pin66=PA13 (JTMS/SWDIO) +Mcu.Pin67=PA14 (JTCK/SWCLK) +Mcu.Pin68=PA15 (JTDI) +Mcu.Pin69=PC10 +Mcu.Pin7=PF1 +Mcu.Pin70=PC11 +Mcu.Pin71=PC12 +Mcu.Pin72=PD0 +Mcu.Pin73=PD1 +Mcu.Pin74=PD2 +Mcu.Pin75=PD3 +Mcu.Pin76=PD4 +Mcu.Pin77=PD6 +Mcu.Pin78=PG9 +Mcu.Pin79=PG10 +Mcu.Pin8=PF2 +Mcu.Pin80=PG14 +Mcu.Pin81=PG15 Mcu.Pin82=PB3 (JTDO/TRACESWO) Mcu.Pin83=PB4 (NJTRST) -Mcu.Pin88=VP_FREERTOS_VS_CMSIS_V1 -PA3.Signal=USART2_RX -Mcu.Pin89=VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC +Mcu.Pin84=PB5 +Mcu.Pin85=PB6 Mcu.Pin86=PE0 Mcu.Pin87=PE1 -SH.FMC_A3.ConfNb=1 -PB3\ (JTDO/TRACESWO).GPIO_Label=ENC1_CH2 -RCC.I2SFreq_Value=96000000 -USB_HOST.IPParameters=USBH_HandleTypeDef-ALL_Classes_HS,VirtualModeHS -Dma.UART5_RX.4.SyncEnable=DISABLE -Dma.UART5_TX.5.Mode=DMA_NORMAL -SH.S_TIM2_CH1.0=TIM2_CH1,Encoder_Interface -Dma.SPI2_TX.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING -RCC.UART7Freq_Value=42000000 -USART2.DMADisableonRxErrorParam=ADVFEATURE_DMA_DISABLEONRXERROR -PC9.GPIO_Label=USB_HOST_PWR_EN -SPI4.DataSize=SPI_DATASIZE_8BIT -NVIC.SavedSvcallIrqHandlerGenerated=true -PC11.Signal=GPXTI11 -TIM6.Prescaler=3500 -USB_HOST0.BSP.solution=PC9 -VP_TIM6_VS_ClockSourceINT.Mode=Enable_Timer -ProjectManager.DefaultFWLocation=true -Dma.UART5_TX.5.MemDataAlignment=DMA_MDATAALIGN_BYTE -PD9.Signal=FMC_D14_DA14 -PB12.Locked=true -ProjectManager.DeletePrevious=true -RCC.LCDTFToutputFreq_Value=25000000 -SPI5.Mode=SPI_MODE_MASTER -RCC.FamilyName=M -PH1-OSC_OUT\ (PH1).Signal=RCC_OSC_OUT -VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 -PA9.Mode=Activate_VBUS -SH.FMC_A15_BA1.ConfNb=1 -TIM6.IPParameters=Prescaler,Period,TIM_MasterOutputTrigger -PF6.Signal=GPIO_Output -PB10.GPIO_Label=OLED_SCK -RCC.VCO1OutputFreq_Value=960000000 -PC3_C.Locked=true -PF6.Locked=true -SH.FMC_D13_DA13.0=FMC_D13,sd-16b-d1 -Dma.ADC1.3.SyncRequestNumber=1 -SAI1.BasicDataSize-SAI_B_SyncSlave=SAI_PROTOCOL_DATASIZE_24BIT -RCC.AXIClockFreq_Value=240000000 -SH.GPXTI12.ConfNb=1 -SPI2.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,DataSize,VirtualType,Direction -PE2.GPIOParameters=GPIO_Label -PG10.GPIOParameters=GPIO_Label -RCC.USBFreq_Value=48000000 -PF9.GPIO_Label=FLASH_MOSI +Mcu.Pin88=VP_FREERTOS_VS_CMSIS_V1 +Mcu.Pin89=VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC +Mcu.Pin9=PF3 +Mcu.Pin90=VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC +Mcu.Pin91=VP_SYS_VS_Systick +Mcu.Pin92=VP_TIM6_VS_ClockSourceINT +Mcu.Pin93=VP_USB_HOST_VS_USB_HOST_ALL_CLASS_HS +Mcu.PinsNb=94 +Mcu.ThirdPartyNb=0 +Mcu.UserConstants= +Mcu.UserName=STM32H743ZGTx +MxCube.Version=6.3.0 +MxDb.Version=DB.6.0.30 +NVIC.ADC_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.DMA1_Stream0_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.DMA1_Stream1_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.DMA1_Stream2_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.DMA1_Stream3_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.DMA1_Stream4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.DMA1_Stream5_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.DMA2_Stream1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.DMA2_Stream4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.EXTI15_10_IRQn=true\:15\:0\:true\:false\:true\:false\:true\:true +NVIC.EXTI2_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true +NVIC.EXTI4_IRQn=true\:15\:0\:true\:false\:true\:false\:true\:true +NVIC.ForceEnableDMAVector=true +NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.OTG_FS_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true +NVIC.OTG_HS_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true +NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false +NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 +NVIC.SPI2_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.SavedPendsvIrqHandlerGenerated=true +NVIC.SavedSvcallIrqHandlerGenerated=true +NVIC.SavedSystickIrqHandlerGenerated=true +NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:true\:true +NVIC.TIM2_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true +NVIC.TIM3_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true +NVIC.UART5_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.USART2_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +PA0.GPIOParameters=GPIO_Label +PA0.GPIO_Label=ADC0 +PA0.Locked=true +PA0.Mode=IN16-Single-Ended +PA0.Signal=ADC1_INP16 +PA1.GPIOParameters=GPIO_Label +PA1.GPIO_Label=ADC1 +PA1.Locked=true PA1.Signal=SharedAnalog_PA1 -PA7.GPIO_PuPd=GPIO_PULLUP -Dma.USART2_TX.7.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -RCC.CKPERFreq_Value=16000000 -RCC.VCOI2SOutputFreq_Value=192000000 -Dma.ADC1.3.Direction=DMA_PERIPH_TO_MEMORY -RCC.PLLSAIPCLKFreq_Value=50000000 -board=Player -RCC.VCOOutputFreq_Value=336000000 -PB15.Mode=Host_FS -RCC.UART4Freq_Value=42000000 -MxCube.Version=6.2.1 -RCC.FDCANFreq_Value=48000000 -PE5.Mode=SAI_A_AsyncSlave -RCC.ADCFreq_Value=30000000 -PC1.GPIO_Label=OLED_MOSI PA10.GPIOParameters=GPIO_Label -PD4.GPIOParameters=GPIO_Label -VP_SYS_VS_Systick.Mode=SysTick -TIM6.TIM_MasterOutputTrigger=TIM_TRGO_UPDATE -SH.FMC_D12_DA12.0=FMC_D12,sd-16b-d1 -USB_OTG_FS.Sof_enable=ENABLE -VP_USB_HOST_VS_USB_HOST_ALL_CLASS_HS.Mode=ALL_Classes_HS -PF1.Signal=FMC_A1 -SH.FMC_D11_DA11.ConfNb=1 -RCC.UART5Freq_Value=42000000 -ADC1.NbrOfConversion=2 +PA10.GPIO_Label=USB_HOST_PWR_FAULT +PA10.Locked=true +PA10.Signal=GPIO_Input +PA11.GPIOParameters=GPIO_Speed +PA11.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PA11.Mode=Device_Only +PA11.Signal=USB_OTG_FS_DM +PA12.GPIOParameters=GPIO_Speed +PA12.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PA12.Mode=Device_Only +PA12.Signal=USB_OTG_FS_DP +PA13\ (JTMS/SWDIO).Mode=Serial_Wire +PA13\ (JTMS/SWDIO).Signal=DEBUG_JTMS-SWDIO +PA14\ (JTCK/SWCLK).Mode=Serial_Wire +PA14\ (JTCK/SWCLK).Signal=DEBUG_JTCK-SWCLK +PA15\ (JTDI).GPIOParameters=GPIO_PuPd,GPIO_Label PA15\ (JTDI).GPIO_Label=ENC1_CH1 -RCC.IPParameters=ADCFreq_Value,AHB12Freq_Value,AHB4Freq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,APB3Freq_Value,APB4Freq_Value,AXIClockFreq_Value,CECFreq_Value,CKPERFreq_Value,CortexFreq_Value,CpuClockFreq_Value,D1CPREFreq_Value,D1PPRE,D2PPRE1,D2PPRE2,D3PPRE,DFSDMACLkFreq_Value,DFSDMFreq_Value,DIVM1,DIVM2,DIVN1,DIVN2,DIVP1Freq_Value,DIVP2,DIVP2Freq_Value,DIVP3Freq_Value,DIVQ1,DIVQ1Freq_Value,DIVQ2Freq_Value,DIVQ3Freq_Value,DIVR1Freq_Value,DIVR2Freq_Value,DIVR3Freq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FDCANFreq_Value,FMCFreq_Value,FamilyName,HCLK3ClockFreq_Value,HCLKFreq_Value,HPRE,HRTIMFreq_Value,HSE_VALUE,HSI_VALUE,I2C123Freq_Value,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SFreq_Value,LCDTFToutputFreq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPTIM345Freq_Value,LPUART1Freq_Value,LSE_VALUE,LSI_VALUE,LTDCFreq_Value,MCO1PinFreq_Value,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLFRACN,PLLI2SPCLKFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLI2SRoutputFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLQoutputFreq_Value,PLLSAIN,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIRCLKFreq_Value,PLLSAIoutputFreq_Value,ProductRev,QSPIFreq_Value,RNGFreq_Value,RTCFreq_Value,SAI1Freq_Value,SAI23Freq_Value,SAI2Freq_Value,SAI4AFreq_Value,SAI4BFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SPI123Freq_Value,SPI45Freq_Value,SPI6Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,Tim1OutputFreq_Value,Tim2OutputFreq_Value,TraceFreq_Value,UART4Freq_Value,UART5Freq_Value,UART7Freq_Value,UART8Freq_Value,USART16Freq_Value,USART1Freq_Value,USART234578Freq_Value,USART2Freq_Value,USART3Freq_Value,USART6Freq_Value,USBFreq_Value,VCO1OutputFreq_Value,VCO2OutputFreq_Value,VCO3OutputFreq_Value,VCOI2SOutputFreq_Value,VCOInput1Freq_Value,VCOInput2Freq_Value,VCOInput3Freq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value -ProjectManager.AskForMigrate=true -PE0.Signal=FMC_NBL0 -PE12.Signal=FMC_D9_DA9 -NVIC.SavedPendsvIrqHandlerGenerated=true -Dma.USART2_TX.7.Polarity=HAL_DMAMUX_REQ_GEN_RISING -Mcu.IP8=RCC -Mcu.IP9=SAI1 -Mcu.IP6=FREERTOS -Mcu.IP7=NVIC -ProjectManager.CoupleFile=false -RCC.SYSCLKFreq_VALUE=480000000 -Dma.USART2_RX.6.SignalID=NONE -RCC.I2C123Freq_Value=120000000 -PA1.Locked=true -SH.GPXTI4.0=GPIO_EXTI4 -KeepUserPlacement=true -SH.GPXTI4.ConfNb=1 -Dma.UART5_TX.5.RequestNumber=1 -RCC.HSI_VALUE=16000000 -SH.SharedAnalog_PA1.1=ADC1_INP17,IN17-Single-Ended -RCC.PLLQ=7 -SH.SharedAnalog_PA1.0=ADC1_INN16 -RCC.PLLM=25 -PC3_C.Signal=GPIO_Output -RCC.PLLN=336 +PA15\ (JTDI).GPIO_PuPd=GPIO_PULLUP +PA15\ (JTDI).Signal=S_TIM2_CH1 PA2.Mode=Asynchronous -NVIC.DMA1_Stream3_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true -SH.FMC_D8_DA8.ConfNb=1 -Dma.SPI2_TX.0.Direction=DMA_MEMORY_TO_PERIPH -Dma.UART5_TX.5.Direction=DMA_MEMORY_TO_PERIPH +PA2.Signal=USART2_TX +PA3.Mode=Asynchronous +PA3.Signal=USART2_RX +PA4.Signal=COMP_DAC11_group +PA5.Signal=COMP_DAC12_group +PA6.GPIOParameters=GPIO_PuPd,GPIO_Label +PA6.GPIO_Label=ENC2_CH1 +PA6.GPIO_PuPd=GPIO_PULLUP +PA6.Signal=S_TIM3_CH1 +PA7.GPIOParameters=GPIO_PuPd,GPIO_Label +PA7.GPIO_Label=ENC2_CH2 +PA7.GPIO_PuPd=GPIO_PULLUP +PA7.Signal=S_TIM3_CH2 +PA9.Mode=Activate_VBUS +PA9.Signal=USB_OTG_FS_VBUS +PB10.GPIOParameters=GPIO_Label +PB10.GPIO_Label=OLED_SCK +PB10.Mode=TX_Only_Simplex_Unidirect_Master +PB10.Signal=SPI2_SCK +PB11.GPIOParameters=GPIO_Label +PB11.GPIO_Label=OLED_CS +PB11.Locked=true +PB11.Signal=GPIO_Output +PB12.GPIOParameters=GPIO_Speed +PB12.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM +PB12.Locked=true +PB12.Mode=Asynchronous PB12.Signal=UART5_RX -USB_HOST0.BSP.instance=PC9 +PB13.GPIOParameters=GPIO_Speed +PB13.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM +PB13.Locked=true +PB13.Mode=Asynchronous +PB13.Signal=UART5_TX +PB14.GPIOParameters=GPIO_Speed +PB14.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PB14.Mode=Host_FS +PB14.Signal=USB_OTG_HS_DM +PB15.GPIOParameters=GPIO_Speed +PB15.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PB15.Mode=Host_FS +PB15.Signal=USB_OTG_HS_DP +PB3\ (JTDO/TRACESWO).GPIOParameters=GPIO_PuPd,GPIO_Label +PB3\ (JTDO/TRACESWO).GPIO_Label=ENC1_CH2 +PB3\ (JTDO/TRACESWO).GPIO_PuPd=GPIO_PULLUP +PB3\ (JTDO/TRACESWO).Signal=S_TIM2_CH2 +PB4\ (NJTRST).GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PB4\ (NJTRST).GPIO_Label=ENC2_SW +PB4\ (NJTRST).GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PB4\ (NJTRST).GPIO_PuPd=GPIO_PULLUP +PB4\ (NJTRST).Locked=true PB4\ (NJTRST).Signal=GPXTI4 -PA11.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH -USB_OTG_HS.VirtualMode-Host_FS=Host_FS -SH.FMC_D7_DA7.0=FMC_D7,sd-16b-d1 -Dma.USART2_RX.6.RequestNumber=1 -RCC.USART1Freq_Value=84000000 -SH.FMC_A4.ConfNb=1 -SPI4.VirtualType=VM_MASTER -SAI1.VirtualMode-SAI_A_AsyncSlave=VM_SLAVE -FMC.RCDDelay1=2 -Dma.USART2_TX.7.FIFOMode=DMA_FIFOMODE_DISABLE -SPI2.VirtualType=VM_MASTER -PB10.Mode=TX_Only_Simplex_Unidirect_Master -Dma.UART5_TX.5.Priority=DMA_PRIORITY_LOW +PB5.Mode=SdramChipSelect2_1 +PB5.Signal=FMC_SDCKE1 +PB6.Mode=SdramChipSelect2_1 +PB6.Signal=FMC_SDNE1 +PC0.Signal=FMC_SDNWE +PC1.GPIOParameters=GPIO_Label +PC1.GPIO_Label=OLED_MOSI +PC1.Mode=TX_Only_Simplex_Unidirect_Master +PC1.Signal=SPI2_MOSI +PC10.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PC10.GPIO_Label=SW_A +PC10.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PC10.GPIO_PuPd=GPIO_PULLUP +PC10.Locked=true +PC10.Signal=GPXTI10 +PC11.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PC11.GPIO_Label=TR_IN_A +PC11.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PC11.GPIO_PuPd=GPIO_PULLUP +PC11.Locked=true +PC11.Signal=GPXTI11 +PC12.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PC12.GPIO_Label=SW_B +PC12.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PC12.GPIO_PuPd=GPIO_PULLUP PC12.Locked=true -PG4.Signal=FMC_A14_BA0 -NVIC.DMA1_Stream2_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true -RCC.PLLCLKFreq_Value=168000000 PC12.Signal=GPXTI12 -SPI5.DataSize=SPI_DATASIZE_8BIT +PC13.GPIOParameters=GPIO_Label +PC13.GPIO_Label=FLASH_WP +PC13.Locked=true +PC13.Signal=GPIO_Output +PC2_C.GPIOParameters=GPIO_Label +PC2_C.GPIO_Label=OLED_RST +PC2_C.Locked=true +PC2_C.Signal=GPIO_Output +PC3_C.GPIOParameters=GPIO_Label +PC3_C.GPIO_Label=OLED_DC +PC3_C.Locked=true +PC3_C.Signal=GPIO_Output +PC9.GPIOParameters=GPIO_Label +PC9.GPIO_Label=USB_HOST_PWR_EN +PC9.Locked=true +PC9.Signal=GPIO_Output +PD0.Signal=FMC_D2_DA2 +PD1.Signal=FMC_D3_DA3 +PD10.Signal=FMC_D15_DA15 +PD14.Signal=FMC_D0_DA0 +PD15.Signal=FMC_D1_DA1 +PD2.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PD2.GPIO_Label=TR_IN_B +PD2.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PD2.GPIO_PuPd=GPIO_PULLUP +PD2.Locked=true +PD2.Signal=GPXTI2 PD3.GPIOParameters=GPIO_Label -Dma.USART2_TX.7.SignalID=NONE -FMC.LoadToActiveDelay1=2 -USB_HOST0.BSP.condition= -Dma.SAI1_B.2.SyncSignalID=NONE -PA6.GPIO_Label=ENC2_CH1 -Dma.USART2_RX.6.SyncEnable=DISABLE -Dma.USART2_TX.7.EventEnable=DISABLE -PD4.Locked=true -PB13.Signal=UART5_TX -Dma.SAI1_A.1.MemDataAlignment=DMA_MDATAALIGN_WORD -PD6.GPIO_Label=CS_SDIN -Dma.SAI1_B.2.Mode=DMA_CIRCULAR -Dma.SPI2_TX.0.Instance=DMA1_Stream4 -PinOutPanel.RotationAngle=0 -PF6.GPIO_Label=FLASH_nCS -PE6.GPIO_Label=CS_SDA -RCC.MCO1PinFreq_Value=16000000 -RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK -RCC.AHB4Freq_Value=240000000 -SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 -Dma.UART5_RX.4.SyncRequestNumber=1 -Dma.ADC1.3.MemInc=DMA_MINC_ENABLE -Dma.UART5_RX.4.MemDataAlignment=DMA_MDATAALIGN_BYTE -PA14\ (JTCK/SWCLK).Signal=DEBUG_JTCK-SWCLK -Dma.SPI2_TX.0.SignalID=NONE -PE2.Mode=TX_Only_Simplex_Unidirect_Master -Dma.SAI1_B.2.SyncEnable=DISABLE -TIM2.IPParameters=EncoderMode,Period,IC1Filter,IC2Filter +PD3.GPIO_Label=TR_OUT_B +PD3.Locked=true +PD3.Signal=GPIO_Output +PD4.GPIOParameters=GPIO_Label +PD4.GPIO_Label=TR_OUT_A +PD4.Locked=true PD4.Signal=GPIO_Output -SH.FMC_D10_DA10.ConfNb=1 -USB_HOST0.BSP.component= -PB6.Mode=SdramChipSelect2_1 -RCC.DIVQ3Freq_Value=50390625 -Dma.USART2_RX.6.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -RCC.SAI2Freq_Value=50000000 +PD6.GPIOParameters=GPIO_Label +PD6.GPIO_Label=CS_SDIN +PD6.Locked=true +PD6.Mode=SAI_A_AsyncSlave +PD6.Signal=SAI1_SD_A +PD8.Signal=FMC_D13_DA13 +PD9.Signal=FMC_D14_DA14 +PE0.Signal=FMC_NBL0 +PE1.Signal=FMC_NBL1 +PE10.Signal=FMC_D7_DA7 +PE11.Signal=FMC_D8_DA8 +PE12.Signal=FMC_D9_DA9 +PE13.Signal=FMC_D10_DA10 +PE14.Signal=FMC_D11_DA11 +PE15.Signal=FMC_D12_DA12 +PE2.GPIOParameters=GPIO_Label +PE2.GPIO_Label=CS_SCK +PE2.Mode=TX_Only_Simplex_Unidirect_Master +PE2.Signal=SPI4_SCK +PE3.GPIOParameters=GPIO_Label +PE3.GPIO_Label=CS_SDOUT +PE3.Mode=SAI_B_SyncSlave +PE3.Signal=SAI1_SD_B +PE4.GPIOParameters=GPIO_Label +PE4.GPIO_Label=CS_LRCK +PE4.Mode=SAI_A_AsyncSlave +PE4.Signal=SAI1_FS_A +PE5.GPIOParameters=GPIO_Label +PE5.GPIO_Label=CS_SCK +PE5.Mode=SAI_A_AsyncSlave PE5.Signal=SAI1_SCK_A +PE6.GPIOParameters=GPIO_Label +PE6.GPIO_Label=CS_SDA +PE6.Mode=TX_Only_Simplex_Unidirect_Master +PE6.Signal=SPI4_MOSI +PE7.Signal=FMC_D4_DA4 +PE8.Signal=FMC_D5_DA5 +PE9.Signal=FMC_D6_DA6 +PF0.Signal=FMC_A0 +PF1.Signal=FMC_A1 +PF10.GPIOParameters=GPIO_Label PF10.GPIO_Label=FLASH_HOLD -PB13.Locked=true -Dma.SAI1_A.1.MemInc=DMA_MINC_ENABLE -PD2.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -RCC.DIVM2=2 -RCC.DIVM1=5 -UART5.DMADisableonRxErrorParam=UART_ADVFEATURE_DMA_DISABLEONRXERROR -Dma.ADC1.3.Instance=DMA1_Stream0 -Dma.USART2_RX.6.EventEnable=DISABLE -MxDb.Version=DB.6.0.21 -PA1.GPIOParameters=GPIO_Label -Dma.UART5_RX.4.Direction=DMA_PERIPH_TO_MEMORY -SH.FMC_D15_DA15.ConfNb=1 -PA0.Mode=IN16-Single-Ended -SPI2.CalculateBaudRate=375.0 KBits/s -PE2.Signal=SPI4_SCK -PF8.Mode=Full_Duplex_Master -PA14\ (JTCK/SWCLK).Mode=Serial_Wire -Dma.USART2_RX.6.Polarity=HAL_DMAMUX_REQ_GEN_RISING -SH.GPXTI11.ConfNb=1 -NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false +PF10.Locked=true +PF10.Signal=GPIO_Output +PF11.Signal=FMC_SDNRAS +PF12.Signal=FMC_A6 +PF13.Signal=FMC_A7 +PF14.Signal=FMC_A8 +PF15.Signal=FMC_A9 +PF2.Signal=FMC_A2 PF3.Signal=FMC_A3 -RCC.DIVR2Freq_Value=75000000 -PE10.Signal=FMC_D7_DA7 -ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_64CYCLES_5 -RCC.MCO2PinFreq_Value=480000000 -UART5.OverrunDisableParam=UART_ADVFEATURE_OVERRUN_DISABLE +PF4.Signal=FMC_A4 +PF5.Signal=FMC_A5 +PF6.GPIOParameters=GPIO_Label +PF6.GPIO_Label=FLASH_nCS +PF6.Locked=true +PF6.Signal=GPIO_Output +PF7.GPIOParameters=GPIO_Label +PF7.GPIO_Label=FLASH_CLK +PF7.Mode=Full_Duplex_Master +PF7.Signal=SPI5_SCK PF8.GPIOParameters=GPIO_Label -SH.GPXTI11.0=GPIO_EXTI11 -Dma.SAI1_A.1.Direction=DMA_MEMORY_TO_PERIPH -RCC.DFSDMFreq_Value=120000000 -PB14.GPIOParameters=GPIO_Speed -SH.FMC_A1.0=FMC_A1,12b-sda1 -SH.GPXTI14.ConfNb=1 -Dma.SPI2_TX.0.PeriphInc=DMA_PINC_DISABLE -Dma.USART2_TX.7.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -SH.FMC_SDCLK.0=FMC_SDCLK,12b-sda1 -RCC.TraceFreq_Value=480000000 -RCC.APB4Freq_Value=120000000 -RCC.CECFreq_Value=32000 -RCC.SAI23Freq_Value=48000000 -PF14.Signal=FMC_A8 -NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -UART5.BaudRate=31250 -PB10.GPIOParameters=GPIO_Label -PC12.GPIO_PuPd=GPIO_PULLUP -PH0-OSC_IN\ (PH0).Mode=HSE-External-Oscillator -SH.FMC_D3_DA3.0=FMC_D3,sd-16b-d1 -Dma.USART2_TX.7.Instance=DMA1_Stream5 -SPI5.VirtualType=VM_MASTER -ProjectManager.CustomerFirmwarePackage= -USART2.OverrunDisableParam=ADVFEATURE_OVERRUN_DISABLE -NVIC.EXTI4_IRQn=true\:15\:0\:true\:false\:true\:false\:true\:true -SH.FMC_A7.ConfNb=1 -RCC.PLLQoutputFreq_Value=48000000 -SH.FMC_A1.ConfNb=1 -RCC.DIVQ1=20 -ADC1.Rank-0\#ChannelRegularConversion=1 -DAC1.DAC_Channel-DAC_OUT2=DAC_CHANNEL_2 -DAC1.DAC_Channel-DAC_OUT1=DAC_CHANNEL_1 -Dma.SAI1_B.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -Dma.USART2_RX.6.SyncSignalID=NONE -PD2.GPIO_PuPd=GPIO_PULLUP -VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC.Mode=SAI_A_BASIC -ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,master,ContinuousConvMode,ClockPrescaler,Resolution,Overrun,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,OffsetNumber-1\#ChannelRegularConversion,NbrOfConversion,EOCSelection,ConversionDataManagement -TIM2.IC1Filter=8 +PF8.GPIO_Label=FLASH_MISO +PF8.Mode=Full_Duplex_Master +PF8.Signal=SPI5_MISO +PF9.GPIOParameters=GPIO_Label +PF9.GPIO_Label=FLASH_MOSI +PF9.Mode=Full_Duplex_Master +PF9.Signal=SPI5_MOSI +PG0.Signal=FMC_A10 +PG1.Signal=FMC_A11 +PG10.GPIOParameters=GPIO_Label +PG10.GPIO_Label=CS_RST +PG10.Locked=true +PG10.Signal=GPIO_Output +PG14.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PG14.GPIO_Label=ENC1_SW +PG14.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PG14.GPIO_PuPd=GPIO_PULLUP +PG14.Locked=true +PG14.Signal=GPXTI14 +PG15.Signal=FMC_SDNCAS +PG4.Signal=FMC_A14_BA0 +PG5.Signal=FMC_A15_BA1 +PG8.Signal=FMC_SDCLK +PG9.GPIOParameters=GPIO_Label +PG9.GPIO_Label=CS_CS PG9.Locked=true PG9.Signal=GPIO_Output -USB_HOST.USBH_HandleTypeDef-ALL_Classes_HS=hUsbHostHS -RCC.SWPMI1Freq_Value=120000000 -FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 -PB11.GPIO_Label=OLED_CS -PD1.Signal=FMC_D3_DA3 -VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC.Signal=SAI1_VP_$IpInstance_SAIA_SAI_BASIC -RCC.DIVP2=5 -NVIC.DMA2_Stream1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -RCC.UART8Freq_Value=42000000 -PC0.Signal=FMC_SDNWE -Dma.UART5_RX.4.MemInc=DMA_MINC_ENABLE -RCC.APB1CLKDivider=RCC_HCLK_DIV4 -PC11.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -RCC.QSPIFreq_Value=240000000 -Dma.USART2_RX.6.PeriphInc=DMA_PINC_DISABLE -PG10.Signal=GPIO_Output -PG10.Locked=true -VP_TIM6_VS_ClockSourceINT.Signal=TIM6_VS_ClockSourceINT -USB_HOST0.BSP.STBoard=false -SH.FMC_A3.0=FMC_A3,12b-sda1 -Dma.SAI1_A.1.Polarity=HAL_DMAMUX_REQ_GEN_RISING -RCC.USART234578Freq_Value=120000000 -FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_3 -RCC.SPI123Freq_Value=48000000 -PB14.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH -SH.FMC_D15_DA15.0=FMC_D15,sd-16b-d1 -Dma.SAI1_B.2.PeriphDataAlignment=DMA_PDATAALIGN_WORD -PC3_C.GPIOParameters=GPIO_Label -Dma.UART5_RX.4.SignalID=NONE -USB_HOST.VirtualModeHS=All_Classes -PA9.Signal=USB_OTG_FS_VBUS -SH.S_TIM2_CH2.ConfNb=1 -RCC.DIVN2=12 -RCC.DIVN1=192 -ADC1.OffsetSignedSaturation-0\#ChannelRegularConversion=DISABLE -PB10.Signal=SPI2_SCK -FREERTOS.MEMORY_ALLOCATION=2 +PH0-OSC_IN\ (PH0).Mode=HSE-External-Oscillator +PH0-OSC_IN\ (PH0).Signal=RCC_OSC_IN +PH1-OSC_OUT\ (PH1).Mode=HSE-External-Oscillator +PH1-OSC_OUT\ (PH1).Signal=RCC_OSC_OUT +PinOutPanel.RotationAngle=0 +ProjectManager.AskForMigrate=true +ProjectManager.BackupPrevious=false +ProjectManager.CompilerOptimize=2 +ProjectManager.ComputerToolchain=false +ProjectManager.CoupleFile=false +ProjectManager.CustomerFirmwarePackage= +ProjectManager.DefaultFWLocation=true +ProjectManager.DeletePrevious=true +ProjectManager.DeviceId=STM32H743ZGTx +ProjectManager.FirmwarePackage=STM32Cube FW_H7 V1.9.0 +ProjectManager.FreePins=true +ProjectManager.HalAssertFull=true +ProjectManager.HeapSize=0x400 +ProjectManager.KeepUserCode=true ProjectManager.LastFirmware=true -PE15.Signal=FMC_D12_DA12 -Dma.UART5_TX.5.Polarity=HAL_DMAMUX_REQ_GEN_RISING -PC11.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -PE8.Signal=FMC_D5_DA5 -RCC.RNGFreq_Value=48000000 +ProjectManager.LibraryCopy=2 +ProjectManager.MainLocation=Src +ProjectManager.NoMain=false +ProjectManager.PreviousToolchain=TrueSTUDIO +ProjectManager.ProjectBuild=false +ProjectManager.ProjectFileName=Genius.ioc +ProjectManager.ProjectName=Genius +ProjectManager.RegisterCallBack= +ProjectManager.StackSize=0x200 +ProjectManager.TargetToolchain=Other Toolchains (GPDSC) +ProjectManager.ToolChainLocation= +ProjectManager.UnderRoot=false +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI2_Init-SPI2-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-MX_SPI5_Init-SPI5-false-HAL-true,9-MX_TIM2_Init-TIM2-false-HAL-true,10-MX_TIM3_Init-TIM3-false-HAL-true,11-MX_TIM6_Init-TIM6-false-HAL-true,12-MX_USART2_UART_Init-USART2-false-HAL-true,13-MX_ADC1_Init-ADC1-false-HAL-true,14-MX_DAC1_Init-DAC1-false-HAL-true,15-MX_UART5_Init-UART5-false-HAL-true,16-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-false-HAL-true,17-MX_USB_HOST_Init-USB_HOST-false-HAL-false,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true +RCC.ADCFreq_Value=30000000 +RCC.AHB12Freq_Value=240000000 +RCC.AHB4Freq_Value=240000000 +RCC.AHBFreq_Value=168000000 +RCC.APB1CLKDivider=RCC_HCLK_DIV4 +RCC.APB1Freq_Value=120000000 +RCC.APB1TimFreq_Value=84000000 +RCC.APB2CLKDivider=RCC_HCLK_DIV2 +RCC.APB2Freq_Value=120000000 +RCC.APB2TimFreq_Value=168000000 +RCC.APB3Freq_Value=120000000 +RCC.APB4Freq_Value=120000000 +RCC.AXIClockFreq_Value=240000000 +RCC.CECFreq_Value=32000 +RCC.CKPERFreq_Value=16000000 +RCC.CortexFreq_Value=480000000 +RCC.CpuClockFreq_Value=480000000 +RCC.D1CPREFreq_Value=480000000 +RCC.D1PPRE=RCC_APB3_DIV2 +RCC.D2PPRE1=RCC_APB1_DIV2 +RCC.D2PPRE2=RCC_APB2_DIV2 +RCC.D3PPRE=RCC_APB4_DIV2 +RCC.DFSDMACLkFreq_Value=48000000 +RCC.DFSDMFreq_Value=120000000 +RCC.DIVM1=5 +RCC.DIVM2=2 +RCC.DIVN1=192 +RCC.DIVN2=12 +RCC.DIVP1Freq_Value=480000000 +RCC.DIVP2=5 +RCC.DIVP2Freq_Value=30000000 +RCC.DIVP3Freq_Value=50390625 +RCC.DIVQ1=20 +RCC.DIVQ1Freq_Value=48000000 +RCC.DIVQ2Freq_Value=75000000 +RCC.DIVQ3Freq_Value=50390625 +RCC.DIVR1Freq_Value=480000000 +RCC.DIVR2Freq_Value=75000000 +RCC.DIVR3Freq_Value=50390625 RCC.EthernetFreq_Value=168000000 -TIM3.IPParameters=EncoderMode,Period,IC1Filter,IC2Filter -Dma.USART2_TX.7.Direction=DMA_MEMORY_TO_PERIPH -Dma.SAI1_A.1.EventEnable=DISABLE -PG14.GPIO_Label=ENC1_SW -SH.FMC_SDNCAS.0=FMC_SDNCAS,12b-sda1 -RCC.ProductRev=revV -ProjectManager.FreePins=true +RCC.FCLKCortexFreq_Value=168000000 +RCC.FDCANFreq_Value=48000000 +RCC.FMCFreq_Value=240000000 +RCC.FamilyName=M +RCC.HCLK3ClockFreq_Value=240000000 +RCC.HCLKFreq_Value=240000000 +RCC.HPRE=RCC_HCLK_DIV2 +RCC.HRTIMFreq_Value=240000000 +RCC.HSE_VALUE=25000000 +RCC.HSI_VALUE=16000000 +RCC.I2C123Freq_Value=120000000 +RCC.I2C1Freq_Value=42000000 +RCC.I2C2Freq_Value=42000000 +RCC.I2C3Freq_Value=42000000 +RCC.I2C4Freq_Value=120000000 +RCC.I2SFreq_Value=96000000 +RCC.IPParameters=ADCFreq_Value,AHB12Freq_Value,AHB4Freq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,APB3Freq_Value,APB4Freq_Value,AXIClockFreq_Value,CECFreq_Value,CKPERFreq_Value,CortexFreq_Value,CpuClockFreq_Value,D1CPREFreq_Value,D1PPRE,D2PPRE1,D2PPRE2,D3PPRE,DFSDMACLkFreq_Value,DFSDMFreq_Value,DIVM1,DIVM2,DIVN1,DIVN2,DIVP1Freq_Value,DIVP2,DIVP2Freq_Value,DIVP3Freq_Value,DIVQ1,DIVQ1Freq_Value,DIVQ2Freq_Value,DIVQ3Freq_Value,DIVR1Freq_Value,DIVR2Freq_Value,DIVR3Freq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FDCANFreq_Value,FMCFreq_Value,FamilyName,HCLK3ClockFreq_Value,HCLKFreq_Value,HPRE,HRTIMFreq_Value,HSE_VALUE,HSI_VALUE,I2C123Freq_Value,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SFreq_Value,LCDTFToutputFreq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPTIM345Freq_Value,LPUART1Freq_Value,LSE_VALUE,LSI_VALUE,LTDCFreq_Value,MCO1PinFreq_Value,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLFRACN,PLLI2SPCLKFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLI2SRoutputFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLQoutputFreq_Value,PLLSAIN,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIRCLKFreq_Value,PLLSAIoutputFreq_Value,ProductRev,QSPIFreq_Value,RNGFreq_Value,RTCFreq_Value,SAI1Freq_Value,SAI23Freq_Value,SAI2Freq_Value,SAI4AFreq_Value,SAI4BFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SPI123Freq_Value,SPI45Freq_Value,SPI6Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,Tim1OutputFreq_Value,Tim2OutputFreq_Value,TraceFreq_Value,UART4Freq_Value,UART5Freq_Value,UART7Freq_Value,UART8Freq_Value,USART16Freq_Value,USART1Freq_Value,USART234578Freq_Value,USART2Freq_Value,USART3Freq_Value,USART6Freq_Value,USBFreq_Value,VCO1OutputFreq_Value,VCO2OutputFreq_Value,VCO3OutputFreq_Value,VCOI2SOutputFreq_Value,VCOInput1Freq_Value,VCOInput2Freq_Value,VCOInput3Freq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value +RCC.LCDTFToutputFreq_Value=25000000 +RCC.LPTIM1Freq_Value=120000000 RCC.LPTIM2Freq_Value=120000000 -SH.FMC_NBL1.ConfNb=1 -Dma.SPI2_TX.0.FIFOMode=DMA_FIFOMODE_DISABLE -ProjectManager.UnderRoot=false -SH.FMC_D7_DA7.ConfNb=1 -PA4.Signal=COMP_DAC11_group -ADC1.SamplingTime-1\#ChannelRegularConversion=ADC_SAMPLETIME_64CYCLES_5 -PB5.Signal=FMC_SDCKE1 -SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX -SH.FMC_A10.ConfNb=1 -Dma.SAI1_A.1.SyncRequestNumber=1 -ProjectManager.CompilerOptimize=2 -ADC1.Rank-1\#ChannelRegularConversion=2 -SH.FMC_A5.0=FMC_A5,12b-sda1 -PA11.Signal=USB_OTG_FS_DM -Dma.ADC1.3.SignalID=NONE -SH.S_TIM3_CH1.ConfNb=1 RCC.LPTIM345Freq_Value=120000000 -ProjectManager.ComputerToolchain=false -PF9.Signal=SPI5_MOSI -SAI1.InitProtocol-SAI_A_AsyncSlave=Enable +RCC.LPUART1Freq_Value=120000000 +RCC.LSE_VALUE=32768 +RCC.LSI_VALUE=32000 RCC.LTDCFreq_Value=50390625 -Dma.SAI1_B.2.Instance=DMA2_Stream4 -Dma.SAI1_A.1.Priority=DMA_PRIORITY_HIGH -Dma.ADC1.3.EventEnable=DISABLE -SPI2.DataSize=SPI_DATASIZE_8BIT -PB4\ (NJTRST).GPIO_Label=ENC2_SW -Dma.SAI1_B.2.FIFOMode=DMA_FIFOMODE_DISABLE -SH.FMC_D12_DA12.ConfNb=1 -RCC.HCLK3ClockFreq_Value=240000000 -RCC.I2C2Freq_Value=42000000 -SPI5.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,DataSize,VirtualType,Direction -USB_HOST0.BSP.mode=Output -PA7.GPIOParameters=GPIO_PuPd,GPIO_Label -PC1.Signal=SPI2_MOSI -PB12.GPIOParameters=GPIO_Speed -PD2.GPIO_Label=TR_IN_B -PG10.GPIO_Label=CS_RST -Dma.USART2_RX.6.SyncRequestNumber=1 -PA13\ (JTMS/SWDIO).Signal=DEBUG_JTMS-SWDIO -RCC.DIVQ2Freq_Value=75000000 -RCC.SAI1Freq_Value=48000000 -RCC.CortexFreq_Value=480000000 -SH.FMC_A2.ConfNb=1 -Mcu.UserName=STM32H743ZGTx -RCC.HPRE=RCC_HCLK_DIV2 -Dma.SAI1_A.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -Dma.SAI1_B.2.MemInc=DMA_MINC_ENABLE -PC10.Locked=true -PC10.Signal=GPXTI10 -SPI4.Direction=SPI_DIRECTION_2LINES_TXONLY -SH.FMC_NBL0.0=FMC_NBL0,Sd2ByteEnable1 -TIM3.EncoderMode=TIM_ENCODERMODE_TI12 -ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI2_Init-SPI2-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-MX_SPI5_Init-SPI5-false-HAL-true,9-MX_TIM2_Init-TIM2-false-HAL-true,10-MX_TIM3_Init-TIM3-false-HAL-true,11-MX_TIM6_Init-TIM6-false-HAL-true,12-MX_USART2_UART_Init-USART2-false-HAL-true,13-MX_ADC1_Init-ADC1-false-HAL-true,14-MX_DAC1_Init-DAC1-false-HAL-true,15-MX_UART5_Init-UART5-false-HAL-true,16-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-false-HAL-true,17-MX_USB_OTG_HS_HCD_Init-USB_OTG_HS-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true -SH.FMC_D6_DA6.0=FMC_D6,sd-16b-d1 -PC9.Locked=true +RCC.MCO1PinFreq_Value=16000000 +RCC.MCO2PinFreq_Value=480000000 +RCC.PLLCLKFreq_Value=168000000 +RCC.PLLFRACN=0 +RCC.PLLI2SPCLKFreq_Value=96000000 +RCC.PLLI2SQCLKFreq_Value=96000000 RCC.PLLI2SRCLKFreq_Value=96000000 -TIM2.EncoderMode=TIM_ENCODERMODE_TI12 -RCC.USART2Freq_Value=42000000 -Dma.SPI2_TX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -PC13.GPIO_Label=FLASH_WP -Dma.ADC1.3.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD -PB11.Signal=GPIO_Output -NVIC.DMA1_Stream4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -Dma.UART5_TX.5.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -PE5.GPIOParameters=GPIO_Label -ProjectManager.StackSize=0x200 -NVIC.UART5_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -Dma.SPI2_TX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE -RCC.VCOInput3Freq_Value=781250 -RCC.I2C3Freq_Value=42000000 -NVIC.ADC_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -SH.FMC_A7.0=FMC_A7,12b-sda1 -PA12.Signal=USB_OTG_FS_DP -Dma.SAI1_B.2.SyncRequestNumber=1 -Mcu.UserConstants= -SPI4.Mode=SPI_MODE_MASTER -PC1.GPIOParameters=GPIO_Label -Mcu.ThirdPartyNb=0 -Dma.SPI2_TX.0.SyncSignalID=NONE -Dma.USART2_TX.7.PeriphInc=DMA_PINC_DISABLE -RCC.HCLKFreq_Value=240000000 -Mcu.IPNb=22 RCC.PLLI2SRoutputFreq_Value=96000000 +RCC.PLLM=25 +RCC.PLLN=336 +RCC.PLLQ=7 +RCC.PLLQCLKFreq_Value=48000000 +RCC.PLLQoutputFreq_Value=48000000 +RCC.PLLSAIN=100 +RCC.PLLSAIPCLKFreq_Value=50000000 +RCC.PLLSAIQCLKFreq_Value=50000000 +RCC.PLLSAIRCLKFreq_Value=50000000 +RCC.PLLSAIoutputFreq_Value=50000000 +RCC.ProductRev=revV +RCC.QSPIFreq_Value=240000000 +RCC.RNGFreq_Value=48000000 +RCC.RTCFreq_Value=32000 +RCC.SAI1Freq_Value=48000000 +RCC.SAI23Freq_Value=48000000 +RCC.SAI2Freq_Value=50000000 +RCC.SAI4AFreq_Value=48000000 +RCC.SAI4BFreq_Value=48000000 +RCC.SDMMCFreq_Value=48000000 RCC.SPDIFRXFreq_Value=48000000 -Dma.ADC1.3.PeriphInc=DMA_PINC_DISABLE -SH.SharedAnalog_PA1.ConfNb=2 -PF12.Signal=FMC_A6 -FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 -Mcu.Pin6=PF0 -Mcu.Pin7=PF1 -Mcu.Pin8=PF2 -Mcu.Pin9=PF3 +RCC.SPI123Freq_Value=48000000 +RCC.SPI45Freq_Value=120000000 +RCC.SPI6Freq_Value=120000000 +RCC.SWPMI1Freq_Value=120000000 +RCC.SYSCLKFreq_VALUE=480000000 +RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK +RCC.Tim1OutputFreq_Value=240000000 +RCC.Tim2OutputFreq_Value=240000000 +RCC.TraceFreq_Value=480000000 +RCC.UART4Freq_Value=42000000 +RCC.UART5Freq_Value=42000000 +RCC.UART7Freq_Value=42000000 +RCC.UART8Freq_Value=42000000 +RCC.USART16Freq_Value=120000000 +RCC.USART1Freq_Value=84000000 +RCC.USART234578Freq_Value=120000000 +RCC.USART2Freq_Value=42000000 +RCC.USART3Freq_Value=42000000 +RCC.USART6Freq_Value=84000000 +RCC.USBFreq_Value=48000000 +RCC.VCO1OutputFreq_Value=960000000 +RCC.VCO2OutputFreq_Value=150000000 +RCC.VCO3OutputFreq_Value=100781250 +RCC.VCOI2SOutputFreq_Value=192000000 +RCC.VCOInput1Freq_Value=5000000 +RCC.VCOInput2Freq_Value=12500000 +RCC.VCOInput3Freq_Value=781250 +RCC.VCOInputFreq_Value=1000000 +RCC.VCOOutputFreq_Value=336000000 RCC.VCOSAIOutputFreq_Value=100000000 -Dma.SPI2_TX.0.Mode=DMA_NORMAL -PC2_C.Signal=GPIO_Output +SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX +SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_RX +SAI1.BasicDataSize-SAI_A_AsyncSlave=SAI_PROTOCOL_DATASIZE_24BIT +SAI1.BasicDataSize-SAI_B_SyncSlave=SAI_PROTOCOL_DATASIZE_24BIT +SAI1.IPParameters=Instance-SAI_A_AsyncSlave,VirtualMode-SAI_A_AsyncSlave,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,InitProtocol-SAI_B_SyncSlave,VirtualProtocol-SAI_B_BASIC,AudioMode-SAI_A_AsyncSlave,TriState-SAI_A_AsyncSlave,InitProtocol-SAI_A_AsyncSlave,VirtualProtocol-SAI_A_BASIC,BasicDataSize-SAI_B_SyncSlave,BasicDataSize-SAI_A_AsyncSlave,AudioMode-SAI_B_SyncSlave +SAI1.InitProtocol-SAI_A_AsyncSlave=Enable +SAI1.InitProtocol-SAI_B_SyncSlave=Enable +SAI1.Instance-SAI_A_AsyncSlave=SAI$Index_Block_A +SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B +SAI1.TriState-SAI_A_AsyncSlave=SAI_OUTPUT_NOTRELEASED +SAI1.VirtualMode-SAI_A_AsyncSlave=VM_SLAVE +SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE +SAI1.VirtualProtocol-SAI_A_BASIC=VM_BASIC_PROTOCOL +SAI1.VirtualProtocol-SAI_B_BASIC=VM_BASIC_PROTOCOL +SH.COMP_DAC11_group.0=DAC1_OUT1,DAC_OUT1 +SH.COMP_DAC11_group.ConfNb=1 +SH.COMP_DAC12_group.0=DAC1_OUT2,DAC_OUT2 +SH.COMP_DAC12_group.ConfNb=1 +SH.FMC_A0.0=FMC_A0,12b-sda1 +SH.FMC_A0.ConfNb=1 +SH.FMC_A1.0=FMC_A1,12b-sda1 +SH.FMC_A1.ConfNb=1 SH.FMC_A10.0=FMC_A10,12b-sda1 -RCC.AHBFreq_Value=168000000 -SPI2.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128 -Mcu.Pin0=PE2 -Mcu.Pin1=PE3 -GPIO.groupedBy=Group By Peripherals -Mcu.Pin2=PE4 -Mcu.Pin3=PE5 -Mcu.Pin4=PE6 -Mcu.Pin5=PC13 -Dma.USART2_TX.7.SyncEnable=DISABLE -SH.FMC_D8_DA8.0=FMC_D8,sd-16b-d1 -USART2.VirtualMode-Asynchronous=VM_ASYNC -FMC.RPDelay1=2 +SH.FMC_A10.ConfNb=1 +SH.FMC_A11.0=FMC_A11,12b-sda1 +SH.FMC_A11.ConfNb=1 +SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 +SH.FMC_A14_BA0.ConfNb=1 +SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 +SH.FMC_A15_BA1.ConfNb=1 +SH.FMC_A2.0=FMC_A2,12b-sda1 +SH.FMC_A2.ConfNb=1 +SH.FMC_A3.0=FMC_A3,12b-sda1 +SH.FMC_A3.ConfNb=1 +SH.FMC_A4.0=FMC_A4,12b-sda1 +SH.FMC_A4.ConfNb=1 +SH.FMC_A5.0=FMC_A5,12b-sda1 +SH.FMC_A5.ConfNb=1 +SH.FMC_A6.0=FMC_A6,12b-sda1 +SH.FMC_A6.ConfNb=1 +SH.FMC_A7.0=FMC_A7,12b-sda1 +SH.FMC_A7.ConfNb=1 +SH.FMC_A8.0=FMC_A8,12b-sda1 +SH.FMC_A8.ConfNb=1 +SH.FMC_A9.0=FMC_A9,12b-sda1 +SH.FMC_A9.ConfNb=1 +SH.FMC_D0_DA0.0=FMC_D0,sd-16b-d1 +SH.FMC_D0_DA0.ConfNb=1 +SH.FMC_D10_DA10.0=FMC_D10,sd-16b-d1 +SH.FMC_D10_DA10.ConfNb=1 +SH.FMC_D11_DA11.0=FMC_D11,sd-16b-d1 +SH.FMC_D11_DA11.ConfNb=1 +SH.FMC_D12_DA12.0=FMC_D12,sd-16b-d1 +SH.FMC_D12_DA12.ConfNb=1 +SH.FMC_D13_DA13.0=FMC_D13,sd-16b-d1 +SH.FMC_D13_DA13.ConfNb=1 +SH.FMC_D14_DA14.0=FMC_D14,sd-16b-d1 +SH.FMC_D14_DA14.ConfNb=1 +SH.FMC_D15_DA15.0=FMC_D15,sd-16b-d1 +SH.FMC_D15_DA15.ConfNb=1 +SH.FMC_D1_DA1.0=FMC_D1,sd-16b-d1 +SH.FMC_D1_DA1.ConfNb=1 SH.FMC_D2_DA2.0=FMC_D2,sd-16b-d1 -PE13.Signal=FMC_D10_DA10 -PF7.GPIO_Label=FLASH_CLK -Dma.UART5_TX.5.PeriphInc=DMA_PINC_DISABLE -File.Version=6 -PA10.GPIO_Label=USB_HOST_PWR_FAULT -SH.FMC_D5_DA5.ConfNb=1 -SH.S_TIM2_CH1.ConfNb=1 SH.FMC_D2_DA2.ConfNb=1 -NVIC.SPI2_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -FMC.ReadPipeDelay1=FMC_SDRAM_RPIPE_DELAY_0 -PE4.Mode=SAI_A_AsyncSlave -TIM6.Period=8 -SH.FMC_SDNRAS.0=FMC_SDNRAS,12b-sda1 -Dma.SPI2_TX.0.RequestNumber=1 -USB_HOST0.BSP.i2creg= -PE4.Signal=SAI1_FS_A -PE6.GPIOParameters=GPIO_Label -Dma.RequestsNb=8 -Dma.UART5_TX.5.MemInc=DMA_MINC_ENABLE -SPI4.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_32 -PC2_C.Locked=true -ProjectManager.ProjectName=Genius -RCC.APB3Freq_Value=120000000 -USB_HOST0.BSP.i2caddr=0 -SPI5.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_4 -SH.FMC_D0_DA0.0=FMC_D0,sd-16b-d1 -RCC.D1PPRE=RCC_APB3_DIV2 -RCC.LSI_VALUE=32000 -USB_OTG_FS.VirtualMode=Device_Only -SH.FMC_A9.0=FMC_A9,12b-sda1 -ADC1.OffsetNumber-1\#ChannelRegularConversion=ADC_OFFSET_NONE +SH.FMC_D3_DA3.0=FMC_D3,sd-16b-d1 +SH.FMC_D3_DA3.ConfNb=1 SH.FMC_D4_DA4.0=FMC_D4,sd-16b-d1 -USART2.WordLength=WORDLENGTH_8B -RCC.PLLSAIN=100 -PF5.Signal=FMC_A5 -Dma.UART5_RX.4.SyncSignalID=NONE -SPI2.Direction=SPI_DIRECTION_2LINES_TXONLY -PF0.Signal=FMC_A0 +SH.FMC_D4_DA4.ConfNb=1 +SH.FMC_D5_DA5.0=FMC_D5,sd-16b-d1 +SH.FMC_D5_DA5.ConfNb=1 +SH.FMC_D6_DA6.0=FMC_D6,sd-16b-d1 +SH.FMC_D6_DA6.ConfNb=1 +SH.FMC_D7_DA7.0=FMC_D7,sd-16b-d1 +SH.FMC_D7_DA7.ConfNb=1 +SH.FMC_D8_DA8.0=FMC_D8,sd-16b-d1 +SH.FMC_D8_DA8.ConfNb=1 +SH.FMC_D9_DA9.0=FMC_D9,sd-16b-d1 +SH.FMC_D9_DA9.ConfNb=1 +SH.FMC_NBL0.0=FMC_NBL0,Sd2ByteEnable1 SH.FMC_NBL0.ConfNb=1 -Dma.SAI1_A.1.SyncEnable=DISABLE -SH.COMP_DAC11_group.ConfNb=1 -Dma.UART5_RX.4.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -PE3.Mode=SAI_B_SyncSlave -PC12.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -RCC.Tim2OutputFreq_Value=240000000 -RCC.DFSDMACLkFreq_Value=48000000 -Dma.USART2_RX.6.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -Dma.SAI1_B.2.EventEnable=DISABLE -SH.FMC_A9.ConfNb=1 -Dma.USART2_TX.7.SyncRequestNumber=1 -PA13\ (JTMS/SWDIO).Mode=Serial_Wire -PC10.GPIO_Label=SW_A -Dma.UART5_TX.5.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -ProjectManager.NoMain=false -PG1.Signal=FMC_A11 -RCC.SAI4BFreq_Value=48000000 +SH.FMC_NBL1.0=FMC_NBL1,Sd2ByteEnable1 +SH.FMC_NBL1.ConfNb=1 +SH.FMC_SDCLK.0=FMC_SDCLK,12b-sda1 SH.FMC_SDCLK.ConfNb=1 -USB_HOST.BSP.number=1 -RCC.D2PPRE2=RCC_APB2_DIV2 -RCC.D2PPRE1=RCC_APB1_DIV2 -Dma.UART5_RX.4.EventEnable=DISABLE -NVIC.DMA1_Stream1_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true -NVIC.USART2_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -Dma.ADC1.3.FIFOMode=DMA_FIFOMODE_DISABLE -Dma.ADC1.3.SyncEnable=DISABLE -RCC.SPI6Freq_Value=120000000 -PC12.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -PF7.Mode=Full_Duplex_Master +SH.FMC_SDNCAS.0=FMC_SDNCAS,12b-sda1 +SH.FMC_SDNCAS.ConfNb=1 +SH.FMC_SDNRAS.0=FMC_SDNRAS,12b-sda1 +SH.FMC_SDNRAS.ConfNb=1 +SH.FMC_SDNWE.0=FMC_SDNWE,12b-sda1 +SH.FMC_SDNWE.ConfNb=1 +SH.GPXTI10.0=GPIO_EXTI10 +SH.GPXTI10.ConfNb=1 +SH.GPXTI11.0=GPIO_EXTI11 +SH.GPXTI11.ConfNb=1 +SH.GPXTI12.0=GPIO_EXTI12 +SH.GPXTI12.ConfNb=1 +SH.GPXTI14.0=GPIO_EXTI14 +SH.GPXTI14.ConfNb=1 +SH.GPXTI2.0=GPIO_EXTI2 +SH.GPXTI2.ConfNb=1 +SH.GPXTI4.0=GPIO_EXTI4 +SH.GPXTI4.ConfNb=1 +SH.S_TIM2_CH1.0=TIM2_CH1,Encoder_Interface +SH.S_TIM2_CH1.ConfNb=1 SH.S_TIM2_CH2.0=TIM2_CH2,Encoder_Interface -PB4\ (NJTRST).GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -Dma.UART5_TX.5.SyncSignalID=NONE -RCC.SPI45Freq_Value=120000000 -SAI1.BasicDataSize-SAI_A_AsyncSlave=SAI_PROTOCOL_DATASIZE_24BIT -PB3\ (JTDO/TRACESWO).Signal=S_TIM2_CH2 -ProjectManager.TargetToolchain=Other Toolchains (GPDSC) -NVIC.DMA1_Stream5_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true -SH.FMC_D1_DA1.ConfNb=1 -ADC1.Channel-1\#ChannelRegularConversion=ADC_CHANNEL_17 -PF2.Signal=FMC_A2 -ProjectManager.RegisterCallBack= -RCC.PLLSAIoutputFreq_Value=50000000 -PE11.Signal=FMC_D8_DA8 -RCC.LSE_VALUE=32768 -PD3.Locked=true -Dma.USART2_TX.7.Mode=DMA_NORMAL -PB12.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM -Dma.UART5_TX.5.SyncEnable=DISABLE -Dma.UART5_RX.4.PeriphInc=DMA_PINC_DISABLE -SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_RX -PG9.GPIO_Label=CS_CS +SH.S_TIM2_CH2.ConfNb=1 +SH.S_TIM3_CH1.0=TIM3_CH1,Encoder_Interface +SH.S_TIM3_CH1.ConfNb=1 SH.S_TIM3_CH2.0=TIM3_CH2,Encoder_Interface -PG14.Signal=GPXTI14 -Dma.ADC1.3.MemDataAlignment=DMA_MDATAALIGN_HALFWORD -SAI1.IPParameters=Instance-SAI_A_AsyncSlave,VirtualMode-SAI_A_AsyncSlave,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,InitProtocol-SAI_B_SyncSlave,VirtualProtocol-SAI_B_BASIC,AudioMode-SAI_A_AsyncSlave,TriState-SAI_A_AsyncSlave,InitProtocol-SAI_A_AsyncSlave,VirtualProtocol-SAI_A_BASIC,BasicDataSize-SAI_B_SyncSlave,BasicDataSize-SAI_A_AsyncSlave,AudioMode-SAI_B_SyncSlave -RCC.VCOInput1Freq_Value=5000000 -NVIC.SavedSystickIrqHandlerGenerated=true -RCC.APB2Freq_Value=120000000 -USB_HOST0.BSP.api=Unknown -Dma.UART5_TX.5.SyncRequestNumber=1 -Dma.USART2_TX.7.RequestNumber=1 -SH.FMC_D13_DA13.ConfNb=1 -PD4.GPIO_Label=TR_OUT_A -PC13.GPIOParameters=GPIO_Label -Dma.SPI2_TX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -PF10.Signal=GPIO_Output -Dma.SAI1_B.2.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -PB15.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH -PF15.Signal=FMC_A9 +SH.S_TIM3_CH2.ConfNb=1 +SH.SharedAnalog_PA1.0=ADC1_INN16 +SH.SharedAnalog_PA1.1=ADC1_INP17,IN17-Single-Ended +SH.SharedAnalog_PA1.ConfNb=2 +SPI2.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128 +SPI2.CalculateBaudRate=375.0 KBits/s +SPI2.DataSize=SPI_DATASIZE_8BIT +SPI2.Direction=SPI_DIRECTION_2LINES_TXONLY +SPI2.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,DataSize,VirtualType,Direction +SPI2.Mode=SPI_MODE_MASTER +SPI2.VirtualType=VM_MASTER +SPI4.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_32 SPI4.CalculateBaudRate=3.75 MBits/s -Dma.SAI1_B.2.Priority=DMA_PRIORITY_HIGH -Dma.UART5_RX.4.Instance=DMA1_Stream1 -PE6.Signal=SPI4_MOSI -PB15.GPIOParameters=GPIO_Speed -Mcu.Name=STM32H743ZGTx -Dma.SAI1_B.2.Direction=DMA_PERIPH_TO_MEMORY -PA2.Signal=USART2_TX -PD14.Signal=FMC_D0_DA0 -Dma.SPI2_TX.0.Priority=DMA_PRIORITY_LOW -Dma.UART5_RX.4.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -PA7.GPIO_Label=ENC2_CH2 -Dma.SAI1_B.2.RequestNumber=1 -PA12.Mode=Device_Only -Dma.UART5_RX.4.FIFOMode=DMA_FIFOMODE_DISABLE -SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B -PF6.GPIOParameters=GPIO_Label -Dma.USART2_RX.6.Priority=DMA_PRIORITY_LOW -RCC.SAI4AFreq_Value=48000000 -ADC1.NbrOfConversionFlag=1 -Dma.SAI1_A.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD -RCC.DIVQ1Freq_Value=48000000 -PC2_C.GPIOParameters=GPIO_Label -PE3.GPIO_Label=CS_SDOUT -RCC.D3PPRE=RCC_APB4_DIV2 -PC9.Signal=GPIO_Output -RCC.VCOInput2Freq_Value=12500000 -RCC.APB1Freq_Value=120000000 -SAI1.InitProtocol-SAI_B_SyncSlave=Enable -ADC1.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV4 -PB11.Locked=true -ProjectManager.DeviceId=STM32H743ZGTx -ProjectManager.LibraryCopy=2 +SPI4.DataSize=SPI_DATASIZE_8BIT +SPI4.Direction=SPI_DIRECTION_2LINES_TXONLY +SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,DataSize,NSSPMode,VirtualType,Direction +SPI4.Mode=SPI_MODE_MASTER +SPI4.NSSPMode=SPI_NSS_PULSE_DISABLE +SPI4.VirtualType=VM_MASTER +SPI5.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_4 +SPI5.CalculateBaudRate=30.0 MBits/s +SPI5.DataSize=SPI_DATASIZE_8BIT SPI5.Direction=SPI_DIRECTION_2LINES -PA7.Signal=S_TIM3_CH2 +SPI5.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,DataSize,VirtualType,Direction,NSSPMode +SPI5.Mode=SPI_MODE_MASTER +SPI5.NSSPMode=SPI_NSS_PULSE_DISABLE +SPI5.VirtualType=VM_MASTER +TIM2.EncoderMode=TIM_ENCODERMODE_TI12 +TIM2.IC1Filter=8 +TIM2.IC2Filter=8 +TIM2.IPParameters=EncoderMode,Period,IC1Filter,IC2Filter +TIM2.Period=0xffff +TIM3.EncoderMode=TIM_ENCODERMODE_TI12 +TIM3.IC1Filter=8 +TIM3.IC2Filter=8 +TIM3.IPParameters=EncoderMode,Period,IC1Filter,IC2Filter +TIM3.Period=0xffff +TIM6.IPParameters=Prescaler,Period,TIM_MasterOutputTrigger +TIM6.Period=8 +TIM6.Prescaler=3500 +TIM6.TIM_MasterOutputTrigger=TIM_TRGO_UPDATE +UART5.BaudRate=31250 +UART5.DMADisableonRxErrorParam=UART_ADVFEATURE_DMA_DISABLEONRXERROR +UART5.IPParameters=BaudRate,DMADisableonRxErrorParam,OverrunDisableParam +UART5.OverrunDisableParam=UART_ADVFEATURE_OVERRUN_DISABLE +USART2.DMADisableonRxErrorParam=ADVFEATURE_DMA_DISABLEONRXERROR +USART2.IPParameters=WordLength,VirtualMode-Asynchronous,OverrunDisableParam,DMADisableonRxErrorParam +USART2.OverrunDisableParam=ADVFEATURE_OVERRUN_DISABLE +USART2.VirtualMode-Asynchronous=VM_ASYNC +USART2.WordLength=WORDLENGTH_8B +USB_HOST.BSP.number=1 +USB_HOST.IPParameters=USBH_HandleTypeDef-ALL_Classes_HS,VirtualModeHS +USB_HOST.USBH_HandleTypeDef-ALL_Classes_HS=hUsbHostHS +USB_HOST.VirtualModeHS=All_Classes +USB_HOST0.BSP.STBoard=false +USB_HOST0.BSP.api=Unknown +USB_HOST0.BSP.component= +USB_HOST0.BSP.condition= +USB_HOST0.BSP.i2caddr=0 +USB_HOST0.BSP.i2creg= +USB_HOST0.BSP.instance=PC9 +USB_HOST0.BSP.ip=GPIO +USB_HOST0.BSP.mode=Output +USB_HOST0.BSP.name=Drive_VBUS_HS +USB_HOST0.BSP.semaphore= +USB_HOST0.BSP.solution=PC9 +USB_OTG_FS.IPParameters=VirtualMode,Sof_enable +USB_OTG_FS.Sof_enable=ENABLE +USB_OTG_FS.VirtualMode=Device_Only +USB_OTG_HS.IPParameters=VirtualMode-Host_FS +USB_OTG_HS.VirtualMode-Host_FS=Host_FS +VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 +VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 +VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC.Mode=SAI_A_BASIC +VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC.Signal=SAI1_VP_$IpInstance_SAIA_SAI_BASIC +VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC.Mode=SAI_B_BASIC +VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC.Signal=SAI1_VP_$IpInstance_SAIB_SAI_BASIC +VP_SYS_VS_Systick.Mode=SysTick +VP_SYS_VS_Systick.Signal=SYS_VS_Systick +VP_TIM6_VS_ClockSourceINT.Mode=Enable_Timer +VP_TIM6_VS_ClockSourceINT.Signal=TIM6_VS_ClockSourceINT +VP_USB_HOST_VS_USB_HOST_ALL_CLASS_HS.Mode=ALL_Classes_HS +VP_USB_HOST_VS_USB_HOST_ALL_CLASS_HS.Signal=USB_HOST_VS_USB_HOST_ALL_CLASS_HS +board=Player diff --git a/Genius/Inc/GeniusParameterController.hpp b/Genius/Inc/GeniusParameterController.hpp index 59bbfd3d..dee6a02b 100644 --- a/Genius/Inc/GeniusParameterController.hpp +++ b/Genius/Inc/GeniusParameterController.hpp @@ -27,9 +27,10 @@ extern DigitalBusReader bus; extern VersionToken* bootloader_token; #define NOF_ENCODERS 2 +#define GENIUS_ADC_OFFSET (-120) enum DisplayMode { - STANDARD_DISPLAY_MODE, CONFIGURATION_DISPLAY_MODE, PROGRESS_DISPLAY_MODE, SELECT_ONE_DISPLAY_MODE, SELECT_TWO_DISPLAY_MODE, EXIT_DISPLAY_MODE, ERROR_DISPLAY_MODE + STANDARD_DISPLAY_MODE, CONFIGURATION_DISPLAY_MODE, PROGRESS_DISPLAY_MODE, SELECT_ONE_DISPLAY_MODE, SELECT_TWO_DISPLAY_MODE, EXIT_DISPLAY_MODE, ASSIGN_DISPLAY_MODE, ERROR_DISPLAY_MODE }; // DisplayMode displayMode; void setDisplayMode(DisplayMode mode); @@ -98,20 +99,9 @@ class GeniusParameterController : public ParameterController { // @param values the modulation ADC values void updateValues(int16_t* values, size_t len){ for(size_t pid=0; pid>1)); } - // void updateValue(uint8_t pid, int16_t value){ - // // smoothing at apprx 50Hz - // parameters[pid] = max(0, min(4095, (parameters[pid] + user[pid] + value)>>1)); - // } - // update value from patch or MIDI - // void setValue(uint8_t ch, int16_t value){ - // parameters[ch] = value; - // } - // int16_t getValue(uint8_t pid){ - // return parameters[pid]; - // } private: }; @@ -149,8 +139,8 @@ class SelectControlPage : public Page { void draw(ScreenBuffer& screen){ if(!sw(ctrl)){ // encoder switch released - if(ctrl == 0 && counter < TOGGLE_LIMIT){ - setDisplayMode(CONFIGURATION_DISPLAY_MODE); + if(counter < TOGGLE_LIMIT){ + setDisplayMode(ctrl == 0 ? CONFIGURATION_DISPLAY_MODE : ASSIGN_DISPLAY_MODE); }else{ setDisplayMode(STANDARD_DISPLAY_MODE); } @@ -279,6 +269,43 @@ class StatsPage : public Page { SelectControlPage selectOnePage(0, 0); SelectControlPage selectTwoPage(1, 1); +class AssignPage : public Page { +private: + uint8_t select; + uint8_t assign; + static constexpr char* assignations[] = {"CV A In", "CV B In", "CV A Out", "CV B Out"}; +public: + void encoderChanged(uint8_t encoder, int32_t delta){ + if(encoder == 0){ + if(delta > 0) + select = min(3, select+1); + else if(delta < 0) + select = max(0, select-1); + }else{ + if(delta > 0) + assign = min(NOF_PARAMETERS-1, assign+1); + else if(delta < 0) + assign = max(0, assign-1); + } + } + void enter(){ + select = 0; + assign = 0; + } + void draw(ScreenBuffer& screen){ + if(sw1() || sw2()){ + setDisplayMode(EXIT_DISPLAY_MODE); + }else{ + screen.setTextSize(2); + screen.print(1, 16, "ASSIGN"); + screen.setTextSize(1); + screen.print(1, 26, assignations[select]); + screen.print(": "); + screen.print(params.getName(assign)); + } + } +}; + class StandardPage : public Page { public: void encoderChanged(uint8_t encoder, int32_t delta){ @@ -316,6 +343,7 @@ ProgressPage progressPage; ErrorPage errorPage; ExitPage exitPage; StatsPage configurationPage; +AssignPage assignPage; void changePage(Page* page){ if(params.page != page){ @@ -347,6 +375,9 @@ void setDisplayMode(DisplayMode mode){ case EXIT_DISPLAY_MODE: changePage(&exitPage); break; + case ASSIGN_DISPLAY_MODE: + changePage(&assignPage); + break; case ERROR_DISPLAY_MODE: changePage(&errorPage); break; diff --git a/Genius/Inc/hardware.h b/Genius/Inc/hardware.h index d972fab4..61165a1e 100644 --- a/Genius/Inc/hardware.h +++ b/Genius/Inc/hardware.h @@ -29,6 +29,7 @@ #define USE_SCREEN #define SSD1309 +#define OLED_DMA #define ENCODER_TIM1 htim3 #define ENCODER_TIM2 htim2 diff --git a/Genius/Inc/stm32h7xx_hal_conf.h b/Genius/Inc/stm32h7xx_hal_conf.h index 5f834e34..ae041d25 100644 --- a/Genius/Inc/stm32h7xx_hal_conf.h +++ b/Genius/Inc/stm32h7xx_hal_conf.h @@ -65,6 +65,7 @@ /* #define HAL_LPTIM_MODULE_ENABLED */ /* #define HAL_LTDC_MODULE_ENABLED */ /* #define HAL_QSPI_MODULE_ENABLED */ +/* #define HAL_RAMECC_MODULE_ENABLED */ /* #define HAL_RNG_MODULE_ENABLED */ /* #define HAL_RTC_MODULE_ENABLED */ #define HAL_SAI_MODULE_ENABLED diff --git a/Genius/Src/Genius.cpp b/Genius/Src/Genius.cpp index eb73f5ea..d71215fe 100644 --- a/Genius/Src/Genius.cpp +++ b/Genius/Src/Genius.cpp @@ -36,11 +36,15 @@ extern "C"{ extern TIM_HandleTypeDef ENCODER_TIM1; extern TIM_HandleTypeDef ENCODER_TIM2; -Pin tr_out_a_pin(GPIOD, GPIO_PIN_3); -Pin tr_out_b_pin(GPIOD, GPIO_PIN_4); +Pin tr_out_a_pin(GPIOD, GPIO_PIN_4); +Pin tr_out_b_pin(GPIOD, GPIO_PIN_3); GeniusParameterController params; -Graphics graphics; +// #ifdef OLED_DMA +Graphics graphics DMA_RAM; +// #else +// Graphics graphics; +// #endif char* progress_message = NULL; uint16_t progress_counter = 0; @@ -147,19 +151,21 @@ void onChangePin(uint16_t pin){ } extern "C"{ - // void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc){ - // } + void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc){ + // this runs at apprx 3.3kHz + // with 64.5 cycles sample time, 30 MHz ADC clock, and ClockPrescaler = 32 + extern uint16_t adc_values[NOF_ADC_VALUES]; + for(size_t i=0; i> 2; + } + // tr_out_a_pin.toggle(); + } void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc){ error(CONFIG_ERROR, "ADC error"); } - void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* adc_values, size_t adc_len){ - // graphics.params.parameters params.updateValues((int16_t*)adc_values, adc_len); - // graphics.params.updateValue(0, adc_values[0]); - // graphics.params.updateValue(1, adc_values[1]); - // parameter_values[0] = adc_values[0]; // todo: sum with user / encoder setting - // parameter_values[1] = adc_values[1]; } } diff --git a/Genius/Src/main.c b/Genius/Src/main.c index 6fd1f11c..62d7b2ed 100644 --- a/Genius/Src/main.c +++ b/Genius/Src/main.c @@ -21,6 +21,7 @@ #include "main.h" #include "cmsis_os.h" #include "usb_host.h" +#include "usb_host.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ @@ -271,6 +272,9 @@ void SystemClock_Config(void) __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE0); while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {} + /** Macro to configure the PLL clock source + */ + __HAL_RCC_PLL_PLLSOURCE_CONFIG(RCC_PLLSOURCE_HSE); /** Initializes the RCC Oscillators according to the specified parameters * in the RCC_OscInitTypeDef structure. */ @@ -330,8 +334,8 @@ static void MX_ADC1_Init(void) /** Common config */ hadc1.Instance = ADC1; - hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4; - hadc1.Init.Resolution = ADC_RESOLUTION_12B; + hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV32; + hadc1.Init.Resolution = ADC_RESOLUTION_12B_OPT; hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE; hadc1.Init.EOCSelection = ADC_EOC_SEQ_CONV; hadc1.Init.LowPowerAutoWait = DISABLE; diff --git a/Genius/Src/stm32h7xx_hal_msp.c b/Genius/Src/stm32h7xx_hal_msp.c index eaead0c5..72f5046e 100644 --- a/Genius/Src/stm32h7xx_hal_msp.c +++ b/Genius/Src/stm32h7xx_hal_msp.c @@ -98,11 +98,29 @@ void HAL_MspInit(void) void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) { GPIO_InitTypeDef GPIO_InitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; if(hadc->Instance==ADC1) { /* USER CODE BEGIN ADC1_MspInit 0 */ /* USER CODE END ADC1_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_ADC; + PeriphClkInitStruct.PLL2.PLL2M = 2; + PeriphClkInitStruct.PLL2.PLL2N = 12; + PeriphClkInitStruct.PLL2.PLL2P = 5; + PeriphClkInitStruct.PLL2.PLL2Q = 2; + PeriphClkInitStruct.PLL2.PLL2R = 2; + PeriphClkInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_3; + PeriphClkInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOMEDIUM; + PeriphClkInitStruct.PLL2.PLL2FRACN = 0; + PeriphClkInitStruct.AdcClockSelection = RCC_ADCCLKSOURCE_PLL2; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + /* Peripheral clock enable */ __HAL_RCC_ADC12_CLK_ENABLE(); @@ -1204,7 +1222,7 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; HAL_GPIO_Init(CS_SDIN_GPIO_Port, &GPIO_InitStruct); - /* Peripheral DMA init*/ + /* Peripheral DMA init*/ hdma_sai1_a.Instance = DMA2_Stream1; hdma_sai1_a.Init.Request = DMA_REQUEST_SAI1_A; @@ -1256,7 +1274,7 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; HAL_GPIO_Init(CS_SDOUT_GPIO_Port, &GPIO_InitStruct); - /* Peripheral DMA init*/ + /* Peripheral DMA init*/ hdma_sai1_b.Instance = DMA2_Stream4; hdma_sai1_b.Init.Request = DMA_REQUEST_SAI1_B; @@ -1301,6 +1319,7 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) HAL_GPIO_DeInit(CS_SDIN_GPIO_Port, CS_SDIN_Pin); + /* SAI1 DMA Deinit */ HAL_DMA_DeInit(hsai->hdmarx); HAL_DMA_DeInit(hsai->hdmatx); } @@ -1318,6 +1337,7 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) */ HAL_GPIO_DeInit(CS_SDOUT_GPIO_Port, CS_SDOUT_Pin); + /* SAI1 DMA Deinit */ HAL_DMA_DeInit(hsai->hdmarx); HAL_DMA_DeInit(hsai->hdmatx); } From a3d310f17e9364b77d30a8a1d3ab595993b1062b Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 26 Oct 2021 12:58:27 +0200 Subject: [PATCH 142/286] updated SPI error handling --- Source/ssd1309.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/ssd1309.c b/Source/ssd1309.c index 63756e83..e47e408f 100644 --- a/Source/ssd1309.c +++ b/Source/ssd1309.c @@ -1,8 +1,9 @@ // _____ Includes ______________________________________________________________________ +#include #include "oled.h" #include "device.h" +#include "message.h" #include "errorhandlers.h" -#include /* static void NopDelay(uint32_t nops){ */ /* while (nops--) */ @@ -108,9 +109,9 @@ static void OLED_writeCMD(const uint8_t* data, uint16_t length) void HAL_SPI_ErrorCallback(SPI_HandleTypeDef *hspi){ if(hspi->ErrorCode == HAL_SPI_ERROR_OVR){ __HAL_SPI_CLEAR_OVRFLAG(hspi); - error(RUNTIME_ERROR, "SPI OVR"); + debugMessage("SPI OVR"); }else{ - assert_param(0); + error(RUNTIME_ERROR, "SPI Error"); } } From 55e2d777c4adf4848fb84c0848016071486d0745 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 26 Oct 2021 13:04:25 +0200 Subject: [PATCH 143/286] fixed ADC smoothing --- Genius/Src/Genius.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Genius/Src/Genius.cpp b/Genius/Src/Genius.cpp index d71215fe..5877bb6d 100644 --- a/Genius/Src/Genius.cpp +++ b/Genius/Src/Genius.cpp @@ -151,13 +151,14 @@ void onChangePin(uint16_t pin){ } extern "C"{ + static uint16_t smooth_adc_values[NOF_ADC_VALUES]; void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc){ // this runs at apprx 3.3kHz // with 64.5 cycles sample time, 30 MHz ADC clock, and ClockPrescaler = 32 extern uint16_t adc_values[NOF_ADC_VALUES]; for(size_t i=0; i> 2; + smooth_adc_values[i] = (smooth_adc_values[i]*3 + adc_values[i]) >> 2; } // tr_out_a_pin.toggle(); } @@ -165,7 +166,7 @@ extern "C"{ error(CONFIG_ERROR, "ADC error"); } void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* adc_values, size_t adc_len){ - params.updateValues((int16_t*)adc_values, adc_len); + params.updateValues((int16_t*)smooth_adc_values, adc_len); } } From 296f634080b5ead8a29e4d68405eb418116639fb Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 26 Oct 2021 13:45:37 +0200 Subject: [PATCH 144/286] constexpr char* made const --- Genius/Inc/GeniusParameterController.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Genius/Inc/GeniusParameterController.hpp b/Genius/Inc/GeniusParameterController.hpp index dee6a02b..e8704d20 100644 --- a/Genius/Inc/GeniusParameterController.hpp +++ b/Genius/Inc/GeniusParameterController.hpp @@ -273,7 +273,7 @@ class AssignPage : public Page { private: uint8_t select; uint8_t assign; - static constexpr char* assignations[] = {"CV A In", "CV B In", "CV A Out", "CV B Out"}; + static constexpr const char* assignations[] = {"CV A In", "CV B In", "CV A Out", "CV B Out"}; public: void encoderChanged(uint8_t encoder, int32_t delta){ if(encoder == 0){ From d48e00aef39e434e577e33b7d31e13e0294f7ae1 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 27 Oct 2021 18:24:26 +0200 Subject: [PATCH 145/286] use DMA RAM for graphics --- Magus3/Src/Magus.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Magus3/Src/Magus.cpp b/Magus3/Src/Magus.cpp index ff356da6..f00dccc5 100644 --- a/Magus3/Src/Magus.cpp +++ b/Magus3/Src/Magus.cpp @@ -18,7 +18,7 @@ const uint32_t* dyn_rainbowinputs = rainbowinputs; const uint32_t* dyn_rainbowoutputs = rainbowoutputs; static MagusParameterController params; -Graphics graphics; +Graphics graphics DMA_RAM; extern "C" void onResourceUpdate(void); From d1f760467fff9dc92610e3870cbe1809829a1136 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 27 Oct 2021 18:24:53 +0200 Subject: [PATCH 146/286] print error message and cause --- Genius/Inc/GeniusParameterController.hpp | 8 +++++--- Genius/Src/Genius.cpp | 4 ---- Genius/Src/main.c | 1 - 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Genius/Inc/GeniusParameterController.hpp b/Genius/Inc/GeniusParameterController.hpp index e8704d20..a52234fd 100644 --- a/Genius/Inc/GeniusParameterController.hpp +++ b/Genius/Inc/GeniusParameterController.hpp @@ -9,6 +9,7 @@ #include "VersionToken.h" #include "ScreenBuffer.h" #include "Owl.h" +#include "message.h" #ifdef USE_DIGITALBUS #include "DigitalBusReader.h" extern DigitalBusReader bus; @@ -202,10 +203,11 @@ class ErrorPage : public Page { }else{ screen.setTextSize(2); screen.print(1, 16, "ERROR"); - if(getErrorMessage() != NULL){ - screen.setTextSize(1); + screen.setTextSize(1); + if(getErrorMessage() != NULL) screen.print(2, 25, getErrorMessage()); - } + if(getDebugMessage() != NULL) + screen.print(2, 32, getDebugMessage()); } } }; diff --git a/Genius/Src/Genius.cpp b/Genius/Src/Genius.cpp index 5877bb6d..3877be29 100644 --- a/Genius/Src/Genius.cpp +++ b/Genius/Src/Genius.cpp @@ -40,11 +40,7 @@ Pin tr_out_a_pin(GPIOD, GPIO_PIN_4); Pin tr_out_b_pin(GPIOD, GPIO_PIN_3); GeniusParameterController params; -// #ifdef OLED_DMA Graphics graphics DMA_RAM; -// #else -// Graphics graphics; -// #endif char* progress_message = NULL; uint16_t progress_counter = 0; diff --git a/Genius/Src/main.c b/Genius/Src/main.c index 62d7b2ed..6a674eb6 100644 --- a/Genius/Src/main.c +++ b/Genius/Src/main.c @@ -103,7 +103,6 @@ void StartDefaultTask(void const * argument); /* USER CODE BEGIN PFP */ void setup(void); void loop(void); -void MX_USB_HOST_Process(void); void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram); void initialise_monitor_handles(void); void MPU_Config(void); From 4aa2b8573d32f4fbba09506ba0b3bf4cc4ae367f Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 28 Oct 2021 17:21:08 +0200 Subject: [PATCH 147/286] accept patches with a program size > binary size --- Source/MidiController.cpp | 2 +- Source/ParameterController.hpp | 8 ++++---- Source/PatchDefinition.hpp | 26 +++++++++++++++++--------- Source/PatchRegistry.cpp | 2 +- Source/ProgramManager.cpp | 4 ++-- Source/callbacks.cpp | 3 +-- Source/message.h | 1 + 7 files changed, 27 insertions(+), 19 deletions(-) diff --git a/Source/MidiController.cpp b/Source/MidiController.cpp index 6552c9a8..2461d115 100644 --- a/Source/MidiController.cpp +++ b/Source/MidiController.cpp @@ -124,7 +124,7 @@ void MidiController::sendPatchName(uint8_t slot){ if(slot == 0){ PatchDefinition* def = registry.getPatchDefinition(); if(def) - sendName(SYSEX_PRESET_NAME_COMMAND, slot, def->getName(), def->getProgramSize(), 0); + sendName(SYSEX_PRESET_NAME_COMMAND, slot, def->getName(), def->getBinarySize(), 0); }else{ Resource* resource = registry.getPatch(slot-1); if(resource) diff --git a/Source/ParameterController.hpp b/Source/ParameterController.hpp index 6f65e1ec..4c65f8ad 100644 --- a/Source/ParameterController.hpp +++ b/Source/ParameterController.hpp @@ -13,11 +13,11 @@ class ParameterController { public: virtual void reset(){ for(size_t i=0; i 8) - names[i][ch++] = '@'+(i/8); - names[i][ch++] = 'A'+(i%8); - names[i][ch++] = '\0'; + names[i][c++] = '@'+(i/8); + names[i][c++] = 'A'+(i%8); + names[i][c] = '\0'; parameters[i] = 0; } } diff --git a/Source/PatchDefinition.hpp b/Source/PatchDefinition.hpp index 92a40901..c470ba42 100644 --- a/Source/PatchDefinition.hpp +++ b/Source/PatchDefinition.hpp @@ -16,34 +16,35 @@ class PatchDefinition { typedef void (*ProgramFunction)(void); ProgramFunction programFunction = NULL; uint32_t* linkAddress; - uint32_t* jumpAddress; + uint32_t binarySize; uint32_t programSize; char programName[24]; Resource* sourceResource = NULL; void* sourceAddress = NULL; bool load(ProgramHeader* header, uint32_t sz){ + binarySize = sz; + // check we've got an entry function + if(header->magic != 0xDADAC0DE) + return false; linkAddress = header->linkAddress; programSize = (uint32_t)header->endAddress - (uint32_t)header->linkAddress; - if(header->magic != 0xDADAC0DE || sz != programSize) - return false; stackBase = header->stackBegin; stackSize = (uint32_t)header->stackEnd - (uint32_t)header->stackBegin; - jumpAddress = header->jumpAddress; programVector = header->programVector; strlcpy(programName, header->programName, sizeof(programName)); - programFunction = (ProgramFunction)jumpAddress; + programFunction = (ProgramFunction)header->jumpAddress; return true; } public: PatchDefinition() {} void copy(){ if(sourceResource){ - storage.readResource(sourceResource, linkAddress, 0, programSize); + storage.readResource(sourceResource, linkAddress, 0, binarySize); sourceResource = NULL; }else if(sourceAddress){ if(linkAddress != sourceAddress) - memmove(linkAddress, sourceAddress, programSize); + memmove(linkAddress, sourceAddress, binarySize); sourceAddress = NULL; } } @@ -82,7 +83,8 @@ class PatchDefinition { return false; } bool isValid(){ - // check we've got an entry function + // if(binarySize != programSize) + // return false; if(programFunction == NULL || programVector == NULL) return false; extern char _PATCHRAM, _PATCHRAM_SIZE; @@ -97,12 +99,18 @@ class PatchDefinition { } void run(){ // check magic - if((*(uint32_t*)linkAddress) == 0xDADAC0DE) + if((*(uint32_t*)linkAddress) == 0xDADAC0DE){ + if(binarySize < programSize) // blank out bss area + memset(linkAddress+binarySize, 0, programSize - binarySize); programFunction(); + } } uint32_t getProgramSize(){ return programSize; } + uint32_t getBinarySize(){ + return binarySize; + } uint32_t* getLinkAddress(){ return linkAddress; } diff --git a/Source/PatchRegistry.cpp b/Source/PatchRegistry.cpp index 914ddb5f..f6a126a5 100644 --- a/Source/PatchRegistry.cpp +++ b/Source/PatchRegistry.cpp @@ -88,5 +88,5 @@ bool PatchRegistry::loadProgram(uint8_t index){ } bool PatchRegistry::loadProgram(void* address, uint32_t length){ - return patchDefinition.load(address, length) && patchDefinition.isValid(); + return patchDefinition.load(address, length) && patchDefinition.isValid(); } diff --git a/Source/ProgramManager.cpp b/Source/ProgramManager.cpp index e4326a5b..a97c7969 100644 --- a/Source/ProgramManager.cpp +++ b/Source/ProgramManager.cpp @@ -725,7 +725,7 @@ void ProgramManager::loadDynamicProgram(void* address, uint32_t length){ if(registry.loadProgram(address, length)) updateProgramIndex(0); else - error(PROGRAM_ERROR, "Load error"); + error(PROGRAM_ERROR, "Load failed"); } void ProgramManager::loadProgram(uint8_t pid){ @@ -733,7 +733,7 @@ void ProgramManager::loadProgram(uint8_t pid){ if(registry.loadProgram(pid)) updateProgramIndex(pid); else - error(PROGRAM_ERROR, "Load error"); + error(PROGRAM_ERROR, "Load failed"); }else{ owl.setOperationMode(CONFIGURE_MODE); } diff --git a/Source/callbacks.cpp b/Source/callbacks.cpp index 716c69b7..b1e855e7 100644 --- a/Source/callbacks.cpp +++ b/Source/callbacks.cpp @@ -92,8 +92,6 @@ void owl_mode_button(void){ gainselect = getGainSelectionValue(); owl.setOperationMode(CONFIGURE_MODE); setLed(0, NO_COLOUR); - }else if(getErrorStatus() != NO_ERROR){ - owl.setOperationMode(ERROR_MODE); }else{ #ifdef USE_RGB_LED updateLed(); @@ -262,6 +260,7 @@ void onError(int8_t code, const char* msg){ #if defined OWL_PEDAL || defined OWL_MODULAR || defined OWL_BIOSIGNALS setLed(0, RED_COLOUR); #endif + owl.setOperationMode(ERROR_MODE); } __weak void onChangePin(uint16_t pin){ diff --git a/Source/message.h b/Source/message.h index d6c207a7..45220d9c 100644 --- a/Source/message.h +++ b/Source/message.h @@ -24,6 +24,7 @@ #endif void debugMessage(const char* msg); + const char* getDebugMessage(); void error(int8_t code, const char* reason); void assert_failed(uint8_t* location, uint32_t line); From d2f6892dca89a25f25ab72a7071c0f5a8a1304cc Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 2 Nov 2021 12:52:05 +0100 Subject: [PATCH 148/286] updated notes --- Expander/expander-notes.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Expander/expander-notes.txt b/Expander/expander-notes.txt index c7d1becd..8a8f82bd 100644 --- a/Expander/expander-notes.txt +++ b/Expander/expander-notes.txt @@ -1,6 +1,7 @@ LQFP-48 +STM32F100CBT6/7 24 MHz 128k FLASH 8k RAM full compatible: STM32F100C8Tx 24 MHz 64k FLASH 8k RAM @@ -21,3 +22,19 @@ STM32L4P5CE 120MHz 1M FLASH 320k RAM, 1x USB OTG STM32L4P5CET6 LQFP-48, USD 3.9641 / 10k Ultra-low-power with FPU Arm Cortex-M4 MCU 120 MHz with 512 kbytes of Flash memory, USB OTG, DFSDM, CHROM-ART + + +LCSC STM32F103C8T6 4943 in stock 29/10 2021 +https://lcsc.com/product-detail/ST-Microelectronics_STMicroelectronics-STM32F103C8T6_C8734.html +USD 10.1218 @100 + +STM32L051C8T6TR 13602 in stock 29/10 2021 +https://lcsc.com/product-detail/ST-Microelectronics_STMicroelectronics-STM32L051C8T6TR_C2802165.html +USD 1.9934 @100 + +STM32L051C8 M0 32 Mhz 64k FLASH 8k RAM compatible? + +STM32F030CCT6 US$ 5.7171 @100 48Mhz 32k RAM 256k FLASH compatible? + +STM32F302C8T6 2879 in stock, US$4.3153 @100 + From 053c6df1c575088966511ab15cad2f07441854ef Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 2 Nov 2021 12:52:20 +0100 Subject: [PATCH 149/286] removed comments --- MidiBoot3/Inc/hardware.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/MidiBoot3/Inc/hardware.h b/MidiBoot3/Inc/hardware.h index 5467f7f2..b531d634 100644 --- a/MidiBoot3/Inc/hardware.h +++ b/MidiBoot3/Inc/hardware.h @@ -21,6 +21,3 @@ #else #error Invalid configuration #endif - -/* #define USE_IWDG */ -/* #define INIT_FMC */ From c85006cc787915f963102780afd7b5c8f28270dd Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 2 Nov 2021 12:52:35 +0100 Subject: [PATCH 150/286] removed duplicate USBD_MAX_POWER setting --- MidiBoot/Inc/hardware.h | 1 - 1 file changed, 1 deletion(-) diff --git a/MidiBoot/Inc/hardware.h b/MidiBoot/Inc/hardware.h index 00cc2b1e..e463d92b 100644 --- a/MidiBoot/Inc/hardware.h +++ b/MidiBoot/Inc/hardware.h @@ -4,7 +4,6 @@ #define USE_BOOTLOADER_MODE #define USE_USBD_MIDI -#define USBD_MAX_POWER 100 // 100mA for iPad compatibility #ifdef USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS #else From 867db2af1c6e4ba9d20d31ee8e842f7faa89d406 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 2 Nov 2021 12:53:12 +0100 Subject: [PATCH 151/286] updated notes --- openware-notes.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/openware-notes.txt b/openware-notes.txt index 2511185b..e08f3ea7 100644 --- a/openware-notes.txt +++ b/openware-notes.txt @@ -386,3 +386,20 @@ play -c 1 -r 48k -t f32 sample.raw FirmwareSender -in sample.raw -out "OWL*" -name "sample.wav" ----------------------------------------------------------------- + +H7 ADC: +set Scan enable, Continuous enable, Conversion End of sequence, and ConversionDataManagement = ADC_CONVERSIONDATA_DMA_CIRCULAR + +----------------------------------------------------------------- + +ABFSR 0x04: AHBP busfault + +----------------------------------------------------------------- + +Dynamic module / code loading with Position Independent Code / Executables PIC / PIE +https://github.com/rgujju/STM32-projects/tree/master/got_plt +https://community.arm.com/support-forums/f/architectures-and-processors-forum/45919/gcc-does-not-generate-correct-code-while-building-pic +https://systemoverlord.com/2017/03/19/got-and-plt-for-pwning.html +https://reverseengineering.stackexchange.com/questions/1992/what-is-plt-got + +----------------------------------------------------------------- From 73149218672717c8aeeee89b6515f4b5c6765a3b Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 2 Nov 2021 15:19:30 +0100 Subject: [PATCH 152/286] added comment --- OwlPedal2/Src/OwlPedal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OwlPedal2/Src/OwlPedal.cpp b/OwlPedal2/Src/OwlPedal.cpp index 18a7e5e7..98e93c3d 100644 --- a/OwlPedal2/Src/OwlPedal.cpp +++ b/OwlPedal2/Src/OwlPedal.cpp @@ -9,7 +9,7 @@ // Pin footswitch_pin(GPIOA, GPIO_PIN_0); Pin bypass_pin(GPIOA, GPIO_PIN_0); -Pin bufpass_pin(GPIOF, GPIO_PIN_9); +Pin bufpass_pin(GPIOF, GPIO_PIN_9); // high is bypass Pin exp1_ring_pin(GPIOA, GPIO_PIN_2); Pin led_green_pin(GPIOB, GPIO_PIN_8); Pin led_red_pin(GPIOB, GPIO_PIN_9); From a097a6fa9e5d61b6b4b9b7739dc239a429ce53d2 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 2 Nov 2021 15:20:09 +0100 Subject: [PATCH 153/286] moved device-specific code to callbacks.cpp --- Source/ProgramManager.cpp | 6 ------ Source/callbacks.cpp | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/ProgramManager.cpp b/Source/ProgramManager.cpp index 9e471a05..4a992759 100644 --- a/Source/ProgramManager.cpp +++ b/Source/ProgramManager.cpp @@ -176,12 +176,6 @@ void audioCallback(int32_t* rx, int32_t* tx, uint16_t size){ pv->audio_input = rx; pv->audio_output = tx; pv->audio_blocksize = size; -#ifdef FASCINATION_MACHINE - extern uint32_t ledstatus; - static float audio_envelope_lambda = 0.999995f; - static float audio_envelope = 0.0; - audio_envelope = audio_envelope*audio_envelope_lambda + (1.0f-audio_envelope_lambda)*abs(pv->audio_output[0])*(1.0f/INT16_MAX); -#endif if(audioTask != NULL){ BaseType_t yield; // wake up audio task diff --git a/Source/callbacks.cpp b/Source/callbacks.cpp index b8e08c2f..25252fbf 100644 --- a/Source/callbacks.cpp +++ b/Source/callbacks.cpp @@ -394,4 +394,10 @@ __weak void updateParameters(int16_t* parameter_values, size_t parameter_len, ui // parameter_values[3] = 4095-adc_values[3]; #endif #endif +#ifdef FASCINATION_MACHINE + extern uint32_t ledstatus; + static float audio_envelope_lambda = 0.999995f; + static float audio_envelope = 0.0; + audio_envelope = audio_envelope*audio_envelope_lambda + (1.0f-audio_envelope_lambda)*abs(pv->audio_output[0])*(1.0f/INT16_MAX); +#endif } From 076c033adf79350d1222fe0a2a3521ccc09497d7 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 2 Nov 2021 20:57:06 +0100 Subject: [PATCH 154/286] process USB messages each audio block, before patch runs (or in loop if no patch is loaded) --- Source/Owl.cpp | 6 ++++-- Source/ProgramManager.cpp | 7 +++++++ Source/ProgramManager.h | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Source/Owl.cpp b/Source/Owl.cpp index 323974d3..9e7b3594 100644 --- a/Source/Owl.cpp +++ b/Source/Owl.cpp @@ -215,8 +215,10 @@ void Owl::setOperationMode(OperationMode mode){ } void Owl::loop(){ - midi_tx.transmit(); - midi_rx.receive(); // push queued up MIDI messages through to patch + if(program.isProgramRunning()){ + midi_tx.transmit(); + midi_rx.receive(); // push queued up MIDI messages through to patch + } #ifdef USE_DIGITALBUS busstatus = bus_status(); #endif diff --git a/Source/ProgramManager.cpp b/Source/ProgramManager.cpp index 4a992759..7901dd53 100644 --- a/Source/ProgramManager.cpp +++ b/Source/ProgramManager.cpp @@ -257,6 +257,9 @@ void onProgramReady(){ #ifdef DEBUG_DWT DWT->CYCCNT = 0; #endif + // push queued up MIDI messages through to patch + midi_tx.transmit(); + midi_rx.receive(); #ifdef USE_ADC #ifdef USE_SCREEN updateParameters(graphics.params.parameters, NOF_PARAMETERS, adc_values, NOF_ADC_VALUES); @@ -736,6 +739,10 @@ uint8_t ProgramManager::getProgramIndex(){ return patchindex; } +bool ProgramManager::isProgramRunning(){ + return audioTask != NULL; +} + extern "C" { void vApplicationMallocFailedHook(void) { program.exitProgram(false); diff --git a/Source/ProgramManager.h b/Source/ProgramManager.h index e02fcd3c..b0b92ddc 100644 --- a/Source/ProgramManager.h +++ b/Source/ProgramManager.h @@ -46,6 +46,7 @@ class ProgramManager { uint32_t getCyclesPerBlock(); uint32_t getHeapMemoryUsed(); uint8_t getProgramIndex(); + bool isProgramRunning(); private: void updateProgramIndex(uint8_t index); }; From 7cd809e5b1ae0efc48afa4733dcd6f3af59b4e07 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 3 Nov 2021 16:30:48 +0100 Subject: [PATCH 155/286] configurable hs/fs --- OwlPedal2/Inc/usbd_desc.h | 4 ++-- OwlPedal2/Src/usbd_desc.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/OwlPedal2/Inc/usbd_desc.h b/OwlPedal2/Inc/usbd_desc.h index 2348ea1c..90f8968c 100644 --- a/OwlPedal2/Inc/usbd_desc.h +++ b/OwlPedal2/Inc/usbd_desc.h @@ -30,7 +30,7 @@ #include "usbd_def.h" /* USER CODE BEGIN INCLUDE */ - +#include "device.h" /* USER CODE END INCLUDE */ /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY @@ -105,7 +105,7 @@ */ /** Descriptor for the Usb device. */ -extern USBD_DescriptorsTypeDef FS_Desc; +extern USBD_DescriptorsTypeDef USBD_DESC; /* USER CODE BEGIN EXPORTED_VARIABLES */ diff --git a/OwlPedal2/Src/usbd_desc.c b/OwlPedal2/Src/usbd_desc.c index 6a4b7740..508959aa 100644 --- a/OwlPedal2/Src/usbd_desc.c +++ b/OwlPedal2/Src/usbd_desc.c @@ -135,7 +135,7 @@ uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); * @{ */ -USBD_DescriptorsTypeDef FS_Desc = +USBD_DescriptorsTypeDef USBD_DESC = { USBD_FS_DeviceDescriptor , USBD_FS_LangIDStrDescriptor From 30b27567bd0b7433601e61d077f41a3d7de7f067 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 3 Nov 2021 16:31:17 +0100 Subject: [PATCH 156/286] configurable hs/fs --- OwlPedal2/Inc/hardware.h | 12 +- OwlPedal2/Inc/stm32f4xx_hal_conf.h | 2 +- OwlPedal2/Inc/stm32f4xx_it.h | 1 + OwlPedal2/OwlPedal2.ioc | 1218 ++++++++++++++-------------- OwlPedal2/Src/OwlPedal.cpp | 4 + OwlPedal2/Src/main.c | 107 ++- OwlPedal2/Src/stm32f4xx_hal_msp.c | 18 +- OwlPedal2/Src/stm32f4xx_it.c | 22 +- OwlPedal2/Src/usb_device.c | 12 +- OwlPedal2/Src/usbd_conf.c | 45 +- 10 files changed, 806 insertions(+), 635 deletions(-) diff --git a/OwlPedal2/Inc/hardware.h b/OwlPedal2/Inc/hardware.h index 151eaefe..4dcd8abe 100644 --- a/OwlPedal2/Inc/hardware.h +++ b/OwlPedal2/Inc/hardware.h @@ -7,14 +7,22 @@ #define HARDWARE_ID OWL_PEDAL_HARDWARE #define HARDWARE_VERSION "OWL Pedal mkII" +/* #define USE_USBD_FS */ +/* #define USBD_DESC FS_Desc */ +/* #define USBD_HSFS DEVICE_FS */ +/* #define USBD_HANDLE hUsbDeviceFS */ + +#define USE_USBD_HS +#define USBD_DESC HS_Desc +#define USBD_HSFS DEVICE_HS +#define USBD_HANDLE hUsbDeviceHS + #define USE_USBD_AUDIO #define USE_USBD_RX_FB #define USE_USBD_AUDIO_FEATURES #define USE_USBD_AUDIO_TX // microphone #define USE_USBD_AUDIO_RX // speaker #define USE_USBD_MIDI -#define USE_USBD_FS -#define USBD_HANDLE hUsbDeviceFS /* USB audio settings */ #define AUDIO_BITS_PER_SAMPLE 16 diff --git a/OwlPedal2/Inc/stm32f4xx_hal_conf.h b/OwlPedal2/Inc/stm32f4xx_hal_conf.h index 396890ad..90a5d561 100644 --- a/OwlPedal2/Inc/stm32f4xx_hal_conf.h +++ b/OwlPedal2/Inc/stm32f4xx_hal_conf.h @@ -70,7 +70,7 @@ /* #define HAL_SMBUS_MODULE_ENABLED */ /* #define HAL_WWDG_MODULE_ENABLED */ #define HAL_PCD_MODULE_ENABLED -/* #define HAL_HCD_MODULE_ENABLED */ +#define HAL_HCD_MODULE_ENABLED /* #define HAL_DSI_MODULE_ENABLED */ /* #define HAL_QSPI_MODULE_ENABLED */ /* #define HAL_QSPI_MODULE_ENABLED */ diff --git a/OwlPedal2/Inc/stm32f4xx_it.h b/OwlPedal2/Inc/stm32f4xx_it.h index c695ac53..cc7e46bd 100644 --- a/OwlPedal2/Inc/stm32f4xx_it.h +++ b/OwlPedal2/Inc/stm32f4xx_it.h @@ -71,6 +71,7 @@ void DMA2_Stream1_IRQHandler(void); void DMA2_Stream3_IRQHandler(void); void DMA2_Stream4_IRQHandler(void); void OTG_FS_IRQHandler(void); +void OTG_HS_IRQHandler(void); void SAI1_IRQHandler(void); /* USER CODE BEGIN EFP */ diff --git a/OwlPedal2/OwlPedal2.ioc b/OwlPedal2/OwlPedal2.ioc index b7a651c4..f98be83b 100644 --- a/OwlPedal2/OwlPedal2.ioc +++ b/OwlPedal2/OwlPedal2.ioc @@ -1,649 +1,647 @@ #MicroXplorer Configuration settings - do not modify -PF7.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -SH.FMC_D7_DA7.0=FMC_D7,sd-16b-d1 -Dma.ADC3.0.FIFOMode=DMA_FIFOMODE_DISABLE -SH.FMC_D0_DA0.ConfNb=1 -RCC.USART1Freq_Value=108000000 -Dma.ADC3.0.Priority=DMA_PRIORITY_LOW -SH.FMC_A8.ConfNb=1 -SH.FMC_A4.ConfNb=1 -SPI4.VirtualType=VM_MASTER -SH.FMC_A0.ConfNb=1 -SH.FMC_D6_DA6.ConfNb=1 -SAI1.VirtualMode-SAI_A_AsyncSlave=VM_SLAVE -FMC.SDClockPeriod2=FMC_SDRAM_CLOCK_PERIOD_2 -SH.FMC_D9_DA9.ConfNb=1 -FMC.RCDDelay1=2 -FMC.SDClockPeriod1=FMC_SDRAM_CLOCK_PERIOD_2 -SH.FMC_A0.0=FMC_A0,12b-sda1 -SPI1.VirtualType=VM_MASTER -Dma.SAI1_B.2.MemDataAlignment=DMA_MDATAALIGN_WORD -SH.GPXTI9.0=GPIO_EXTI9 -PG4.Signal=FMC_A14_BA0 -PG8.Signal=FMC_SDCLK -RCC.PLLCLKFreq_Value=168000000 -RCC.PLLQCLKFreq_Value=48000000 -PG0.Signal=FMC_A10 -FMC.LoadToActiveDelay1=2 -VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled -PC3.Locked=true -RCC.RTCFreq_Value=32000 -PA3.GPIOParameters=GPIO_Label -PA6.GPIO_Label=FLASH_MISO -Dma.SAI1_A.1.Mode=DMA_CIRCULAR -PD2.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -SH.FMC_SDNWE.ConfNb=1 -SH.FMC_D5_DA5.0=FMC_D5,sd-16b-d1 -Dma.SAI1_A.1.MemDataAlignment=DMA_MDATAALIGN_WORD -PD6.GPIO_Label=CS_SDIN -Dma.SAI1_B.2.Mode=DMA_CIRCULAR -PinOutPanel.RotationAngle=0 -PE6.GPIO_Label=CS_SDA -RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK -SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 -SH.FMC_D9_DA9.0=FMC_D9,sd-16b-d1 -RCC.LPTIM1Freq_Value=54000000 -USB_DEVICE.PID_AUDIO_FS=0xdada -SH.GPXTI7.ConfNb=1 -NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -SAI1.FSDefinition-SAI_B_SyncSlave=SAI_FS_CHANNEL_IDENTIFICATION -NVIC.EXTI1_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true -PF7.Signal=GPXTI7 -SH.FMC_SDNWE.0=FMC_SDNWE,12b-sda1 -SPI1.Direction=SPI_DIRECTION_2LINES -SH.FMC_D11_DA11.0=FMC_D11,sd-16b-d1 -Dma.SAI1_A.1.Instance=DMA2_Stream3 -RCC.I2C4Freq_Value=54000000 -PE2.Mode=TX_Only_Simplex_Unidirect_Master -RCC.APB2TimFreq_Value=168000000 -PB2/BOOT1.GPIO_Label=EXP_TIP -PB6.Signal=FMC_SDNE1 -Dma.ADC3.0.Direction=DMA_PERIPH_TO_MEMORY -SH.FMC_D10_DA10.ConfNb=1 -PH1/OSC_OUT.Signal=RCC_OSC_OUT -PB6.Mode=SdramChipSelect2_1 -SPI1.CalculateBaudRate=42.0 MBits/s -PC3.Signal=ADCx_IN13 -PD0.Signal=FMC_D2_DA2 -ADC3.ScanConvMode=ENABLE -RCC.SAI2Freq_Value=50000000 -PD8.Signal=FMC_D13_DA13 -PE5.Signal=SAI1_SCK_A -Dma.SAI1_A.1.FIFOMode=DMA_FIFOMODE_DISABLE -PE1.Signal=FMC_NBL1 -PA1.GPIO_PuPd=GPIO_NOPULL -PF10.GPIO_Label=ADC4 -Dma.SAI1_A.1.MemInc=DMA_MINC_ENABLE -RCC.USART3Freq_Value=54000000 -PD2.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -RCC.PLLSAIRCLKFreq_Value=50000000 -ProjectManager.ProjectBuild=false -NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_9 +ADC1.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV8 +ADC1.ContinuousConvMode=ENABLE +ADC1.DMAContinuousRequests=DISABLE +ADC1.EOCSelection=ADC_EOC_SEQ_CONV +ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,NbrOfConversionFlag,master,ClockPrescaler,ScanConvMode,ContinuousConvMode,DMAContinuousRequests,EOCSelection,NbrOfConversion +ADC1.NbrOfConversion=1 +ADC1.NbrOfConversionFlag=1 +ADC1.Rank-0\#ChannelRegularConversion=1 +ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES ADC1.ScanConvMode=ENABLE -PB3.Mode=Full_Duplex_Master -Dma.ADC3.0.PeriphInc=DMA_PINC_DISABLE -SH.GPXTI7.0=GPIO_EXTI7 -ADC3.ExternalTrigConv=ADC_SOFTWARE_START -FMC.SelfRefreshTime1=4 -ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.26.2 -MxDb.Version=DB.6.0.21 -USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology -USB_DEVICE.USBD_MAX_NUM_CONFIGURATION-AUDIO_FS=2 -PA1.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -ProjectManager.BackupPrevious=false -SAI1.SlotNumber-SAI_A_AsyncSlave=2 -PC4.GPIO_Label=FLASH_HOLD -PE9.Signal=FMC_D6_DA6 -SH.FMC_A2.0=FMC_A2,12b-sda1 -PB1.GPIO_Label=EXP_RING -SH.FMC_D15_DA15.ConfNb=1 -ADC3.ContinuousConvMode=ENABLE -PE4.GPIO_Label=CS_LRCK -PF10.Locked=true -ADC3.IPParameters=Rank-31\#ChannelRegularConversion,Channel-31\#ChannelRegularConversion,SamplingTime-31\#ChannelRegularConversion,NbrOfConversionFlag,ScanConvMode,ContinuousConvMode,DMAContinuousRequests,EOCSelection,InjNumberOfConversion,EnableAnalogWatchDog,ExternalTrigConv,Rank-32\#ChannelRegularConversion,Channel-32\#ChannelRegularConversion,SamplingTime-32\#ChannelRegularConversion,Rank-33\#ChannelRegularConversion,Channel-33\#ChannelRegularConversion,SamplingTime-33\#ChannelRegularConversion,Rank-34\#ChannelRegularConversion,Channel-34\#ChannelRegularConversion,SamplingTime-34\#ChannelRegularConversion,NbrOfConversion,ClockPrescaler,Resolution,DataAlign,DiscontinuousConvMode,ExternalTrigConvEdge,Rank-35\#ChannelRegularConversion,Channel-35\#ChannelRegularConversion,SamplingTime-35\#ChannelRegularConversion -SH.ADCx_IN11.ConfNb=2 -PE2.Signal=SPI4_SCK +ADC1.master=1 +ADC3.Channel-31\#ChannelRegularConversion=ADC_CHANNEL_13 +ADC3.Channel-32\#ChannelRegularConversion=ADC_CHANNEL_12 ADC3.Channel-33\#ChannelRegularConversion=ADC_CHANNEL_11 -SH.FMC_D1_DA1.0=FMC_D1,sd-16b-d1 -NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false -PC15/OSC32_OUT.Locked=true -PF3.Signal=FMC_A3 -VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 -NVIC.SAI1_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true -PE10.Signal=FMC_D7_DA7 -ProjectManager.HalAssertFull=true -ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -RCC.MCO2PinFreq_Value=168000000 -Mcu.Package=LQFP144 -PF8.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -PB1.Signal=ADCx_IN9 -SH.GPXTI8.0=GPIO_EXTI8 -Dma.SAI1_A.1.Direction=DMA_MEMORY_TO_PERIPH -SH.FMC_SDNCAS.ConfNb=1 -VP_SYS_VS_Systick.Signal=SYS_VS_Systick -SH.GPXTI8.ConfNb=1 -SH.FMC_A11.ConfNb=1 -FREERTOS.FootprintOK=true -FMC.WriteRecoveryTime1=2 -PF7.Locked=true -SH.ADCx_IN9.0=ADC1_IN9,IN9 -SH.FMC_A1.0=FMC_A1,12b-sda1 +ADC3.Channel-34\#ChannelRegularConversion=ADC_CHANNEL_8 +ADC3.Channel-35\#ChannelRegularConversion=ADC_CHANNEL_3 +ADC3.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV8 +ADC3.ContinuousConvMode=ENABLE ADC3.DMAContinuousRequests=ENABLE -RCC.APB2CLKDivider=RCC_HCLK_DIV2 -NVIC.EXTI2_IRQn=true\:15\:0\:true\:false\:true\:false\:true\:true -SH.FMC_SDCLK.0=FMC_SDCLK,12b-sda1 -RCC.CECFreq_Value=32786.88524590164 -PF14.Signal=FMC_A8 +ADC3.DataAlign=ADC_DATAALIGN_RIGHT +ADC3.DiscontinuousConvMode=DISABLE +ADC3.EOCSelection=ADC_EOC_SEQ_CONV +ADC3.EnableAnalogWatchDog=false +ADC3.ExternalTrigConv=ADC_SOFTWARE_START ADC3.ExternalTrigConvEdge=ADC_EXTERNALTRIGCONVEDGE_NONE -RCC.APB1TimFreq_Value=84000000 -Dma.ADC3.0.Instance=DMA2_Stream1 -NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -FMC.RowCycleDelay2=6 -PF10.Mode=IN8 -SH.ADCx_IN9.ConfNb=1 -FMC.RowCycleDelay1=6 -USB_OTG_FS.IPParameters=VirtualMode -PB10.GPIOParameters=GPIO_Label +ADC3.IPParameters=Rank-31\#ChannelRegularConversion,Channel-31\#ChannelRegularConversion,SamplingTime-31\#ChannelRegularConversion,NbrOfConversionFlag,ScanConvMode,ContinuousConvMode,DMAContinuousRequests,EOCSelection,InjNumberOfConversion,EnableAnalogWatchDog,ExternalTrigConv,Rank-32\#ChannelRegularConversion,Channel-32\#ChannelRegularConversion,SamplingTime-32\#ChannelRegularConversion,Rank-33\#ChannelRegularConversion,Channel-33\#ChannelRegularConversion,SamplingTime-33\#ChannelRegularConversion,Rank-34\#ChannelRegularConversion,Channel-34\#ChannelRegularConversion,SamplingTime-34\#ChannelRegularConversion,NbrOfConversion,ClockPrescaler,Resolution,DataAlign,DiscontinuousConvMode,ExternalTrigConvEdge,Rank-35\#ChannelRegularConversion,Channel-35\#ChannelRegularConversion,SamplingTime-35\#ChannelRegularConversion +ADC3.InjNumberOfConversion=0 +ADC3.NbrOfConversion=5 +ADC3.NbrOfConversionFlag=1 +ADC3.Rank-31\#ChannelRegularConversion=1 +ADC3.Rank-32\#ChannelRegularConversion=2 +ADC3.Rank-33\#ChannelRegularConversion=3 ADC3.Rank-34\#ChannelRegularConversion=4 -SAI1.SlotSize-SAI_A_AsyncSlave=SAI_SLOTSIZE_32B -ADC1.EOCSelection=ADC_EOC_SEQ_CONV -PD15.Signal=FMC_D1_DA1 -SH.FMC_D3_DA3.0=FMC_D3,sd-16b-d1 -ProjectManager.CustomerFirmwarePackage= -PC4.GPIOParameters=GPIO_Label -RCC.SAI_AClocksFreq_Value=25000000 -RCC.PLLSAIQCLKFreq_Value=50000000 -USB_DEVICE.USBD_AUDIO_FREQ-AUDIO_FS=48000 -SH.FMC_D3_DA3.ConfNb=1 -PA6.GPIOParameters=GPIO_Label -USB_DEVICE.VID-AUDIO_FS=0x1209 -PD6.GPIOParameters=GPIO_Label -SH.FMC_A4.0=FMC_A4,12b-sda1 -SH.FMC_A7.ConfNb=1 -RCC.PLLQoutputFreq_Value=48000000 -ProjectManager.ProjectFileName=OwlPedal2.ioc -SH.FMC_A5.ConfNb=1 -SH.FMC_A1.ConfNb=1 -FREERTOS.Tasks01=defaultTask,0,128,StartDefaultTask,Default,NULL -ADC1.Rank-0\#ChannelRegularConversion=1 -USB_DEVICE.VirtualMode-AUDIO_FS=Audio -Mcu.PinsNb=75 -Dma.SAI1_B.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -PD2.GPIO_PuPd=GPIO_PULLUP -Mcu.Pin73=VP_SYS_VS_Systick -PG9.GPIO_PuPd=GPIO_PULLUP -Mcu.Pin74=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS -Mcu.Pin71=VP_FREERTOS_VS_CMSIS_V1 -Mcu.Pin72=VP_RTC_VS_RTC_Activate -ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,NbrOfConversionFlag,master,ClockPrescaler,ScanConvMode,ContinuousConvMode,DMAContinuousRequests,EOCSelection,NbrOfConversion -PG9.Locked=true -PG5.Signal=FMC_A15_BA1 -PG9.Signal=GPXTI9 -SH.FMC_D10_DA10.0=FMC_D10,sd-16b-d1 -PA9.GPIO_Label=USBD_VBUS -FREERTOS.INCLUDE_vTaskDelayUntil=1 -FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 -Mcu.Pin70=PE1 -PC2.Signal=ADCx_IN12 -PB11.GPIO_Label=CS_nRST -PD1.Signal=FMC_D3_DA3 -PA11.GPIO_Label=USBD_DM -RCC.VCOSAIOutputFreq_ValueQ=25000000 -NVIC.DMA2_Stream1_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true -Mcu.Pin68=PB6 -Mcu.Pin69=PE0 -RCC.UART8Freq_Value=54000000 -PC0.Signal=FMC_SDNWE -RCC.APB1CLKDivider=RCC_HCLK_DIV4 -ADC3.Channel-31\#ChannelRegularConversion=ADC_CHANNEL_13 -PD6.Mode=SAI_A_AsyncSlave -Mcu.Pin62=PD2 -Mcu.Pin63=PD6 -Mcu.Pin60=PD0 -Mcu.Pin61=PD1 -Mcu.Pin66=PB3 -Mcu.Pin67=PB5 -Mcu.Pin64=PG9 +ADC3.Rank-35\#ChannelRegularConversion=5 ADC3.Resolution=ADC_RESOLUTION_12B -Mcu.Pin65=PG15 -Dma.SAI1_B.2.PeriphInc=DMA_PINC_DISABLE -PF8.GPIO_Label=EXP2_R -PC3.GPIOParameters=GPIO_Label -PD10.Signal=FMC_D15_DA15 -SH.FMC_A3.0=FMC_A3,12b-sda1 -Mcu.Pin59=PA14 -FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_3 -Mcu.Pin57=PA12 -SH.GPXTI2.ConfNb=1 -Mcu.Pin58=PA13 -Mcu.Pin51=PD15 -RCC.USART6Freq_Value=108000000 -SH.FMC_D15_DA15.0=FMC_D15,sd-16b-d1 -Mcu.Pin52=PG4 -Dma.SAI1_B.2.PeriphDataAlignment=DMA_PDATAALIGN_WORD -Mcu.Pin50=PD14 -Mcu.Pin55=PA9 -Mcu.Pin56=PA11 -Mcu.Pin53=PG5 -Mcu.Pin54=PG8 -PA9.Signal=USB_OTG_FS_VBUS -PB11.GPIOParameters=GPIO_Label -ADC3.NbrOfConversion=5 -Mcu.Pin48=PD9 -Mcu.Pin49=PD10 -Mcu.Pin46=PB11 -Mcu.Pin47=PD8 -PB10.Signal=GPIO_Output -Mcu.Pin40=PE11 -Mcu.Pin41=PE12 -FREERTOS.MEMORY_ALLOCATION=2 -Mcu.Pin44=PE15 -Mcu.Pin45=PB10 -Mcu.Pin42=PE13 -Mcu.Pin43=PE14 -ProjectManager.LastFirmware=true -FMC.ReadBurst1=FMC_SDRAM_RBURST_ENABLE -SH.FMC_A6.0=FMC_A6,12b-sda1 -FMC.ReadBurst2=FMC_SDRAM_RBURST_ENABLE -PE14.Signal=FMC_D11_DA11 -PE6.Mode=TX_Only_Simplex_Unidirect_Master -PE15.Signal=FMC_D12_DA12 -Mcu.Pin37=PE8 -Mcu.Pin38=PE9 -Mcu.Pin35=PG1 -RCC.I2C1Freq_Value=54000000 -Mcu.Pin36=PE7 -PE8.Signal=FMC_D5_DA5 -RCC.PLLI2SPCLKFreq_Value=96000000 -SPI1.Mode=SPI_MODE_MASTER -SH.FMC_D14_DA14.ConfNb=1 -Mcu.Pin39=PE10 -PC2.GPIOParameters=GPIO_Label -Mcu.Pin30=PF12 -PA1.GPIO_Label=FOOTSWITCH -RCC.EthernetFreq_Value=168000000 -SH.ADCx_IN12.ConfNb=2 -Mcu.Pin33=PF15 -Mcu.Pin34=PG0 +ADC3.SamplingTime-31\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-32\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES ADC3.SamplingTime-33\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -Mcu.Pin31=PF13 -Mcu.Pin32=PF14 -NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -FREERTOS.configUSE_MUTEXES=0 -PF13.Signal=FMC_A7 -ADC1.DMAContinuousRequests=DISABLE -PA13.Mode=Serial_Wire -SH.FMC_SDNCAS.0=FMC_SDNCAS,12b-sda1 -ProjectManager.FreePins=true -Dma.ADC3.0.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD -SH.FMC_NBL1.ConfNb=1 -RCC.PLLI2SQCLKFreq_Value=96000000 -Mcu.Pin26=PC5 -Mcu.Pin27=PB1 -NVIC.DMA2_Stream4_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true -RCC.RTCHSEDivFreq_Value=12500000 -Mcu.Pin24=PA7 -ProjectManager.UnderRoot=false -Mcu.Pin25=PC4 -PF7.GPIO_PuPd=GPIO_PULLUP -Mcu.Pin28=PB2/BOOT1 -Mcu.Pin29=PF11 -SH.FMC_D7_DA7.ConfNb=1 -Mcu.Pin22=PA3 -PB5.Signal=FMC_SDCKE1 -Mcu.Pin23=PA6 -Mcu.Pin20=PC3 -ADC1.master=1 -Mcu.Pin21=PA1 -NVIC.ForceEnableDMAVector=true -SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX -NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -PE5.GPIO_Label=CS_SCK -SH.FMC_A10.ConfNb=1 -ProjectManager.CompilerOptimize=6 -SH.FMC_A5.0=FMC_A5,12b-sda1 -PA11.Signal=USB_OTG_FS_DM -SH.FMC_SDNRAS.ConfNb=1 -ProjectManager.HeapSize=0x200 -Mcu.Pin15=PH0/OSC_IN -NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -Mcu.Pin16=PH1/OSC_OUT -ADC3.EOCSelection=ADC_EOC_SEQ_CONV -Mcu.Pin13=PF8 -Dma.ADC3.0.Mode=DMA_CIRCULAR -PF8.Locked=true -Mcu.Pin14=PF10 -Mcu.Pin19=PC2 -PF10.GPIOParameters=GPIO_Label -ProjectManager.ComputerToolchain=false -Mcu.Pin17=PC0 -Mcu.Pin18=PC1 -Dma.SAI1_B.2.Instance=DMA2_Stream4 -NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 -Mcu.Pin11=PF5 -Mcu.Pin12=PF7 -Mcu.Pin10=PF4 -Dma.SAI1_A.1.Priority=DMA_PRIORITY_VERY_HIGH -PE3.Signal=SAI1_SD_B -PC3.GPIO_Label=ADC1 -ADC3.Rank-33\#ChannelRegularConversion=3 -Dma.SAI1_A.1.PeriphInc=DMA_PINC_DISABLE -PC15/OSC32_OUT.Signal=GPIO_Output -PF4.Signal=FMC_A4 -Dma.SAI1_B.2.FIFOMode=DMA_FIFOMODE_DISABLE -SH.GPXTI1.ConfNb=1 -SH.FMC_D12_DA12.ConfNb=1 -PD2.Signal=GPXTI2 -RCC.I2C2Freq_Value=54000000 -SAI1.SlotSize-SAI_B_SyncSlave=SAI_SLOTSIZE_32B -PA7.GPIOParameters=GPIO_Label -PC1.Signal=ADCx_IN11 -PD2.GPIO_Label=SW1 -ADC3.EnableAnalogWatchDog=false -Mcu.Family=STM32F4 -FMC.IPParameters=ReadPipeDelay1,ReadBurst1,ReadBurst2,SDClockPeriod1,SDClockPeriod2,CASLatency1,LoadToActiveDelay1,ExitSelfRefreshDelay1,SelfRefreshTime1,RowCycleDelay1,RowCycleDelay2,WriteRecoveryTime1,RPDelay1,RPDelay2,RCDDelay1 -SH.GPXTI1.0=GPIO_EXTI1 -ProjectManager.MainLocation=Src -SH.FMC_A6.ConfNb=1 -PA6.Mode=Full_Duplex_Master -USB_DEVICE.CLASS_NAME_FS=AUDIO -SH.FMC_A8.0=FMC_A8,12b-sda1 -RCC.SAI1Freq_Value=50000000 -RCC.CortexFreq_Value=168000000 -SH.FMC_A2.ConfNb=1 -PC15/OSC32_OUT.GPIO_Label=EXTSPI_nCS -PG9.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -ProjectManager.KeepUserCode=true -Mcu.UserName=STM32F427ZITx -ADC3.Channel-35\#ChannelRegularConversion=ADC_CHANNEL_3 -ADC1.ContinuousConvMode=ENABLE -SH.FMC_D14_DA14.0=FMC_D14,sd-16b-d1 +ADC3.SamplingTime-34\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-35\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.ScanConvMode=ENABLE +Dma.ADC3.0.Direction=DMA_PERIPH_TO_MEMORY +Dma.ADC3.0.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.ADC3.0.Instance=DMA2_Stream1 +Dma.ADC3.0.MemDataAlignment=DMA_MDATAALIGN_HALFWORD +Dma.ADC3.0.MemInc=DMA_MINC_ENABLE +Dma.ADC3.0.Mode=DMA_CIRCULAR +Dma.ADC3.0.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD +Dma.ADC3.0.PeriphInc=DMA_PINC_DISABLE +Dma.ADC3.0.Priority=DMA_PRIORITY_LOW +Dma.ADC3.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +Dma.Request0=ADC3 +Dma.Request1=SAI1_A +Dma.Request2=SAI1_B +Dma.RequestsNb=3 +Dma.SAI1_A.1.Direction=DMA_MEMORY_TO_PERIPH +Dma.SAI1_A.1.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SAI1_A.1.Instance=DMA2_Stream3 +Dma.SAI1_A.1.MemDataAlignment=DMA_MDATAALIGN_WORD +Dma.SAI1_A.1.MemInc=DMA_MINC_ENABLE +Dma.SAI1_A.1.Mode=DMA_CIRCULAR +Dma.SAI1_A.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD +Dma.SAI1_A.1.PeriphInc=DMA_PINC_DISABLE +Dma.SAI1_A.1.Priority=DMA_PRIORITY_VERY_HIGH Dma.SAI1_A.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +Dma.SAI1_B.2.Direction=DMA_PERIPH_TO_MEMORY +Dma.SAI1_B.2.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SAI1_B.2.Instance=DMA2_Stream4 +Dma.SAI1_B.2.MemDataAlignment=DMA_MDATAALIGN_WORD Dma.SAI1_B.2.MemInc=DMA_MINC_ENABLE -SAI1.FrameLength-SAI_A_AsyncSlave=64 -SAI1.FrameLength-SAI_B_SyncSlave=64 -PC5.Locked=true -SPI4.Direction=SPI_DIRECTION_2LINES -SH.FMC_NBL0.0=FMC_NBL0,Sd2ByteEnable1 -PA12.GPIOParameters=GPIO_Label -ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-SystemClock_Config-RCC-false-HAL-true,9-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,10-MX_RTC_Init-RTC-false-HAL-true,11-MX_ADC1_Init-ADC1-false-HAL-true -PA9.GPIOParameters=GPIO_Label -PA11.GPIOParameters=GPIO_Label -SH.FMC_D6_DA6.0=FMC_D6,sd-16b-d1 -PA11.Mode=Device_Only -PB2/BOOT1.GPIOParameters=GPIO_Label -RCC.PLLI2SRCLKFreq_Value=96000000 -ADC3.SamplingTime-35\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -RCC.USART2Freq_Value=54000000 -SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 -PD2.Locked=true -SH.FMC_A11.0=FMC_A11,12b-sda1 -PC1.Locked=true -PB11.Signal=GPIO_Output -ADC3.Channel-32\#ChannelRegularConversion=ADC_CHANNEL_12 -PG15.Signal=FMC_SDNCAS -PE5.GPIOParameters=GPIO_Label -ProjectManager.StackSize=0x400 -SH.GPXTI2.0=GPIO_EXTI2 -RCC.SAI_BClocksFreq_Value=25000000 -ADC3.SamplingTime-32\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -SAI1.Instance-SAI_A_AsyncSlave=SAI$Index_Block_A -RCC.I2C3Freq_Value=54000000 -Mcu.IP4=FREERTOS -Mcu.IP5=NVIC -RCC.FCLKCortexFreq_Value=168000000 -Mcu.IP2=DMA -NVIC.ADC_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -Mcu.IP3=FMC +Dma.SAI1_B.2.Mode=DMA_CIRCULAR +Dma.SAI1_B.2.PeriphDataAlignment=DMA_PDATAALIGN_WORD +Dma.SAI1_B.2.PeriphInc=DMA_PINC_DISABLE +Dma.SAI1_B.2.Priority=DMA_PRIORITY_VERY_HIGH +Dma.SAI1_B.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_3 +FMC.ExitSelfRefreshDelay1=6 +FMC.IPParameters=ReadPipeDelay1,ReadBurst1,ReadBurst2,SDClockPeriod1,SDClockPeriod2,CASLatency1,LoadToActiveDelay1,ExitSelfRefreshDelay1,SelfRefreshTime1,RowCycleDelay1,RowCycleDelay2,WriteRecoveryTime1,RPDelay1,RPDelay2,RCDDelay1 +FMC.LoadToActiveDelay1=2 +FMC.RCDDelay1=2 +FMC.RPDelay1=2 +FMC.RPDelay2=2 +FMC.ReadBurst1=FMC_SDRAM_RBURST_ENABLE +FMC.ReadBurst2=FMC_SDRAM_RBURST_ENABLE +FMC.ReadPipeDelay1=FMC_SDRAM_RPIPE_DELAY_0 +FMC.RowCycleDelay1=6 +FMC.RowCycleDelay2=6 +FMC.SDClockPeriod1=FMC_SDRAM_CLOCK_PERIOD_2 +FMC.SDClockPeriod2=FMC_SDRAM_CLOCK_PERIOD_2 +FMC.SelfRefreshTime1=4 +FMC.WriteRecoveryTime1=2 +FREERTOS.FootprintOK=true +FREERTOS.INCLUDE_vTaskDelayUntil=1 +FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configENABLE_BACKWARD_COMPATIBILITY,configUSE_MUTEXES,FootprintOK,MEMORY_ALLOCATION,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,INCLUDE_vTaskDelayUntil,configTOTAL_HEAP_SIZE +FREERTOS.MEMORY_ALLOCATION=2 +FREERTOS.Tasks01=defaultTask,0,128,StartDefaultTask,Default,NULL +FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 +FREERTOS.configENABLE_BACKWARD_COMPATIBILITY=0 +FREERTOS.configTOTAL_HEAP_SIZE=8192 +FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 +FREERTOS.configUSE_MUTEXES=0 +FREERTOS.configUSE_PREEMPTION=0 +File.Version=6 +GPIO.groupedBy=Group By Peripherals +KeepUserPlacement=false +Mcu.Family=STM32F4 Mcu.IP0=ADC1 -SH.FMC_A7.0=FMC_A7,12b-sda1 Mcu.IP1=ADC3 -PA12.Signal=USB_OTG_FS_DP -PE4.GPIOParameters=GPIO_Label -Mcu.UserConstants= -SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE -SPI4.Mode=SPI_MODE_MASTER -PC1.GPIOParameters=GPIO_Label -RCC.SDMMCFreq_Value=216000000 -Mcu.ThirdPartyNb=0 -PH0/OSC_IN.Mode=HSE-External-Oscillator -RCC.HCLKFreq_Value=168000000 -SH.ADCx_IN3.0=ADC3_IN3,IN3 +Mcu.IP10=SPI4 +Mcu.IP11=SYS +Mcu.IP12=USB_OTG_FS +Mcu.IP13=USB_OTG_HS +Mcu.IP2=DMA +Mcu.IP3=FMC +Mcu.IP4=FREERTOS +Mcu.IP5=NVIC +Mcu.IP6=RCC +Mcu.IP7=RTC +Mcu.IP8=SAI1 +Mcu.IP9=SPI1 Mcu.IPNb=14 -RCC.I2SClocksFreq_Value=96000000 -RCC.PLLI2SRoutputFreq_Value=96000000 -ProjectManager.PreviousToolchain= -RCC.SPDIFRXFreq_Value=96000000 -RCC.VcooutputI2S=96000000 -SH.FMC_NBL1.0=FMC_NBL1,Sd2ByteEnable1 -PF12.Signal=FMC_A6 -SH.ADCx_IN3.ConfNb=1 -FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 -Mcu.Pin6=PF0 -Mcu.Pin7=PF1 -Mcu.Pin8=PF2 -Mcu.Pin9=PF3 -RCC.VCOSAIOutputFreq_Value=100000000 -SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,VirtualType,Direction -Dma.ADC3.0.MemDataAlignment=DMA_MDATAALIGN_HALFWORD -FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configENABLE_BACKWARD_COMPATIBILITY,configUSE_MUTEXES,FootprintOK,MEMORY_ALLOCATION,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,INCLUDE_vTaskDelayUntil,configTOTAL_HEAP_SIZE -SH.FMC_A10.0=FMC_A10,12b-sda1 -RCC.AHBFreq_Value=168000000 +Mcu.Name=STM32F427Z(G-I)Tx +Mcu.Package=LQFP144 Mcu.Pin0=PE2 Mcu.Pin1=PE3 -GPIO.groupedBy=Group By Peripherals +Mcu.Pin10=PF4 +Mcu.Pin11=PF5 +Mcu.Pin12=PF7 +Mcu.Pin13=PF8 +Mcu.Pin14=PF10 +Mcu.Pin15=PH0/OSC_IN +Mcu.Pin16=PH1/OSC_OUT +Mcu.Pin17=PC0 +Mcu.Pin18=PC1 +Mcu.Pin19=PC2 Mcu.Pin2=PE4 -FREERTOS.configUSE_PREEMPTION=0 +Mcu.Pin20=PC3 +Mcu.Pin21=PA1 +Mcu.Pin22=PA3 +Mcu.Pin23=PA6 +Mcu.Pin24=PA7 +Mcu.Pin25=PC4 +Mcu.Pin26=PC5 +Mcu.Pin27=PB1 +Mcu.Pin28=PB2/BOOT1 +Mcu.Pin29=PF11 Mcu.Pin3=PE5 +Mcu.Pin30=PF12 +Mcu.Pin31=PF13 +Mcu.Pin32=PF14 +Mcu.Pin33=PF15 +Mcu.Pin34=PG0 +Mcu.Pin35=PG1 +Mcu.Pin36=PE7 +Mcu.Pin37=PE8 +Mcu.Pin38=PE9 +Mcu.Pin39=PE10 Mcu.Pin4=PE6 +Mcu.Pin40=PE11 +Mcu.Pin41=PE12 +Mcu.Pin42=PE13 +Mcu.Pin43=PE14 +Mcu.Pin44=PE15 +Mcu.Pin45=PB10 +Mcu.Pin46=PB11 +Mcu.Pin47=PB12 +Mcu.Pin48=PB13 +Mcu.Pin49=PB14 Mcu.Pin5=PC15/OSC32_OUT -ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_9 -RCC.HSE_VALUE=25000000 +Mcu.Pin50=PB15 +Mcu.Pin51=PD8 +Mcu.Pin52=PD9 +Mcu.Pin53=PD10 +Mcu.Pin54=PD14 +Mcu.Pin55=PD15 +Mcu.Pin56=PG4 +Mcu.Pin57=PG5 +Mcu.Pin58=PG8 +Mcu.Pin59=PA9 +Mcu.Pin6=PF0 +Mcu.Pin60=PA10 +Mcu.Pin61=PA11 +Mcu.Pin62=PA12 +Mcu.Pin63=PA13 +Mcu.Pin64=PA14 +Mcu.Pin65=PD0 +Mcu.Pin66=PD1 +Mcu.Pin67=PD2 +Mcu.Pin68=PD6 +Mcu.Pin69=PG9 +Mcu.Pin7=PF1 +Mcu.Pin70=PG15 +Mcu.Pin71=PB3 +Mcu.Pin72=PB5 +Mcu.Pin73=PB6 +Mcu.Pin74=PE0 +Mcu.Pin75=PE1 +Mcu.Pin76=VP_FREERTOS_VS_CMSIS_V1 +Mcu.Pin77=VP_RTC_VS_RTC_Activate +Mcu.Pin78=VP_SYS_VS_Systick +Mcu.Pin8=PF2 +Mcu.Pin9=PF3 +Mcu.PinsNb=79 +Mcu.ThirdPartyNb=0 +Mcu.UserConstants= +Mcu.UserName=STM32F427ZITx +MxCube.Version=6.3.0 +MxDb.Version=DB.6.0.30 +NVIC.ADC_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.DMA2_Stream1_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true +NVIC.DMA2_Stream3_IRQn=true\:5\:0\:false\:false\:true\:false\:false\:true +NVIC.DMA2_Stream4_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -SH.FMC_A14_BA0.ConfNb=1 -ADC3.InjNumberOfConversion=0 -SH.FMC_D8_DA8.0=FMC_D8,sd-16b-d1 -FMC.ExitSelfRefreshDelay1=6 -FMC.RPDelay2=2 -Mcu.IP10=SPI4 -FMC.RPDelay1=2 +NVIC.EXTI1_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true +NVIC.EXTI2_IRQn=true\:15\:0\:true\:false\:true\:false\:true\:true +NVIC.EXTI9_5_IRQn=true\:15\:0\:true\:false\:true\:false\:true\:true +NVIC.ForceEnableDMAVector=true +NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false +NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 +NVIC.SAI1_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true +NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.SavedPendsvIrqHandlerGenerated=true +NVIC.SavedSvcallIrqHandlerGenerated=true +NVIC.SavedSystickIrqHandlerGenerated=true NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:true\:true -Mcu.IP12=USB_DEVICE -Mcu.IP11=SYS -FREERTOS.configENABLE_BACKWARD_COMPATIBILITY=0 +NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +PA1.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PA1.GPIO_Label=FOOTSWITCH +PA1.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PA1.GPIO_PuPd=GPIO_NOPULL +PA1.Locked=true +PA1.Signal=GPXTI1 +PA10.Mode=OTG/Dual_Role_Device +PA10.Signal=USB_OTG_FS_ID +PA11.GPIOParameters=GPIO_Label +PA11.GPIO_Label=USBD_DM +PA11.Mode=OTG/Dual_Role_Device +PA11.Signal=USB_OTG_FS_DM +PA12.GPIOParameters=GPIO_Label +PA12.GPIO_Label=USBD_DP +PA12.Mode=OTG/Dual_Role_Device +PA12.Signal=USB_OTG_FS_DP +PA13.Mode=Serial_Wire +PA13.Signal=SYS_JTMS-SWDIO +PA14.Mode=Serial_Wire +PA14.Signal=SYS_JTCK-SWCLK +PA3.GPIOParameters=GPIO_Label +PA3.GPIO_Label=EXP +PA3.Signal=ADCx_IN3 +PA6.GPIOParameters=GPIO_Label +PA6.GPIO_Label=FLASH_MISO +PA6.Mode=Full_Duplex_Master +PA6.Signal=SPI1_MISO +PA7.GPIOParameters=GPIO_Label +PA7.GPIO_Label=FLASH_MOSI +PA7.Mode=Full_Duplex_Master +PA7.Signal=SPI1_MOSI +PA9.GPIOParameters=GPIO_Label +PA9.GPIO_Label=USBD_VBUS +PA9.Mode=Activate_VBUS +PA9.Signal=USB_OTG_FS_VBUS +PB1.GPIOParameters=GPIO_Label +PB1.GPIO_Label=EXP_RING +PB1.Locked=true +PB1.Signal=ADCx_IN9 +PB10.GPIOParameters=GPIO_Label +PB10.GPIO_Label=CS_nCS +PB10.Locked=true +PB10.Signal=GPIO_Output +PB11.GPIOParameters=GPIO_Label +PB11.GPIO_Label=CS_nRST +PB11.Locked=true +PB11.Signal=GPIO_Output +PB12.Mode=OTG/Dual-Role-Device-FS +PB12.Signal=USB_OTG_HS_ID +PB13.Mode=Activate_VBUS_FS +PB13.Signal=USB_OTG_HS_VBUS +PB14.Mode=OTG/Dual-Role-Device-FS +PB14.Signal=USB_OTG_HS_DM +PB15.Mode=OTG/Dual-Role-Device-FS +PB15.Signal=USB_OTG_HS_DP +PB2/BOOT1.GPIOParameters=GPIO_Label +PB2/BOOT1.GPIO_Label=EXP_TIP +PB2/BOOT1.Locked=true +PB2/BOOT1.Signal=GPIO_Output +PB3.GPIOParameters=GPIO_Label +PB3.GPIO_Label=FLASH_SCK +PB3.Locked=true +PB3.Mode=Full_Duplex_Master +PB3.Signal=SPI1_SCK +PB5.Mode=SdramChipSelect2_1 +PB5.Signal=FMC_SDCKE1 +PB6.Mode=SdramChipSelect2_1 +PB6.Signal=FMC_SDNE1 +PC0.Signal=FMC_SDNWE +PC1.GPIOParameters=GPIO_Label +PC1.GPIO_Label=ADC3 +PC1.Locked=true +PC1.Signal=ADCx_IN11 PC15/OSC32_OUT.GPIOParameters=GPIO_Label -SH.FMC_D2_DA2.0=FMC_D2,sd-16b-d1 -Mcu.IP13=USB_OTG_FS +PC15/OSC32_OUT.GPIO_Label=EXTSPI_nCS +PC15/OSC32_OUT.Locked=true +PC15/OSC32_OUT.Signal=GPIO_Output +PC2.GPIOParameters=GPIO_Label +PC2.GPIO_Label=ADC2 +PC2.Locked=true +PC2.Signal=ADCx_IN12 +PC3.GPIOParameters=GPIO_Label +PC3.GPIO_Label=ADC1 +PC3.Locked=true +PC3.Signal=ADCx_IN13 +PC4.GPIOParameters=GPIO_Label +PC4.GPIO_Label=FLASH_HOLD +PC4.Locked=true +PC4.Signal=GPIO_Output +PC5.GPIOParameters=GPIO_Label +PC5.GPIO_Label=FLASH_nCS +PC5.Locked=true +PC5.Signal=GPIO_Output +PD0.Signal=FMC_D2_DA2 +PD1.Signal=FMC_D3_DA3 +PD10.Signal=FMC_D15_DA15 +PD14.Signal=FMC_D0_DA0 +PD15.Signal=FMC_D1_DA1 +PD2.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PD2.GPIO_Label=SW1 +PD2.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PD2.GPIO_PuPd=GPIO_PULLUP +PD2.Locked=true +PD2.Signal=GPXTI2 +PD6.GPIOParameters=GPIO_Label +PD6.GPIO_Label=CS_SDIN +PD6.Mode=SAI_A_AsyncSlave +PD6.Signal=SAI1_SD_A +PD8.Signal=FMC_D13_DA13 +PD9.Signal=FMC_D14_DA14 +PE0.Signal=FMC_NBL0 +PE1.Signal=FMC_NBL1 +PE10.Signal=FMC_D7_DA7 +PE11.Signal=FMC_D8_DA8 +PE12.Signal=FMC_D9_DA9 PE13.Signal=FMC_D10_DA10 -PF7.GPIO_Label=EXP2_T -RCC.VCOInputFreq_Value=1000000 -PF8.GPIO_PuPd=GPIO_PULLUP -PF7.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -PA14.Mode=Serial_Wire -PF11.Signal=FMC_SDNRAS -PB5.Mode=SdramChipSelect2_1 -File.Version=6 +PE14.Signal=FMC_D11_DA11 +PE15.Signal=FMC_D12_DA12 +PE2.GPIOParameters=GPIO_Label +PE2.GPIO_Label=CS_SCK +PE2.Mode=TX_Only_Simplex_Unidirect_Master +PE2.Signal=SPI4_SCK PE3.GPIOParameters=GPIO_Label -ADC3.DataAlign=ADC_DATAALIGN_RIGHT -SH.ADCx_IN13.ConfNb=2 -SH.FMC_D5_DA5.ConfNb=1 -PB3.GPIOParameters=GPIO_Label -Dma.ADC3.0.MemInc=DMA_MINC_ENABLE -SH.FMC_D2_DA2.ConfNb=1 -FMC.ReadPipeDelay1=FMC_SDRAM_RPIPE_DELAY_0 +PE3.GPIO_Label=CS_SDOUT +PE3.Mode=SAI_B_SyncSlave +PE3.Signal=SAI1_SD_B +PE4.GPIOParameters=GPIO_Label +PE4.GPIO_Label=CS_LRCK PE4.Mode=SAI_A_AsyncSlave -SH.FMC_SDNRAS.0=FMC_SDNRAS,12b-sda1 -PH1/OSC_OUT.Mode=HSE-External-Oscillator PE4.Signal=SAI1_FS_A +PE5.GPIOParameters=GPIO_Label +PE5.GPIO_Label=CS_SCK +PE5.Mode=SAI_A_AsyncSlave +PE5.Signal=SAI1_SCK_A PE6.GPIOParameters=GPIO_Label -Dma.RequestsNb=3 -SPI4.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128 -FREERTOS.configTOTAL_HEAP_SIZE=8192 +PE6.GPIO_Label=CS_SDA +PE6.Mode=TX_Only_Simplex_Unidirect_Master +PE6.Signal=SPI4_MOSI +PE7.Signal=FMC_D4_DA4 +PE8.Signal=FMC_D5_DA5 +PE9.Signal=FMC_D6_DA6 +PF0.Signal=FMC_A0 +PF1.Signal=FMC_A1 +PF10.GPIOParameters=GPIO_Label +PF10.GPIO_Label=ADC4 +PF10.Locked=true +PF10.Mode=IN8 +PF10.Signal=ADC3_IN8 +PF11.Signal=FMC_SDNRAS +PF12.Signal=FMC_A6 +PF13.Signal=FMC_A7 +PF14.Signal=FMC_A8 +PF15.Signal=FMC_A9 +PF2.Signal=FMC_A2 +PF3.Signal=FMC_A3 +PF4.Signal=FMC_A4 +PF5.Signal=FMC_A5 +PF7.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PF7.GPIO_Label=EXP2_T +PF7.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PF7.GPIO_PuPd=GPIO_PULLUP +PF7.Locked=true +PF7.Signal=GPXTI7 +PF8.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PF8.GPIO_Label=EXP2_R +PF8.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PF8.GPIO_PuPd=GPIO_PULLUP +PF8.Locked=true +PF8.Signal=GPXTI8 +PG0.Signal=FMC_A10 +PG1.Signal=FMC_A11 +PG15.Signal=FMC_SDNCAS +PG4.Signal=FMC_A14_BA0 +PG5.Signal=FMC_A15_BA1 +PG8.Signal=FMC_SDCLK +PG9.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PG9.GPIO_Label=SW2 +PG9.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PG9.GPIO_PuPd=GPIO_PULLUP +PG9.Locked=true +PG9.Signal=GPXTI9 +PH0/OSC_IN.Mode=HSE-External-Oscillator +PH0/OSC_IN.Signal=RCC_OSC_IN +PH1/OSC_OUT.Mode=HSE-External-Oscillator +PH1/OSC_OUT.Signal=RCC_OSC_OUT +PinOutPanel.RotationAngle=0 +ProjectManager.AskForMigrate=true +ProjectManager.BackupPrevious=false +ProjectManager.CompilerOptimize=6 +ProjectManager.ComputerToolchain=false +ProjectManager.CoupleFile=false +ProjectManager.CustomerFirmwarePackage= +ProjectManager.DefaultFWLocation=true +ProjectManager.DeletePrevious=true +ProjectManager.DeviceId=STM32F427ZITx +ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.26.2 +ProjectManager.FreePins=true +ProjectManager.HalAssertFull=true +ProjectManager.HeapSize=0x200 +ProjectManager.KeepUserCode=true +ProjectManager.LastFirmware=true +ProjectManager.LibraryCopy=2 +ProjectManager.MainLocation=Src +ProjectManager.NoMain=false +ProjectManager.PreviousToolchain= +ProjectManager.ProjectBuild=false +ProjectManager.ProjectFileName=OwlPedal2.ioc ProjectManager.ProjectName=OwlPedal2 -USB_DEVICE.PRODUCT_STRING_AUDIO_FS=OWL-PEDAL -PA6.Signal=SPI1_MISO -SH.FMC_D0_DA0.0=FMC_D0,sd-16b-d1 -SAI1.DataSize-SAI_A_AsyncSlave=SAI_DATASIZE_24 -SH.FMC_D4_DA4.ConfNb=1 -NVIC.OTG_FS_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +ProjectManager.RegisterCallBack= +ProjectManager.StackSize=0x400 +ProjectManager.TargetToolchain=Other Toolchains (GPDSC) ProjectManager.ToolChainLocation= +ProjectManager.UnderRoot=false +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-SystemClock_Config-RCC-false-HAL-true,9-MX_RTC_Init-RTC-false-HAL-true,10-MX_ADC1_Init-ADC1-false-HAL-true,11-MX_USB_OTG_FS_USB_Init-USB_OTG_FS-false-HAL-true,12-MX_USB_OTG_HS_USB_Init-USB_OTG_HS-false-HAL-true +RCC.48MHZClocksFreq_Value=48000000 +RCC.AHBFreq_Value=168000000 +RCC.APB1CLKDivider=RCC_HCLK_DIV4 +RCC.APB1Freq_Value=42000000 +RCC.APB1TimFreq_Value=84000000 +RCC.APB2CLKDivider=RCC_HCLK_DIV2 +RCC.APB2Freq_Value=84000000 +RCC.APB2TimFreq_Value=168000000 +RCC.CECFreq_Value=32786.88524590164 +RCC.CortexFreq_Value=168000000 +RCC.EthernetFreq_Value=168000000 +RCC.FCLKCortexFreq_Value=168000000 +RCC.FamilyName=M +RCC.HCLKFreq_Value=168000000 +RCC.HSE_VALUE=25000000 +RCC.HSI_VALUE=16000000 +RCC.I2C1Freq_Value=54000000 +RCC.I2C2Freq_Value=54000000 +RCC.I2C3Freq_Value=54000000 +RCC.I2C4Freq_Value=54000000 +RCC.I2SClocksFreq_Value=96000000 +RCC.I2SFreq_Value=96000000 +RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CECFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SClocksFreq_Value,I2SFreq_Value,LCDTFToutputFreq_Value,LPTIM1Freq_Value,LSE_VALUE,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLI2SPCLKFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLI2SRoutputFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLQoutputFreq_Value,PLLSAIN,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIRCLKFreq_Value,PLLSAIoutputFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SAI1Freq_Value,SAI2Freq_Value,SAI_AClocksFreq_Value,SAI_BClocksFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,UART4Freq_Value,UART5Freq_Value,UART7Freq_Value,UART8Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USART6Freq_Value,USBFreq_Value,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value,VCOSAIOutputFreq_ValueQ,VcooutputI2S,VcooutputI2SQ +RCC.LCDTFToutputFreq_Value=25000000 +RCC.LPTIM1Freq_Value=54000000 +RCC.LSE_VALUE=32768 RCC.LSI_VALUE=32000 -USB_OTG_FS.VirtualMode=Device_Only -SH.FMC_A9.0=FMC_A9,12b-sda1 -PG9.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -PF8.Signal=GPXTI8 -SH.FMC_D4_DA4.0=FMC_D4,sd-16b-d1 -ADC3.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV8 +RCC.MCO2PinFreq_Value=168000000 +RCC.PLLCLKFreq_Value=168000000 +RCC.PLLI2SPCLKFreq_Value=96000000 +RCC.PLLI2SQCLKFreq_Value=96000000 +RCC.PLLI2SRCLKFreq_Value=96000000 +RCC.PLLI2SRoutputFreq_Value=96000000 +RCC.PLLM=25 +RCC.PLLN=336 +RCC.PLLQ=7 +RCC.PLLQCLKFreq_Value=48000000 +RCC.PLLQoutputFreq_Value=48000000 RCC.PLLSAIN=100 -PF5.Signal=FMC_A5 -Dma.Request2=SAI1_B -SAI1.Synchro-SAI_B_SyncSlave=SAI_SYNCHRONOUS -Dma.Request1=SAI1_A -ADC3.Rank-32\#ChannelRegularConversion=2 -PC4.Locked=true -PC5.Signal=GPIO_Output -PF0.Signal=FMC_A0 -PE7.Signal=FMC_D4_DA4 -SH.FMC_NBL0.ConfNb=1 -PD6.Signal=SAI1_SD_A -SAI1.Synchro-SAI_A_AsyncSlave=SAI_ASYNCHRONOUS -Dma.Request0=ADC3 -PA1.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -PC2.GPIO_Label=ADC2 -PE2.GPIO_Label=CS_SCK -PE3.Mode=SAI_B_SyncSlave -PB3.Locked=true -PA3.Signal=ADCx_IN3 -PB3.GPIO_Label=FLASH_SCK -SH.FMC_A3.ConfNb=1 -VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate -ADC3.SamplingTime-31\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -SH.ADCx_IN13.1=ADC1_IN13 -RCC.I2SFreq_Value=96000000 -ADC3.DiscontinuousConvMode=DISABLE -SH.ADCx_IN13.0=ADC3_IN13,IN13 -SAI1.Synchro_A=SAI_ASYNCHRONOUS -SH.FMC_A9.ConfNb=1 -SAI1.Synchro_B=SAI_SYNCHRONOUS -PA7.Mode=Full_Duplex_Master +RCC.PLLSAIPCLKFreq_Value=50000000 +RCC.PLLSAIQCLKFreq_Value=50000000 +RCC.PLLSAIRCLKFreq_Value=50000000 +RCC.PLLSAIoutputFreq_Value=50000000 +RCC.RTCFreq_Value=32000 +RCC.RTCHSEDivFreq_Value=12500000 +RCC.SAI1Freq_Value=50000000 +RCC.SAI2Freq_Value=50000000 +RCC.SAI_AClocksFreq_Value=25000000 +RCC.SAI_BClocksFreq_Value=25000000 +RCC.SDMMCFreq_Value=216000000 +RCC.SPDIFRXFreq_Value=96000000 +RCC.SYSCLKFreq_VALUE=168000000 +RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK +RCC.UART4Freq_Value=54000000 +RCC.UART5Freq_Value=54000000 RCC.UART7Freq_Value=54000000 -ProjectManager.NoMain=false -SPI1.IPParameters=Mode,CalculateBaudRate,VirtualType,Direction -USB_DEVICE.VirtualModeFS=Audio_FS -PG1.Signal=FMC_A11 -NVIC.SavedSvcallIrqHandlerGenerated=true -SH.FMC_SDCLK.ConfNb=1 -PC4.Signal=GPIO_Output -ProjectManager.DefaultFWLocation=true -PD9.Signal=FMC_D14_DA14 -ProjectManager.DeletePrevious=true -USB_DEVICE.USBD_MAX_NUM_INTERFACES-AUDIO_FS=5 -PB10.Locked=true -RCC.LCDTFToutputFreq_Value=25000000 -USB_DEVICE.IPParameters=VirtualMode-AUDIO_FS,VirtualModeFS,CLASS_NAME_FS,PID_AUDIO_FS,MANUFACTURER_STRING-AUDIO_FS,VID-AUDIO_FS,PRODUCT_STRING_AUDIO_FS,USBD_MAX_NUM_INTERFACES-AUDIO_FS,USBD_MAX_NUM_CONFIGURATION-AUDIO_FS,USBD_AUDIO_FREQ-AUDIO_FS -PA12.GPIO_Label=USBD_DP -RCC.FamilyName=M -PA13.Signal=SYS_JTMS-SWDIO -VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 -SH.ADCx_IN12.1=ADC1_IN12 -SH.ADCx_IN12.0=ADC3_IN12,IN12 -PA9.Mode=Activate_VBUS -SH.FMC_A15_BA1.ConfNb=1 -PB2/BOOT1.Signal=GPIO_Output -ADC3.SamplingTime-34\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -ProjectManager.TargetToolchain=Other Toolchains (GPDSC) -PB10.GPIO_Label=CS_nCS -SH.FMC_D13_DA13.0=FMC_D13,sd-16b-d1 -SH.FMC_D1_DA1.ConfNb=1 -PC5.GPIOParameters=GPIO_Label -RCC.VcooutputI2SQ=96000000 -PF2.Signal=FMC_A2 -PE2.GPIOParameters=GPIO_Label -PC2.Locked=true -ProjectManager.RegisterCallBack= +RCC.UART8Freq_Value=54000000 +RCC.USART1Freq_Value=108000000 +RCC.USART2Freq_Value=54000000 +RCC.USART3Freq_Value=54000000 +RCC.USART6Freq_Value=108000000 RCC.USBFreq_Value=48000000 -NVIC.DMA2_Stream3_IRQn=true\:5\:0\:false\:false\:true\:false\:false\:true -RCC.PLLSAIoutputFreq_Value=50000000 -PE11.Signal=FMC_D8_DA8 -RCC.LSE_VALUE=32768 -PA1.Signal=GPXTI1 -PB1.Locked=true +RCC.VCOI2SOutputFreq_Value=192000000 +RCC.VCOInputFreq_Value=1000000 +RCC.VCOOutputFreq_Value=336000000 +RCC.VCOSAIOutputFreq_Value=100000000 +RCC.VCOSAIOutputFreq_ValueQ=25000000 +RCC.VcooutputI2S=96000000 +RCC.VcooutputI2SQ=96000000 +SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_RX +SAI1.DataSize-SAI_A_AsyncSlave=SAI_DATASIZE_24 SAI1.FSDefinition-SAI_A_AsyncSlave=SAI_FS_CHANNEL_IDENTIFICATION -RCC.VCOI2SOutputFreq_Value=192000000 -PG9.GPIO_Label=SW2 -RCC.PLLSAIPCLKFreq_Value=50000000 -board=Alchemist +SAI1.FSDefinition-SAI_B_SyncSlave=SAI_FS_CHANNEL_IDENTIFICATION +SAI1.FrameLength-SAI_A_AsyncSlave=64 +SAI1.FrameLength-SAI_B_SyncSlave=64 SAI1.IPParameters=Instance-SAI_A_AsyncSlave,VirtualMode-SAI_A_AsyncSlave,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,Synchro-SAI_B_SyncSlave,FrameLength-SAI_B_SyncSlave,SlotSize-SAI_B_SyncSlave,AudioMode-SAI_B_SyncSlave,AudioMode-SAI_A_AsyncSlave,DataSize-SAI_A_AsyncSlave,FrameLength-SAI_A_AsyncSlave,SlotSize-SAI_A_AsyncSlave,SlotNumber-SAI_A_AsyncSlave,FSDefinition-SAI_A_AsyncSlave,FSDefinition-SAI_B_SyncSlave,Synchro-SAI_A_AsyncSlave,Synchro_A,Synchro_B -RCC.VCOOutputFreq_Value=336000000 -PH0/OSC_IN.Signal=RCC_OSC_IN -NVIC.SavedSystickIrqHandlerGenerated=true -RCC.APB2Freq_Value=84000000 -RCC.UART4Freq_Value=54000000 -SH.ADCx_IN11.1=ADC1_IN11 +SAI1.Instance-SAI_A_AsyncSlave=SAI$Index_Block_A +SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B +SAI1.SlotNumber-SAI_A_AsyncSlave=2 +SAI1.SlotSize-SAI_A_AsyncSlave=SAI_SLOTSIZE_32B +SAI1.SlotSize-SAI_B_SyncSlave=SAI_SLOTSIZE_32B +SAI1.Synchro-SAI_A_AsyncSlave=SAI_ASYNCHRONOUS +SAI1.Synchro-SAI_B_SyncSlave=SAI_SYNCHRONOUS +SAI1.Synchro_A=SAI_ASYNCHRONOUS +SAI1.Synchro_B=SAI_SYNCHRONOUS +SAI1.VirtualMode-SAI_A_AsyncSlave=VM_SLAVE +SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE SH.ADCx_IN11.0=ADC3_IN11,IN11 -MxCube.Version=6.2.1 -SH.FMC_D13_DA13.ConfNb=1 -PF10.Signal=ADC3_IN8 -PE5.Mode=SAI_A_AsyncSlave -PC1.GPIO_Label=ADC3 -VP_SYS_VS_Systick.Mode=SysTick -SH.FMC_D12_DA12.0=FMC_D12,sd-16b-d1 -PF15.Signal=FMC_A9 -SPI4.CalculateBaudRate=656.25 KBits/s -Dma.SAI1_B.2.Priority=DMA_PRIORITY_VERY_HIGH -PF1.Signal=FMC_A1 -VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_FS -VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Mode=AUDIO_FS -PE6.Signal=SPI4_MOSI +SH.ADCx_IN11.1=ADC1_IN11 +SH.ADCx_IN11.ConfNb=2 +SH.ADCx_IN12.0=ADC3_IN12,IN12 +SH.ADCx_IN12.1=ADC1_IN12 +SH.ADCx_IN12.ConfNb=2 +SH.ADCx_IN13.0=ADC3_IN13,IN13 +SH.ADCx_IN13.1=ADC1_IN13 +SH.ADCx_IN13.ConfNb=2 +SH.ADCx_IN3.0=ADC3_IN3,IN3 +SH.ADCx_IN3.ConfNb=1 +SH.ADCx_IN9.0=ADC1_IN9,IN9 +SH.ADCx_IN9.ConfNb=1 +SH.FMC_A0.0=FMC_A0,12b-sda1 +SH.FMC_A0.ConfNb=1 +SH.FMC_A1.0=FMC_A1,12b-sda1 +SH.FMC_A1.ConfNb=1 +SH.FMC_A10.0=FMC_A10,12b-sda1 +SH.FMC_A10.ConfNb=1 +SH.FMC_A11.0=FMC_A11,12b-sda1 +SH.FMC_A11.ConfNb=1 +SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 +SH.FMC_A14_BA0.ConfNb=1 +SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 +SH.FMC_A15_BA1.ConfNb=1 +SH.FMC_A2.0=FMC_A2,12b-sda1 +SH.FMC_A2.ConfNb=1 +SH.FMC_A3.0=FMC_A3,12b-sda1 +SH.FMC_A3.ConfNb=1 +SH.FMC_A4.0=FMC_A4,12b-sda1 +SH.FMC_A4.ConfNb=1 +SH.FMC_A5.0=FMC_A5,12b-sda1 +SH.FMC_A5.ConfNb=1 +SH.FMC_A6.0=FMC_A6,12b-sda1 +SH.FMC_A6.ConfNb=1 +SH.FMC_A7.0=FMC_A7,12b-sda1 +SH.FMC_A7.ConfNb=1 +SH.FMC_A8.0=FMC_A8,12b-sda1 +SH.FMC_A8.ConfNb=1 +SH.FMC_A9.0=FMC_A9,12b-sda1 +SH.FMC_A9.ConfNb=1 +SH.FMC_D0_DA0.0=FMC_D0,sd-16b-d1 +SH.FMC_D0_DA0.ConfNb=1 +SH.FMC_D10_DA10.0=FMC_D10,sd-16b-d1 +SH.FMC_D10_DA10.ConfNb=1 +SH.FMC_D11_DA11.0=FMC_D11,sd-16b-d1 SH.FMC_D11_DA11.ConfNb=1 -RCC.UART5Freq_Value=54000000 -ADC1.NbrOfConversion=1 -ADC3.Channel-34\#ChannelRegularConversion=ADC_CHANNEL_8 -RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CECFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SClocksFreq_Value,I2SFreq_Value,LCDTFToutputFreq_Value,LPTIM1Freq_Value,LSE_VALUE,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLI2SPCLKFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLI2SRoutputFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLQoutputFreq_Value,PLLSAIN,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIRCLKFreq_Value,PLLSAIoutputFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SAI1Freq_Value,SAI2Freq_Value,SAI_AClocksFreq_Value,SAI_BClocksFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,UART4Freq_Value,UART5Freq_Value,UART7Freq_Value,UART8Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USART6Freq_Value,USBFreq_Value,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value,VCOSAIOutputFreq_ValueQ,VcooutputI2S,VcooutputI2SQ -ProjectManager.AskForMigrate=true -Mcu.Name=STM32F427Z(G-I)Tx -PE0.Signal=FMC_NBL0 -Dma.SAI1_B.2.Direction=DMA_PERIPH_TO_MEMORY -PE12.Signal=FMC_D9_DA9 -NVIC.SavedPendsvIrqHandlerGenerated=true -PF8.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -Mcu.IP8=SAI1 -Mcu.IP9=SPI1 -PD14.Signal=FMC_D0_DA0 -Mcu.IP6=RCC -Mcu.IP7=RTC -ProjectManager.CoupleFile=false -RCC.48MHZClocksFreq_Value=48000000 -PB3.Signal=SPI1_SCK -RCC.SYSCLKFreq_VALUE=168000000 -PA7.GPIO_Label=FLASH_MOSI -PA1.Locked=true -PA12.Mode=Device_Only -KeepUserPlacement=false -PC5.GPIO_Label=FLASH_nCS -SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B -SH.GPXTI9.ConfNb=1 -NVIC.EXTI9_5_IRQn=true\:15\:0\:true\:false\:true\:false\:true\:true -PA14.Signal=SYS_JTCK-SWCLK -ADC3.Rank-35\#ChannelRegularConversion=5 -RCC.HSI_VALUE=16000000 -Dma.ADC3.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -RCC.PLLQ=7 -ADC1.NbrOfConversionFlag=1 -RCC.PLLM=25 -RCC.PLLN=336 -PB2/BOOT1.Locked=true -Dma.SAI1_A.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD -PE3.GPIO_Label=CS_SDOUT +SH.FMC_D12_DA12.0=FMC_D12,sd-16b-d1 +SH.FMC_D12_DA12.ConfNb=1 +SH.FMC_D13_DA13.0=FMC_D13,sd-16b-d1 +SH.FMC_D13_DA13.ConfNb=1 +SH.FMC_D14_DA14.0=FMC_D14,sd-16b-d1 +SH.FMC_D14_DA14.ConfNb=1 +SH.FMC_D15_DA15.0=FMC_D15,sd-16b-d1 +SH.FMC_D15_DA15.ConfNb=1 +SH.FMC_D1_DA1.0=FMC_D1,sd-16b-d1 +SH.FMC_D1_DA1.ConfNb=1 +SH.FMC_D2_DA2.0=FMC_D2,sd-16b-d1 +SH.FMC_D2_DA2.ConfNb=1 +SH.FMC_D3_DA3.0=FMC_D3,sd-16b-d1 +SH.FMC_D3_DA3.ConfNb=1 +SH.FMC_D4_DA4.0=FMC_D4,sd-16b-d1 +SH.FMC_D4_DA4.ConfNb=1 +SH.FMC_D5_DA5.0=FMC_D5,sd-16b-d1 +SH.FMC_D5_DA5.ConfNb=1 +SH.FMC_D6_DA6.0=FMC_D6,sd-16b-d1 +SH.FMC_D6_DA6.ConfNb=1 +SH.FMC_D7_DA7.0=FMC_D7,sd-16b-d1 +SH.FMC_D7_DA7.ConfNb=1 +SH.FMC_D8_DA8.0=FMC_D8,sd-16b-d1 SH.FMC_D8_DA8.ConfNb=1 -RCC.APB1Freq_Value=42000000 -ADC3.NbrOfConversionFlag=1 -ADC1.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV8 -PB11.Locked=true -ProjectManager.DeviceId=STM32F427ZITx -ProjectManager.LibraryCopy=2 -PA3.GPIO_Label=EXP -ADC3.Rank-31\#ChannelRegularConversion=1 -PB1.GPIOParameters=GPIO_Label -PA7.Signal=SPI1_MOSI +SH.FMC_D9_DA9.0=FMC_D9,sd-16b-d1 +SH.FMC_D9_DA9.ConfNb=1 +SH.FMC_NBL0.0=FMC_NBL0,Sd2ByteEnable1 +SH.FMC_NBL0.ConfNb=1 +SH.FMC_NBL1.0=FMC_NBL1,Sd2ByteEnable1 +SH.FMC_NBL1.ConfNb=1 +SH.FMC_SDCLK.0=FMC_SDCLK,12b-sda1 +SH.FMC_SDCLK.ConfNb=1 +SH.FMC_SDNCAS.0=FMC_SDNCAS,12b-sda1 +SH.FMC_SDNCAS.ConfNb=1 +SH.FMC_SDNRAS.0=FMC_SDNRAS,12b-sda1 +SH.FMC_SDNRAS.ConfNb=1 +SH.FMC_SDNWE.0=FMC_SDNWE,12b-sda1 +SH.FMC_SDNWE.ConfNb=1 +SH.GPXTI1.0=GPIO_EXTI1 +SH.GPXTI1.ConfNb=1 +SH.GPXTI2.0=GPIO_EXTI2 +SH.GPXTI2.ConfNb=1 +SH.GPXTI7.0=GPIO_EXTI7 +SH.GPXTI7.ConfNb=1 +SH.GPXTI8.0=GPIO_EXTI8 +SH.GPXTI8.ConfNb=1 +SH.GPXTI9.0=GPIO_EXTI9 +SH.GPXTI9.ConfNb=1 +SPI1.CalculateBaudRate=42.0 MBits/s +SPI1.Direction=SPI_DIRECTION_2LINES +SPI1.IPParameters=Mode,CalculateBaudRate,VirtualType,Direction +SPI1.Mode=SPI_MODE_MASTER +SPI1.VirtualType=VM_MASTER +SPI4.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128 +SPI4.CalculateBaudRate=656.25 KBits/s +SPI4.Direction=SPI_DIRECTION_2LINES +SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,VirtualType,Direction +SPI4.Mode=SPI_MODE_MASTER +SPI4.VirtualType=VM_MASTER +VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 +VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 +VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled +VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate +VP_SYS_VS_Systick.Mode=SysTick +VP_SYS_VS_Systick.Signal=SYS_VS_Systick +board=Alchemist diff --git a/OwlPedal2/Src/OwlPedal.cpp b/OwlPedal2/Src/OwlPedal.cpp index 98e93c3d..301f9b9b 100644 --- a/OwlPedal2/Src/OwlPedal.cpp +++ b/OwlPedal2/Src/OwlPedal.cpp @@ -4,6 +4,7 @@ #include "MidiController.h" #include "OpenWareMidiControl.h" #include "Pin.h" +#include "usb_device.h" #define PATCH_RESET_COUNTER (1000/MAIN_LOOP_SLEEP_MS) @@ -104,6 +105,9 @@ void setup(){ setLed(0, RED_COLOUR); owl.setup(); setLed(0, GREEN_COLOUR); + + MX_USB_DEVICE_Init(); + } void loop(){ diff --git a/OwlPedal2/Src/main.c b/OwlPedal2/Src/main.c index a3918334..ded4e27a 100644 --- a/OwlPedal2/Src/main.c +++ b/OwlPedal2/Src/main.c @@ -50,7 +50,6 @@ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "cmsis_os.h" -#include "usb_device.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ @@ -97,6 +96,7 @@ osThreadId defaultTaskHandle; /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); +void PeriphCommonClock_Config(void); static void MX_GPIO_Init(void); static void MX_DMA_Init(void); static void MX_ADC3_Init(void); @@ -106,6 +106,8 @@ static void MX_SPI1_Init(void); static void MX_SPI4_Init(void); static void MX_RTC_Init(void); static void MX_ADC1_Init(void); +static void MX_USB_OTG_FS_USB_Init(void); +static void MX_USB_OTG_HS_USB_Init(void); void StartDefaultTask(void const * argument); /* USER CODE BEGIN PFP */ @@ -150,6 +152,9 @@ int main(void) /* Configure the system clock */ SystemClock_Config(); +/* Configure the peripherals common clocks */ + PeriphCommonClock_Config(); + /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ @@ -164,6 +169,8 @@ int main(void) MX_SPI4_Init(); MX_RTC_Init(); MX_ADC1_Init(); + MX_USB_OTG_FS_USB_Init(); + MX_USB_OTG_HS_USB_Init(); /* USER CODE BEGIN 2 */ HAL_SAI_DeInit(&hsai_BlockA1); @@ -244,7 +251,6 @@ void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; - RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; /** Macro to configure SAI1BlockB clock source selection */ @@ -285,11 +291,22 @@ void SystemClock_Config(void) { Error_Handler(); } - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SAI_PLLSAI|RCC_PERIPHCLK_RTC; +} + +/** + * @brief Peripherals Common Clock Configuration + * @retval None + */ +void PeriphCommonClock_Config(void) +{ + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SAI_PLLSAI; PeriphClkInitStruct.PLLSAI.PLLSAIN = 100; PeriphClkInitStruct.PLLSAI.PLLSAIQ = 4; PeriphClkInitStruct.PLLSAIDivQ = 1; - PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) { Error_Handler(); @@ -603,6 +620,48 @@ static void MX_SPI4_Init(void) } +/** + * @brief USB_OTG_FS Initialization Function + * @param None + * @retval None + */ +static void MX_USB_OTG_FS_USB_Init(void) +{ + + /* USER CODE BEGIN USB_OTG_FS_Init 0 */ + + /* USER CODE END USB_OTG_FS_Init 0 */ + + /* USER CODE BEGIN USB_OTG_FS_Init 1 */ + + /* USER CODE END USB_OTG_FS_Init 1 */ + /* USER CODE BEGIN USB_OTG_FS_Init 2 */ + + /* USER CODE END USB_OTG_FS_Init 2 */ + +} + +/** + * @brief USB_OTG_HS Initialization Function + * @param None + * @retval None + */ +static void MX_USB_OTG_HS_USB_Init(void) +{ + + /* USER CODE BEGIN USB_OTG_HS_Init 0 */ + + /* USER CODE END USB_OTG_HS_Init 0 */ + + /* USER CODE BEGIN USB_OTG_HS_Init 1 */ + + /* USER CODE END USB_OTG_HS_Init 1 */ + /* USER CODE BEGIN USB_OTG_HS_Init 2 */ + + /* USER CODE END USB_OTG_HS_Init 2 */ + +} + /** * Enable DMA controller clock */ @@ -727,9 +786,9 @@ static void MX_GPIO_Init(void) HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); /*Configure GPIO pins : PA0 PA2 PA4 PA5 - PA8 PA10 PA15 */ + PA8 PA15 */ GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_4|GPIO_PIN_5 - |GPIO_PIN_8|GPIO_PIN_10|GPIO_PIN_15; + |GPIO_PIN_8|GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); @@ -740,11 +799,9 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(FOOTSWITCH_GPIO_Port, &GPIO_InitStruct); - /*Configure GPIO pins : PB0 PB12 PB13 PB14 - PB15 PB4 PB7 PB8 + /*Configure GPIO pins : PB0 PB4 PB7 PB8 PB9 */ - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 - |GPIO_PIN_15|GPIO_PIN_4|GPIO_PIN_7|GPIO_PIN_8 + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_4|GPIO_PIN_7|GPIO_PIN_8 |GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; @@ -757,6 +814,20 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + /*Configure GPIO pins : PB12 PB14 PB15 */ + GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_14|GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_OTG_HS_FS; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /*Configure GPIO pin : PB13 */ + GPIO_InitStruct.Pin = GPIO_PIN_13; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + /*Configure GPIO pins : PD11 PD12 PD13 PD3 PD4 PD5 PD7 */ GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_3 @@ -775,6 +846,20 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + /*Configure GPIO pin : USBD_VBUS_Pin */ + GPIO_InitStruct.Pin = USBD_VBUS_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(USBD_VBUS_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pins : PA10 USBD_DM_Pin USBD_DP_Pin */ + GPIO_InitStruct.Pin = GPIO_PIN_10|USBD_DM_Pin|USBD_DP_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + /*Configure GPIO pin : SW1_Pin */ GPIO_InitStruct.Pin = SW1_Pin; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; @@ -812,8 +897,6 @@ static void MX_GPIO_Init(void) /* USER CODE END Header_StartDefaultTask */ void StartDefaultTask(void const * argument) { - /* init code for USB_DEVICE */ - MX_USB_DEVICE_Init(); /* USER CODE BEGIN 5 */ setup(); diff --git a/OwlPedal2/Src/stm32f4xx_hal_msp.c b/OwlPedal2/Src/stm32f4xx_hal_msp.c index 2e97b31d..00f5a5aa 100644 --- a/OwlPedal2/Src/stm32f4xx_hal_msp.c +++ b/OwlPedal2/Src/stm32f4xx_hal_msp.c @@ -301,11 +301,21 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) */ void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc) { + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; if(hrtc->Instance==RTC) { /* USER CODE BEGIN RTC_MspInit 0 */ /* USER CODE END RTC_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC; + PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + /* Peripheral clock enable */ __HAL_RCC_RTC_ENABLE(); /* USER CODE BEGIN RTC_MspInit 1 */ @@ -703,7 +713,7 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; HAL_GPIO_Init(CS_SDIN_GPIO_Port, &GPIO_InitStruct); - /* Peripheral DMA init*/ + /* Peripheral DMA init*/ hdma_sai1_a.Instance = DMA2_Stream3; hdma_sai1_a.Init.Channel = DMA_CHANNEL_0; @@ -750,7 +760,7 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; HAL_GPIO_Init(CS_SDOUT_GPIO_Port, &GPIO_InitStruct); - /* Peripheral DMA init*/ + /* Peripheral DMA init*/ hdma_sai1_b.Instance = DMA2_Stream4; hdma_sai1_b.Init.Channel = DMA_CHANNEL_1; @@ -784,6 +794,7 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) { /* Peripheral clock disable */ __HAL_RCC_SAI1_CLK_DISABLE(); + /* SAI1 interrupt DeInit */ HAL_NVIC_DisableIRQ(SAI1_IRQn); } @@ -796,6 +807,7 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) HAL_GPIO_DeInit(CS_SDIN_GPIO_Port, CS_SDIN_Pin); + /* SAI1 DMA Deinit */ HAL_DMA_DeInit(hsai->hdmarx); HAL_DMA_DeInit(hsai->hdmatx); } @@ -806,6 +818,7 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) { /* Peripheral clock disable */ __HAL_RCC_SAI1_CLK_DISABLE(); + /* SAI1 interrupt DeInit */ HAL_NVIC_DisableIRQ(SAI1_IRQn); } @@ -814,6 +827,7 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) */ HAL_GPIO_DeInit(CS_SDOUT_GPIO_Port, CS_SDOUT_Pin); + /* SAI1 DMA Deinit */ HAL_DMA_DeInit(hsai->hdmarx); HAL_DMA_DeInit(hsai->hdmatx); } diff --git a/OwlPedal2/Src/stm32f4xx_it.c b/OwlPedal2/Src/stm32f4xx_it.c index 97fc86ec..62c166c1 100644 --- a/OwlPedal2/Src/stm32f4xx_it.c +++ b/OwlPedal2/Src/stm32f4xx_it.c @@ -40,6 +40,7 @@ #include "task.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ +#include "device.h" /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -73,7 +74,6 @@ /* USER CODE END 0 */ /* External variables --------------------------------------------------------*/ -extern PCD_HandleTypeDef hpcd_USB_OTG_FS; extern DMA_HandleTypeDef hdma_adc3; extern ADC_HandleTypeDef hadc1; extern ADC_HandleTypeDef hadc3; @@ -218,19 +218,37 @@ void DMA2_Stream4_IRQHandler(void) /* USER CODE END DMA2_Stream4_IRQn 1 */ } +#ifdef USE_USBD_FS /** * @brief This function handles USB On The Go FS global interrupt. */ void OTG_FS_IRQHandler(void) { /* USER CODE BEGIN OTG_FS_IRQn 0 */ - + extern PCD_HandleTypeDef hpcd_USB_OTG_FS; /* USER CODE END OTG_FS_IRQn 0 */ HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS); /* USER CODE BEGIN OTG_FS_IRQn 1 */ /* USER CODE END OTG_FS_IRQn 1 */ } +#endif + +#ifdef USE_USBD_HS +/** + * @brief This function handles USB On The Go HS global interrupt. + */ +void OTG_HS_IRQHandler(void) +{ + /* USER CODE BEGIN OTG_HS_IRQn 0 */ + extern PCD_HandleTypeDef hpcd_USB_OTG_HS; + /* USER CODE END OTG_HS_IRQn 0 */ + HAL_PCD_IRQHandler(&hpcd_USB_OTG_HS); + /* USER CODE BEGIN OTG_HS_IRQn 1 */ + + /* USER CODE END OTG_HS_IRQn 1 */ +} +#endif /** * @brief This function handles SAI1 global interrupt. diff --git a/OwlPedal2/Src/usb_device.c b/OwlPedal2/Src/usb_device.c index 95ded99c..723305ee 100644 --- a/OwlPedal2/Src/usb_device.c +++ b/OwlPedal2/Src/usb_device.c @@ -27,6 +27,8 @@ #include "usbd_audio.h" /* USER CODE BEGIN Includes */ +#include "device.h" + /* USER CODE END Includes */ /* USER CODE BEGIN PV */ @@ -40,7 +42,7 @@ /* USER CODE END PFP */ /* USB Device Core handle declaration. */ -USBD_HandleTypeDef hUsbDeviceFS; +USBD_HandleTypeDef USBD_HANDLE; /* * -- Insert your variables declaration here -- @@ -67,19 +69,19 @@ void MX_USB_DEVICE_Init(void) /* USER CODE END USB_DEVICE_Init_PreTreatment */ /* Init Device Library, add supported class and start the library. */ - if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK) + if (USBD_Init(&USBD_HANDLE, &USBD_DESC, USBD_HSFS) != USBD_OK) { Error_Handler(); } - if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_AUDIO) != USBD_OK) + if (USBD_RegisterClass(&USBD_HANDLE, &USBD_AUDIO) != USBD_OK) { Error_Handler(); } - if (USBD_AUDIO_RegisterInterface(&hUsbDeviceFS, NULL) != USBD_OK) + if (USBD_AUDIO_RegisterInterface(&USBD_HANDLE, NULL) != USBD_OK) { Error_Handler(); } - if (USBD_Start(&hUsbDeviceFS) != USBD_OK) + if (USBD_Start(&USBD_HANDLE) != USBD_OK) { Error_Handler(); } diff --git a/OwlPedal2/Src/usbd_conf.c b/OwlPedal2/Src/usbd_conf.c index 15eb9fd3..6d1a8bdf 100644 --- a/OwlPedal2/Src/usbd_conf.c +++ b/OwlPedal2/Src/usbd_conf.c @@ -39,7 +39,7 @@ uint8_t USBD_AUDIO_SetFiFos(PCD_HandleTypeDef *hpcd); /* USER CODE END PV */ -PCD_HandleTypeDef hpcd_USB_OTG_FS; +PCD_HandleTypeDef USBD_HANDLE; void Error_Handler(void); /* External functions --------------------------------------------------------*/ @@ -100,6 +100,34 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0); HAL_NVIC_EnableIRQ(OTG_FS_IRQn); /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */ + } + if(pcdHandle->Instance==USB_OTG_HS) + { + + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**USB_OTG_HS GPIO Configuration + PB13 ------> USB_OTG_HS_VBUS + PB14 ------> USB_OTG_HS_DM + PB15 ------> USB_OTG_HS_DP + */ + GPIO_InitStruct.Pin = GPIO_PIN_13; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_OTG_HS_FS; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* Peripheral clock enable */ + __HAL_RCC_USB_OTG_HS_CLK_ENABLE(); + + /* Peripheral interrupt init */ + HAL_NVIC_SetPriority(OTG_HS_IRQn, 8, 0); + HAL_NVIC_EnableIRQ(OTG_HS_IRQn); /* USER CODE END USB_OTG_FS_MspInit 1 */ } @@ -127,6 +155,21 @@ void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) HAL_NVIC_DisableIRQ(OTG_FS_IRQn); /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */ + } + if(pcdHandle->Instance==USB_OTG_HS) + { + /* Peripheral clock disable */ + __HAL_RCC_USB_OTG_HS_CLK_DISABLE(); + + /**USB_OTG_HS GPIO Configuration + PB13 ------> USB_OTG_HS_VBUS + PB14 ------> USB_OTG_HS_DM + PB15 ------> USB_OTG_HS_DP + */ + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15); + + /* Peripheral interrupt Deinit*/ + HAL_NVIC_DisableIRQ(OTG_HS_IRQn); /* USER CODE END USB_OTG_FS_MspDeInit 1 */ } From 3da8f5405be8f8d0ae6b12cb08e0b1d53731ac0a Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 3 Nov 2021 16:55:53 +0100 Subject: [PATCH 157/286] updated to new graphics format --- Xibeca/Core/Inc/XibecaParameterController.hpp | 39 ++++++++++++------- Xibeca/Core/Src/Xibeca.cpp | 4 +- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/Xibeca/Core/Inc/XibecaParameterController.hpp b/Xibeca/Core/Inc/XibecaParameterController.hpp index 6e09912a..7b87b44b 100644 --- a/Xibeca/Core/Inc/XibecaParameterController.hpp +++ b/Xibeca/Core/Inc/XibecaParameterController.hpp @@ -1,5 +1,5 @@ -#ifndef __ParameterController_hpp__ -#define __ParameterController_hpp__ +#ifndef __XibecaParameterController_hpp__ +#define __XibecaParameterController_hpp__ #include #include @@ -9,6 +9,7 @@ #include "VersionToken.h" #include "ScreenBuffer.h" #include "Owl.h" +#include "ParameterController.hpp" #ifdef USE_DIGITALBUS #include "DigitalBusReader.h" extern DigitalBusReader bus; @@ -26,18 +27,20 @@ extern DigitalBusReader bus; extern VersionToken* bootloader_token; +#define NOF_ENCODERS 4 + void defaultDrawCallback(uint8_t* pixels, uint16_t width, uint16_t height); /* shows a single parameter selected and controlled with a single encoder */ -template -class ParameterController { +class XibecaParameterController : public ParameterController { public: char title[11] = "Xibeca"; - int16_t parameters[SIZE]; - char names[SIZE][12]; + int16_t encoders[NOF_ENCODERS]; // last seen encoder values + int16_t parameters[NOF_PARAMETERS]; + char names[NOF_PARAMETERS][12]; int8_t selected = 0; - ParameterController(){ + XibecaParameterController(){ reset(); } void setTitle(const char* str){ @@ -45,7 +48,7 @@ class ParameterController { } void reset(){ drawCallback = defaultDrawCallback; - for(int i=0; i 1) - selected = min(SIZE-1, selected+1); + selected = min(NOF_PARAMETERS-1, selected+1); else if(delta < 1) selected = max(0, selected-1); }else{ @@ -148,11 +161,11 @@ class ParameterController { } // todo: change patch with enc1/sw1 } void setName(uint8_t pid, const char* name){ - if(pid < SIZE) + if(pid < NOF_PARAMETERS) strncpy(names[pid], name, 11); } uint8_t getSize(){ - return SIZE; + return NOF_PARAMETERS; } void setValue(uint8_t ch, int16_t value){ parameters[ch] = value; @@ -195,4 +208,4 @@ class ParameterController { } }; -#endif // __ParameterController_hpp__ +#endif // __XibecaParameterController_hpp__ diff --git a/Xibeca/Core/Src/Xibeca.cpp b/Xibeca/Core/Src/Xibeca.cpp index 0d55ecdd..826b53ec 100644 --- a/Xibeca/Core/Src/Xibeca.cpp +++ b/Xibeca/Core/Src/Xibeca.cpp @@ -4,6 +4,7 @@ #include "Pin.h" #include "ApplicationSettings.h" #include "OpenWareMidiControl.h" +#include "XibecaParameterController.hpp" #include "message.h" #if 0 @@ -52,6 +53,7 @@ #include "Graphics.h" Graphics graphics; #endif +static XibecaParameterController params; #define ENCODER_TIM1 htim4 extern TIM_HandleTypeDef ENCODER_TIM1; @@ -297,7 +299,7 @@ void setup(){ #ifdef USE_SCREEN HAL_GPIO_WritePin(OLED_RST_GPIO_Port, OLED_RST_Pin, GPIO_PIN_RESET); // OLED off extern SPI_HandleTypeDef OLED_SPI; - graphics.begin(&OLED_SPI); + graphics.begin(¶ms, &OLED_SPI); #endif owl.setup(); From 73c082e0b24ba1f5dc6553a05b9af9ec9e8d79cd Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 3 Nov 2021 17:34:43 +0100 Subject: [PATCH 158/286] usbd hs/fs configuration --- OwlPedal2/Inc/hardware.h | 2 + OwlPedal2/Inc/stm32f4xx_hal_conf.h | 2 +- OwlPedal2/Inc/stm32f4xx_it.h | 1 - OwlPedal2/Inc/usbd_conf.h | 31 ++-- OwlPedal2/OwlPedal2.ioc | 97 ++++++----- OwlPedal2/Src/OwlPedal.cpp | 3 - OwlPedal2/Src/main.c | 88 ++++------ OwlPedal2/Src/stm32f4xx_it.c | 19 +-- OwlPedal2/Src/usbd_conf.c | 256 ++++++++++++++++++----------- OwlPedal2/Src/usbd_desc.c | 112 +++++++------ 10 files changed, 318 insertions(+), 293 deletions(-) diff --git a/OwlPedal2/Inc/hardware.h b/OwlPedal2/Inc/hardware.h index 4dcd8abe..7b92eabd 100644 --- a/OwlPedal2/Inc/hardware.h +++ b/OwlPedal2/Inc/hardware.h @@ -11,11 +11,13 @@ /* #define USBD_DESC FS_Desc */ /* #define USBD_HSFS DEVICE_FS */ /* #define USBD_HANDLE hUsbDeviceFS */ +/* #define USBD_PCD_HANDLE hpcd_USB_OTG_FS */ #define USE_USBD_HS #define USBD_DESC HS_Desc #define USBD_HSFS DEVICE_HS #define USBD_HANDLE hUsbDeviceHS +#define USBD_PCD_HANDLE hpcd_USB_OTG_HS #define USE_USBD_AUDIO #define USE_USBD_RX_FB diff --git a/OwlPedal2/Inc/stm32f4xx_hal_conf.h b/OwlPedal2/Inc/stm32f4xx_hal_conf.h index 90a5d561..396890ad 100644 --- a/OwlPedal2/Inc/stm32f4xx_hal_conf.h +++ b/OwlPedal2/Inc/stm32f4xx_hal_conf.h @@ -70,7 +70,7 @@ /* #define HAL_SMBUS_MODULE_ENABLED */ /* #define HAL_WWDG_MODULE_ENABLED */ #define HAL_PCD_MODULE_ENABLED -#define HAL_HCD_MODULE_ENABLED +/* #define HAL_HCD_MODULE_ENABLED */ /* #define HAL_DSI_MODULE_ENABLED */ /* #define HAL_QSPI_MODULE_ENABLED */ /* #define HAL_QSPI_MODULE_ENABLED */ diff --git a/OwlPedal2/Inc/stm32f4xx_it.h b/OwlPedal2/Inc/stm32f4xx_it.h index cc7e46bd..91e69242 100644 --- a/OwlPedal2/Inc/stm32f4xx_it.h +++ b/OwlPedal2/Inc/stm32f4xx_it.h @@ -70,7 +70,6 @@ void EXTI9_5_IRQHandler(void); void DMA2_Stream1_IRQHandler(void); void DMA2_Stream3_IRQHandler(void); void DMA2_Stream4_IRQHandler(void); -void OTG_FS_IRQHandler(void); void OTG_HS_IRQHandler(void); void SAI1_IRQHandler(void); /* USER CODE BEGIN EFP */ diff --git a/OwlPedal2/Inc/usbd_conf.h b/OwlPedal2/Inc/usbd_conf.h index a4ae0135..387bb83f 100644 --- a/OwlPedal2/Inc/usbd_conf.h +++ b/OwlPedal2/Inc/usbd_conf.h @@ -68,19 +68,19 @@ */ /*---------- -----------*/ -#define USBD_MAX_NUM_INTERFACES 5U +#define USBD_MAX_NUM_INTERFACES 1U /*---------- -----------*/ #define USBD_MAX_NUM_CONFIGURATION 1U /*---------- -----------*/ #define USBD_MAX_STR_DESC_SIZ 512U /*---------- -----------*/ -#define USBD_DEBUG_LEVEL DEBUG_LEVEL +#define USBD_DEBUG_LEVEL 0U /*---------- -----------*/ #define USBD_LPM_ENABLED 0U /*---------- -----------*/ -#define USBD_SELF_POWERED 0U +#define USBD_SELF_POWERED 1U /*---------- -----------*/ -#define USBD_AUDIO_FREQ AUDIO_SAMPLINGRATE +#define USBD_AUDIO_FREQ 22100U /****************************************/ /* #define for FS and HS identification */ @@ -95,14 +95,13 @@ * @brief Aliases. * @{ */ - -/* Memory management macros */ - +/* Memory management macros make sure to use static memory allocation */ /** Alias for memory allocation. */ -#define USBD_malloc malloc + +#define USBD_malloc (void *)USBD_static_malloc /** Alias for memory release. */ -#define USBD_free free +#define USBD_free USBD_static_free /** Alias for memory set. */ #define USBD_memset memset @@ -116,25 +115,25 @@ /* DEBUG macros */ #if (USBD_DEBUG_LEVEL > 0) -#define USBD_UsrLog(...) do { printf(__VA_ARGS__); \ - printf("\n"); } while(0) +#define USBD_UsrLog(...) printf(__VA_ARGS__);\ + printf("\n"); #else #define USBD_UsrLog(...) #endif #if (USBD_DEBUG_LEVEL > 1) -#define USBD_ErrLog(...) do { printf("ERROR: ") ;\ +#define USBD_ErrLog(...) printf("ERROR: ") ;\ printf(__VA_ARGS__);\ - printf("\n"); } while(0) + printf("\n"); #else #define USBD_ErrLog(...) #endif #if (USBD_DEBUG_LEVEL > 2) -#define USBD_DbgLog(...) do { printf("DEBUG : ") ; \ +#define USBD_DbgLog(...) printf("DEBUG : ") ;\ printf(__VA_ARGS__);\ - printf("\n"); } while(0) + printf("\n"); #else #define USBD_DbgLog(...) #endif @@ -158,6 +157,8 @@ */ /* Exported functions -------------------------------------------------------*/ +void *USBD_static_malloc(uint32_t size); +void USBD_static_free(void *p); /** * @} diff --git a/OwlPedal2/OwlPedal2.ioc b/OwlPedal2/OwlPedal2.ioc index f98be83b..921819a9 100644 --- a/OwlPedal2/OwlPedal2.ioc +++ b/OwlPedal2/OwlPedal2.ioc @@ -110,8 +110,9 @@ Mcu.IP0=ADC1 Mcu.IP1=ADC3 Mcu.IP10=SPI4 Mcu.IP11=SYS -Mcu.IP12=USB_OTG_FS -Mcu.IP13=USB_OTG_HS +Mcu.IP12=USB_DEVICE +Mcu.IP13=USB_OTG_FS +Mcu.IP14=USB_OTG_HS Mcu.IP2=DMA Mcu.IP3=FMC Mcu.IP4=FREERTOS @@ -120,7 +121,7 @@ Mcu.IP6=RCC Mcu.IP7=RTC Mcu.IP8=SAI1 Mcu.IP9=SPI1 -Mcu.IPNb=14 +Mcu.IPNb=15 Mcu.Name=STM32F427Z(G-I)Tx Mcu.Package=LQFP144 Mcu.Pin0=PE2 @@ -165,44 +166,43 @@ Mcu.Pin43=PE14 Mcu.Pin44=PE15 Mcu.Pin45=PB10 Mcu.Pin46=PB11 -Mcu.Pin47=PB12 -Mcu.Pin48=PB13 -Mcu.Pin49=PB14 +Mcu.Pin47=PB13 +Mcu.Pin48=PB14 +Mcu.Pin49=PB15 Mcu.Pin5=PC15/OSC32_OUT -Mcu.Pin50=PB15 -Mcu.Pin51=PD8 -Mcu.Pin52=PD9 -Mcu.Pin53=PD10 -Mcu.Pin54=PD14 -Mcu.Pin55=PD15 -Mcu.Pin56=PG4 -Mcu.Pin57=PG5 -Mcu.Pin58=PG8 -Mcu.Pin59=PA9 +Mcu.Pin50=PD8 +Mcu.Pin51=PD9 +Mcu.Pin52=PD10 +Mcu.Pin53=PD14 +Mcu.Pin54=PD15 +Mcu.Pin55=PG4 +Mcu.Pin56=PG5 +Mcu.Pin57=PG8 +Mcu.Pin58=PA9 +Mcu.Pin59=PA11 Mcu.Pin6=PF0 -Mcu.Pin60=PA10 -Mcu.Pin61=PA11 -Mcu.Pin62=PA12 -Mcu.Pin63=PA13 -Mcu.Pin64=PA14 -Mcu.Pin65=PD0 -Mcu.Pin66=PD1 -Mcu.Pin67=PD2 -Mcu.Pin68=PD6 -Mcu.Pin69=PG9 +Mcu.Pin60=PA12 +Mcu.Pin61=PA13 +Mcu.Pin62=PA14 +Mcu.Pin63=PD0 +Mcu.Pin64=PD1 +Mcu.Pin65=PD2 +Mcu.Pin66=PD6 +Mcu.Pin67=PG9 +Mcu.Pin68=PG15 +Mcu.Pin69=PB3 Mcu.Pin7=PF1 -Mcu.Pin70=PG15 -Mcu.Pin71=PB3 -Mcu.Pin72=PB5 -Mcu.Pin73=PB6 -Mcu.Pin74=PE0 -Mcu.Pin75=PE1 -Mcu.Pin76=VP_FREERTOS_VS_CMSIS_V1 -Mcu.Pin77=VP_RTC_VS_RTC_Activate -Mcu.Pin78=VP_SYS_VS_Systick +Mcu.Pin70=PB5 +Mcu.Pin71=PB6 +Mcu.Pin72=PE0 +Mcu.Pin73=PE1 +Mcu.Pin74=VP_FREERTOS_VS_CMSIS_V1 +Mcu.Pin75=VP_RTC_VS_RTC_Activate +Mcu.Pin76=VP_SYS_VS_Systick +Mcu.Pin77=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_HS Mcu.Pin8=PF2 Mcu.Pin9=PF3 -Mcu.PinsNb=79 +Mcu.PinsNb=78 Mcu.ThirdPartyNb=0 Mcu.UserConstants= Mcu.UserName=STM32F427ZITx @@ -221,6 +221,7 @@ NVIC.ForceEnableDMAVector=true NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.OTG_HS_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 NVIC.SAI1_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true @@ -236,15 +237,13 @@ PA1.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING PA1.GPIO_PuPd=GPIO_NOPULL PA1.Locked=true PA1.Signal=GPXTI1 -PA10.Mode=OTG/Dual_Role_Device -PA10.Signal=USB_OTG_FS_ID PA11.GPIOParameters=GPIO_Label PA11.GPIO_Label=USBD_DM -PA11.Mode=OTG/Dual_Role_Device +PA11.Mode=Device_Only PA11.Signal=USB_OTG_FS_DM PA12.GPIOParameters=GPIO_Label PA12.GPIO_Label=USBD_DP -PA12.Mode=OTG/Dual_Role_Device +PA12.Mode=Device_Only PA12.Signal=USB_OTG_FS_DP PA13.Mode=Serial_Wire PA13.Signal=SYS_JTMS-SWDIO @@ -277,13 +276,11 @@ PB11.GPIOParameters=GPIO_Label PB11.GPIO_Label=CS_nRST PB11.Locked=true PB11.Signal=GPIO_Output -PB12.Mode=OTG/Dual-Role-Device-FS -PB12.Signal=USB_OTG_HS_ID PB13.Mode=Activate_VBUS_FS PB13.Signal=USB_OTG_HS_VBUS -PB14.Mode=OTG/Dual-Role-Device-FS +PB14.Mode=Device_Only_FS PB14.Signal=USB_OTG_HS_DM -PB15.Mode=OTG/Dual-Role-Device-FS +PB15.Mode=Device_Only_FS PB15.Signal=USB_OTG_HS_DP PB2/BOOT1.GPIOParameters=GPIO_Label PB2/BOOT1.GPIO_Label=EXP_TIP @@ -443,7 +440,7 @@ ProjectManager.StackSize=0x400 ProjectManager.TargetToolchain=Other Toolchains (GPDSC) ProjectManager.ToolChainLocation= ProjectManager.UnderRoot=false -ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-SystemClock_Config-RCC-false-HAL-true,9-MX_RTC_Init-RTC-false-HAL-true,10-MX_ADC1_Init-ADC1-false-HAL-true,11-MX_USB_OTG_FS_USB_Init-USB_OTG_FS-false-HAL-true,12-MX_USB_OTG_HS_USB_Init-USB_OTG_HS-false-HAL-true +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-SystemClock_Config-RCC-false-HAL-true,9-MX_RTC_Init-RTC-false-HAL-true,10-MX_ADC1_Init-ADC1-false-HAL-true,11-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-false-HAL-true,12-MX_USB_OTG_HS_PCD_Init-USB_OTG_HS-false-HAL-true RCC.48MHZClocksFreq_Value=48000000 RCC.AHBFreq_Value=168000000 RCC.APB1CLKDivider=RCC_HCLK_DIV4 @@ -638,10 +635,20 @@ SPI4.Direction=SPI_DIRECTION_2LINES SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,VirtualType,Direction SPI4.Mode=SPI_MODE_MASTER SPI4.VirtualType=VM_MASTER +USB_DEVICE.CLASS_NAME_HS=AUDIO +USB_DEVICE.IPParameters=VirtualMode-AUDIO_HS,VirtualModeHS,CLASS_NAME_HS +USB_DEVICE.VirtualMode-AUDIO_HS=Audio +USB_DEVICE.VirtualModeHS=Audio_HS +USB_OTG_FS.IPParameters=VirtualMode +USB_OTG_FS.VirtualMode=Device_Only +USB_OTG_HS.IPParameters=VirtualMode-Device_Only_FS +USB_OTG_HS.VirtualMode-Device_Only_FS=Device_Only_FS VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate VP_SYS_VS_Systick.Mode=SysTick VP_SYS_VS_Systick.Signal=SYS_VS_Systick +VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_HS.Mode=AUDIO_HS +VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_HS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_HS board=Alchemist diff --git a/OwlPedal2/Src/OwlPedal.cpp b/OwlPedal2/Src/OwlPedal.cpp index 301f9b9b..01e9741d 100644 --- a/OwlPedal2/Src/OwlPedal.cpp +++ b/OwlPedal2/Src/OwlPedal.cpp @@ -4,7 +4,6 @@ #include "MidiController.h" #include "OpenWareMidiControl.h" #include "Pin.h" -#include "usb_device.h" #define PATCH_RESET_COUNTER (1000/MAIN_LOOP_SLEEP_MS) @@ -106,8 +105,6 @@ void setup(){ owl.setup(); setLed(0, GREEN_COLOUR); - MX_USB_DEVICE_Init(); - } void loop(){ diff --git a/OwlPedal2/Src/main.c b/OwlPedal2/Src/main.c index ded4e27a..3f672ee1 100644 --- a/OwlPedal2/Src/main.c +++ b/OwlPedal2/Src/main.c @@ -50,6 +50,7 @@ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "cmsis_os.h" +#include "usb_device.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ @@ -86,6 +87,8 @@ DMA_HandleTypeDef hdma_sai1_b; SPI_HandleTypeDef hspi1; SPI_HandleTypeDef hspi4; +PCD_HandleTypeDef hpcd_USB_OTG_FS; + SDRAM_HandleTypeDef hsdram1; osThreadId defaultTaskHandle; @@ -106,8 +109,7 @@ static void MX_SPI1_Init(void); static void MX_SPI4_Init(void); static void MX_RTC_Init(void); static void MX_ADC1_Init(void); -static void MX_USB_OTG_FS_USB_Init(void); -static void MX_USB_OTG_HS_USB_Init(void); +static void MX_USB_OTG_FS_PCD_Init(void); void StartDefaultTask(void const * argument); /* USER CODE BEGIN PFP */ @@ -169,8 +171,7 @@ int main(void) MX_SPI4_Init(); MX_RTC_Init(); MX_ADC1_Init(); - MX_USB_OTG_FS_USB_Init(); - MX_USB_OTG_HS_USB_Init(); + MX_USB_OTG_FS_PCD_Init(); /* USER CODE BEGIN 2 */ HAL_SAI_DeInit(&hsai_BlockA1); @@ -625,7 +626,7 @@ static void MX_SPI4_Init(void) * @param None * @retval None */ -static void MX_USB_OTG_FS_USB_Init(void) +static void MX_USB_OTG_FS_PCD_Init(void) { /* USER CODE BEGIN USB_OTG_FS_Init 0 */ @@ -635,33 +636,26 @@ static void MX_USB_OTG_FS_USB_Init(void) /* USER CODE BEGIN USB_OTG_FS_Init 1 */ /* USER CODE END USB_OTG_FS_Init 1 */ + hpcd_USB_OTG_FS.Instance = USB_OTG_FS; + hpcd_USB_OTG_FS.Init.dev_endpoints = 4; + hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; + hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; + hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; + hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; + hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; + hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; + hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE; + hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE; + if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) + { + Error_Handler(); + } /* USER CODE BEGIN USB_OTG_FS_Init 2 */ /* USER CODE END USB_OTG_FS_Init 2 */ } -/** - * @brief USB_OTG_HS Initialization Function - * @param None - * @retval None - */ -static void MX_USB_OTG_HS_USB_Init(void) -{ - - /* USER CODE BEGIN USB_OTG_HS_Init 0 */ - - /* USER CODE END USB_OTG_HS_Init 0 */ - - /* USER CODE BEGIN USB_OTG_HS_Init 1 */ - - /* USER CODE END USB_OTG_HS_Init 1 */ - /* USER CODE BEGIN USB_OTG_HS_Init 2 */ - - /* USER CODE END USB_OTG_HS_Init 2 */ - -} - /** * Enable DMA controller clock */ @@ -786,9 +780,9 @@ static void MX_GPIO_Init(void) HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); /*Configure GPIO pins : PA0 PA2 PA4 PA5 - PA8 PA15 */ + PA8 PA10 PA15 */ GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_4|GPIO_PIN_5 - |GPIO_PIN_8|GPIO_PIN_15; + |GPIO_PIN_8|GPIO_PIN_10|GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); @@ -799,10 +793,10 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(FOOTSWITCH_GPIO_Port, &GPIO_InitStruct); - /*Configure GPIO pins : PB0 PB4 PB7 PB8 - PB9 */ - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_4|GPIO_PIN_7|GPIO_PIN_8 - |GPIO_PIN_9; + /*Configure GPIO pins : PB0 PB12 PB4 PB7 + PB8 PB9 */ + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_12|GPIO_PIN_4|GPIO_PIN_7 + |GPIO_PIN_8|GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); @@ -814,20 +808,6 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - /*Configure GPIO pins : PB12 PB14 PB15 */ - GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_14|GPIO_PIN_15; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF12_OTG_HS_FS; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /*Configure GPIO pin : PB13 */ - GPIO_InitStruct.Pin = GPIO_PIN_13; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - /*Configure GPIO pins : PD11 PD12 PD13 PD3 PD4 PD5 PD7 */ GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_3 @@ -846,20 +826,6 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); - /*Configure GPIO pin : USBD_VBUS_Pin */ - GPIO_InitStruct.Pin = USBD_VBUS_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(USBD_VBUS_GPIO_Port, &GPIO_InitStruct); - - /*Configure GPIO pins : PA10 USBD_DM_Pin USBD_DP_Pin */ - GPIO_InitStruct.Pin = GPIO_PIN_10|USBD_DM_Pin|USBD_DP_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - /*Configure GPIO pin : SW1_Pin */ GPIO_InitStruct.Pin = SW1_Pin; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; @@ -897,6 +863,8 @@ static void MX_GPIO_Init(void) /* USER CODE END Header_StartDefaultTask */ void StartDefaultTask(void const * argument) { + /* init code for USB_DEVICE */ + MX_USB_DEVICE_Init(); /* USER CODE BEGIN 5 */ setup(); diff --git a/OwlPedal2/Src/stm32f4xx_it.c b/OwlPedal2/Src/stm32f4xx_it.c index 62c166c1..86e960fd 100644 --- a/OwlPedal2/Src/stm32f4xx_it.c +++ b/OwlPedal2/Src/stm32f4xx_it.c @@ -74,6 +74,7 @@ /* USER CODE END 0 */ /* External variables --------------------------------------------------------*/ +extern PCD_HandleTypeDef hpcd_USB_OTG_HS; extern DMA_HandleTypeDef hdma_adc3; extern ADC_HandleTypeDef hadc1; extern ADC_HandleTypeDef hadc3; @@ -218,23 +219,6 @@ void DMA2_Stream4_IRQHandler(void) /* USER CODE END DMA2_Stream4_IRQn 1 */ } -#ifdef USE_USBD_FS -/** - * @brief This function handles USB On The Go FS global interrupt. - */ -void OTG_FS_IRQHandler(void) -{ - /* USER CODE BEGIN OTG_FS_IRQn 0 */ - extern PCD_HandleTypeDef hpcd_USB_OTG_FS; - /* USER CODE END OTG_FS_IRQn 0 */ - HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS); - /* USER CODE BEGIN OTG_FS_IRQn 1 */ - - /* USER CODE END OTG_FS_IRQn 1 */ -} -#endif - -#ifdef USE_USBD_HS /** * @brief This function handles USB On The Go HS global interrupt. */ @@ -248,7 +232,6 @@ void OTG_HS_IRQHandler(void) /* USER CODE END OTG_HS_IRQn 1 */ } -#endif /** * @brief This function handles SAI1 global interrupt. diff --git a/OwlPedal2/Src/usbd_conf.c b/OwlPedal2/Src/usbd_conf.c index 6d1a8bdf..f7366629 100644 --- a/OwlPedal2/Src/usbd_conf.c +++ b/OwlPedal2/Src/usbd_conf.c @@ -25,6 +25,8 @@ #include "usbd_def.h" #include "usbd_core.h" +#include "usbd_audio.h" + /* USER CODE BEGIN Includes */ #include "device.h" uint8_t USBD_AUDIO_SetFiFos(PCD_HandleTypeDef *hpcd); @@ -39,7 +41,9 @@ uint8_t USBD_AUDIO_SetFiFos(PCD_HandleTypeDef *hpcd); /* USER CODE END PV */ -PCD_HandleTypeDef USBD_HANDLE; +PCD_HandleTypeDef hpcd_USB_OTG_HS; +extern PCD_HandleTypeDef hpcd_USB_OTG_FS; + void Error_Handler(void); /* External functions --------------------------------------------------------*/ @@ -73,20 +77,19 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */ /* USER CODE END USB_OTG_FS_MspInit 0 */ - + __HAL_RCC_GPIOA_CLK_ENABLE(); - /**USB_OTG_FS GPIO Configuration + /**USB_OTG_FS GPIO Configuration PA9 ------> USB_OTG_FS_VBUS - PA10 ------> USB_OTG_FS_ID PA11 ------> USB_OTG_FS_DM - PA12 ------> USB_OTG_FS_DP + PA12 ------> USB_OTG_FS_DP */ GPIO_InitStruct.Pin = USBD_VBUS_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(USBD_VBUS_GPIO_Port, &GPIO_InitStruct); - GPIO_InitStruct.Pin = USBD_ID_Pin|USBD_DM_Pin|USBD_DP_Pin; + GPIO_InitStruct.Pin = USBD_DM_Pin|USBD_DP_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; @@ -100,15 +103,20 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0); HAL_NVIC_EnableIRQ(OTG_FS_IRQn); /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */ + + /* USER CODE END USB_OTG_FS_MspInit 1 */ } - if(pcdHandle->Instance==USB_OTG_HS) + else if(pcdHandle->Instance==USB_OTG_HS) { - + /* USER CODE BEGIN USB_OTG_HS_MspInit 0 */ + + /* USER CODE END USB_OTG_HS_MspInit 0 */ + __HAL_RCC_GPIOB_CLK_ENABLE(); - /**USB_OTG_HS GPIO Configuration + /**USB_OTG_HS GPIO Configuration PB13 ------> USB_OTG_HS_VBUS PB14 ------> USB_OTG_HS_DM - PB15 ------> USB_OTG_HS_DP + PB15 ------> USB_OTG_HS_DP */ GPIO_InitStruct.Pin = GPIO_PIN_13; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; @@ -126,10 +134,11 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) __HAL_RCC_USB_OTG_HS_CLK_ENABLE(); /* Peripheral interrupt init */ - HAL_NVIC_SetPriority(OTG_HS_IRQn, 8, 0); + HAL_NVIC_SetPriority(OTG_HS_IRQn, 5, 0); HAL_NVIC_EnableIRQ(OTG_HS_IRQn); + /* USER CODE BEGIN USB_OTG_HS_MspInit 1 */ - /* USER CODE END USB_OTG_FS_MspInit 1 */ + /* USER CODE END USB_OTG_HS_MspInit 1 */ } } @@ -142,36 +151,42 @@ void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) /* USER CODE END USB_OTG_FS_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); - - /**USB_OTG_FS GPIO Configuration + + /**USB_OTG_FS GPIO Configuration PA9 ------> USB_OTG_FS_VBUS - PA10 ------> USB_OTG_FS_ID PA11 ------> USB_OTG_FS_DM - PA12 ------> USB_OTG_FS_DP + PA12 ------> USB_OTG_FS_DP */ - HAL_GPIO_DeInit(GPIOA, USBD_VBUS_Pin|USBD_ID_Pin|USBD_DM_Pin|USBD_DP_Pin); + HAL_GPIO_DeInit(GPIOA, USBD_VBUS_Pin|USBD_DM_Pin|USBD_DP_Pin); /* Peripheral interrupt Deinit*/ HAL_NVIC_DisableIRQ(OTG_FS_IRQn); /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */ + + /* USER CODE END USB_OTG_FS_MspDeInit 1 */ } - if(pcdHandle->Instance==USB_OTG_HS) + else if(pcdHandle->Instance==USB_OTG_HS) { + /* USER CODE BEGIN USB_OTG_HS_MspDeInit 0 */ + + /* USER CODE END USB_OTG_HS_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_USB_OTG_HS_CLK_DISABLE(); - - /**USB_OTG_HS GPIO Configuration + + /**USB_OTG_HS GPIO Configuration PB13 ------> USB_OTG_HS_VBUS PB14 ------> USB_OTG_HS_DM - PB15 ------> USB_OTG_HS_DP + PB15 ------> USB_OTG_HS_DP */ HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15); /* Peripheral interrupt Deinit*/ HAL_NVIC_DisableIRQ(OTG_HS_IRQn); - /* USER CODE END USB_OTG_FS_MspDeInit 1 */ + /* USER CODE BEGIN USB_OTG_HS_MspDeInit 1 */ + + /* USER CODE END USB_OTG_HS_MspDeInit 1 */ } } @@ -243,7 +258,7 @@ static void PCD_ResetCallback(PCD_HandleTypeDef *hpcd) #else void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ -{ +{ USBD_SpeedTypeDef speed = USBD_SPEED_FULL; if ( hpcd->Init.speed == PCD_SPEED_HIGH) @@ -378,41 +393,68 @@ USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) { /* Init USB Ip. */ if (pdev->id == DEVICE_FS) { - /* Link the driver to the stack. */ - hpcd_USB_OTG_FS.pData = pdev; - pdev->pData = &hpcd_USB_OTG_FS; + hpcd_USB_OTG_FS.pData = pdev; + pdev->pData = &hpcd_USB_OTG_FS; - hpcd_USB_OTG_FS.Instance = USB_OTG_FS; - hpcd_USB_OTG_FS.Init.dev_endpoints = 4; - hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; - hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; - hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; - hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; - hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; - hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; - hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE; - hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE; - if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) + hpcd_USB_OTG_FS.Instance = USB_OTG_FS; + hpcd_USB_OTG_FS.Init.dev_endpoints = 4; + hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; + hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; + hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; + hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; + hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; + hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; + hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE; + hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE; + if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) + { + Error_Handler( ); + } + HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_FS, 0x200); + HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x80); + HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x174); + + }else + if (pdev->id == DEVICE_HS) { + /* Link the driver to the stack. */ + hpcd_USB_OTG_HS.pData = pdev; + pdev->pData = &hpcd_USB_OTG_HS; + + hpcd_USB_OTG_HS.Instance = USB_OTG_HS; + hpcd_USB_OTG_HS.Init.dev_endpoints = 6; + hpcd_USB_OTG_HS.Init.speed = PCD_SPEED_FULL; + hpcd_USB_OTG_HS.Init.dma_enable = DISABLE; + hpcd_USB_OTG_HS.Init.phy_itface = USB_OTG_EMBEDDED_PHY; + hpcd_USB_OTG_HS.Init.Sof_enable = DISABLE; + hpcd_USB_OTG_HS.Init.low_power_enable = DISABLE; + hpcd_USB_OTG_HS.Init.lpm_enable = DISABLE; + hpcd_USB_OTG_HS.Init.vbus_sensing_enable = ENABLE; + hpcd_USB_OTG_HS.Init.use_dedicated_ep1 = DISABLE; + hpcd_USB_OTG_HS.Init.use_external_vbus = DISABLE; + if (HAL_PCD_Init(&hpcd_USB_OTG_HS) != HAL_OK) { Error_Handler( ); } #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) + #error /* Register USB PCD CallBacks */ - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SOF_CB_ID, PCD_SOFCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SETUPSTAGE_CB_ID, PCD_SetupStageCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESET_CB_ID, PCD_ResetCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SUSPEND_CB_ID, PCD_SuspendCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESUME_CB_ID, PCD_ResumeCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_CONNECT_CB_ID, PCD_ConnectCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_DISCONNECT_CB_ID, PCD_DisconnectCallback); - - HAL_PCD_RegisterDataOutStageCallback(&hpcd_USB_OTG_FS, PCD_DataOutStageCallback); - HAL_PCD_RegisterDataInStageCallback(&hpcd_USB_OTG_FS, PCD_DataInStageCallback); - HAL_PCD_RegisterIsoOutIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOOUTIncompleteCallback); - HAL_PCD_RegisterIsoInIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOINIncompleteCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_SOF_CB_ID, PCD_SOFCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_SETUPSTAGE_CB_ID, PCD_SetupStageCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_RESET_CB_ID, PCD_ResetCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_SUSPEND_CB_ID, PCD_SuspendCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_RESUME_CB_ID, PCD_ResumeCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_CONNECT_CB_ID, PCD_ConnectCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_DISCONNECT_CB_ID, PCD_DisconnectCallback); + + HAL_PCD_RegisterDataOutStageCallback(&hpcd_USB_OTG_HS, PCD_DataOutStageCallback); + HAL_PCD_RegisterDataInStageCallback(&hpcd_USB_OTG_HS, PCD_DataInStageCallback); + HAL_PCD_RegisterIsoOutIncpltCallback(&hpcd_USB_OTG_HS, PCD_ISOOUTIncompleteCallback); + HAL_PCD_RegisterIsoInIncpltCallback(&hpcd_USB_OTG_HS, PCD_ISOINIncompleteCallback); #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ - USBD_AUDIO_SetFiFos(&hpcd_USB_OTG_FS); + HAL_PCDEx_SetRxFiFo(pdev->pData, 0x200); + HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 0, 0x80); + HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 1, 0x174); } return USBD_OK; } @@ -430,12 +472,12 @@ USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev) hal_status = HAL_PCD_DeInit(pdev->pData); usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + return usb_status; } /** - * @brief Starts the low level portion of the device driver. + * @brief Starts the low level portion of the device driver. * @param pdev: Device handle * @retval USBD status */ @@ -443,11 +485,11 @@ USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev) { HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - + hal_status = HAL_PCD_Start(pdev->pData); - - usb_status = USBD_Get_USB_Status(hal_status); - + + usb_status = USBD_Get_USB_Status(hal_status); + return usb_status; } @@ -462,9 +504,9 @@ USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev) USBD_StatusTypeDef usb_status = USBD_OK; hal_status = HAL_PCD_Stop(pdev->pData); - + usb_status = USBD_Get_USB_Status(hal_status); - + return usb_status; } @@ -484,7 +526,7 @@ USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uin hal_status = HAL_PCD_EP_Open(pdev->pData, ep_addr, ep_mps, ep_type); usb_status = USBD_Get_USB_Status(hal_status); - + return usb_status; } @@ -499,12 +541,11 @@ USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - USB_DISABLE_EP_BEFORE_CLOSE(ep_addr); hal_status = HAL_PCD_EP_Close(pdev->pData, ep_addr); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; } /** @@ -517,12 +558,12 @@ USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) { HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - + hal_status = HAL_PCD_EP_Flush(pdev->pData, ep_addr); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; } /** @@ -535,12 +576,12 @@ USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) { HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - + hal_status = HAL_PCD_EP_SetStall(pdev->pData, ep_addr); usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + return usb_status; } /** @@ -553,12 +594,12 @@ USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_add { HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - + hal_status = HAL_PCD_EP_ClrStall(pdev->pData, ep_addr); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; } /** @@ -570,14 +611,14 @@ USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_add uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) { PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef*) pdev->pData; - + if((ep_addr & 0x80) == 0x80) { - return hpcd->IN_ep[ep_addr & 0x7F].is_stall; + return hpcd->IN_ep[ep_addr & 0x7F].is_stall; } else { - return hpcd->OUT_ep[ep_addr & 0x7F].is_stall; + return hpcd->OUT_ep[ep_addr & 0x7F].is_stall; } } @@ -591,12 +632,12 @@ USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_a { HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - + hal_status = HAL_PCD_SetAddress(pdev->pData, dev_addr); - + usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + return usb_status; } /** @@ -604,7 +645,7 @@ USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_a * @param pdev: Device handle * @param ep_addr: Endpoint number * @param pbuf: Pointer to data to be sent - * @param size: Data size + * @param size: Data size * @retval USBD status */ USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size) @@ -613,10 +654,10 @@ USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, u USBD_StatusTypeDef usb_status = USBD_OK; hal_status = HAL_PCD_EP_Transmit(pdev->pData, ep_addr, pbuf, size); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; } /** @@ -633,23 +674,44 @@ USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_a USBD_StatusTypeDef usb_status = USBD_OK; hal_status = HAL_PCD_EP_Receive(pdev->pData, ep_addr, pbuf, size); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; } /** - * @brief Returns the last transfered packet size. + * @brief Returns the last transferred packet size. * @param pdev: Device handle * @param ep_addr: Endpoint number - * @retval Recived Data Size + * @retval Received Data Size */ uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr) { return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef*) pdev->pData, ep_addr); } +/** + * @brief Static single allocation. + * @param size: Size of allocated memory + * @retval None + */ +void *USBD_static_malloc(uint32_t size) +{ + static uint32_t mem[(sizeof(USBD_AUDIO_HandleTypeDef)/4)+1];/* On 32-bit boundary */ + return mem; +} + +/** + * @brief Dummy memory free + * @param p: Pointer to allocated memory address + * @retval None + */ +void USBD_static_free(void *p) +{ + +} + /** * @brief Delays routine for the USB Device Library. * @param Delay: Delay in ms @@ -661,7 +723,7 @@ void USBD_LL_Delay(uint32_t Delay) } /** - * @brief Retuns the USB status depending on the HAL status: + * @brief Returns the USB status depending on the HAL status: * @param hal_status: HAL status * @retval USB status */ diff --git a/OwlPedal2/Src/usbd_desc.c b/OwlPedal2/Src/usbd_desc.c index 508959aa..d2f7e236 100644 --- a/OwlPedal2/Src/usbd_desc.c +++ b/OwlPedal2/Src/usbd_desc.c @@ -25,7 +25,7 @@ #include "usbd_conf.h" /* USER CODE BEGIN INCLUDE */ - +#include "device.h" /* USER CODE END INCLUDE */ /* Private typedef -----------------------------------------------------------*/ @@ -66,10 +66,14 @@ #define USBD_VID 0x1209 #define USBD_LANGID_STRING 1033 #define USBD_MANUFACTURER_STRING "Rebel Technology" -#define USBD_PID_FS 0xdada +#define USBD_PID_FS 0xDADA #define USBD_PRODUCT_STRING_FS "OWL-PEDAL" #define USBD_CONFIGURATION_STRING_FS "AUDIO Config" #define USBD_INTERFACE_STRING_FS "AUDIO Interface" +#define USBD_PID_HS 0xDADA +#define USBD_PRODUCT_STRING_HS "OWL-PEDAL" +#define USBD_CONFIGURATION_STRING_HS "AUDIO Config" +#define USBD_INTERFACE_STRING_HS "AUDIO Interface" #define USB_SIZ_BOS_DESC 0x0C @@ -111,19 +115,20 @@ static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len); */ /** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes - * @brief Private functions declaration for FS. + * @brief Private functions declaration for HS. * @{ */ -uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); + #if (USBD_LPM_ENABLED == 1) -uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); #endif /* (USBD_LPM_ENABLED == 1) */ /** @@ -135,17 +140,17 @@ uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); * @{ */ -USBD_DescriptorsTypeDef USBD_DESC = +USBD_DescriptorsTypeDef HS_Desc = { - USBD_FS_DeviceDescriptor -, USBD_FS_LangIDStrDescriptor -, USBD_FS_ManufacturerStrDescriptor -, USBD_FS_ProductStrDescriptor -, USBD_FS_SerialStrDescriptor -, USBD_FS_ConfigStrDescriptor -, USBD_FS_InterfaceStrDescriptor + USBD_FSHS_DeviceDescriptor +, USBD_FSHS_LangIDStrDescriptor +, USBD_FSHS_ManufacturerStrDescriptor +, USBD_FSHS_ProductStrDescriptor +, USBD_FSHS_SerialStrDescriptor +, USBD_FSHS_ConfigStrDescriptor +, USBD_FSHS_InterfaceStrDescriptor #if (USBD_LPM_ENABLED == 1) -, USBD_FS_USR_BOSDescriptor +, USBD_FSHS_USR_BOSDescriptor #endif /* (USBD_LPM_ENABLED == 1) */ }; @@ -153,7 +158,7 @@ USBD_DescriptorsTypeDef USBD_DESC = #pragma data_alignment=4 #endif /* defined ( __ICCARM__ ) */ /** USB standard device descriptor. */ -__ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = +__ALIGN_BEGIN uint8_t USBD_FSHS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = { 0x12, /*bLength */ USB_DESC_TYPE_DEVICE, /*bDescriptorType*/ @@ -164,6 +169,7 @@ __ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = #else 0x00, /*bcdUSB */ #endif /* (USBD_LPM_ENABLED == 1) */ + 0x02, 0x00, /*bDeviceClass*/ 0x00, /*bDeviceSubClass*/ @@ -171,8 +177,8 @@ __ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = USB_MAX_EP0_SIZE, /*bMaxPacketSize*/ LOBYTE(USBD_VID), /*idVendor*/ HIBYTE(USBD_VID), /*idVendor*/ - LOBYTE(USBD_PID_FS), /*idProduct*/ - HIBYTE(USBD_PID_FS), /*idProduct*/ + LOBYTE(USBD_PID_HS), /*idProduct*/ + HIBYTE(USBD_PID_HS), /*idProduct*/ 0x00, /*bcdDevice rel. 2.00*/ 0x02, USBD_IDX_MFC_STR, /*Index of manufacturer string*/ @@ -181,24 +187,23 @@ __ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/ }; -/* USB_DeviceDescriptor */ /** BOS descriptor. */ #if (USBD_LPM_ENABLED == 1) #if defined ( __ICCARM__ ) /* IAR Compiler */ #pragma data_alignment=4 #endif /* defined ( __ICCARM__ ) */ -__ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = +__ALIGN_BEGIN uint8_t USBD_FSHS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = { 0x5, USB_DESC_TYPE_BOS, 0xC, 0x0, - 0x1, /* 1 device capability*/ - /* device capability*/ + 0x1, /* 1 device capability */ + /* device capability */ 0x7, USB_DEVICE_CAPABITY_TYPE, 0x2, - 0x2, /* LPM capability bit set*/ + 0x2, /*LPM capability bit set */ 0x0, 0x0, 0x0 @@ -218,7 +223,7 @@ __ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = #pragma data_alignment=4 #endif /* defined ( __ICCARM__ ) */ -/** USB lang indentifier descriptor. */ +/** USB lang identifier descriptor. */ __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = { USB_LEN_LANGID_STR_DESC, @@ -256,11 +261,11 @@ __ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); - *length = sizeof(USBD_FS_DeviceDesc); - return USBD_FS_DeviceDesc; + *length = sizeof(USBD_FSHS_DeviceDesc); + return USBD_FSHS_DeviceDesc; } /** @@ -269,7 +274,7 @@ uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); *length = sizeof(USBD_LangIDDesc); @@ -278,19 +283,19 @@ uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) /** * @brief Return the product string descriptor - * @param speed : Current device speed - * @param length : Pointer to data length variable - * @retval Pointer to descriptor buffer + * @param speed : current device speed + * @param length : pointer to data length variable + * @retval pointer to descriptor buffer */ -uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { if(speed == 0) { - USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_HS, USBD_StrDesc, length); } else { - USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_HS, USBD_StrDesc, length); } return USBD_StrDesc; } @@ -301,7 +306,7 @@ uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length); @@ -314,7 +319,7 @@ uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *l * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); *length = USB_SIZ_STRING_SERIAL; @@ -322,9 +327,10 @@ uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) /* Update the serial number string descriptor with the data from the unique * ID */ Get_SerialNum(); - /* USER CODE BEGIN USBD_FS_SerialStrDescriptor */ - - /* USER CODE END USBD_FS_SerialStrDescriptor */ + /* USER CODE BEGIN USBD_HS_SerialStrDescriptor */ + + /* USER CODE END USBD_HS_SerialStrDescriptor */ + return (uint8_t *) USBD_StringSerial; } @@ -334,15 +340,15 @@ uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { if(speed == USBD_SPEED_HIGH) { - USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_HS, USBD_StrDesc, length); } else { - USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_HS, USBD_StrDesc, length); } return USBD_StrDesc; } @@ -353,15 +359,15 @@ uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { if(speed == 0) { - USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_HS, USBD_StrDesc, length); } else { - USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_HS, USBD_StrDesc, length); } return USBD_StrDesc; } @@ -373,11 +379,11 @@ uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *leng * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); - *length = sizeof(USBD_FS_BOSDesc); - return (uint8_t*)USBD_FS_BOSDesc; + *length = sizeof(USBD_FSHS_BOSDesc); + return (uint8_t*)USBD_FSHS_BOSDesc; } #endif /* (USBD_LPM_ENABLED == 1) */ From 11ea20e9fd6164dd9b40090d8f908dd312f66a80 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 3 Nov 2021 18:01:15 +0100 Subject: [PATCH 159/286] hs/fs descriptor --- OwlPedal2/Src/usbd_desc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OwlPedal2/Src/usbd_desc.c b/OwlPedal2/Src/usbd_desc.c index d2f7e236..9999c7a8 100644 --- a/OwlPedal2/Src/usbd_desc.c +++ b/OwlPedal2/Src/usbd_desc.c @@ -140,7 +140,7 @@ uint8_t * USBD_FSHS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) * @{ */ -USBD_DescriptorsTypeDef HS_Desc = +USBD_DescriptorsTypeDef USBD_DESC = { USBD_FSHS_DeviceDescriptor , USBD_FSHS_LangIDStrDescriptor From fb9b8072621599b69157e19ec9bca17d8b5e0b34 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 3 Nov 2021 18:01:17 +0100 Subject: [PATCH 160/286] toggle buffered bypass with led button --- OwlPedal2/Src/OwlPedal.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/OwlPedal2/Src/OwlPedal.cpp b/OwlPedal2/Src/OwlPedal.cpp index 01e9741d..c1b14176 100644 --- a/OwlPedal2/Src/OwlPedal.cpp +++ b/OwlPedal2/Src/OwlPedal.cpp @@ -48,8 +48,15 @@ void onChangePin(uint16_t pin){ bool state = HAL_GPIO_ReadPin(SW1_GPIO_Port, SW1_Pin) == GPIO_PIN_RESET; setButtonValue(PUSHBUTTON, state); setButtonValue(BUTTON_A, state); - midi_tx.sendCc(PATCH_BUTTON, state ? 127 : 0); - setLed(0, state ? RED_COLOUR : GREEN_COLOUR); + // midi_tx.sendCc(PATCH_BUTTON, state ? 127 : 0); + // setLed(0, state ? RED_COLOUR : GREEN_COLOUR); + if(state){ + // toggle buffered bypass + static bool buffered_bypass = false; + buffered_bypass = !buffered_bypass; + bufpass_pin.set(buffered_bypass); + setLed(0, buffered_bypass ? RED_COLOUR : GREEN_COLOUR); + } break; } case SW2_Pin: { // mode button @@ -86,6 +93,7 @@ void setGateValue(uint8_t ch, int16_t value){ break; case BUTTON_1: bufpass_pin.set(value); + setLed(0, value ? RED_COLOUR : GREEN_COLOUR); break; } } From 9a9dec666b13c76d9a583969e4cc3a55eb33be6a Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 3 Nov 2021 18:08:27 +0100 Subject: [PATCH 161/286] FS config not quite working --- OwlPedal2/Inc/hardware.h | 18 +++++++++--------- OwlPedal2/Inc/stm32f4xx_it.h | 1 + OwlPedal2/OwlPedal2.ioc | 18 +++++++++--------- OwlPedal2/Src/stm32f4xx_it.c | 19 ++++++++++++++++++- 4 files changed, 37 insertions(+), 19 deletions(-) diff --git a/OwlPedal2/Inc/hardware.h b/OwlPedal2/Inc/hardware.h index 7b92eabd..7fdea0e6 100644 --- a/OwlPedal2/Inc/hardware.h +++ b/OwlPedal2/Inc/hardware.h @@ -7,17 +7,17 @@ #define HARDWARE_ID OWL_PEDAL_HARDWARE #define HARDWARE_VERSION "OWL Pedal mkII" -/* #define USE_USBD_FS */ -/* #define USBD_DESC FS_Desc */ -/* #define USBD_HSFS DEVICE_FS */ -/* #define USBD_HANDLE hUsbDeviceFS */ +#define USE_USBD_FS +#define USBD_DESC FS_Desc +#define USBD_HSFS DEVICE_FS +#define USBD_HANDLE hUsbDeviceFS /* #define USBD_PCD_HANDLE hpcd_USB_OTG_FS */ -#define USE_USBD_HS -#define USBD_DESC HS_Desc -#define USBD_HSFS DEVICE_HS -#define USBD_HANDLE hUsbDeviceHS -#define USBD_PCD_HANDLE hpcd_USB_OTG_HS +/* #define USE_USBD_HS */ +/* #define USBD_DESC HS_Desc */ +/* #define USBD_HSFS DEVICE_HS */ +/* #define USBD_HANDLE hUsbDeviceHS */ +/* #define USBD_PCD_HANDLE hpcd_USB_OTG_HS */ #define USE_USBD_AUDIO #define USE_USBD_RX_FB diff --git a/OwlPedal2/Inc/stm32f4xx_it.h b/OwlPedal2/Inc/stm32f4xx_it.h index 91e69242..cc7e46bd 100644 --- a/OwlPedal2/Inc/stm32f4xx_it.h +++ b/OwlPedal2/Inc/stm32f4xx_it.h @@ -70,6 +70,7 @@ void EXTI9_5_IRQHandler(void); void DMA2_Stream1_IRQHandler(void); void DMA2_Stream3_IRQHandler(void); void DMA2_Stream4_IRQHandler(void); +void OTG_FS_IRQHandler(void); void OTG_HS_IRQHandler(void); void SAI1_IRQHandler(void); /* USER CODE BEGIN EFP */ diff --git a/OwlPedal2/OwlPedal2.ioc b/OwlPedal2/OwlPedal2.ioc index 921819a9..52f79ff3 100644 --- a/OwlPedal2/OwlPedal2.ioc +++ b/OwlPedal2/OwlPedal2.ioc @@ -199,7 +199,7 @@ Mcu.Pin73=PE1 Mcu.Pin74=VP_FREERTOS_VS_CMSIS_V1 Mcu.Pin75=VP_RTC_VS_RTC_Activate Mcu.Pin76=VP_SYS_VS_Systick -Mcu.Pin77=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_HS +Mcu.Pin77=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS Mcu.Pin8=PF2 Mcu.Pin9=PF3 Mcu.PinsNb=78 @@ -221,7 +221,7 @@ NVIC.ForceEnableDMAVector=true NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -NVIC.OTG_HS_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.OTG_FS_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 NVIC.SAI1_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true @@ -440,7 +440,7 @@ ProjectManager.StackSize=0x400 ProjectManager.TargetToolchain=Other Toolchains (GPDSC) ProjectManager.ToolChainLocation= ProjectManager.UnderRoot=false -ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-SystemClock_Config-RCC-false-HAL-true,9-MX_RTC_Init-RTC-false-HAL-true,10-MX_ADC1_Init-ADC1-false-HAL-true,11-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-false-HAL-true,12-MX_USB_OTG_HS_PCD_Init-USB_OTG_HS-false-HAL-true +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-SystemClock_Config-RCC-false-HAL-true,9-MX_RTC_Init-RTC-false-HAL-true,10-MX_ADC1_Init-ADC1-false-HAL-true,11-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-false-HAL-true,12-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false RCC.48MHZClocksFreq_Value=48000000 RCC.AHBFreq_Value=168000000 RCC.APB1CLKDivider=RCC_HCLK_DIV4 @@ -635,10 +635,10 @@ SPI4.Direction=SPI_DIRECTION_2LINES SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,VirtualType,Direction SPI4.Mode=SPI_MODE_MASTER SPI4.VirtualType=VM_MASTER -USB_DEVICE.CLASS_NAME_HS=AUDIO -USB_DEVICE.IPParameters=VirtualMode-AUDIO_HS,VirtualModeHS,CLASS_NAME_HS -USB_DEVICE.VirtualMode-AUDIO_HS=Audio -USB_DEVICE.VirtualModeHS=Audio_HS +USB_DEVICE.CLASS_NAME_FS=AUDIO +USB_DEVICE.IPParameters=VirtualMode-AUDIO_FS,VirtualModeFS,CLASS_NAME_FS +USB_DEVICE.VirtualMode-AUDIO_FS=Audio +USB_DEVICE.VirtualModeFS=Audio_FS USB_OTG_FS.IPParameters=VirtualMode USB_OTG_FS.VirtualMode=Device_Only USB_OTG_HS.IPParameters=VirtualMode-Device_Only_FS @@ -649,6 +649,6 @@ VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate VP_SYS_VS_Systick.Mode=SysTick VP_SYS_VS_Systick.Signal=SYS_VS_Systick -VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_HS.Mode=AUDIO_HS -VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_HS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_HS +VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Mode=AUDIO_FS +VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_FS board=Alchemist diff --git a/OwlPedal2/Src/stm32f4xx_it.c b/OwlPedal2/Src/stm32f4xx_it.c index 86e960fd..62c166c1 100644 --- a/OwlPedal2/Src/stm32f4xx_it.c +++ b/OwlPedal2/Src/stm32f4xx_it.c @@ -74,7 +74,6 @@ /* USER CODE END 0 */ /* External variables --------------------------------------------------------*/ -extern PCD_HandleTypeDef hpcd_USB_OTG_HS; extern DMA_HandleTypeDef hdma_adc3; extern ADC_HandleTypeDef hadc1; extern ADC_HandleTypeDef hadc3; @@ -219,6 +218,23 @@ void DMA2_Stream4_IRQHandler(void) /* USER CODE END DMA2_Stream4_IRQn 1 */ } +#ifdef USE_USBD_FS +/** + * @brief This function handles USB On The Go FS global interrupt. + */ +void OTG_FS_IRQHandler(void) +{ + /* USER CODE BEGIN OTG_FS_IRQn 0 */ + extern PCD_HandleTypeDef hpcd_USB_OTG_FS; + /* USER CODE END OTG_FS_IRQn 0 */ + HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS); + /* USER CODE BEGIN OTG_FS_IRQn 1 */ + + /* USER CODE END OTG_FS_IRQn 1 */ +} +#endif + +#ifdef USE_USBD_HS /** * @brief This function handles USB On The Go HS global interrupt. */ @@ -232,6 +248,7 @@ void OTG_HS_IRQHandler(void) /* USER CODE END OTG_HS_IRQn 1 */ } +#endif /** * @brief This function handles SAI1 global interrupt. From 3481f4b70b444a20543942d342c261fb9112b6a5 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 4 Nov 2021 12:12:26 +0100 Subject: [PATCH 162/286] updated USBD configuration, works with FS USBD --- OwlPedal2/Inc/hardware.h | 3 +- OwlPedal2/OwlPedal2.ioc | 21 +-- OwlPedal2/Src/OwlPedal.cpp | 4 +- OwlPedal2/Src/main.c | 42 +++++- OwlPedal2/Src/stm32f4xx_hal_msp.c | 131 ++++++++++++++++ OwlPedal2/Src/stm32f4xx_it.c | 10 +- OwlPedal2/Src/usbd_conf.c | 238 ++---------------------------- 7 files changed, 197 insertions(+), 252 deletions(-) diff --git a/OwlPedal2/Inc/hardware.h b/OwlPedal2/Inc/hardware.h index 7fdea0e6..c0efeb7c 100644 --- a/OwlPedal2/Inc/hardware.h +++ b/OwlPedal2/Inc/hardware.h @@ -11,7 +11,7 @@ #define USBD_DESC FS_Desc #define USBD_HSFS DEVICE_FS #define USBD_HANDLE hUsbDeviceFS -/* #define USBD_PCD_HANDLE hpcd_USB_OTG_FS */ +#define USBD_PCD_HANDLE hpcd_USB_OTG_FS /* #define USE_USBD_HS */ /* #define USBD_DESC HS_Desc */ @@ -35,6 +35,7 @@ #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) #define USE_BKPSRAM +#define AUDIO_OUTPUT_GAIN 123 /* #define USE_MODE_BUTTON */ /* #define MODE_BUTTON_PIN SW3_Pin */ diff --git a/OwlPedal2/OwlPedal2.ioc b/OwlPedal2/OwlPedal2.ioc index 52f79ff3..c8ba298b 100644 --- a/OwlPedal2/OwlPedal2.ioc +++ b/OwlPedal2/OwlPedal2.ioc @@ -110,9 +110,8 @@ Mcu.IP0=ADC1 Mcu.IP1=ADC3 Mcu.IP10=SPI4 Mcu.IP11=SYS -Mcu.IP12=USB_DEVICE -Mcu.IP13=USB_OTG_FS -Mcu.IP14=USB_OTG_HS +Mcu.IP12=USB_OTG_FS +Mcu.IP13=USB_OTG_HS Mcu.IP2=DMA Mcu.IP3=FMC Mcu.IP4=FREERTOS @@ -121,7 +120,7 @@ Mcu.IP6=RCC Mcu.IP7=RTC Mcu.IP8=SAI1 Mcu.IP9=SPI1 -Mcu.IPNb=15 +Mcu.IPNb=14 Mcu.Name=STM32F427Z(G-I)Tx Mcu.Package=LQFP144 Mcu.Pin0=PE2 @@ -199,10 +198,9 @@ Mcu.Pin73=PE1 Mcu.Pin74=VP_FREERTOS_VS_CMSIS_V1 Mcu.Pin75=VP_RTC_VS_RTC_Activate Mcu.Pin76=VP_SYS_VS_Systick -Mcu.Pin77=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS Mcu.Pin8=PF2 Mcu.Pin9=PF3 -Mcu.PinsNb=78 +Mcu.PinsNb=77 Mcu.ThirdPartyNb=0 Mcu.UserConstants= Mcu.UserName=STM32F427ZITx @@ -221,7 +219,8 @@ NVIC.ForceEnableDMAVector=true NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -NVIC.OTG_FS_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.OTG_FS_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.OTG_HS_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 NVIC.SAI1_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true @@ -440,7 +439,7 @@ ProjectManager.StackSize=0x400 ProjectManager.TargetToolchain=Other Toolchains (GPDSC) ProjectManager.ToolChainLocation= ProjectManager.UnderRoot=false -ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-SystemClock_Config-RCC-false-HAL-true,9-MX_RTC_Init-RTC-false-HAL-true,10-MX_ADC1_Init-ADC1-false-HAL-true,11-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-false-HAL-true,12-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-SystemClock_Config-RCC-false-HAL-true,9-MX_RTC_Init-RTC-false-HAL-true,10-MX_ADC1_Init-ADC1-false-HAL-true,11-MX_USB_OTG_HS_PCD_Init-USB_OTG_HS-false-HAL-true,12-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-false-HAL-true RCC.48MHZClocksFreq_Value=48000000 RCC.AHBFreq_Value=168000000 RCC.APB1CLKDivider=RCC_HCLK_DIV4 @@ -635,10 +634,6 @@ SPI4.Direction=SPI_DIRECTION_2LINES SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,VirtualType,Direction SPI4.Mode=SPI_MODE_MASTER SPI4.VirtualType=VM_MASTER -USB_DEVICE.CLASS_NAME_FS=AUDIO -USB_DEVICE.IPParameters=VirtualMode-AUDIO_FS,VirtualModeFS,CLASS_NAME_FS -USB_DEVICE.VirtualMode-AUDIO_FS=Audio -USB_DEVICE.VirtualModeFS=Audio_FS USB_OTG_FS.IPParameters=VirtualMode USB_OTG_FS.VirtualMode=Device_Only USB_OTG_HS.IPParameters=VirtualMode-Device_Only_FS @@ -649,6 +644,4 @@ VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate VP_SYS_VS_Systick.Mode=SysTick VP_SYS_VS_Systick.Signal=SYS_VS_Systick -VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Mode=AUDIO_FS -VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_FS board=Alchemist diff --git a/OwlPedal2/Src/OwlPedal.cpp b/OwlPedal2/Src/OwlPedal.cpp index c1b14176..84cc2b0d 100644 --- a/OwlPedal2/Src/OwlPedal.cpp +++ b/OwlPedal2/Src/OwlPedal.cpp @@ -4,6 +4,7 @@ #include "MidiController.h" #include "OpenWareMidiControl.h" #include "Pin.h" +#include "usb_device.h" #define PATCH_RESET_COUNTER (1000/MAIN_LOOP_SLEEP_MS) @@ -54,7 +55,7 @@ void onChangePin(uint16_t pin){ // toggle buffered bypass static bool buffered_bypass = false; buffered_bypass = !buffered_bypass; - bufpass_pin.set(buffered_bypass); + bufpass_pin.set(!buffered_bypass); setLed(0, buffered_bypass ? RED_COLOUR : GREEN_COLOUR); } break; @@ -113,6 +114,7 @@ void setup(){ owl.setup(); setLed(0, GREEN_COLOUR); + MX_USB_DEVICE_Init(); } void loop(){ diff --git a/OwlPedal2/Src/main.c b/OwlPedal2/Src/main.c index 3f672ee1..829f3037 100644 --- a/OwlPedal2/Src/main.c +++ b/OwlPedal2/Src/main.c @@ -50,7 +50,6 @@ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "cmsis_os.h" -#include "usb_device.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ @@ -88,6 +87,7 @@ SPI_HandleTypeDef hspi1; SPI_HandleTypeDef hspi4; PCD_HandleTypeDef hpcd_USB_OTG_FS; +PCD_HandleTypeDef hpcd_USB_OTG_HS; SDRAM_HandleTypeDef hsdram1; @@ -109,6 +109,7 @@ static void MX_SPI1_Init(void); static void MX_SPI4_Init(void); static void MX_RTC_Init(void); static void MX_ADC1_Init(void); +static void MX_USB_OTG_HS_PCD_Init(void); static void MX_USB_OTG_FS_PCD_Init(void); void StartDefaultTask(void const * argument); @@ -171,6 +172,7 @@ int main(void) MX_SPI4_Init(); MX_RTC_Init(); MX_ADC1_Init(); + MX_USB_OTG_HS_PCD_Init(); MX_USB_OTG_FS_PCD_Init(); /* USER CODE BEGIN 2 */ @@ -656,6 +658,42 @@ static void MX_USB_OTG_FS_PCD_Init(void) } +/** + * @brief USB_OTG_HS Initialization Function + * @param None + * @retval None + */ +static void MX_USB_OTG_HS_PCD_Init(void) +{ + + /* USER CODE BEGIN USB_OTG_HS_Init 0 */ + + /* USER CODE END USB_OTG_HS_Init 0 */ + + /* USER CODE BEGIN USB_OTG_HS_Init 1 */ + + /* USER CODE END USB_OTG_HS_Init 1 */ + hpcd_USB_OTG_HS.Instance = USB_OTG_HS; + hpcd_USB_OTG_HS.Init.dev_endpoints = 6; + hpcd_USB_OTG_HS.Init.speed = PCD_SPEED_FULL; + hpcd_USB_OTG_HS.Init.dma_enable = DISABLE; + hpcd_USB_OTG_HS.Init.phy_itface = USB_OTG_EMBEDDED_PHY; + hpcd_USB_OTG_HS.Init.Sof_enable = DISABLE; + hpcd_USB_OTG_HS.Init.low_power_enable = DISABLE; + hpcd_USB_OTG_HS.Init.lpm_enable = DISABLE; + hpcd_USB_OTG_HS.Init.vbus_sensing_enable = ENABLE; + hpcd_USB_OTG_HS.Init.use_dedicated_ep1 = DISABLE; + hpcd_USB_OTG_HS.Init.use_external_vbus = DISABLE; + if (HAL_PCD_Init(&hpcd_USB_OTG_HS) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN USB_OTG_HS_Init 2 */ + + /* USER CODE END USB_OTG_HS_Init 2 */ + +} + /** * Enable DMA controller clock */ @@ -863,8 +901,6 @@ static void MX_GPIO_Init(void) /* USER CODE END Header_StartDefaultTask */ void StartDefaultTask(void const * argument) { - /* init code for USB_DEVICE */ - MX_USB_DEVICE_Init(); /* USER CODE BEGIN 5 */ setup(); diff --git a/OwlPedal2/Src/stm32f4xx_hal_msp.c b/OwlPedal2/Src/stm32f4xx_hal_msp.c index 00f5a5aa..83400d01 100644 --- a/OwlPedal2/Src/stm32f4xx_hal_msp.c +++ b/OwlPedal2/Src/stm32f4xx_hal_msp.c @@ -466,6 +466,137 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) } +/** +* @brief PCD MSP Initialization +* This function configures the hardware resources used in this example +* @param hpcd: PCD handle pointer +* @retval None +*/ +void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(hpcd->Instance==USB_OTG_FS) + { + /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */ + + /* USER CODE END USB_OTG_FS_MspInit 0 */ + + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**USB_OTG_FS GPIO Configuration + PA9 ------> USB_OTG_FS_VBUS + PA11 ------> USB_OTG_FS_DM + PA12 ------> USB_OTG_FS_DP + */ + GPIO_InitStruct.Pin = USBD_VBUS_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(USBD_VBUS_GPIO_Port, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = USBD_DM_Pin|USBD_DP_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* Peripheral clock enable */ + __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); + /* USB_OTG_FS interrupt Init */ + HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(OTG_FS_IRQn); + /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */ + + /* USER CODE END USB_OTG_FS_MspInit 1 */ + } + else if(hpcd->Instance==USB_OTG_HS) + { + /* USER CODE BEGIN USB_OTG_HS_MspInit 0 */ + + /* USER CODE END USB_OTG_HS_MspInit 0 */ + + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**USB_OTG_HS GPIO Configuration + PB13 ------> USB_OTG_HS_VBUS + PB14 ------> USB_OTG_HS_DM + PB15 ------> USB_OTG_HS_DP + */ + GPIO_InitStruct.Pin = GPIO_PIN_13; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_OTG_HS_FS; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* Peripheral clock enable */ + __HAL_RCC_USB_OTG_HS_CLK_ENABLE(); + /* USB_OTG_HS interrupt Init */ + HAL_NVIC_SetPriority(OTG_HS_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(OTG_HS_IRQn); + /* USER CODE BEGIN USB_OTG_HS_MspInit 1 */ + + /* USER CODE END USB_OTG_HS_MspInit 1 */ + } + +} + +/** +* @brief PCD MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hpcd: PCD handle pointer +* @retval None +*/ +void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd) +{ + if(hpcd->Instance==USB_OTG_FS) + { + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */ + + /* USER CODE END USB_OTG_FS_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); + + /**USB_OTG_FS GPIO Configuration + PA9 ------> USB_OTG_FS_VBUS + PA11 ------> USB_OTG_FS_DM + PA12 ------> USB_OTG_FS_DP + */ + HAL_GPIO_DeInit(GPIOA, USBD_VBUS_Pin|USBD_DM_Pin|USBD_DP_Pin); + + /* USB_OTG_FS interrupt DeInit */ + HAL_NVIC_DisableIRQ(OTG_FS_IRQn); + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */ + + /* USER CODE END USB_OTG_FS_MspDeInit 1 */ + } + else if(hpcd->Instance==USB_OTG_HS) + { + /* USER CODE BEGIN USB_OTG_HS_MspDeInit 0 */ + + /* USER CODE END USB_OTG_HS_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_USB_OTG_HS_CLK_DISABLE(); + + /**USB_OTG_HS GPIO Configuration + PB13 ------> USB_OTG_HS_VBUS + PB14 ------> USB_OTG_HS_DM + PB15 ------> USB_OTG_HS_DP + */ + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15); + + /* USB_OTG_HS interrupt DeInit */ + HAL_NVIC_DisableIRQ(OTG_HS_IRQn); + /* USER CODE BEGIN USB_OTG_HS_MspDeInit 1 */ + + /* USER CODE END USB_OTG_HS_MspDeInit 1 */ + } + +} + static uint32_t FMC_Initialized = 0; static void HAL_FMC_MspInit(void){ diff --git a/OwlPedal2/Src/stm32f4xx_it.c b/OwlPedal2/Src/stm32f4xx_it.c index 62c166c1..836603ab 100644 --- a/OwlPedal2/Src/stm32f4xx_it.c +++ b/OwlPedal2/Src/stm32f4xx_it.c @@ -81,6 +81,8 @@ extern DMA_HandleTypeDef hdma_sai1_a; extern DMA_HandleTypeDef hdma_sai1_b; extern SAI_HandleTypeDef hsai_BlockA1; extern SAI_HandleTypeDef hsai_BlockB1; +extern PCD_HandleTypeDef hpcd_USB_OTG_FS; +extern PCD_HandleTypeDef hpcd_USB_OTG_HS; /* USER CODE BEGIN EV */ /* USER CODE END EV */ @@ -218,37 +220,33 @@ void DMA2_Stream4_IRQHandler(void) /* USER CODE END DMA2_Stream4_IRQn 1 */ } -#ifdef USE_USBD_FS /** * @brief This function handles USB On The Go FS global interrupt. */ void OTG_FS_IRQHandler(void) { /* USER CODE BEGIN OTG_FS_IRQn 0 */ - extern PCD_HandleTypeDef hpcd_USB_OTG_FS; + /* USER CODE END OTG_FS_IRQn 0 */ HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS); /* USER CODE BEGIN OTG_FS_IRQn 1 */ /* USER CODE END OTG_FS_IRQn 1 */ } -#endif -#ifdef USE_USBD_HS /** * @brief This function handles USB On The Go HS global interrupt. */ void OTG_HS_IRQHandler(void) { /* USER CODE BEGIN OTG_HS_IRQn 0 */ - extern PCD_HandleTypeDef hpcd_USB_OTG_HS; + /* USER CODE END OTG_HS_IRQn 0 */ HAL_PCD_IRQHandler(&hpcd_USB_OTG_HS); /* USER CODE BEGIN OTG_HS_IRQn 1 */ /* USER CODE END OTG_HS_IRQn 1 */ } -#endif /** * @brief This function handles SAI1 global interrupt. diff --git a/OwlPedal2/Src/usbd_conf.c b/OwlPedal2/Src/usbd_conf.c index f7366629..22ab2ba9 100644 --- a/OwlPedal2/Src/usbd_conf.c +++ b/OwlPedal2/Src/usbd_conf.c @@ -41,7 +41,7 @@ uint8_t USBD_AUDIO_SetFiFos(PCD_HandleTypeDef *hpcd); /* USER CODE END PV */ -PCD_HandleTypeDef hpcd_USB_OTG_HS; +extern PCD_HandleTypeDef hpcd_USB_OTG_HS; extern PCD_HandleTypeDef hpcd_USB_OTG_FS; void Error_Handler(void); @@ -67,139 +67,18 @@ USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status); /******************************************************************************* LL Driver Callbacks (PCD -> USB Device Library) *******************************************************************************/ -/* MSP Init */ -void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - if(pcdHandle->Instance==USB_OTG_FS) - { - /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */ - - /* USER CODE END USB_OTG_FS_MspInit 0 */ - - __HAL_RCC_GPIOA_CLK_ENABLE(); - /**USB_OTG_FS GPIO Configuration - PA9 ------> USB_OTG_FS_VBUS - PA11 ------> USB_OTG_FS_DM - PA12 ------> USB_OTG_FS_DP - */ - GPIO_InitStruct.Pin = USBD_VBUS_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(USBD_VBUS_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = USBD_DM_Pin|USBD_DP_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* Peripheral clock enable */ - __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); - - /* Peripheral interrupt init */ - HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(OTG_FS_IRQn); - /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */ - - /* USER CODE END USB_OTG_FS_MspInit 1 */ - } - else if(pcdHandle->Instance==USB_OTG_HS) - { - /* USER CODE BEGIN USB_OTG_HS_MspInit 0 */ - - /* USER CODE END USB_OTG_HS_MspInit 0 */ - - __HAL_RCC_GPIOB_CLK_ENABLE(); - /**USB_OTG_HS GPIO Configuration - PB13 ------> USB_OTG_HS_VBUS - PB14 ------> USB_OTG_HS_DM - PB15 ------> USB_OTG_HS_DP - */ - GPIO_InitStruct.Pin = GPIO_PIN_13; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF12_OTG_HS_FS; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /* Peripheral clock enable */ - __HAL_RCC_USB_OTG_HS_CLK_ENABLE(); - - /* Peripheral interrupt init */ - HAL_NVIC_SetPriority(OTG_HS_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(OTG_HS_IRQn); - /* USER CODE BEGIN USB_OTG_HS_MspInit 1 */ - - /* USER CODE END USB_OTG_HS_MspInit 1 */ - } -} - -void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) -{ - if(pcdHandle->Instance==USB_OTG_FS) - { - /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */ - - /* USER CODE END USB_OTG_FS_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); - - /**USB_OTG_FS GPIO Configuration - PA9 ------> USB_OTG_FS_VBUS - PA11 ------> USB_OTG_FS_DM - PA12 ------> USB_OTG_FS_DP - */ - HAL_GPIO_DeInit(GPIOA, USBD_VBUS_Pin|USBD_DM_Pin|USBD_DP_Pin); - - /* Peripheral interrupt Deinit*/ - HAL_NVIC_DisableIRQ(OTG_FS_IRQn); - - /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */ - - /* USER CODE END USB_OTG_FS_MspDeInit 1 */ - } - else if(pcdHandle->Instance==USB_OTG_HS) - { - /* USER CODE BEGIN USB_OTG_HS_MspDeInit 0 */ - - /* USER CODE END USB_OTG_HS_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_USB_OTG_HS_CLK_DISABLE(); - - /**USB_OTG_HS GPIO Configuration - PB13 ------> USB_OTG_HS_VBUS - PB14 ------> USB_OTG_HS_DM - PB15 ------> USB_OTG_HS_DP - */ - HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15); - - /* Peripheral interrupt Deinit*/ - HAL_NVIC_DisableIRQ(OTG_HS_IRQn); - - /* USER CODE BEGIN USB_OTG_HS_MspDeInit 1 */ - - /* USER CODE END USB_OTG_HS_MspDeInit 1 */ - } -} +/* defined in stm32f4xx_hal_msp.c : + * void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd) + * void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd) + */ /** * @brief Setup stage callback * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_SetupStage((USBD_HandleTypeDef*)hpcd->pData, (uint8_t *)hpcd->Setup); } @@ -210,11 +89,7 @@ void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) * @param epnum: Endpoint number * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#else void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_DataOutStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff); } @@ -225,11 +100,7 @@ void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) * @param epnum: Endpoint number * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#else void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_DataInStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff); } @@ -239,11 +110,7 @@ void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_SOFCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_SOF((USBD_HandleTypeDef*)hpcd->pData); } @@ -253,11 +120,7 @@ void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ResetCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_SpeedTypeDef speed = USBD_SPEED_FULL; @@ -286,11 +149,7 @@ void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { /* Inform USB library that core enters in suspend Mode. */ USBD_LL_Suspend((USBD_HandleTypeDef*)hpcd->pData); @@ -311,11 +170,7 @@ void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { /* USER CODE BEGIN 3 */ /* USER CODE END 3 */ @@ -328,11 +183,7 @@ void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) * @param epnum: Endpoint number * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#else void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_IsoOUTIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); } @@ -343,11 +194,7 @@ void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) * @param epnum: Endpoint number * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#else void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_IsoINIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); } @@ -357,11 +204,7 @@ void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_DevConnected((USBD_HandleTypeDef*)hpcd->pData); } @@ -371,11 +214,7 @@ void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_DevDisconnected((USBD_HandleTypeDef*)hpcd->pData); } @@ -391,71 +230,16 @@ void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) */ USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) { - /* Init USB Ip. */ if (pdev->id == DEVICE_FS) { + /* Link the driver to the stack. */ hpcd_USB_OTG_FS.pData = pdev; pdev->pData = &hpcd_USB_OTG_FS; - - hpcd_USB_OTG_FS.Instance = USB_OTG_FS; - hpcd_USB_OTG_FS.Init.dev_endpoints = 4; - hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; - hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; - hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; - hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; - hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; - hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; - hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE; - hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE; - if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) - { - Error_Handler( ); - } - HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_FS, 0x200); - HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x80); - HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x174); - - }else - if (pdev->id == DEVICE_HS) { - /* Link the driver to the stack. */ - hpcd_USB_OTG_HS.pData = pdev; - pdev->pData = &hpcd_USB_OTG_HS; - - hpcd_USB_OTG_HS.Instance = USB_OTG_HS; - hpcd_USB_OTG_HS.Init.dev_endpoints = 6; - hpcd_USB_OTG_HS.Init.speed = PCD_SPEED_FULL; - hpcd_USB_OTG_HS.Init.dma_enable = DISABLE; - hpcd_USB_OTG_HS.Init.phy_itface = USB_OTG_EMBEDDED_PHY; - hpcd_USB_OTG_HS.Init.Sof_enable = DISABLE; - hpcd_USB_OTG_HS.Init.low_power_enable = DISABLE; - hpcd_USB_OTG_HS.Init.lpm_enable = DISABLE; - hpcd_USB_OTG_HS.Init.vbus_sensing_enable = ENABLE; - hpcd_USB_OTG_HS.Init.use_dedicated_ep1 = DISABLE; - hpcd_USB_OTG_HS.Init.use_external_vbus = DISABLE; - if (HAL_PCD_Init(&hpcd_USB_OTG_HS) != HAL_OK) - { - Error_Handler( ); - } - -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) - #error - /* Register USB PCD CallBacks */ - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_SOF_CB_ID, PCD_SOFCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_SETUPSTAGE_CB_ID, PCD_SetupStageCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_RESET_CB_ID, PCD_ResetCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_SUSPEND_CB_ID, PCD_SuspendCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_RESUME_CB_ID, PCD_ResumeCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_CONNECT_CB_ID, PCD_ConnectCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_HS, HAL_PCD_DISCONNECT_CB_ID, PCD_DisconnectCallback); - - HAL_PCD_RegisterDataOutStageCallback(&hpcd_USB_OTG_HS, PCD_DataOutStageCallback); - HAL_PCD_RegisterDataInStageCallback(&hpcd_USB_OTG_HS, PCD_DataInStageCallback); - HAL_PCD_RegisterIsoOutIncpltCallback(&hpcd_USB_OTG_HS, PCD_ISOOUTIncompleteCallback); - HAL_PCD_RegisterIsoInIncpltCallback(&hpcd_USB_OTG_HS, PCD_ISOINIncompleteCallback); -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ - HAL_PCDEx_SetRxFiFo(pdev->pData, 0x200); - HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 0, 0x80); - HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 1, 0x174); + } else if (pdev->id == DEVICE_HS) { + /* Link the driver to the stack. */ + hpcd_USB_OTG_HS.pData = pdev; + pdev->pData = &hpcd_USB_OTG_HS; } + USBD_AUDIO_SetFiFos(pdev->pData); return USBD_OK; } From d448303c19c7a7340367c3a3b472a2c5bca54509 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 4 Nov 2021 12:43:19 +0100 Subject: [PATCH 163/286] managed buffered bypass --- OwlPedal2/Src/OwlPedal.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/OwlPedal2/Src/OwlPedal.cpp b/OwlPedal2/Src/OwlPedal.cpp index 84cc2b0d..a21cd726 100644 --- a/OwlPedal2/Src/OwlPedal.cpp +++ b/OwlPedal2/Src/OwlPedal.cpp @@ -37,6 +37,15 @@ void setLed(uint8_t led, uint32_t rgb){ } } +bool getBufferedBypass(){ + return !bufpass_pin.get(); +} + +void setBufferedBypass(bool value){ + setLed(0, value ? RED_COLOUR : GREEN_COLOUR); + bufpass_pin.set(!value); +} + void onChangePin(uint16_t pin){ switch(pin){ case FOOTSWITCH_Pin: { // stomp switch @@ -53,10 +62,7 @@ void onChangePin(uint16_t pin){ // setLed(0, state ? RED_COLOUR : GREEN_COLOUR); if(state){ // toggle buffered bypass - static bool buffered_bypass = false; - buffered_bypass = !buffered_bypass; - bufpass_pin.set(!buffered_bypass); - setLed(0, buffered_bypass ? RED_COLOUR : GREEN_COLOUR); + setBufferedBypass(!getBufferedBypass()); } break; } @@ -93,8 +99,7 @@ void setGateValue(uint8_t ch, int16_t value){ setLed(0, value ? RED_COLOUR : NO_COLOUR); break; case BUTTON_1: - bufpass_pin.set(value); - setLed(0, value ? RED_COLOUR : GREEN_COLOUR); + setBufferedBypass(value); break; } } @@ -112,9 +117,10 @@ void setup(){ setLed(0, RED_COLOUR); owl.setup(); - setLed(0, GREEN_COLOUR); MX_USB_DEVICE_Init(); + + setBufferedBypass(false); } void loop(){ From 7e3bf509461e210b0743f06de0049aa17c069907 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 4 Nov 2021 12:48:30 +0100 Subject: [PATCH 164/286] explicit precedence with parenthesis --- Source/Pin.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Source/Pin.h b/Source/Pin.h index 0a3086c4..12702c5d 100644 --- a/Source/Pin.h +++ b/Source/Pin.h @@ -38,11 +38,7 @@ class Pin { port->BSRR = (1<<(pin+16U)); } void set(bool on){ - port->BSRR = (1<<(pin+16U*!on)); - // if(on) - // high(pin); - // else - // low(pin); + port->BSRR = (1<<(pin+(16U*!on))); } void toggle(){ port->ODR ^= 1< Date: Thu, 4 Nov 2021 13:20:15 +0100 Subject: [PATCH 165/286] update history and bump version --- HISTORY.md | 6 ++++++ Source/device.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index c95ba073..d90293a4 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,9 @@ +22.1.rc2 +------ + +* Process USB messages each audio block, before patch runs (or in loop if no patch is loaded) + + 22.1.rc1 ------ diff --git a/Source/device.h b/Source/device.h index b6019557..262b72e9 100644 --- a/Source/device.h +++ b/Source/device.h @@ -3,7 +3,7 @@ #include "hardware.h" -#define FIRMWARE_VERSION "v22.1.rc1" +#define FIRMWARE_VERSION "v22.1.rc2" #ifdef USE_SPI_FLASH #define MAX_SPI_FLASH_HEADERS 32 From eb3371142b6cfde8087a2e9a63aa080b9984c02e Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 4 Nov 2021 15:20:43 +0100 Subject: [PATCH 166/286] adding ACDC project --- ACDC/ACDC.ioc | 888 ++++++++++++++++++++ ACDC/Core/Inc/FreeRTOSConfig.h | 145 ++++ ACDC/Core/Inc/hardware.h | 59 ++ ACDC/Core/Inc/main.h | 126 +++ ACDC/Core/Inc/stm32h7xx_hal_conf.h | 511 ++++++++++++ ACDC/Core/Inc/stm32h7xx_it.h | 74 ++ ACDC/Core/Src/ACDC.cpp | 115 +++ ACDC/Core/Src/freertos.c | 106 +++ ACDC/Core/Src/main.c | 1223 +++++++++++++++++++++++++++ ACDC/Core/Src/stm32h7xx_hal_msp.c | 1250 ++++++++++++++++++++++++++++ ACDC/Core/Src/stm32h7xx_it.c | 296 +++++++ ACDC/Core/Src/system_stm32h7xx.c | 402 +++++++++ ACDC/Makefile | 44 + ACDC/USB_DEVICE/App/usb_device.c | 100 +++ ACDC/USB_DEVICE/App/usb_device.h | 105 +++ ACDC/USB_DEVICE/App/usbd_desc.c | 394 +++++++++ ACDC/USB_DEVICE/App/usbd_desc.h | 145 ++++ ACDC/USB_DEVICE/Target/usbd_conf.c | 680 +++++++++++++++ ACDC/USB_DEVICE/Target/usbd_conf.h | 176 ++++ 19 files changed, 6839 insertions(+) create mode 100644 ACDC/ACDC.ioc create mode 100644 ACDC/Core/Inc/FreeRTOSConfig.h create mode 100644 ACDC/Core/Inc/hardware.h create mode 100644 ACDC/Core/Inc/main.h create mode 100644 ACDC/Core/Inc/stm32h7xx_hal_conf.h create mode 100644 ACDC/Core/Inc/stm32h7xx_it.h create mode 100644 ACDC/Core/Src/ACDC.cpp create mode 100644 ACDC/Core/Src/freertos.c create mode 100644 ACDC/Core/Src/main.c create mode 100644 ACDC/Core/Src/stm32h7xx_hal_msp.c create mode 100644 ACDC/Core/Src/stm32h7xx_it.c create mode 100644 ACDC/Core/Src/system_stm32h7xx.c create mode 100644 ACDC/Makefile create mode 100644 ACDC/USB_DEVICE/App/usb_device.c create mode 100644 ACDC/USB_DEVICE/App/usb_device.h create mode 100644 ACDC/USB_DEVICE/App/usbd_desc.c create mode 100644 ACDC/USB_DEVICE/App/usbd_desc.h create mode 100644 ACDC/USB_DEVICE/Target/usbd_conf.c create mode 100644 ACDC/USB_DEVICE/Target/usbd_conf.h diff --git a/ACDC/ACDC.ioc b/ACDC/ACDC.ioc new file mode 100644 index 00000000..9041930a --- /dev/null +++ b/ACDC/ACDC.ioc @@ -0,0 +1,888 @@ +#MicroXplorer Configuration settings - do not modify +ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_10 +ADC1.Channel-1\#ChannelRegularConversion=ADC_CHANNEL_14 +ADC1.Channel-2\#ChannelRegularConversion=ADC_CHANNEL_5 +ADC1.Channel-3\#ChannelRegularConversion=ADC_CHANNEL_8 +ADC1.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV4 +ADC1.ContinuousConvMode=ENABLE +ADC1.ConversionDataManagement=ADC_CONVERSIONDATA_DMA_CIRCULAR +ADC1.EOCSelection=ADC_EOC_SEQ_CONV +ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,NbrOfConversion,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,OffsetNumber-1\#ChannelRegularConversion,OffsetSignedSaturation-1\#ChannelRegularConversion,Rank-2\#ChannelRegularConversion,Channel-2\#ChannelRegularConversion,SamplingTime-2\#ChannelRegularConversion,OffsetNumber-2\#ChannelRegularConversion,OffsetSignedSaturation-2\#ChannelRegularConversion,Rank-3\#ChannelRegularConversion,Channel-3\#ChannelRegularConversion,SamplingTime-3\#ChannelRegularConversion,OffsetNumber-3\#ChannelRegularConversion,OffsetSignedSaturation-3\#ChannelRegularConversion,OversamplingMode,ContinuousConvMode,EOCSelection,Resolution,ClockPrescaler,master,ConversionDataManagement,Overrun +ADC1.NbrOfConversion=4 +ADC1.NbrOfConversionFlag=1 +ADC1.OffsetNumber-0\#ChannelRegularConversion=ADC_OFFSET_NONE +ADC1.OffsetNumber-1\#ChannelRegularConversion=ADC_OFFSET_NONE +ADC1.OffsetNumber-2\#ChannelRegularConversion=ADC_OFFSET_NONE +ADC1.OffsetNumber-3\#ChannelRegularConversion=ADC_OFFSET_NONE +ADC1.OffsetSignedSaturation-0\#ChannelRegularConversion=DISABLE +ADC1.OffsetSignedSaturation-1\#ChannelRegularConversion=DISABLE +ADC1.OffsetSignedSaturation-2\#ChannelRegularConversion=DISABLE +ADC1.OffsetSignedSaturation-3\#ChannelRegularConversion=DISABLE +ADC1.Overrun=ADC_OVR_DATA_OVERWRITTEN +ADC1.OversamplingMode=DISABLE +ADC1.Rank-0\#ChannelRegularConversion=1 +ADC1.Rank-1\#ChannelRegularConversion=2 +ADC1.Rank-2\#ChannelRegularConversion=3 +ADC1.Rank-3\#ChannelRegularConversion=4 +ADC1.Resolution=ADC_RESOLUTION_12B +ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_387CYCLES_5 +ADC1.SamplingTime-1\#ChannelRegularConversion=ADC_SAMPLETIME_387CYCLES_5 +ADC1.SamplingTime-2\#ChannelRegularConversion=ADC_SAMPLETIME_387CYCLES_5 +ADC1.SamplingTime-3\#ChannelRegularConversion=ADC_SAMPLETIME_387CYCLES_5 +ADC1.master=1 +Dma.ADC1.3.Direction=DMA_PERIPH_TO_MEMORY +Dma.ADC1.3.EventEnable=DISABLE +Dma.ADC1.3.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.ADC1.3.Instance=DMA1_Stream3 +Dma.ADC1.3.MemDataAlignment=DMA_MDATAALIGN_HALFWORD +Dma.ADC1.3.MemInc=DMA_MINC_ENABLE +Dma.ADC1.3.Mode=DMA_CIRCULAR +Dma.ADC1.3.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD +Dma.ADC1.3.PeriphInc=DMA_PINC_DISABLE +Dma.ADC1.3.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.ADC1.3.Priority=DMA_PRIORITY_LOW +Dma.ADC1.3.RequestNumber=1 +Dma.ADC1.3.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.ADC1.3.SignalID=NONE +Dma.ADC1.3.SyncEnable=DISABLE +Dma.ADC1.3.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.ADC1.3.SyncRequestNumber=1 +Dma.ADC1.3.SyncSignalID=NONE +Dma.Request0=SAI1_A +Dma.Request1=SAI1_B +Dma.Request2=SPI3_TX +Dma.Request3=ADC1 +Dma.RequestsNb=4 +Dma.SAI1_A.0.Direction=DMA_PERIPH_TO_MEMORY +Dma.SAI1_A.0.EventEnable=DISABLE +Dma.SAI1_A.0.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SAI1_A.0.Instance=DMA1_Stream0 +Dma.SAI1_A.0.MemDataAlignment=DMA_MDATAALIGN_WORD +Dma.SAI1_A.0.MemInc=DMA_MINC_ENABLE +Dma.SAI1_A.0.Mode=DMA_CIRCULAR +Dma.SAI1_A.0.PeriphDataAlignment=DMA_PDATAALIGN_WORD +Dma.SAI1_A.0.PeriphInc=DMA_PINC_DISABLE +Dma.SAI1_A.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.SAI1_A.0.Priority=DMA_PRIORITY_VERY_HIGH +Dma.SAI1_A.0.RequestNumber=1 +Dma.SAI1_A.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.SAI1_A.0.SignalID=NONE +Dma.SAI1_A.0.SyncEnable=DISABLE +Dma.SAI1_A.0.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.SAI1_A.0.SyncRequestNumber=1 +Dma.SAI1_A.0.SyncSignalID=NONE +Dma.SAI1_B.1.Direction=DMA_MEMORY_TO_PERIPH +Dma.SAI1_B.1.EventEnable=DISABLE +Dma.SAI1_B.1.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SAI1_B.1.Instance=DMA1_Stream1 +Dma.SAI1_B.1.MemDataAlignment=DMA_MDATAALIGN_WORD +Dma.SAI1_B.1.MemInc=DMA_MINC_ENABLE +Dma.SAI1_B.1.Mode=DMA_CIRCULAR +Dma.SAI1_B.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD +Dma.SAI1_B.1.PeriphInc=DMA_PINC_DISABLE +Dma.SAI1_B.1.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.SAI1_B.1.Priority=DMA_PRIORITY_VERY_HIGH +Dma.SAI1_B.1.RequestNumber=1 +Dma.SAI1_B.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.SAI1_B.1.SignalID=NONE +Dma.SAI1_B.1.SyncEnable=DISABLE +Dma.SAI1_B.1.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.SAI1_B.1.SyncRequestNumber=1 +Dma.SAI1_B.1.SyncSignalID=NONE +Dma.SPI3_TX.2.Direction=DMA_MEMORY_TO_PERIPH +Dma.SPI3_TX.2.EventEnable=DISABLE +Dma.SPI3_TX.2.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SPI3_TX.2.Instance=DMA1_Stream2 +Dma.SPI3_TX.2.MemDataAlignment=DMA_MDATAALIGN_BYTE +Dma.SPI3_TX.2.MemInc=DMA_MINC_ENABLE +Dma.SPI3_TX.2.Mode=DMA_NORMAL +Dma.SPI3_TX.2.PeriphDataAlignment=DMA_PDATAALIGN_BYTE +Dma.SPI3_TX.2.PeriphInc=DMA_PINC_DISABLE +Dma.SPI3_TX.2.Polarity=HAL_DMAMUX_REQ_GEN_RISING +Dma.SPI3_TX.2.Priority=DMA_PRIORITY_LOW +Dma.SPI3_TX.2.RequestNumber=1 +Dma.SPI3_TX.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber +Dma.SPI3_TX.2.SignalID=NONE +Dma.SPI3_TX.2.SyncEnable=DISABLE +Dma.SPI3_TX.2.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT +Dma.SPI3_TX.2.SyncRequestNumber=1 +Dma.SPI3_TX.2.SyncSignalID=NONE +FREERTOS.FootprintOK=true +FREERTOS.INCLUDE_vTaskDelayUntil=1 +FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configUSE_IDLE_HOOK,configUSE_TICK_HOOK,configUSE_MALLOC_FAILED_HOOK,INCLUDE_vTaskDelayUntil,configUSE_MUTEXES,configCHECK_FOR_STACK_OVERFLOW,FootprintOK +FREERTOS.Tasks01=defaultTask,0,1024,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL +FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 +FREERTOS.configUSE_IDLE_HOOK=0 +FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 +FREERTOS.configUSE_MUTEXES=0 +FREERTOS.configUSE_PREEMPTION=0 +FREERTOS.configUSE_TICK_HOOK=0 +File.Version=6 +GPIO.groupedBy=Group By Peripherals +KeepUserPlacement=false +Mcu.Family=STM32H7 +Mcu.IP0=ADC1 +Mcu.IP1=CORTEX_M7 +Mcu.IP10=SAI1 +Mcu.IP11=SPI2 +Mcu.IP12=SPI3 +Mcu.IP13=SYS +Mcu.IP14=TIM2 +Mcu.IP15=TIM3 +Mcu.IP16=TIM4 +Mcu.IP17=UART5 +Mcu.IP18=UART7 +Mcu.IP19=USB_DEVICE +Mcu.IP2=DEBUG +Mcu.IP20=USB_OTG_FS +Mcu.IP3=DMA +Mcu.IP4=FMC +Mcu.IP5=FREERTOS +Mcu.IP6=LPTIM1 +Mcu.IP7=NVIC +Mcu.IP8=QUADSPI +Mcu.IP9=RCC +Mcu.IPNb=21 +Mcu.Name=STM32H743IIKx +Mcu.Package=UFBGA176 +Mcu.Pin0=PE3 +Mcu.Pin1=PE2 +Mcu.Pin10=PE4 +Mcu.Pin100=PE14 +Mcu.Pin101=PD9 +Mcu.Pin102=PD8 +Mcu.Pin103=PA3 +Mcu.Pin104=PA7 +Mcu.Pin105=PB1 +Mcu.Pin106=PB0 +Mcu.Pin107=PF11 +Mcu.Pin108=PF14 +Mcu.Pin109=PE7 +Mcu.Pin11=PE5 +Mcu.Pin110=PE10 +Mcu.Pin111=PE12 +Mcu.Pin112=PE15 +Mcu.Pin113=PB10 +Mcu.Pin114=PB11 +Mcu.Pin115=VP_FREERTOS_VS_CMSIS_V1 +Mcu.Pin116=VP_SYS_VS_Systick +Mcu.Pin117=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS +Mcu.Pin12=PE6 +Mcu.Pin13=PB7 +Mcu.Pin14=PB6 +Mcu.Pin15=PG15 +Mcu.Pin16=PG12 +Mcu.Pin17=PG11 +Mcu.Pin18=PG10 +Mcu.Pin19=PD0 +Mcu.Pin2=PE1 +Mcu.Pin20=PC10 +Mcu.Pin21=PA12 +Mcu.Pin22=PI7 +Mcu.Pin23=PI6 +Mcu.Pin24=PI5 +Mcu.Pin25=PD1 +Mcu.Pin26=PI3 +Mcu.Pin27=PI2 +Mcu.Pin28=PA11 +Mcu.Pin29=PC13 +Mcu.Pin3=PE0 +Mcu.Pin30=PI9 +Mcu.Pin31=PI4 +Mcu.Pin32=PD2 +Mcu.Pin33=PH15 +Mcu.Pin34=PI1 +Mcu.Pin35=PC14-OSC32_IN (OSC32_IN) +Mcu.Pin36=PF0 +Mcu.Pin37=PI10 +Mcu.Pin38=PI11 +Mcu.Pin39=PH13 +Mcu.Pin4=PB5 +Mcu.Pin40=PH14 +Mcu.Pin41=PI0 +Mcu.Pin42=PA9 +Mcu.Pin43=PC15-OSC32_OUT (OSC32_OUT) +Mcu.Pin44=PH2 +Mcu.Pin45=PC9 +Mcu.Pin46=PA8 +Mcu.Pin47=PH0-OSC_IN (PH0) +Mcu.Pin48=PH3 +Mcu.Pin49=PC8 +Mcu.Pin5=PB3 (JTDO/TRACESWO) +Mcu.Pin50=PC7 +Mcu.Pin51=PH1-OSC_OUT (PH1) +Mcu.Pin52=PF2 +Mcu.Pin53=PF1 +Mcu.Pin54=PH4 +Mcu.Pin55=PG8 +Mcu.Pin56=PC6 +Mcu.Pin57=PF3 +Mcu.Pin58=PF4 +Mcu.Pin59=PH5 +Mcu.Pin6=PC12 +Mcu.Pin60=PG7 +Mcu.Pin61=PG6 +Mcu.Pin62=PF7 +Mcu.Pin63=PF6 +Mcu.Pin64=PF5 +Mcu.Pin65=PH12 +Mcu.Pin66=PG5 +Mcu.Pin67=PG4 +Mcu.Pin68=PG3 +Mcu.Pin69=PF10 +Mcu.Pin7=PA15 (JTDI) +Mcu.Pin70=PF9 +Mcu.Pin71=PF8 +Mcu.Pin72=PH11 +Mcu.Pin73=PH10 +Mcu.Pin74=PD15 +Mcu.Pin75=PG2 +Mcu.Pin76=PC0 +Mcu.Pin77=PC1 +Mcu.Pin78=PC2_C +Mcu.Pin79=PC3_C +Mcu.Pin8=PA14 (JTCK/SWCLK) +Mcu.Pin80=PG1 +Mcu.Pin81=PH8 +Mcu.Pin82=PH9 +Mcu.Pin83=PD14 +Mcu.Pin84=PD13 +Mcu.Pin85=PA1 +Mcu.Pin86=PA0 +Mcu.Pin87=PF13 +Mcu.Pin88=PG0 +Mcu.Pin89=PE13 +Mcu.Pin9=PA13 (JTMS/SWDIO) +Mcu.Pin90=PD12 +Mcu.Pin91=PD10 +Mcu.Pin92=PA2 +Mcu.Pin93=PA6 +Mcu.Pin94=PC5 +Mcu.Pin95=PF12 +Mcu.Pin96=PF15 +Mcu.Pin97=PE8 +Mcu.Pin98=PE9 +Mcu.Pin99=PE11 +Mcu.PinsNb=118 +Mcu.ThirdPartyNb=0 +Mcu.UserConstants= +Mcu.UserName=STM32H743IIKx +MxCube.Version=6.3.0 +MxDb.Version=DB.6.0.30 +NVIC.ADC_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false +NVIC.DMA1_Stream0_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.DMA1_Stream1_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.DMA1_Stream2_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.DMA1_Stream3_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false +NVIC.EXTI15_10_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.EXTI2_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.EXTI9_5_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.ForceEnableDMAVector=true +NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false +NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false +NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false +NVIC.OTG_FS_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:false +NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 +NVIC.QUADSPI_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.SAI1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.SPI3_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true +NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false +NVIC.SavedPendsvIrqHandlerGenerated=true +NVIC.SavedSvcallIrqHandlerGenerated=true +NVIC.SavedSystickIrqHandlerGenerated=true +NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:false\:true +NVIC.TIM4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false +PA0.Locked=true +PA0.Signal=GPIO_Input +PA1.Signal=S_TIM2_CH2 +PA11.Mode=Device_Only +PA11.Signal=USB_OTG_FS_DM +PA12.Mode=Device_Only +PA12.Signal=USB_OTG_FS_DP +PA13\ (JTMS/SWDIO).Mode=Trace_Asynchronous_SW +PA13\ (JTMS/SWDIO).Signal=DEBUG_JTMS-SWDIO +PA14\ (JTCK/SWCLK).Mode=Trace_Asynchronous_SW +PA14\ (JTCK/SWCLK).Signal=DEBUG_JTCK-SWCLK +PA15\ (JTDI).Signal=S_TIM2_CH1 +PA2.GPIOParameters=GPIO_Label +PA2.GPIO_Label=ADC2 +PA2.Signal=ADCx_INP14 +PA3.Locked=true +PA3.Signal=GPIO_Output +PA6.Locked=true +PA6.Signal=GPIO_Input +PA7.Locked=true +PA7.Signal=GPIO_Output +PA8.Mode=Asynchronous +PA8.Signal=UART7_RX +PA9.Mode=Activate_VBUS +PA9.Signal=USB_OTG_FS_VBUS +PB0.GPIOParameters=GPIO_Label +PB0.GPIO_Label=ADC7 +PB0.Signal=ADCx_INP9 +PB1.GPIOParameters=GPIO_Label +PB1.GPIO_Label=ADC3 +PB1.Signal=ADCx_INP5 +PB10.GPIOParameters=GPIO_Speed,GPIO_Label +PB10.GPIO_Label=ADC_SPI_CLK +PB10.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PB10.Locked=true +PB10.Mode=Full_Duplex_Master +PB10.Signal=SPI2_SCK +PB11.GPIOParameters=GPIO_Label +PB11.GPIO_Label=ADC_SPI_NCS +PB11.Locked=true +PB11.Signal=GPIO_Output +PB3\ (JTDO/TRACESWO).Mode=Trace_Asynchronous_SW +PB3\ (JTDO/TRACESWO).Signal=DEBUG_JTDO-SWO +PB5.Mode=Asynchronous +PB5.Signal=UART5_RX +PB6.Mode=Asynchronous +PB6.Signal=UART5_TX +PB7.Locked=true +PB7.Signal=I2C1_SDA +PC0.GPIOParameters=GPIO_Label +PC0.GPIO_Label=ADC1 +PC0.Signal=ADCx_INP10 +PC1.GPIOParameters=GPIO_Label +PC1.GPIO_Label=ADC5 +PC1.Signal=ADCx_INP11 +PC10.GPIOParameters=GPIO_Speed +PC10.GPIO_Speed=GPIO_SPEED_FREQ_HIGH +PC10.Locked=true +PC10.Signal=SharedStack_PC10 +PC10.Stacked=true +PC12.GPIOParameters=GPIO_Speed +PC12.GPIO_Speed=GPIO_SPEED_FREQ_HIGH +PC12.Locked=true +PC12.Signal=SharedStack_PC12 +PC12.Stacked=true +PC13.GPIOParameters=GPIO_Label +PC13.GPIO_Label=EXTI13 +PC13.Locked=true +PC13.Signal=GPXTI13 +PC14-OSC32_IN\ (OSC32_IN).GPIOParameters=GPIO_Label +PC14-OSC32_IN\ (OSC32_IN).GPIO_Label=EXTI14 +PC14-OSC32_IN\ (OSC32_IN).Locked=true +PC14-OSC32_IN\ (OSC32_IN).Signal=GPXTI14 +PC15-OSC32_OUT\ (OSC32_OUT).Locked=true +PC15-OSC32_OUT\ (OSC32_OUT).Signal=GPIO_Input +PC2_C.GPIOParameters=GPIO_Speed,GPIO_Label +PC2_C.GPIO_Label=ADC_SPI_MISO +PC2_C.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PC2_C.Mode=Full_Duplex_Master +PC2_C.Signal=SPI2_MISO +PC3_C.GPIOParameters=GPIO_Speed,GPIO_Label +PC3_C.GPIO_Label=ADC_SPI_MOSI +PC3_C.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PC3_C.Mode=Full_Duplex_Master +PC3_C.Signal=SPI2_MOSI +PC5.GPIOParameters=GPIO_Label +PC5.GPIO_Label=ADC4 +PC5.Signal=ADCx_INP8 +PC6.Signal=S_TIM3_CH1 +PC7.Signal=S_TIM3_CH2 +PC8.GPIOParameters=GPIO_Label +PC8.GPIO_Label=EXTI8 +PC8.Locked=true +PC8.Signal=SharedStack_PC8 +PC8.Stacked=true +PC9.GPIOParameters=GPIO_Label +PC9.GPIO_Label=EXTI9 +PC9.Locked=true +PC9.Signal=SharedStack_PC9 +PC9.Stacked=true +PD0.Signal=FMC_D2_DA2 +PD1.Signal=FMC_D3_DA3 +PD10.Signal=FMC_D15_DA15 +PD12.GPIOParameters=GPIO_PuPd +PD12.GPIO_PuPd=GPIO_PULLUP +PD12.Signal=S_TIM4_CH1 +PD13.GPIOParameters=GPIO_PuPd +PD13.GPIO_PuPd=GPIO_PULLUP +PD13.Signal=S_TIM4_CH2 +PD14.Signal=FMC_D0_DA0 +PD15.Signal=FMC_D1_DA1 +PD2.GPIOParameters=GPIO_Label +PD2.GPIO_Label=EXTI2 +PD2.Locked=true +PD2.Signal=SharedStack_PD2 +PD2.Stacked=true +PD8.Signal=FMC_D13_DA13 +PD9.Signal=FMC_D14_DA14 +PE0.Signal=FMC_NBL0 +PE1.Signal=FMC_NBL1 +PE10.Signal=FMC_D7_DA7 +PE11.Signal=FMC_D8_DA8 +PE12.Signal=FMC_D9_DA9 +PE13.Signal=FMC_D10_DA10 +PE14.Signal=FMC_D11_DA11 +PE15.Signal=FMC_D12_DA12 +PE2.GPIOParameters=GPIO_Speed,GPIO_Label +PE2.GPIO_Label=FLASH_DQ2 +PE2.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PE2.Mode=Single Bank 1 +PE2.Signal=QUADSPI_BK1_IO2 +PE3.GPIOParameters=GPIO_Speed +PE3.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PE3.Mode=SAI_B_SyncSlave +PE3.Signal=SAI1_SD_B +PE4.GPIOParameters=GPIO_Speed +PE4.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PE4.Mode=SAI_A_MasterWithClock +PE4.Signal=SAI1_FS_A +PE5.GPIOParameters=GPIO_Speed +PE5.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PE5.Mode=SAI_A_MasterWithClock +PE5.Signal=SAI1_SCK_A +PE6.GPIOParameters=GPIO_Speed +PE6.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PE6.Mode=SAI_A_MasterWithClock +PE6.Signal=SAI1_SD_A +PE7.Signal=FMC_D4_DA4 +PE8.Signal=FMC_D5_DA5 +PE9.Signal=FMC_D6_DA6 +PF0.Signal=FMC_A0 +PF1.Signal=FMC_A1 +PF10.GPIOParameters=GPIO_Speed,GPIO_Label +PF10.GPIO_Label=FLASH_CLK +PF10.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PF10.Mode=Single Bank 1 +PF10.Signal=QUADSPI_CLK +PF11.Signal=FMC_SDNRAS +PF12.Signal=FMC_A6 +PF13.Signal=FMC_A7 +PF14.Signal=FMC_A8 +PF15.Signal=FMC_A9 +PF2.Signal=FMC_A2 +PF3.Signal=FMC_A3 +PF4.Signal=FMC_A4 +PF5.Signal=FMC_A5 +PF6.GPIOParameters=GPIO_Speed,GPIO_Label +PF6.GPIO_Label=FLASH_DQ3 +PF6.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PF6.Mode=Single Bank 1 +PF6.Signal=QUADSPI_BK1_IO3 +PF7.Mode=Asynchronous +PF7.Signal=UART7_TX +PF8.GPIOParameters=GPIO_Speed,GPIO_Label +PF8.GPIO_Label=FLASH_DQ0 +PF8.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PF8.Mode=Single Bank 1 +PF8.Signal=QUADSPI_BK1_IO0 +PF9.GPIOParameters=GPIO_Speed,GPIO_Label +PF9.GPIO_Label=FLASH_DQ1 +PF9.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PF9.Mode=Single Bank 1 +PF9.Signal=QUADSPI_BK1_IO1 +PG0.Signal=FMC_A10 +PG1.Signal=FMC_A11 +PG10.Locked=true +PG10.Signal=GPIO_Input +PG11.Mode=Encoder_mode_occur1 +PG11.Signal=LPTIM1_IN2 +PG12.Mode=Encoder_mode_occur1 +PG12.Signal=LPTIM1_IN1 +PG15.Signal=FMC_SDNCAS +PG2.Signal=FMC_A12 +PG3.GPIOParameters=GPIO_Label +PG3.GPIO_Label=ADC_RST +PG3.Locked=true +PG3.Signal=GPIO_Output +PG4.Signal=FMC_A14_BA0 +PG5.Signal=FMC_A15_BA1 +PG6.GPIOParameters=GPIO_Speed,GPIO_Label +PG6.GPIO_Label=FLASH_NCS +PG6.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PG6.Mode=Single Bank 1 +PG6.Signal=QUADSPI_BK1_NCS +PG7.GPIOParameters=GPIO_Speed +PG7.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH +PG7.Mode=SAI_A_MasterWithClock +PG7.Signal=SAI1_MCLK_A +PG8.Signal=FMC_SDCLK +PH0-OSC_IN\ (PH0).Mode=HSE-External-Oscillator +PH0-OSC_IN\ (PH0).Signal=RCC_OSC_IN +PH1-OSC_OUT\ (PH1).Mode=HSE-External-Oscillator +PH1-OSC_OUT\ (PH1).Signal=RCC_OSC_OUT +PH10.Signal=FMC_D18 +PH11.Signal=FMC_D19 +PH12.Signal=FMC_D20 +PH13.Signal=FMC_D21 +PH14.Signal=FMC_D22 +PH15.Signal=FMC_D23 +PH2.Mode=SdramChipSelect1_1 +PH2.Signal=FMC_SDCKE0 +PH3.Mode=SdramChipSelect1_1 +PH3.Signal=FMC_SDNE0 +PH4.Locked=true +PH4.Signal=GPIO_Output +PH5.Signal=FMC_SDNWE +PH8.Signal=FMC_D16 +PH9.Signal=FMC_D17 +PI0.Signal=FMC_D24 +PI1.Signal=FMC_D25 +PI10.Signal=FMC_D31 +PI11.Locked=true +PI11.Signal=GPIO_Output +PI2.Signal=FMC_D26 +PI3.Signal=FMC_D27 +PI4.Signal=FMC_NBL2 +PI5.Signal=FMC_NBL3 +PI6.Signal=FMC_D28 +PI7.Signal=FMC_D29 +PI9.Signal=FMC_D30 +PinOutPanel.CurrentBGAView=Top +PinOutPanel.RotationAngle=0 +ProjectManager.AskForMigrate=true +ProjectManager.BackupPrevious=false +ProjectManager.CompilerOptimize=6 +ProjectManager.ComputerToolchain=false +ProjectManager.CoupleFile=false +ProjectManager.CustomerFirmwarePackage= +ProjectManager.DefaultFWLocation=true +ProjectManager.DeletePrevious=true +ProjectManager.DeviceId=STM32H743IIKx +ProjectManager.FirmwarePackage=STM32Cube FW_H7 V1.9.0 +ProjectManager.FreePins=true +ProjectManager.HalAssertFull=true +ProjectManager.HeapSize=0x200 +ProjectManager.KeepUserCode=true +ProjectManager.LastFirmware=true +ProjectManager.LibraryCopy=1 +ProjectManager.MainLocation=Core/Src +ProjectManager.NoMain=false +ProjectManager.PreviousToolchain= +ProjectManager.ProjectBuild=false +ProjectManager.ProjectFileName=ACDC.ioc +ProjectManager.ProjectName=ACDC +ProjectManager.RegisterCallBack= +ProjectManager.StackSize=0x400 +ProjectManager.TargetToolchain=Other Toolchains (GPDSC) +ProjectManager.ToolChainLocation= +ProjectManager.UnderRoot=false +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_QUADSPI_Init-QUADSPI-false-HAL-true,5-MX_FMC_Init-FMC-false-HAL-true,6-MX_SAI1_Init-SAI1-false-HAL-true,7-MX_ADC1_Init-ADC1-false-HAL-true,8-MX_SPI2_Init-SPI2-false-HAL-true,9-MX_SPI3_Init-SPI3-false-HAL-true,10-MX_TIM2_Init-TIM2-false-HAL-true,11-MX_TIM3_Init-TIM3-false-HAL-true,12-MX_TIM4_Init-TIM4-false-HAL-true,13-MX_UART5_Init-UART5-false-HAL-true,14-MX_UART7_Init-UART7-false-HAL-true,15-MX_LPTIM1_Init-LPTIM1-false-HAL-true,16-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true +QUADSPI.ClockPrescaler=9 +QUADSPI.FifoThreshold=4 +QUADSPI.FlashSize=22 +QUADSPI.IPParameters=ClockPrescaler,FifoThreshold,FlashSize +RCC.ADCFreq_Value=25000000 +RCC.AHB12Freq_Value=240000000 +RCC.AHB4Freq_Value=240000000 +RCC.APB1Freq_Value=120000000 +RCC.APB2Freq_Value=120000000 +RCC.APB3Freq_Value=120000000 +RCC.APB4Freq_Value=120000000 +RCC.AXIClockFreq_Value=240000000 +RCC.CECFreq_Value=32000 +RCC.CKPERFreq_Value=64000000 +RCC.CortexFreq_Value=480000000 +RCC.CpuClockFreq_Value=480000000 +RCC.D1CPREFreq_Value=480000000 +RCC.D1PPRE=RCC_APB3_DIV2 +RCC.D2PPRE1=RCC_APB1_DIV2 +RCC.D2PPRE2=RCC_APB2_DIV2 +RCC.D3PPRE=RCC_APB4_DIV2 +RCC.DFSDMACLkFreq_Value=98285714.2857143 +RCC.DFSDMFreq_Value=120000000 +RCC.DIVM1=1 +RCC.DIVM2=1 +RCC.DIVM3=7 +RCC.DIVN1=120 +RCC.DIVN2=18 +RCC.DIVN3=172 +RCC.DIVP1Freq_Value=480000000 +RCC.DIVP2=6 +RCC.DIVP2Freq_Value=25000000 +RCC.DIVP3Freq_Value=98285714.2857143 +RCC.DIVQ1=5 +RCC.DIVQ1Freq_Value=192000000 +RCC.DIVQ2Freq_Value=75000000 +RCC.DIVQ3Freq_Value=98285714.2857143 +RCC.DIVR1Freq_Value=480000000 +RCC.DIVR2Freq_Value=75000000 +RCC.DIVR3Freq_Value=98285714.2857143 +RCC.FDCANFreq_Value=192000000 +RCC.FMCFreq_Value=240000000 +RCC.FamilyName=M +RCC.HCLK3ClockFreq_Value=240000000 +RCC.HCLKFreq_Value=240000000 +RCC.HPRE=RCC_HCLK_DIV2 +RCC.HRTIMFreq_Value=240000000 +RCC.HSE_VALUE=8000000 +RCC.I2C123Freq_Value=120000000 +RCC.I2C4Freq_Value=120000000 +RCC.IPParameters=ADCFreq_Value,AHB12Freq_Value,AHB4Freq_Value,APB1Freq_Value,APB2Freq_Value,APB3Freq_Value,APB4Freq_Value,AXIClockFreq_Value,CECFreq_Value,CKPERFreq_Value,CortexFreq_Value,CpuClockFreq_Value,D1CPREFreq_Value,D1PPRE,D2PPRE1,D2PPRE2,D3PPRE,DFSDMACLkFreq_Value,DFSDMFreq_Value,DIVM1,DIVM2,DIVM3,DIVN1,DIVN2,DIVN3,DIVP1Freq_Value,DIVP2,DIVP2Freq_Value,DIVP3Freq_Value,DIVQ1,DIVQ1Freq_Value,DIVQ2Freq_Value,DIVQ3Freq_Value,DIVR1Freq_Value,DIVR2Freq_Value,DIVR3Freq_Value,FDCANFreq_Value,FMCFreq_Value,FamilyName,HCLK3ClockFreq_Value,HCLKFreq_Value,HPRE,HRTIMFreq_Value,HSE_VALUE,I2C123Freq_Value,I2C4Freq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPTIM345Freq_Value,LPUART1Freq_Value,LTDCFreq_Value,MCO1PinFreq_Value,MCO2PinFreq_Value,PLL2FRACN,PLL3FRACN,PLLFRACN,PLLSourceVirtual,PWR_Regulator_Voltage_Scale,QSPIFreq_Value,RNGFreq_Value,RTCFreq_Value,SAI1CLockSelection,SAI1Freq_Value,SAI23Freq_Value,SAI4AFreq_Value,SAI4BFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SPI123CLockSelection,SPI123Freq_Value,SPI45Freq_Value,SPI6Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,Tim1OutputFreq_Value,Tim2OutputFreq_Value,TraceFreq_Value,USART16Freq_Value,USART234578Freq_Value,USBCLockSelection,USBFreq_Value,VCO1OutputFreq_Value,VCO2OutputFreq_Value,VCO3OutputFreq_Value,VCOInput1Freq_Value,VCOInput2Freq_Value,VCOInput3Freq_Value +RCC.LPTIM1Freq_Value=120000000 +RCC.LPTIM2Freq_Value=120000000 +RCC.LPTIM345Freq_Value=120000000 +RCC.LPUART1Freq_Value=120000000 +RCC.LTDCFreq_Value=98285714.2857143 +RCC.MCO1PinFreq_Value=64000000 +RCC.MCO2PinFreq_Value=480000000 +RCC.PLL2FRACN=6144 +RCC.PLL3FRACN=0 +RCC.PLLFRACN=0 +RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE +RCC.PWR_Regulator_Voltage_Scale=PWR_REGULATOR_VOLTAGE_SCALE0 +RCC.QSPIFreq_Value=240000000 +RCC.RNGFreq_Value=48000000 +RCC.RTCFreq_Value=32000 +RCC.SAI1CLockSelection=RCC_SAI1CLKSOURCE_PLL3 +RCC.SAI1Freq_Value=98285714.2857143 +RCC.SAI23Freq_Value=192000000 +RCC.SAI4AFreq_Value=192000000 +RCC.SAI4BFreq_Value=192000000 +RCC.SDMMCFreq_Value=192000000 +RCC.SPDIFRXFreq_Value=192000000 +RCC.SPI123CLockSelection=RCC_SPI123CLKSOURCE_PLL2 +RCC.SPI123Freq_Value=25000000 +RCC.SPI45Freq_Value=120000000 +RCC.SPI6Freq_Value=120000000 +RCC.SWPMI1Freq_Value=120000000 +RCC.SYSCLKFreq_VALUE=480000000 +RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK +RCC.Tim1OutputFreq_Value=240000000 +RCC.Tim2OutputFreq_Value=240000000 +RCC.TraceFreq_Value=480000000 +RCC.USART16Freq_Value=120000000 +RCC.USART234578Freq_Value=120000000 +RCC.USBCLockSelection=RCC_USBCLKSOURCE_HSI48 +RCC.USBFreq_Value=48000000 +RCC.VCO1OutputFreq_Value=960000000 +RCC.VCO2OutputFreq_Value=150000000 +RCC.VCO3OutputFreq_Value=196571428.5714286 +RCC.VCOInput1Freq_Value=8000000 +RCC.VCOInput2Freq_Value=8000000 +RCC.VCOInput3Freq_Value=1142857.142857143 +SAI1.ActiveFrameLength-SAI_A_MasterWithClock=128 +SAI1.ActiveFrameLength-SAI_B_SyncSlave=128 +SAI1.AudioFrequency-SAI_A_MasterWithClock=SAI_AUDIO_FREQUENCY_48K +SAI1.AudioMode-SAI_A_MasterWithClock=SAI_MODEMASTER_RX +SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_TX +SAI1.ClockStrobing-SAI_A_MasterWithClock=SAI_CLOCKSTROBING_RISINGEDGE +SAI1.DataSize-SAI_A_MasterWithClock=SAI_DATASIZE_24 +SAI1.DataSize-SAI_B_SyncSlave=SAI_DATASIZE_24 +SAI1.ErrorAudioFreq-SAI_A_MasterWithClock=-0.01 % +SAI1.FSDefinition-SAI_A_MasterWithClock=SAI_FS_CHANNEL_IDENTIFICATION +SAI1.FSDefinition-SAI_B_SyncSlave=SAI_FS_CHANNEL_IDENTIFICATION +SAI1.FSOffset-SAI_A_MasterWithClock=SAI_FS_BEFOREFIRSTBIT +SAI1.FSOffset-SAI_B_SyncSlave=SAI_FS_BEFOREFIRSTBIT +SAI1.FSPolarity-SAI_A_MasterWithClock=SAI_FS_ACTIVE_HIGH +SAI1.FSPolarity-SAI_B_SyncSlave=SAI_FS_ACTIVE_HIGH +SAI1.FrameLength-SAI_A_MasterWithClock=256 +SAI1.FrameLength-SAI_B_SyncSlave=256 +SAI1.IPParameters=Instance-SAI_A_MasterWithClock,VirtualMode-SAI_A_MasterWithClock,MClockEnable-SAI_A_MasterWithClock,RealAudioFreq-SAI_A_MasterWithClock,ErrorAudioFreq-SAI_A_MasterWithClock,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,FrameLength-SAI_A_MasterWithClock,FrameLength-SAI_B_SyncSlave,DataSize-SAI_A_MasterWithClock,SlotSize-SAI_A_MasterWithClock,SlotSize-SAI_B_SyncSlave,SlotNumber-SAI_A_MasterWithClock,AudioFrequency-SAI_A_MasterWithClock,DataSize-SAI_B_SyncSlave,SlotNumber-SAI_B_SyncSlave,AudioMode-SAI_A_MasterWithClock,AudioMode-SAI_B_SyncSlave,FSOffset-SAI_A_MasterWithClock,FSOffset-SAI_B_SyncSlave,FSPolarity-SAI_A_MasterWithClock,FSPolarity-SAI_B_SyncSlave,VirtualSlotActive-SAI_A_MasterWithClock,SlotActive-SAI_A_MasterWithClock,NoDivider-SAI_A_MasterWithClock,ClockStrobing-SAI_A_MasterWithClock,OutputDrive-SAI_A_MasterWithClock,VirtualSlotActive-SAI_B_SyncSlave,SlotActive-SAI_B_SyncSlave,OutputDrive-SAI_B_SyncSlave,FSDefinition-SAI_A_MasterWithClock,FSDefinition-SAI_B_SyncSlave,ActiveFrameLength-SAI_A_MasterWithClock,ActiveFrameLength-SAI_B_SyncSlave +SAI1.Instance-SAI_A_MasterWithClock=SAI$Index_Block_A +SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B +SAI1.MClockEnable-SAI_A_MasterWithClock=SAI_MASTERCLOCK_ENABLE +SAI1.NoDivider-SAI_A_MasterWithClock=SAI_MASTERDIVIDER_ENABLE +SAI1.OutputDrive-SAI_A_MasterWithClock=SAI_OUTPUTDRIVE_ENABLE +SAI1.OutputDrive-SAI_B_SyncSlave=SAI_OUTPUTDRIVE_ENABLE +SAI1.RealAudioFreq-SAI_A_MasterWithClock=47.991 KHz +SAI1.SlotActive-SAI_A_MasterWithClock=0x0000FFFF +SAI1.SlotActive-SAI_B_SyncSlave=0x0000FFFF +SAI1.SlotNumber-SAI_A_MasterWithClock=8 +SAI1.SlotNumber-SAI_B_SyncSlave=8 +SAI1.SlotSize-SAI_A_MasterWithClock=SAI_SLOTSIZE_32B +SAI1.SlotSize-SAI_B_SyncSlave=SAI_SLOTSIZE_32B +SAI1.VirtualMode-SAI_A_MasterWithClock=VM_MASTER +SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE +SAI1.VirtualSlotActive-SAI_A_MasterWithClock=SAI_SLOTACTIVE_ALL +SAI1.VirtualSlotActive-SAI_B_SyncSlave=SAI_SLOTACTIVE_ALL +SH.ADCx_INP10.0=ADC1_INP10,IN10-Single-Ended +SH.ADCx_INP10.ConfNb=1 +SH.ADCx_INP11.0=ADC1_INP11,IN11-Single-Ended +SH.ADCx_INP11.ConfNb=1 +SH.ADCx_INP14.0=ADC1_INP14,IN14-Single-Ended +SH.ADCx_INP14.ConfNb=1 +SH.ADCx_INP5.0=ADC1_INP5,IN5-Single-Ended +SH.ADCx_INP5.ConfNb=1 +SH.ADCx_INP8.0=ADC1_INP8,IN8-Single-Ended +SH.ADCx_INP8.ConfNb=1 +SH.ADCx_INP9.0=ADC1_INP9,IN9-Single-Ended +SH.ADCx_INP9.ConfNb=1 +SH.FMC_A0.0=FMC_A0,13b-sda1 +SH.FMC_A0.ConfNb=1 +SH.FMC_A1.0=FMC_A1,13b-sda1 +SH.FMC_A1.ConfNb=1 +SH.FMC_A10.0=FMC_A10,13b-sda1 +SH.FMC_A10.ConfNb=1 +SH.FMC_A11.0=FMC_A11,13b-sda1 +SH.FMC_A11.ConfNb=1 +SH.FMC_A12.0=FMC_A12,13b-sda1 +SH.FMC_A12.ConfNb=1 +SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 +SH.FMC_A14_BA0.ConfNb=1 +SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 +SH.FMC_A15_BA1.ConfNb=1 +SH.FMC_A2.0=FMC_A2,13b-sda1 +SH.FMC_A2.ConfNb=1 +SH.FMC_A3.0=FMC_A3,13b-sda1 +SH.FMC_A3.ConfNb=1 +SH.FMC_A4.0=FMC_A4,13b-sda1 +SH.FMC_A4.ConfNb=1 +SH.FMC_A5.0=FMC_A5,13b-sda1 +SH.FMC_A5.ConfNb=1 +SH.FMC_A6.0=FMC_A6,13b-sda1 +SH.FMC_A6.ConfNb=1 +SH.FMC_A7.0=FMC_A7,13b-sda1 +SH.FMC_A7.ConfNb=1 +SH.FMC_A8.0=FMC_A8,13b-sda1 +SH.FMC_A8.ConfNb=1 +SH.FMC_A9.0=FMC_A9,13b-sda1 +SH.FMC_A9.ConfNb=1 +SH.FMC_D0_DA0.0=FMC_D0,sd-32b-d1 +SH.FMC_D0_DA0.ConfNb=1 +SH.FMC_D10_DA10.0=FMC_D10,sd-32b-d1 +SH.FMC_D10_DA10.ConfNb=1 +SH.FMC_D11_DA11.0=FMC_D11,sd-32b-d1 +SH.FMC_D11_DA11.ConfNb=1 +SH.FMC_D12_DA12.0=FMC_D12,sd-32b-d1 +SH.FMC_D12_DA12.ConfNb=1 +SH.FMC_D13_DA13.0=FMC_D13,sd-32b-d1 +SH.FMC_D13_DA13.ConfNb=1 +SH.FMC_D14_DA14.0=FMC_D14,sd-32b-d1 +SH.FMC_D14_DA14.ConfNb=1 +SH.FMC_D15_DA15.0=FMC_D15,sd-32b-d1 +SH.FMC_D15_DA15.ConfNb=1 +SH.FMC_D16.0=FMC_D16,sd-32b-d1 +SH.FMC_D16.ConfNb=1 +SH.FMC_D17.0=FMC_D17,sd-32b-d1 +SH.FMC_D17.ConfNb=1 +SH.FMC_D18.0=FMC_D18,sd-32b-d1 +SH.FMC_D18.ConfNb=1 +SH.FMC_D19.0=FMC_D19,sd-32b-d1 +SH.FMC_D19.ConfNb=1 +SH.FMC_D1_DA1.0=FMC_D1,sd-32b-d1 +SH.FMC_D1_DA1.ConfNb=1 +SH.FMC_D20.0=FMC_D20,sd-32b-d1 +SH.FMC_D20.ConfNb=1 +SH.FMC_D21.0=FMC_D21,sd-32b-d1 +SH.FMC_D21.ConfNb=1 +SH.FMC_D22.0=FMC_D22,sd-32b-d1 +SH.FMC_D22.ConfNb=1 +SH.FMC_D23.0=FMC_D23,sd-32b-d1 +SH.FMC_D23.ConfNb=1 +SH.FMC_D24.0=FMC_D24,sd-32b-d1 +SH.FMC_D24.ConfNb=1 +SH.FMC_D25.0=FMC_D25,sd-32b-d1 +SH.FMC_D25.ConfNb=1 +SH.FMC_D26.0=FMC_D26,sd-32b-d1 +SH.FMC_D26.ConfNb=1 +SH.FMC_D27.0=FMC_D27,sd-32b-d1 +SH.FMC_D27.ConfNb=1 +SH.FMC_D28.0=FMC_D28,sd-32b-d1 +SH.FMC_D28.ConfNb=1 +SH.FMC_D29.0=FMC_D29,sd-32b-d1 +SH.FMC_D29.ConfNb=1 +SH.FMC_D2_DA2.0=FMC_D2,sd-32b-d1 +SH.FMC_D2_DA2.ConfNb=1 +SH.FMC_D30.0=FMC_D30,sd-32b-d1 +SH.FMC_D30.ConfNb=1 +SH.FMC_D31.0=FMC_D31,sd-32b-d1 +SH.FMC_D31.ConfNb=1 +SH.FMC_D3_DA3.0=FMC_D3,sd-32b-d1 +SH.FMC_D3_DA3.ConfNb=1 +SH.FMC_D4_DA4.0=FMC_D4,sd-32b-d1 +SH.FMC_D4_DA4.ConfNb=1 +SH.FMC_D5_DA5.0=FMC_D5,sd-32b-d1 +SH.FMC_D5_DA5.ConfNb=1 +SH.FMC_D6_DA6.0=FMC_D6,sd-32b-d1 +SH.FMC_D6_DA6.ConfNb=1 +SH.FMC_D7_DA7.0=FMC_D7,sd-32b-d1 +SH.FMC_D7_DA7.ConfNb=1 +SH.FMC_D8_DA8.0=FMC_D8,sd-32b-d1 +SH.FMC_D8_DA8.ConfNb=1 +SH.FMC_D9_DA9.0=FMC_D9,sd-32b-d1 +SH.FMC_D9_DA9.ConfNb=1 +SH.FMC_NBL0.0=FMC_NBL0,Sd4ByteEnable1 +SH.FMC_NBL0.ConfNb=1 +SH.FMC_NBL1.0=FMC_NBL1,Sd4ByteEnable1 +SH.FMC_NBL1.ConfNb=1 +SH.FMC_NBL2.0=FMC_NBL2,Sd4ByteEnable1 +SH.FMC_NBL2.ConfNb=1 +SH.FMC_NBL3.0=FMC_NBL3,Sd4ByteEnable1 +SH.FMC_NBL3.ConfNb=1 +SH.FMC_SDCLK.0=FMC_SDCLK,13b-sda1 +SH.FMC_SDCLK.ConfNb=1 +SH.FMC_SDNCAS.0=FMC_SDNCAS,13b-sda1 +SH.FMC_SDNCAS.ConfNb=1 +SH.FMC_SDNRAS.0=FMC_SDNRAS,13b-sda1 +SH.FMC_SDNRAS.ConfNb=1 +SH.FMC_SDNWE.0=FMC_SDNWE,13b-sda1 +SH.FMC_SDNWE.ConfNb=1 +SH.GPXTI13.0=GPIO_EXTI13 +SH.GPXTI13.ConfNb=1 +SH.GPXTI14.0=GPIO_EXTI14 +SH.GPXTI14.ConfNb=1 +SH.S_TIM2_CH1.0=TIM2_CH1,Encoder_Interface +SH.S_TIM2_CH1.ConfNb=1 +SH.S_TIM2_CH2.0=TIM2_CH2,Encoder_Interface +SH.S_TIM2_CH2.ConfNb=1 +SH.S_TIM3_CH1.0=TIM3_CH1,Encoder_Interface +SH.S_TIM3_CH1.ConfNb=1 +SH.S_TIM3_CH2.0=TIM3_CH2,Encoder_Interface +SH.S_TIM3_CH2.ConfNb=1 +SH.S_TIM4_CH1.0=TIM4_CH1,Encoder_Interface +SH.S_TIM4_CH1.ConfNb=1 +SH.S_TIM4_CH2.0=TIM4_CH2,Encoder_Interface +SH.S_TIM4_CH2.ConfNb=1 +SH.SharedStack_PC10.0=SDMMC1_D2 +SH.SharedStack_PC10.1=SPI3_SCK,TX_Only_Simplex_Unidirect_Master +SH.SharedStack_PC10.ConfNb=2 +SH.SharedStack_PC12.0=SDMMC1_CK +SH.SharedStack_PC12.1=SPI3_MOSI,TX_Only_Simplex_Unidirect_Master +SH.SharedStack_PC12.ConfNb=2 +SH.SharedStack_PC8.0=SDMMC1_D0 +SH.SharedStack_PC8.1=GPIO_EXTI8 +SH.SharedStack_PC8.ConfNb=2 +SH.SharedStack_PC9.0=SDMMC1_D1 +SH.SharedStack_PC9.1=GPIO_EXTI9 +SH.SharedStack_PC9.ConfNb=2 +SH.SharedStack_PD2.0=SDMMC1_CMD +SH.SharedStack_PD2.1=GPIO_EXTI2 +SH.SharedStack_PD2.ConfNb=2 +SPI2.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_256 +SPI2.CLKPhase=SPI_PHASE_2EDGE +SPI2.CLKPolarity=SPI_POLARITY_HIGH +SPI2.CalculateBaudRate=97.656 KBits/s +SPI2.DataSize=SPI_DATASIZE_8BIT +SPI2.Direction=SPI_DIRECTION_2LINES +SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,DataSize,NSSPMode,CLKPolarity,CLKPhase +SPI2.Mode=SPI_MODE_MASTER +SPI2.NSSPMode=SPI_NSS_PULSE_DISABLE +SPI2.VirtualType=VM_MASTER +SPI3.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_16 +SPI3.CalculateBaudRate=1.5625 MBits/s +SPI3.DataSize=SPI_DATASIZE_8BIT +SPI3.Direction=SPI_DIRECTION_2LINES_TXONLY +SPI3.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,DataSize,BaudRatePrescaler,NSSPMode +SPI3.Mode=SPI_MODE_MASTER +SPI3.NSSPMode=SPI_NSS_PULSE_DISABLE +SPI3.VirtualType=VM_MASTER +TIM4.EncoderMode=TIM_ENCODERMODE_TI12 +TIM4.IC1Filter=4 +TIM4.IC2Filter=4 +TIM4.IPParameters=EncoderMode,IC1Filter,IC2Filter +USB_DEVICE.CLASS_NAME_FS=AUDIO +USB_DEVICE.IPParameters=VirtualMode-AUDIO_FS,VirtualModeFS,CLASS_NAME_FS,VID-AUDIO_FS,MANUFACTURER_STRING-AUDIO_FS,PID_AUDIO_FS,PRODUCT_STRING_AUDIO_FS +USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology +USB_DEVICE.PID_AUDIO_FS=0xDADA +USB_DEVICE.PRODUCT_STRING_AUDIO_FS=OWL-ACDC +USB_DEVICE.VID-AUDIO_FS=0x1209 +USB_DEVICE.VirtualMode-AUDIO_FS=Audio +USB_DEVICE.VirtualModeFS=Audio_FS +USB_OTG_FS.IPParameters=VirtualMode +USB_OTG_FS.VirtualMode=Device_Only +VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 +VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 +VP_SYS_VS_Systick.Mode=SysTick +VP_SYS_VS_Systick.Signal=SYS_VS_Systick +VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Mode=AUDIO_FS +VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_FS +board=custom diff --git a/ACDC/Core/Inc/FreeRTOSConfig.h b/ACDC/Core/Inc/FreeRTOSConfig.h new file mode 100644 index 00000000..36d0599c --- /dev/null +++ b/ACDC/Core/Inc/FreeRTOSConfig.h @@ -0,0 +1,145 @@ +/* USER CODE BEGIN Header */ +/* + * FreeRTOS Kernel V10.2.1 + * Portion Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Portion Copyright (C) 2019 StMicroelectronics, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ +/* USER CODE END Header */ + +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +/*----------------------------------------------------------- + * Application specific definitions. + * + * These definitions should be adjusted for your particular hardware and + * application requirements. + * + * These parameters and more are described within the 'configuration' section of the + * FreeRTOS API documentation available on the FreeRTOS.org web site. + * + * See http://www.freertos.org/a00110.html + *----------------------------------------------------------*/ + +/* USER CODE BEGIN Includes */ +#include "device.h" +#ifdef DEBUG_STACK +#define configUSE_TRACE_FACILITY 1 +#define INCLUDE_uxTaskGetStackHighWaterMark 1 +#endif /* DEBUG_STACK */ +/* USER CODE END Includes */ + +/* Ensure definitions are only used by the compiler, and not by the assembler. */ +#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) + #include + extern uint32_t SystemCoreClock; + void xPortSysTickHandler(void); +#endif +#define configENABLE_FPU 0 +#define configENABLE_MPU 0 + +#define configUSE_PREEMPTION 0 +#define configSUPPORT_STATIC_ALLOCATION 1 +#define configSUPPORT_DYNAMIC_ALLOCATION 1 +#define configUSE_IDLE_HOOK 0 +#define configUSE_TICK_HOOK 0 +#define configCPU_CLOCK_HZ ( SystemCoreClock ) +#define configTICK_RATE_HZ ((TickType_t)1000) +#define configMAX_PRIORITIES ( 7 ) +#define configMINIMAL_STACK_SIZE ((uint16_t)128) +#define configTOTAL_HEAP_SIZE ((size_t)15360) +#define configMAX_TASK_NAME_LEN ( 16 ) +#define configUSE_16_BIT_TICKS 0 +#define configQUEUE_REGISTRY_SIZE 8 +#define configCHECK_FOR_STACK_OVERFLOW 2 +#define configUSE_MALLOC_FAILED_HOOK 1 +#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 +/* USER CODE BEGIN MESSAGE_BUFFER_LENGTH_TYPE */ +/* Defaults to size_t for backward compatibility, but can be changed + if lengths will always be less than the number of bytes in a size_t. */ +#define configMESSAGE_BUFFER_LENGTH_TYPE size_t +/* USER CODE END MESSAGE_BUFFER_LENGTH_TYPE */ + +/* Co-routine definitions. */ +#define configUSE_CO_ROUTINES 0 +#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) + +/* Set the following definitions to 1 to include the API function, or zero +to exclude the API function. */ +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskCleanUpResources 0 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_xTaskGetSchedulerState 1 + +/* Cortex-M specific definitions. */ +#ifdef __NVIC_PRIO_BITS + /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */ + #define configPRIO_BITS __NVIC_PRIO_BITS +#else + #define configPRIO_BITS 4 +#endif + +/* The lowest interrupt priority that can be used in a call to a "set priority" +function. */ +#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15 + +/* The highest interrupt priority that can be used by any interrupt service +routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL +INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER +PRIORITY THAN THIS! (higher priorities are lower numeric values. */ +#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5 + +/* Interrupt priorities used by the kernel port layer itself. These are generic +to all Cortex-M ports, and do not rely on any particular library functions. */ +#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) +/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!! +See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ +#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) + +/* Normal assert() semantics without relying on the provision of an assert.h +header file. */ +/* USER CODE BEGIN 1 */ +#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );} +/* USER CODE END 1 */ + +/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS +standard names. */ +#define vPortSVCHandler SVC_Handler +#define xPortPendSVHandler PendSV_Handler + +/* IMPORTANT: This define is commented when used with STM32Cube firmware, when the timebase source is SysTick, + to prevent overwriting SysTick_Handler defined within STM32Cube HAL */ + +/* #define xPortSysTickHandler SysTick_Handler */ + +/* USER CODE BEGIN Defines */ +/* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */ +/* USER CODE END Defines */ + +#endif /* FREERTOS_CONFIG_H */ diff --git a/ACDC/Core/Inc/hardware.h b/ACDC/Core/Inc/hardware.h new file mode 100644 index 00000000..7b7ccd5a --- /dev/null +++ b/ACDC/Core/Inc/hardware.h @@ -0,0 +1,59 @@ +#include "main.h" +#include "stm32h7xx_hal.h" + +#define OWL_XIBECA +#define HARDWARE_ID XIBECA_HARDWARE +#define HARDWARE_VERSION "Xibeca" +/* #define NO_EXTERNAL_RAM */ +/* #define NO_CCM_RAM */ +#define DMA_RAM __attribute__ ((section (".dmadata"))) +#define USE_PLUS_RAM +/* #define USE_ICACHE */ +/* #define USE_DCACHE */ + +#define ARM_CYCLES_PER_SAMPLE (480000000/AUDIO_SAMPLINGRATE) /* 480MHz / 48kHz */ +#define MAIN_LOOP_SLEEP_MS 20 + +// todo: quad SPI +/* #define USE_SPI_FLASH */ + +#define USE_CODEC +#define USE_PCM3168A +/* #define CODEC_HP_FILTER */ +#define CODEC_SPI hspi2 + +/* USB audio settings */ +#define AUDIO_BITS_PER_SAMPLE 16 +#define AUDIO_BYTES_PER_SAMPLE (AUDIO_BITS_PER_SAMPLE/8) +#define AUDIO_CHANNELS 8 +/* #define AUDIO_INT32_TO_SAMPLE(x) (__REV16((x)>>8)) */ +/* #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(__REV16(x))<<8) */ +#define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) +#define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) +#define USBD_AUDIO_RX_CHANNELS 4 +#define USBD_AUDIO_TX_CHANNELS 4 + +#define USE_USBD_AUDIO +#define USE_USBD_AUDIO_TX // microphone +/* #define USE_USBD_AUDIO_RX // speaker */ +#define USE_USBD_FS +#define USBD_HANDLE hUsbDeviceFS +/* #define USBD_MAX_POWER 100 // 200mA for iPad compatibility */ + +/* #define USE_UART_MIDI_RX */ +/* #define USE_UART_MIDI_TX */ +/* #define UART_MIDI_HANDLE huart2 */ +/* #define UART_MIDI_RX_BUFFER_SIZE 256 */ + +#define AUDIO_SAMPLINGRATE 48000 + +#define USE_ADC +#define ADC_PERIPH hadc1 +#define ADC_A 0 +#define ADC_B 1 +#define ADC_C 2 +#define ADC_D 3 + +#define NOF_ADC_VALUES 4 +#define NOF_PARAMETERS 40 +#define NOF_BUTTONS (0+4) diff --git a/ACDC/Core/Inc/main.h b/ACDC/Core/Inc/main.h new file mode 100644 index 00000000..ee56745a --- /dev/null +++ b/ACDC/Core/Inc/main.h @@ -0,0 +1,126 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : main.h + * @brief : Header for main.c file. + * This file contains the common defines of the application. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __MAIN_H +#define __MAIN_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32h7xx_hal.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* Exported macro ------------------------------------------------------------*/ +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +/* Exported functions prototypes ---------------------------------------------*/ +void Error_Handler(void); + +/* USER CODE BEGIN EFP */ + +/* USER CODE END EFP */ + +/* Private defines -----------------------------------------------------------*/ +#define FLASH_DQ2_Pin GPIO_PIN_2 +#define FLASH_DQ2_GPIO_Port GPIOE +#define OLED_CS_Pin GPIO_PIN_14 +#define OLED_CS_GPIO_Port GPIOG +#define OLED_DC_Pin GPIO_PIN_11 +#define OLED_DC_GPIO_Port GPIOC +#define EXTI13_Pin GPIO_PIN_13 +#define EXTI13_GPIO_Port GPIOC +#define EXTI13_EXTI_IRQn EXTI15_10_IRQn +#define EXTI14_Pin GPIO_PIN_14 +#define EXTI14_GPIO_Port GPIOC +#define EXTI14_EXTI_IRQn EXTI15_10_IRQn +#define FLASH_NCS_Pin GPIO_PIN_6 +#define FLASH_NCS_GPIO_Port GPIOG +#define FLASH_DQ3_Pin GPIO_PIN_6 +#define FLASH_DQ3_GPIO_Port GPIOF +#define ADC_RST_Pin GPIO_PIN_3 +#define ADC_RST_GPIO_Port GPIOG +#define FLASH_CLK_Pin GPIO_PIN_10 +#define FLASH_CLK_GPIO_Port GPIOF +#define FLASH_DQ1_Pin GPIO_PIN_9 +#define FLASH_DQ1_GPIO_Port GPIOF +#define FLASH_DQ0_Pin GPIO_PIN_8 +#define FLASH_DQ0_GPIO_Port GPIOF +#define ADC1_Pin GPIO_PIN_0 +#define ADC1_GPIO_Port GPIOC +#define ADC5_Pin GPIO_PIN_1 +#define ADC5_GPIO_Port GPIOC +#define ADC_SPI_MISO_Pin GPIO_PIN_2 +#define ADC_SPI_MISO_GPIO_Port GPIOC +#define ADC_SPI_MOSI_Pin GPIO_PIN_3 +#define ADC_SPI_MOSI_GPIO_Port GPIOC +#define OLED_RST_Pin GPIO_PIN_4 +#define OLED_RST_GPIO_Port GPIOA +#define ADC2_Pin GPIO_PIN_2 +#define ADC2_GPIO_Port GPIOA +#define ADC4_Pin GPIO_PIN_5 +#define ADC4_GPIO_Port GPIOC +#define ADC3_Pin GPIO_PIN_1 +#define ADC3_GPIO_Port GPIOB +#define ADC7_Pin GPIO_PIN_0 +#define ADC7_GPIO_Port GPIOB +#define ADC_SPI_CLK_Pin GPIO_PIN_10 +#define ADC_SPI_CLK_GPIO_Port GPIOB +#define ADC_SPI_NCS_Pin GPIO_PIN_11 +#define ADC_SPI_NCS_GPIO_Port GPIOB +/* USER CODE BEGIN Private defines */ + +#define OLED_DC_Pin GPIO_PIN_11 +#define OLED_DC_GPIO_Port GPIOC + +#define ADC_NCS_Pin ADC_SPI_NCS_Pin +#define ADC_NCS_GPIO_Port ADC_SPI_NCS_GPIO_Port + +#define ADC_RESET_Pin ADC_RST_Pin +#define ADC_RESET_GPIO_Port ADC_RST_GPIO_Port + +/* USER CODE END Private defines */ + +#ifdef __cplusplus +} +#endif + +#endif /* __MAIN_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ACDC/Core/Inc/stm32h7xx_hal_conf.h b/ACDC/Core/Inc/stm32h7xx_hal_conf.h new file mode 100644 index 00000000..6348633e --- /dev/null +++ b/ACDC/Core/Inc/stm32h7xx_hal_conf.h @@ -0,0 +1,511 @@ +/** + ****************************************************************************** + * @file stm32h7xx_hal_conf.h + * @author MCD Application Team + * @brief HAL configuration file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef STM32H7xx_HAL_CONF_H +#define STM32H7xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED + + #define HAL_ADC_MODULE_ENABLED +/* #define HAL_FDCAN_MODULE_ENABLED */ +/* #define HAL_FMAC_MODULE_ENABLED */ +/* #define HAL_CEC_MODULE_ENABLED */ +/* #define HAL_COMP_MODULE_ENABLED */ +/* #define HAL_CORDIC_MODULE_ENABLED */ +/* #define HAL_CRC_MODULE_ENABLED */ +/* #define HAL_CRYP_MODULE_ENABLED */ +/* #define HAL_DAC_MODULE_ENABLED */ +/* #define HAL_DCMI_MODULE_ENABLED */ +/* #define HAL_DMA2D_MODULE_ENABLED */ +/* #define HAL_ETH_MODULE_ENABLED */ +/* #define HAL_NAND_MODULE_ENABLED */ +/* #define HAL_NOR_MODULE_ENABLED */ +/* #define HAL_OTFDEC_MODULE_ENABLED */ +/* #define HAL_SRAM_MODULE_ENABLED */ +#define HAL_SDRAM_MODULE_ENABLED +/* #define HAL_HASH_MODULE_ENABLED */ +/* #define HAL_HRTIM_MODULE_ENABLED */ +/* #define HAL_HSEM_MODULE_ENABLED */ +/* #define HAL_GFXMMU_MODULE_ENABLED */ +/* #define HAL_JPEG_MODULE_ENABLED */ +/* #define HAL_OPAMP_MODULE_ENABLED */ +/* #define HAL_OSPI_MODULE_ENABLED */ +/* #define HAL_OSPI_MODULE_ENABLED */ +/* #define HAL_I2S_MODULE_ENABLED */ +/* #define HAL_SMBUS_MODULE_ENABLED */ +/* #define HAL_IWDG_MODULE_ENABLED */ +#define HAL_LPTIM_MODULE_ENABLED +/* #define HAL_LTDC_MODULE_ENABLED */ +#define HAL_QSPI_MODULE_ENABLED +/* #define HAL_RNG_MODULE_ENABLED */ +/* #define HAL_RTC_MODULE_ENABLED */ +#define HAL_SAI_MODULE_ENABLED +/* #define HAL_SD_MODULE_ENABLED */ +/* #define HAL_MMC_MODULE_ENABLED */ +/* #define HAL_SPDIFRX_MODULE_ENABLED */ +#define HAL_SPI_MODULE_ENABLED +/* #define HAL_SWPMI_MODULE_ENABLED */ +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +/* #define HAL_USART_MODULE_ENABLED */ +/* #define HAL_IRDA_MODULE_ENABLED */ +/* #define HAL_SMARTCARD_MODULE_ENABLED */ +/* #define HAL_WWDG_MODULE_ENABLED */ +#define HAL_PCD_MODULE_ENABLED +/* #define HAL_HCD_MODULE_ENABLED */ +/* #define HAL_DFSDM_MODULE_ENABLED */ +/* #define HAL_DSI_MODULE_ENABLED */ +/* #define HAL_JPEG_MODULE_ENABLED */ +/* #define HAL_MDIOS_MODULE_ENABLED */ +/* #define HAL_PSSI_MODULE_ENABLED */ +/* #define HAL_DTS_MODULE_ENABLED */ +#define HAL_GPIO_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_MDMA_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED +#define HAL_HSEM_MODULE_ENABLED + +/* ########################## Oscillator Values adaptation ####################*/ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) +#define HSE_VALUE (8000000UL) /*!< Value of the External oscillator in Hz : FPGA case fixed to 60MHZ */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT (100UL) /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal oscillator (CSI) default value. + * This value is the default CSI value after Reset. + */ +#if !defined (CSI_VALUE) + #define CSI_VALUE (4000000UL) /*!< Value of the Internal oscillator in Hz*/ +#endif /* CSI_VALUE */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE (64000000UL) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief External Low Speed oscillator (LSE) value. + * This value is used by the UART, RTC HAL module to compute the system frequency + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE (32768UL) /*!< Value of the External oscillator in Hz*/ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT (5000UL) /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +#if !defined (LSI_VALUE) + #define LSI_VALUE (32000UL) /*!< LSI Typical Value in Hz*/ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature.*/ + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) + #define EXTERNAL_CLOCK_VALUE 12288000UL /*!< Value of the External clock in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE (3300UL) /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY (15UL) /*!< tick interrupt priority */ +#define USE_RTOS 0 +#define USE_SD_TRANSCEIVER 0U /*!< use uSD Transceiver */ +#define USE_SPI_CRC 0U /*!< use CRC in SPI */ + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_COMP_REGISTER_CALLBACKS 0U /* COMP register callback disabled */ +#define USE_HAL_CORDIC_REGISTER_CALLBACKS 0U /* CORDIC register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_DTS_REGISTER_CALLBACKS 0U /* DTS register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_FDCAN_REGISTER_CALLBACKS 0U /* FDCAN register callback disabled */ +#define USE_HAL_FMAC_REGISTER_CALLBACKS 0U /* FMAC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_GFXMMU_REGISTER_CALLBACKS 0U /* GFXMMU register callback disabled */ +#define USE_HAL_HRTIM_REGISTER_CALLBACKS 0U /* HRTIM register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_JPEG_REGISTER_CALLBACKS 0U /* JPEG register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ +#define USE_HAL_MDIOS_REGISTER_CALLBACKS 0U /* MDIO register callback disabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U /* MDIO register callback disabled */ +#define USE_HAL_OSPI_REGISTER_CALLBACKS 0U /* OSPI register callback disabled */ +#define USE_HAL_OTFDEC_REGISTER_CALLBACKS 0U /* OTFDEC register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_SWPMI_REGISTER_CALLBACKS 0U /* SWPMI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + +/* ########################### Ethernet Configuration ######################### */ +#define ETH_TX_DESC_CNT 4 /* number of Ethernet Tx DMA descriptors */ +#define ETH_RX_DESC_CNT 4 /* number of Ethernet Rx DMA descriptors */ + +#define ETH_MAC_ADDR0 (0x02UL) +#define ETH_MAC_ADDR1 (0x00UL) +#define ETH_MAC_ADDR2 (0x00UL) +#define ETH_MAC_ADDR3 (0x00UL) +#define ETH_MAC_ADDR4 (0x00UL) +#define ETH_MAC_ADDR5 (0x00UL) + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ + #define USE_FULL_ASSERT 1U + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32h7xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32h7xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32h7xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_MDMA_MODULE_ENABLED + #include "stm32h7xx_hal_mdma.h" +#endif /* HAL_MDMA_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED + #include "stm32h7xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED + #include "stm32h7xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED + #include "stm32h7xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED + #include "stm32h7xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED + #include "stm32h7xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_DTS_MODULE_ENABLED + #include "stm32h7xx_hal_dts.h" +#endif /* HAL_DTS_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED + #include "stm32h7xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32h7xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32h7xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32h7xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_FDCAN_MODULE_ENABLED + #include "stm32h7xx_hal_fdcan.h" +#endif /* HAL_FDCAN_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED + #include "stm32h7xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_COMP_MODULE_ENABLED + #include "stm32h7xx_hal_comp.h" +#endif /* HAL_COMP_MODULE_ENABLED */ + +#ifdef HAL_CORDIC_MODULE_ENABLED + #include "stm32h7xx_hal_cordic.h" +#endif /* HAL_CORDIC_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32h7xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED + #include "stm32h7xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32h7xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32h7xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_GFXMMU_MODULE_ENABLED + #include "stm32h7xx_hal_gfxmmu.h" +#endif /* HAL_GFXMMU_MODULE_ENABLED */ + +#ifdef HAL_FMAC_MODULE_ENABLED + #include "stm32h7xx_hal_fmac.h" +#endif /* HAL_FMAC_MODULE_ENABLED */ + +#ifdef HAL_HRTIM_MODULE_ENABLED + #include "stm32h7xx_hal_hrtim.h" +#endif /* HAL_HRTIM_MODULE_ENABLED */ + +#ifdef HAL_HSEM_MODULE_ENABLED + #include "stm32h7xx_hal_hsem.h" +#endif /* HAL_HSEM_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32h7xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32h7xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED + #include "stm32h7xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32h7xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32h7xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32h7xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_JPEG_MODULE_ENABLED + #include "stm32h7xx_hal_jpeg.h" +#endif /* HAL_JPEG_MODULE_ENABLED */ + +#ifdef HAL_MDIOS_MODULE_ENABLED + #include "stm32h7xx_hal_mdios.h" +#endif /* HAL_MDIOS_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED + #include "stm32h7xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED +#include "stm32h7xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED +#include "stm32h7xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_OPAMP_MODULE_ENABLED +#include "stm32h7xx_hal_opamp.h" +#endif /* HAL_OPAMP_MODULE_ENABLED */ + +#ifdef HAL_OSPI_MODULE_ENABLED + #include "stm32h7xx_hal_ospi.h" +#endif /* HAL_OSPI_MODULE_ENABLED */ + +#ifdef HAL_OTFDEC_MODULE_ENABLED +#include "stm32h7xx_hal_otfdec.h" +#endif /* HAL_OTFDEC_MODULE_ENABLED */ + +#ifdef HAL_PSSI_MODULE_ENABLED + #include "stm32h7xx_hal_pssi.h" +#endif /* HAL_PSSI_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32h7xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED + #include "stm32h7xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_RAMECC_MODULE_ENABLED + #include "stm32h7xx_hal_ramecc.h" +#endif /* HAL_RAMECC_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED + #include "stm32h7xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32h7xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED + #include "stm32h7xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED + #include "stm32h7xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED + #include "stm32h7xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32h7xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED + #include "stm32h7xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_SWPMI_MODULE_ENABLED + #include "stm32h7xx_hal_swpmi.h" +#endif /* HAL_SWPMI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32h7xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32h7xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32h7xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32h7xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32h7xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED + #include "stm32h7xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32h7xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32h7xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED + #include "stm32h7xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t *file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* STM32H7xx_HAL_CONF_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ACDC/Core/Inc/stm32h7xx_it.h b/ACDC/Core/Inc/stm32h7xx_it.h new file mode 100644 index 00000000..8bfa4d85 --- /dev/null +++ b/ACDC/Core/Inc/stm32h7xx_it.h @@ -0,0 +1,74 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32h7xx_it.h + * @brief This file contains the headers of the interrupt handlers. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32H7xx_IT_H +#define __STM32H7xx_IT_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* Exported macro ------------------------------------------------------------*/ +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +/* Exported functions prototypes ---------------------------------------------*/ +void SysTick_Handler(void); +void EXTI2_IRQHandler(void); +void DMA1_Stream0_IRQHandler(void); +void DMA1_Stream1_IRQHandler(void); +void DMA1_Stream2_IRQHandler(void); +void DMA1_Stream3_IRQHandler(void); +void ADC_IRQHandler(void); +void EXTI9_5_IRQHandler(void); +void TIM4_IRQHandler(void); +void EXTI15_10_IRQHandler(void); +void SPI3_IRQHandler(void); +void SAI1_IRQHandler(void); +void QUADSPI_IRQHandler(void); +void OTG_FS_IRQHandler(void); +/* USER CODE BEGIN EFP */ + +/* USER CODE END EFP */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32H7xx_IT_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ACDC/Core/Src/ACDC.cpp b/ACDC/Core/Src/ACDC.cpp new file mode 100644 index 00000000..2ba2275a --- /dev/null +++ b/ACDC/Core/Src/ACDC.cpp @@ -0,0 +1,115 @@ +#include "Owl.h" +#include "device.h" +#include "errorhandlers.h" +#include "Pin.h" +#include "ApplicationSettings.h" +#include "OpenWareMidiControl.h" +#include "message.h" + +#define XIBECA_PIN3 GPIOD, GPIO_PIN_2 +#define XIBECA_PIN4 GPIOG, GPIO_PIN_10 +#define XIBECA_PIN5 GPIOC, GPIO_PIN_9 +#define XIBECA_PIN6 GPIOC, GPIO_PIN_8 +#define XIBECA_PIN7 GPIOC, GPIO_PIN_13 +#define XIBECA_PIN8 GPIOI, GPIO_PIN_11 +#define XIBECA_PIN9 GPIOC, GPIO_PIN_14 +#define XIBECA_PIN10 GPIOA, GPIO_PIN_0 +#define XIBECA_PIN11 GPIOH, GPIO_PIN_4 +#define XIBECA_PIN12 GPIOC, GPIO_PIN_15 +#define XIBECA_PIN13 GPIOA, GPIO_PIN_7 +#define XIBECA_PIN14 GPIOA, GPIO_PIN_3 + +#define XIBECA_PIN21 GPIOC, GPIO_PIN_6 +#define XIBECA_PIN22 GPIOC, GPIO_PIN_7 +#define XIBECA_PIN23 GPIOD, GPIO_PIN_12 +#define XIBECA_PIN24 GPIOD, GPIO_PIN_13 + +Pin led_in1(XIBECA_PIN17); +Pin led_in2(XIBECA_PIN18); +Pin led_in3(XIBECA_PIN19); +Pin led_in4(XIBECA_PIN20); + +Pin led_clip1(XIBECA_PIN10); +Pin led_clip2(XIBECA_PIN7); +Pin led_clip3(XIBECA_PIN8); +Pin led_clip4(XIBECA_PIN5); + +Pin led_out1(XIBECA_PIN21); +Pin led_out2(XIBECA_PIN22); +Pin led_out3(XIBECA_PIN23); +Pin led_out4(XIBECA_PIN24); + +void setLed(uint8_t led, uint32_t rgb){ + bool value = rgb; + switch(led){ + case 1: + led_in1.set(value); + break; + case 2: + led_in2.set(value); + break; + case 3: + led_in3.set(value); + break; + case 4: + led_in4.set(value); + break; + case 5: + led_clip1.set(value); + break; + case 6: + led_clip2.set(value); + break; + case 7: + led_clip3.set(value); + break; + case 8: + led_clip4.set(value); + break; + case 9: + led_out1.set(value); + break; + case 10: + led_out2.set(value); + break; + case 11: + led_out3.set(value); + break; + case 12: + led_out4.set(value); + break; + } +} + +void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* adc_values, size_t adc_len){ + parameter_values[0] = (parameter_values[0]*3 + adc_values[ADC_A])>>2; + parameter_values[1] = (parameter_values[1]*3 + adc_values[ADC_B])>>2; + parameter_values[2] = (parameter_values[2]*3 + adc_values[ADC_C])>>2; + parameter_values[3] = (parameter_values[3]*3 + adc_values[ADC_D])>>2; +} + +void setup(){ + led_in1.outputMode(); + led_in2.outputMode(); + led_in3.outputMode(); + led_in4.outputMode(); + + led_clip1.outputMode(); + led_clip2.outputMode(); + led_clip3.outputMode(); + led_clip4.outputMode(); + + led_out1.outputMode(); + led_out2.outputMode(); + led_out3.outputMode(); + led_out4.outputMode(); + + for(size_t i=1; i<=12; ++i) + setLed(i, NO_COLOUR); + + owl.setup(); +} + +void loop(void){ + owl.loop(); +} diff --git a/ACDC/Core/Src/freertos.c b/ACDC/Core/Src/freertos.c new file mode 100644 index 00000000..4a5debed --- /dev/null +++ b/ACDC/Core/Src/freertos.c @@ -0,0 +1,106 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * File Name : freertos.c + * Description : Code for freertos applications + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "FreeRTOS.h" +#include "task.h" +#include "main.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN PTD */ + +/* USER CODE END PTD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ + +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN Variables */ + +/* USER CODE END Variables */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN FunctionPrototypes */ + +/* USER CODE END FunctionPrototypes */ + +/* GetIdleTaskMemory prototype (linked to static allocation support) */ +void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ); + +/* Hook prototypes */ +void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName); +void vApplicationMallocFailedHook(void); + +/* USER CODE BEGIN 4 */ +__weak void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName) +{ + /* Run time stack overflow checking is performed if + configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is + called if a stack overflow is detected. */ +} +/* USER CODE END 4 */ + +/* USER CODE BEGIN 5 */ +__weak void vApplicationMallocFailedHook(void) +{ + /* vApplicationMallocFailedHook() will only be called if + configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook + function that will get called if a call to pvPortMalloc() fails. + pvPortMalloc() is called internally by the kernel whenever a task, queue, + timer or semaphore is created. It is also called by various parts of the + demo application. If heap_1.c or heap_2.c are used, then the size of the + heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in + FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used + to query the size of free heap space that remains (although it does not + provide information on how the remaining heap might be fragmented). */ +} +/* USER CODE END 5 */ + +/* USER CODE BEGIN GET_IDLE_TASK_MEMORY */ +static StaticTask_t xIdleTaskTCBBuffer; +static StackType_t xIdleStack[configMINIMAL_STACK_SIZE]; + +void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ) +{ + *ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer; + *ppxIdleTaskStackBuffer = &xIdleStack[0]; + *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; + /* place for user code */ +} +/* USER CODE END GET_IDLE_TASK_MEMORY */ + +/* Private application code --------------------------------------------------*/ +/* USER CODE BEGIN Application */ + +/* USER CODE END Application */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ACDC/Core/Src/main.c b/ACDC/Core/Src/main.c new file mode 100644 index 00000000..1ffdf427 --- /dev/null +++ b/ACDC/Core/Src/main.c @@ -0,0 +1,1223 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : main.c + * @brief : Main program body + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "cmsis_os.h" +#include "usb_device.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ +#include "device.h" +#include "errorhandlers.h" +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN PTD */ + +/* USER CODE END PTD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +ADC_HandleTypeDef hadc1; +DMA_HandleTypeDef hdma_adc1; + +LPTIM_HandleTypeDef hlptim1; + +QSPI_HandleTypeDef hqspi; + +SAI_HandleTypeDef hsai_BlockA1; +SAI_HandleTypeDef hsai_BlockB1; +DMA_HandleTypeDef hdma_sai1_a; +DMA_HandleTypeDef hdma_sai1_b; + +SPI_HandleTypeDef hspi2; +SPI_HandleTypeDef hspi3; +DMA_HandleTypeDef hdma_spi3_tx; + +TIM_HandleTypeDef htim2; +TIM_HandleTypeDef htim3; +TIM_HandleTypeDef htim4; + +UART_HandleTypeDef huart5; +UART_HandleTypeDef huart7; + +SDRAM_HandleTypeDef hsdram1; + +osThreadId defaultTaskHandle; +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +void SystemClock_Config(void); +void PeriphCommonClock_Config(void); +static void MX_GPIO_Init(void); +static void MX_DMA_Init(void); +static void MX_QUADSPI_Init(void); +static void MX_FMC_Init(void); +static void MX_SAI1_Init(void); +static void MX_ADC1_Init(void); +static void MX_SPI2_Init(void); +static void MX_SPI3_Init(void); +static void MX_TIM2_Init(void); +static void MX_TIM3_Init(void); +static void MX_TIM4_Init(void); +static void MX_UART5_Init(void); +static void MX_UART7_Init(void); +static void MX_LPTIM1_Init(void); +void StartDefaultTask(void const * argument); + +/* USER CODE BEGIN PFP */ +void setup(void); +void loop(void); +void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram); +void initialise_monitor_handles(void); +/* USER CODE END PFP */ + +/* Private user code ---------------------------------------------------------*/ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/** + * @brief The application entry point. + * @retval int + */ +int main(void) +{ + /* USER CODE BEGIN 1 */ +#ifdef DEBUG +#warning "DEBUG uses printf and semihosting!" + if(CoreDebug->DHCSR & 0x01) + initialise_monitor_handles(); // remove when not semi-hosting + printf("showtime\n"); +#endif +#ifdef USE_ICACHE + /* Enable I-Cache-------------------------------------------------------------*/ + /* After reset, you must invalidate each cache before enabling (SCB_EnableICache) it. */ + SCB_InvalidateICache(); + SCB_EnableICache(); +#endif +#ifdef USE_DCACHE + /* Enable D-Cache-------------------------------------------------------------*/ + /* Before enabling the data cache, you must invalidate the entire data cache (SCB_InvalidateDCache), because external memory might have changed from when the cache was disabled. */ + SCB_InvalidateDCache(); + SCB_EnableDCache(); +#endif + + /* Enable D2 domain SRAM Clocks */ + /* presumably done in SystemInit by setting DATA_IN_D2_SRAM ? */ + /* should be started before libc_init_array and LoopCopyData in startup.s */ + /* __HAL_RCC_D2SRAM1_CLK_ENABLE(); */ + /* __HAL_RCC_D2SRAM2_CLK_ENABLE(); */ + /* __HAL_RCC_D2SRAM3_CLK_ENABLE(); */ + + /* USER CODE END 1 */ + + /* MCU Configuration--------------------------------------------------------*/ + + /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ + HAL_Init(); + + /* USER CODE BEGIN Init */ + + /* USER CODE END Init */ + + /* Configure the system clock */ + SystemClock_Config(); + +/* Configure the peripherals common clocks */ + PeriphCommonClock_Config(); + + /* USER CODE BEGIN SysInit */ + + /* USER CODE END SysInit */ + + /* Initialize all configured peripherals */ + MX_GPIO_Init(); + MX_DMA_Init(); + MX_QUADSPI_Init(); + MX_FMC_Init(); + MX_SAI1_Init(); + MX_ADC1_Init(); + MX_SPI2_Init(); + MX_SPI3_Init(); + MX_TIM2_Init(); + MX_TIM3_Init(); + MX_TIM4_Init(); + MX_UART5_Init(); + MX_UART7_Init(); + MX_LPTIM1_Init(); + /* USER CODE BEGIN 2 */ + +#ifdef USE_EXTERNAL_RAM + SDRAM_Initialization_Sequence(&hsdram1); +#endif + + /* USER CODE END 2 */ + + /* USER CODE BEGIN RTOS_MUTEX */ + /* add mutexes, ... */ + /* USER CODE END RTOS_MUTEX */ + + /* USER CODE BEGIN RTOS_SEMAPHORES */ + /* add semaphores, ... */ + /* USER CODE END RTOS_SEMAPHORES */ + + /* USER CODE BEGIN RTOS_TIMERS */ + /* start timers, add new ones, ... */ + /* USER CODE END RTOS_TIMERS */ + + /* USER CODE BEGIN RTOS_QUEUES */ + /* add queues, ... */ + /* USER CODE END RTOS_QUEUES */ + + /* Create the thread(s) */ + /* definition and creation of defaultTask */ + osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 1024); + defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL); + + /* USER CODE BEGIN RTOS_THREADS */ + /* add threads, ... */ + /* USER CODE END RTOS_THREADS */ + + /* Start scheduler */ + osKernelStart(); + + /* We should never get here as control is now taken by the scheduler */ + /* Infinite loop */ + /* USER CODE BEGIN WHILE */ + while (1) + { + /* USER CODE END WHILE */ + + /* USER CODE BEGIN 3 */ + } + /* USER CODE END 3 */ +} + +/** + * @brief System Clock Configuration + * @retval None + */ +void SystemClock_Config(void) +{ + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; + + /** Supply configuration update enable + */ + HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY); + /** Configure the main internal regulator output voltage + */ + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE0); + + while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {} + /** Macro to configure the PLL clock source + */ + __HAL_RCC_PLL_PLLSOURCE_CONFIG(RCC_PLLSOURCE_HSE); + /** Initializes the RCC Oscillators according to the specified parameters + * in the RCC_OscInitTypeDef structure. + */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48|RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.HSI48State = RCC_HSI48_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 1; + RCC_OscInitStruct.PLL.PLLN = 120; + RCC_OscInitStruct.PLL.PLLP = 2; + RCC_OscInitStruct.PLL.PLLQ = 5; + RCC_OscInitStruct.PLL.PLLR = 2; + RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_3; + RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE; + RCC_OscInitStruct.PLL.PLLFRACN = 0; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) + { + Error_Handler(); + } + /** Initializes the CPU, AHB and APB buses clocks + */ + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK + |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2 + |RCC_CLOCKTYPE_D3PCLK1|RCC_CLOCKTYPE_D1PCLK1; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2; + RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2; + RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2; + RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2; + RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2; + + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) + { + Error_Handler(); + } +} + +/** + * @brief Peripherals Common Clock Configuration + * @retval None + */ +void PeriphCommonClock_Config(void) +{ + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SAI1|RCC_PERIPHCLK_SPI3 + |RCC_PERIPHCLK_SPI2; + PeriphClkInitStruct.PLL2.PLL2M = 1; + PeriphClkInitStruct.PLL2.PLL2N = 18; + PeriphClkInitStruct.PLL2.PLL2P = 6; + PeriphClkInitStruct.PLL2.PLL2Q = 2; + PeriphClkInitStruct.PLL2.PLL2R = 2; + PeriphClkInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_3; + PeriphClkInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOMEDIUM; + PeriphClkInitStruct.PLL2.PLL2FRACN = 6144; + PeriphClkInitStruct.PLL3.PLL3M = 7; + PeriphClkInitStruct.PLL3.PLL3N = 172; + PeriphClkInitStruct.PLL3.PLL3P = 2; + PeriphClkInitStruct.PLL3.PLL3Q = 2; + PeriphClkInitStruct.PLL3.PLL3R = 2; + PeriphClkInitStruct.PLL3.PLL3RGE = RCC_PLL3VCIRANGE_0; + PeriphClkInitStruct.PLL3.PLL3VCOSEL = RCC_PLL3VCOWIDE; + PeriphClkInitStruct.PLL3.PLL3FRACN = 0; + PeriphClkInitStruct.Sai1ClockSelection = RCC_SAI1CLKSOURCE_PLL3; + PeriphClkInitStruct.Spi123ClockSelection = RCC_SPI123CLKSOURCE_PLL2; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } +} + +/** + * @brief ADC1 Initialization Function + * @param None + * @retval None + */ +static void MX_ADC1_Init(void) +{ + + /* USER CODE BEGIN ADC1_Init 0 */ + + /* USER CODE END ADC1_Init 0 */ + + ADC_MultiModeTypeDef multimode = {0}; + ADC_ChannelConfTypeDef sConfig = {0}; + + /* USER CODE BEGIN ADC1_Init 1 */ + + /* USER CODE END ADC1_Init 1 */ + /** Common config + */ + hadc1.Instance = ADC1; + hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4; + hadc1.Init.Resolution = ADC_RESOLUTION_12B; + hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE; + hadc1.Init.EOCSelection = ADC_EOC_SEQ_CONV; + hadc1.Init.LowPowerAutoWait = DISABLE; + hadc1.Init.ContinuousConvMode = ENABLE; + hadc1.Init.NbrOfConversion = 4; + hadc1.Init.DiscontinuousConvMode = DISABLE; + hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START; + hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; + hadc1.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DMA_CIRCULAR; + hadc1.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN; + hadc1.Init.LeftBitShift = ADC_LEFTBITSHIFT_NONE; + hadc1.Init.OversamplingMode = DISABLE; + if (HAL_ADC_Init(&hadc1) != HAL_OK) + { + Error_Handler(); + } + /** Configure the ADC multi-mode + */ + multimode.Mode = ADC_MODE_INDEPENDENT; + if (HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK) + { + Error_Handler(); + } + /** Configure Regular Channel + */ + sConfig.Channel = ADC_CHANNEL_10; + sConfig.Rank = ADC_REGULAR_RANK_1; + sConfig.SamplingTime = ADC_SAMPLETIME_387CYCLES_5; + sConfig.SingleDiff = ADC_SINGLE_ENDED; + sConfig.OffsetNumber = ADC_OFFSET_NONE; + sConfig.Offset = 0; + sConfig.OffsetSignedSaturation = DISABLE; + if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /** Configure Regular Channel + */ + sConfig.Channel = ADC_CHANNEL_14; + sConfig.Rank = ADC_REGULAR_RANK_2; + if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /** Configure Regular Channel + */ + sConfig.Channel = ADC_CHANNEL_5; + sConfig.Rank = ADC_REGULAR_RANK_3; + if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /** Configure Regular Channel + */ + sConfig.Channel = ADC_CHANNEL_8; + sConfig.Rank = ADC_REGULAR_RANK_4; + if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN ADC1_Init 2 */ + + /* USER CODE END ADC1_Init 2 */ + +} + +/** + * @brief LPTIM1 Initialization Function + * @param None + * @retval None + */ +static void MX_LPTIM1_Init(void) +{ + + /* USER CODE BEGIN LPTIM1_Init 0 */ + + /* USER CODE END LPTIM1_Init 0 */ + + /* USER CODE BEGIN LPTIM1_Init 1 */ + + /* USER CODE END LPTIM1_Init 1 */ + hlptim1.Instance = LPTIM1; + hlptim1.Init.Clock.Source = LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC; + hlptim1.Init.Clock.Prescaler = LPTIM_PRESCALER_DIV1; + hlptim1.Init.UltraLowPowerClock.Polarity = LPTIM_CLOCKPOLARITY_RISING; + hlptim1.Init.UltraLowPowerClock.SampleTime = LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION; + hlptim1.Init.Trigger.Source = LPTIM_TRIGSOURCE_SOFTWARE; + hlptim1.Init.OutputPolarity = LPTIM_OUTPUTPOLARITY_HIGH; + hlptim1.Init.UpdateMode = LPTIM_UPDATE_IMMEDIATE; + hlptim1.Init.CounterSource = LPTIM_COUNTERSOURCE_EXTERNAL; + hlptim1.Init.Input1Source = LPTIM_INPUT1SOURCE_GPIO; + hlptim1.Init.Input2Source = LPTIM_INPUT2SOURCE_GPIO; + if (HAL_LPTIM_Init(&hlptim1) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN LPTIM1_Init 2 */ + + /* USER CODE END LPTIM1_Init 2 */ + +} + +/** + * @brief QUADSPI Initialization Function + * @param None + * @retval None + */ +static void MX_QUADSPI_Init(void) +{ + + /* USER CODE BEGIN QUADSPI_Init 0 */ + + /* USER CODE END QUADSPI_Init 0 */ + + /* USER CODE BEGIN QUADSPI_Init 1 */ + + /* USER CODE END QUADSPI_Init 1 */ + /* QUADSPI parameter configuration*/ + hqspi.Instance = QUADSPI; + hqspi.Init.ClockPrescaler = 9; + hqspi.Init.FifoThreshold = 4; + hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_NONE; + hqspi.Init.FlashSize = 22; + hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_1_CYCLE; + hqspi.Init.ClockMode = QSPI_CLOCK_MODE_0; + hqspi.Init.FlashID = QSPI_FLASH_ID_1; + hqspi.Init.DualFlash = QSPI_DUALFLASH_DISABLE; + if (HAL_QSPI_Init(&hqspi) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN QUADSPI_Init 2 */ + + /* USER CODE END QUADSPI_Init 2 */ + +} + +/** + * @brief SAI1 Initialization Function + * @param None + * @retval None + */ +static void MX_SAI1_Init(void) +{ + + /* USER CODE BEGIN SAI1_Init 0 */ + + /* USER CODE END SAI1_Init 0 */ + + /* USER CODE BEGIN SAI1_Init 1 */ + + /* USER CODE END SAI1_Init 1 */ + hsai_BlockA1.Instance = SAI1_Block_A; + hsai_BlockA1.Init.Protocol = SAI_FREE_PROTOCOL; + hsai_BlockA1.Init.AudioMode = SAI_MODEMASTER_RX; + hsai_BlockA1.Init.DataSize = SAI_DATASIZE_24; + hsai_BlockA1.Init.FirstBit = SAI_FIRSTBIT_MSB; + hsai_BlockA1.Init.ClockStrobing = SAI_CLOCKSTROBING_RISINGEDGE; + hsai_BlockA1.Init.Synchro = SAI_ASYNCHRONOUS; + hsai_BlockA1.Init.OutputDrive = SAI_OUTPUTDRIVE_ENABLE; + hsai_BlockA1.Init.NoDivider = SAI_MASTERDIVIDER_ENABLE; + hsai_BlockA1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; + hsai_BlockA1.Init.AudioFrequency = SAI_AUDIO_FREQUENCY_48K; + hsai_BlockA1.Init.SynchroExt = SAI_SYNCEXT_DISABLE; + hsai_BlockA1.Init.MonoStereoMode = SAI_STEREOMODE; + hsai_BlockA1.Init.CompandingMode = SAI_NOCOMPANDING; + hsai_BlockA1.Init.PdmInit.Activation = DISABLE; + hsai_BlockA1.Init.PdmInit.MicPairsNbr = 1; + hsai_BlockA1.Init.PdmInit.ClockEnable = SAI_PDM_CLOCK1_ENABLE; + hsai_BlockA1.FrameInit.FrameLength = 256; + hsai_BlockA1.FrameInit.ActiveFrameLength = 128; + hsai_BlockA1.FrameInit.FSDefinition = SAI_FS_CHANNEL_IDENTIFICATION; + hsai_BlockA1.FrameInit.FSPolarity = SAI_FS_ACTIVE_HIGH; + hsai_BlockA1.FrameInit.FSOffset = SAI_FS_BEFOREFIRSTBIT; + hsai_BlockA1.SlotInit.FirstBitOffset = 0; + hsai_BlockA1.SlotInit.SlotSize = SAI_SLOTSIZE_32B; + hsai_BlockA1.SlotInit.SlotNumber = 8; + hsai_BlockA1.SlotInit.SlotActive = 0x0000FFFF; + if (HAL_SAI_Init(&hsai_BlockA1) != HAL_OK) + { + Error_Handler(); + } + hsai_BlockB1.Instance = SAI1_Block_B; + hsai_BlockB1.Init.Protocol = SAI_FREE_PROTOCOL; + hsai_BlockB1.Init.AudioMode = SAI_MODESLAVE_TX; + hsai_BlockB1.Init.DataSize = SAI_DATASIZE_24; + hsai_BlockB1.Init.FirstBit = SAI_FIRSTBIT_MSB; + hsai_BlockB1.Init.ClockStrobing = SAI_CLOCKSTROBING_FALLINGEDGE; + hsai_BlockB1.Init.Synchro = SAI_SYNCHRONOUS; + hsai_BlockB1.Init.OutputDrive = SAI_OUTPUTDRIVE_ENABLE; + hsai_BlockB1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; + hsai_BlockB1.Init.SynchroExt = SAI_SYNCEXT_DISABLE; + hsai_BlockB1.Init.MonoStereoMode = SAI_STEREOMODE; + hsai_BlockB1.Init.CompandingMode = SAI_NOCOMPANDING; + hsai_BlockB1.Init.TriState = SAI_OUTPUT_NOTRELEASED; + hsai_BlockB1.Init.PdmInit.Activation = DISABLE; + hsai_BlockB1.Init.PdmInit.MicPairsNbr = 1; + hsai_BlockB1.Init.PdmInit.ClockEnable = SAI_PDM_CLOCK1_ENABLE; + hsai_BlockB1.FrameInit.FrameLength = 256; + hsai_BlockB1.FrameInit.ActiveFrameLength = 128; + hsai_BlockB1.FrameInit.FSDefinition = SAI_FS_CHANNEL_IDENTIFICATION; + hsai_BlockB1.FrameInit.FSPolarity = SAI_FS_ACTIVE_HIGH; + hsai_BlockB1.FrameInit.FSOffset = SAI_FS_BEFOREFIRSTBIT; + hsai_BlockB1.SlotInit.FirstBitOffset = 0; + hsai_BlockB1.SlotInit.SlotSize = SAI_SLOTSIZE_32B; + hsai_BlockB1.SlotInit.SlotNumber = 8; + hsai_BlockB1.SlotInit.SlotActive = 0x0000FFFF; + if (HAL_SAI_Init(&hsai_BlockB1) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN SAI1_Init 2 */ + + /* USER CODE END SAI1_Init 2 */ + +} + +/** + * @brief SPI2 Initialization Function + * @param None + * @retval None + */ +static void MX_SPI2_Init(void) +{ + + /* USER CODE BEGIN SPI2_Init 0 */ + + /* USER CODE END SPI2_Init 0 */ + + /* USER CODE BEGIN SPI2_Init 1 */ + + /* USER CODE END SPI2_Init 1 */ + /* SPI2 parameter configuration*/ + hspi2.Instance = SPI2; + hspi2.Init.Mode = SPI_MODE_MASTER; + hspi2.Init.Direction = SPI_DIRECTION_2LINES; + hspi2.Init.DataSize = SPI_DATASIZE_8BIT; + hspi2.Init.CLKPolarity = SPI_POLARITY_HIGH; + hspi2.Init.CLKPhase = SPI_PHASE_2EDGE; + hspi2.Init.NSS = SPI_NSS_SOFT; + hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_256; + hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB; + hspi2.Init.TIMode = SPI_TIMODE_DISABLE; + hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; + hspi2.Init.CRCPolynomial = 0x0; + hspi2.Init.NSSPMode = SPI_NSS_PULSE_DISABLE; + hspi2.Init.NSSPolarity = SPI_NSS_POLARITY_LOW; + hspi2.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA; + hspi2.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; + hspi2.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; + hspi2.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE; + hspi2.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE; + hspi2.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE; + hspi2.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE; + hspi2.Init.IOSwap = SPI_IO_SWAP_DISABLE; + if (HAL_SPI_Init(&hspi2) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN SPI2_Init 2 */ + + /* USER CODE END SPI2_Init 2 */ + +} + +/** + * @brief SPI3 Initialization Function + * @param None + * @retval None + */ +static void MX_SPI3_Init(void) +{ + + /* USER CODE BEGIN SPI3_Init 0 */ + + /* USER CODE END SPI3_Init 0 */ + + /* USER CODE BEGIN SPI3_Init 1 */ + + /* USER CODE END SPI3_Init 1 */ + /* SPI3 parameter configuration*/ + hspi3.Instance = SPI3; + hspi3.Init.Mode = SPI_MODE_MASTER; + hspi3.Init.Direction = SPI_DIRECTION_2LINES_TXONLY; + hspi3.Init.DataSize = SPI_DATASIZE_8BIT; + hspi3.Init.CLKPolarity = SPI_POLARITY_LOW; + hspi3.Init.CLKPhase = SPI_PHASE_1EDGE; + hspi3.Init.NSS = SPI_NSS_SOFT; + hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16; + hspi3.Init.FirstBit = SPI_FIRSTBIT_MSB; + hspi3.Init.TIMode = SPI_TIMODE_DISABLE; + hspi3.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; + hspi3.Init.CRCPolynomial = 0x0; + hspi3.Init.NSSPMode = SPI_NSS_PULSE_DISABLE; + hspi3.Init.NSSPolarity = SPI_NSS_POLARITY_LOW; + hspi3.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA; + hspi3.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; + hspi3.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; + hspi3.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE; + hspi3.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE; + hspi3.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE; + hspi3.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE; + hspi3.Init.IOSwap = SPI_IO_SWAP_DISABLE; + if (HAL_SPI_Init(&hspi3) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN SPI3_Init 2 */ + + /* USER CODE END SPI3_Init 2 */ + +} + +/** + * @brief TIM2 Initialization Function + * @param None + * @retval None + */ +static void MX_TIM2_Init(void) +{ + + /* USER CODE BEGIN TIM2_Init 0 */ + + /* USER CODE END TIM2_Init 0 */ + + TIM_Encoder_InitTypeDef sConfig = {0}; + TIM_MasterConfigTypeDef sMasterConfig = {0}; + + /* USER CODE BEGIN TIM2_Init 1 */ + + /* USER CODE END TIM2_Init 1 */ + htim2.Instance = TIM2; + htim2.Init.Prescaler = 0; + htim2.Init.CounterMode = TIM_COUNTERMODE_UP; + htim2.Init.Period = 4294967295; + htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; + htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; + sConfig.EncoderMode = TIM_ENCODERMODE_TI1; + sConfig.IC1Polarity = TIM_ICPOLARITY_RISING; + sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI; + sConfig.IC1Prescaler = TIM_ICPSC_DIV1; + sConfig.IC1Filter = 0; + sConfig.IC2Polarity = TIM_ICPOLARITY_RISING; + sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI; + sConfig.IC2Prescaler = TIM_ICPSC_DIV1; + sConfig.IC2Filter = 0; + if (HAL_TIM_Encoder_Init(&htim2, &sConfig) != HAL_OK) + { + Error_Handler(); + } + sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; + sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; + if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN TIM2_Init 2 */ + + /* USER CODE END TIM2_Init 2 */ + +} + +/** + * @brief TIM3 Initialization Function + * @param None + * @retval None + */ +static void MX_TIM3_Init(void) +{ + + /* USER CODE BEGIN TIM3_Init 0 */ + + /* USER CODE END TIM3_Init 0 */ + + TIM_Encoder_InitTypeDef sConfig = {0}; + TIM_MasterConfigTypeDef sMasterConfig = {0}; + + /* USER CODE BEGIN TIM3_Init 1 */ + + /* USER CODE END TIM3_Init 1 */ + htim3.Instance = TIM3; + htim3.Init.Prescaler = 0; + htim3.Init.CounterMode = TIM_COUNTERMODE_UP; + htim3.Init.Period = 65535; + htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; + htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; + sConfig.EncoderMode = TIM_ENCODERMODE_TI1; + sConfig.IC1Polarity = TIM_ICPOLARITY_RISING; + sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI; + sConfig.IC1Prescaler = TIM_ICPSC_DIV1; + sConfig.IC1Filter = 0; + sConfig.IC2Polarity = TIM_ICPOLARITY_RISING; + sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI; + sConfig.IC2Prescaler = TIM_ICPSC_DIV1; + sConfig.IC2Filter = 0; + if (HAL_TIM_Encoder_Init(&htim3, &sConfig) != HAL_OK) + { + Error_Handler(); + } + sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; + sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; + if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN TIM3_Init 2 */ + + /* USER CODE END TIM3_Init 2 */ + +} + +/** + * @brief TIM4 Initialization Function + * @param None + * @retval None + */ +static void MX_TIM4_Init(void) +{ + + /* USER CODE BEGIN TIM4_Init 0 */ + + /* USER CODE END TIM4_Init 0 */ + + TIM_Encoder_InitTypeDef sConfig = {0}; + TIM_MasterConfigTypeDef sMasterConfig = {0}; + + /* USER CODE BEGIN TIM4_Init 1 */ + + /* USER CODE END TIM4_Init 1 */ + htim4.Instance = TIM4; + htim4.Init.Prescaler = 0; + htim4.Init.CounterMode = TIM_COUNTERMODE_UP; + htim4.Init.Period = 65535; + htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; + htim4.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; + sConfig.EncoderMode = TIM_ENCODERMODE_TI12; + sConfig.IC1Polarity = TIM_ICPOLARITY_RISING; + sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI; + sConfig.IC1Prescaler = TIM_ICPSC_DIV1; + sConfig.IC1Filter = 4; + sConfig.IC2Polarity = TIM_ICPOLARITY_RISING; + sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI; + sConfig.IC2Prescaler = TIM_ICPSC_DIV1; + sConfig.IC2Filter = 4; + if (HAL_TIM_Encoder_Init(&htim4, &sConfig) != HAL_OK) + { + Error_Handler(); + } + sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; + sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; + if (HAL_TIMEx_MasterConfigSynchronization(&htim4, &sMasterConfig) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN TIM4_Init 2 */ + + /* USER CODE END TIM4_Init 2 */ + +} + +/** + * @brief UART5 Initialization Function + * @param None + * @retval None + */ +static void MX_UART5_Init(void) +{ + + /* USER CODE BEGIN UART5_Init 0 */ + + /* USER CODE END UART5_Init 0 */ + + /* USER CODE BEGIN UART5_Init 1 */ + + /* USER CODE END UART5_Init 1 */ + huart5.Instance = UART5; + huart5.Init.BaudRate = 115200; + huart5.Init.WordLength = UART_WORDLENGTH_8B; + huart5.Init.StopBits = UART_STOPBITS_1; + huart5.Init.Parity = UART_PARITY_NONE; + huart5.Init.Mode = UART_MODE_TX_RX; + huart5.Init.HwFlowCtl = UART_HWCONTROL_NONE; + huart5.Init.OverSampling = UART_OVERSAMPLING_16; + huart5.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; + huart5.Init.ClockPrescaler = UART_PRESCALER_DIV1; + huart5.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; + if (HAL_UART_Init(&huart5) != HAL_OK) + { + Error_Handler(); + } + if (HAL_UARTEx_SetTxFifoThreshold(&huart5, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK) + { + Error_Handler(); + } + if (HAL_UARTEx_SetRxFifoThreshold(&huart5, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK) + { + Error_Handler(); + } + if (HAL_UARTEx_DisableFifoMode(&huart5) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN UART5_Init 2 */ + + /* USER CODE END UART5_Init 2 */ + +} + +/** + * @brief UART7 Initialization Function + * @param None + * @retval None + */ +static void MX_UART7_Init(void) +{ + + /* USER CODE BEGIN UART7_Init 0 */ + + /* USER CODE END UART7_Init 0 */ + + /* USER CODE BEGIN UART7_Init 1 */ + + /* USER CODE END UART7_Init 1 */ + huart7.Instance = UART7; + huart7.Init.BaudRate = 115200; + huart7.Init.WordLength = UART_WORDLENGTH_8B; + huart7.Init.StopBits = UART_STOPBITS_1; + huart7.Init.Parity = UART_PARITY_NONE; + huart7.Init.Mode = UART_MODE_TX_RX; + huart7.Init.HwFlowCtl = UART_HWCONTROL_NONE; + huart7.Init.OverSampling = UART_OVERSAMPLING_16; + huart7.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; + huart7.Init.ClockPrescaler = UART_PRESCALER_DIV1; + huart7.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; + if (HAL_UART_Init(&huart7) != HAL_OK) + { + Error_Handler(); + } + if (HAL_UARTEx_SetTxFifoThreshold(&huart7, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK) + { + Error_Handler(); + } + if (HAL_UARTEx_SetRxFifoThreshold(&huart7, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK) + { + Error_Handler(); + } + if (HAL_UARTEx_DisableFifoMode(&huart7) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN UART7_Init 2 */ + + /* USER CODE END UART7_Init 2 */ + +} + +/** + * Enable DMA controller clock + */ +static void MX_DMA_Init(void) +{ + + /* DMA controller clock enable */ + __HAL_RCC_DMA1_CLK_ENABLE(); + + /* DMA interrupt init */ + /* DMA1_Stream0_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA1_Stream0_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA1_Stream0_IRQn); + /* DMA1_Stream1_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA1_Stream1_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA1_Stream1_IRQn); + /* DMA1_Stream2_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA1_Stream2_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA1_Stream2_IRQn); + /* DMA1_Stream3_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA1_Stream3_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA1_Stream3_IRQn); + +} + +/* FMC initialization function */ +static void MX_FMC_Init(void) +{ + + /* USER CODE BEGIN FMC_Init 0 */ + + /* USER CODE END FMC_Init 0 */ + + FMC_SDRAM_TimingTypeDef SdramTiming = {0}; + + /* USER CODE BEGIN FMC_Init 1 */ + + /* USER CODE END FMC_Init 1 */ + + /** Perform the SDRAM1 memory initialization sequence + */ + hsdram1.Instance = FMC_SDRAM_DEVICE; + /* hsdram1.Init */ + hsdram1.Init.SDBank = FMC_SDRAM_BANK1; + hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_9; // 8; + hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_13; + hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_32; + hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4; + hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3; // 1; + hsdram1.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE; + hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2; + /* hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_DISABLE; // PERIOD_2; */ + hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE; // DISABLE; + hsdram1.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0; + /* SdramTiming */ + SdramTiming.LoadToActiveDelay = 2; // 16; + SdramTiming.ExitSelfRefreshDelay = 7; // 16; + SdramTiming.SelfRefreshTime = 4; // 16; + SdramTiming.RowCycleDelay = 8; // 16; + SdramTiming.WriteRecoveryTime = 3; // 16; + SdramTiming.RPDelay = 1; // 0 causes assertion error; // 16; + SdramTiming.RCDDelay = 10; // 16; + + if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK) + { + Error_Handler( ); + } + + /* USER CODE BEGIN FMC_Init 2 */ + + /* USER CODE END FMC_Init 2 */ +} + +/** + * @brief GPIO Initialization Function + * @param None + * @retval None + */ +static void MX_GPIO_Init(void) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + + /* GPIO Ports Clock Enable */ + __HAL_RCC_GPIOE_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + __HAL_RCC_GPIOG_CLK_ENABLE(); + __HAL_RCC_GPIOD_CLK_ENABLE(); + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOI_CLK_ENABLE(); + __HAL_RCC_GPIOH_CLK_ENABLE(); + __HAL_RCC_GPIOF_CLK_ENABLE(); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(GPIOG, OLED_CS_Pin|ADC_RST_Pin, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(OLED_DC_GPIO_Port, OLED_DC_Pin, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(GPIOI, GPIO_PIN_11, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(GPIOH, GPIO_PIN_4, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(GPIOA, OLED_RST_Pin|GPIO_PIN_3|GPIO_PIN_7, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(ADC_SPI_NCS_GPIO_Port, ADC_SPI_NCS_Pin, GPIO_PIN_RESET); + + /*Configure GPIO pins : PB8 PB4 PB9 PB2 + PB12 PB13 PB14 PB15 */ + GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_4|GPIO_PIN_9|GPIO_PIN_2 + |GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /*Configure GPIO pin : OLED_CS_Pin */ + GPIO_InitStruct.Pin = OLED_CS_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; + HAL_GPIO_Init(OLED_CS_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pins : PG13 PG9 */ + GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + + /*Configure GPIO pins : PD7 PD6 PD5 PD4 + PD3 PD11 */ + GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_6|GPIO_PIN_5|GPIO_PIN_4 + |GPIO_PIN_3|GPIO_PIN_11; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + /*Configure GPIO pin : PB7 */ + GPIO_InitStruct.Pin = GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF4_I2C1; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /*Configure GPIO pin : PG10 */ + GPIO_InitStruct.Pin = GPIO_PIN_10; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + + /*Configure GPIO pin : OLED_DC_Pin */ + GPIO_InitStruct.Pin = OLED_DC_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; + HAL_GPIO_Init(OLED_DC_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pins : EXTI13_Pin EXTI14_Pin PC9 PC8 */ + GPIO_InitStruct.Pin = EXTI13_Pin|EXTI14_Pin|GPIO_PIN_9|GPIO_PIN_8; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /*Configure GPIO pin : PI8 */ + GPIO_InitStruct.Pin = GPIO_PIN_8; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); + + /*Configure GPIO pin : PD2 */ + GPIO_InitStruct.Pin = GPIO_PIN_2; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + /*Configure GPIO pins : PA10 PA5 */ + GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_5; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /*Configure GPIO pin : PI11 */ + GPIO_InitStruct.Pin = GPIO_PIN_11; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); + + /*Configure GPIO pin : PC15 */ + GPIO_InitStruct.Pin = GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /*Configure GPIO pin : PH4 */ + GPIO_InitStruct.Pin = GPIO_PIN_4; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); + + /*Configure GPIO pin : ADC_RST_Pin */ + GPIO_InitStruct.Pin = ADC_RST_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(ADC_RST_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pins : PH6 PH7 */ + GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); + + /*Configure GPIO pins : PA0 PA6 */ + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_6; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /*Configure GPIO pin : OLED_RST_Pin */ + GPIO_InitStruct.Pin = OLED_RST_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; + HAL_GPIO_Init(OLED_RST_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pin : PC4 */ + GPIO_InitStruct.Pin = GPIO_PIN_4; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /*Configure GPIO pins : PA3 PA7 */ + GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /*Configure GPIO pin : ADC_SPI_NCS_Pin */ + GPIO_InitStruct.Pin = ADC_SPI_NCS_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(ADC_SPI_NCS_GPIO_Port, &GPIO_InitStruct); + + /* EXTI interrupt init*/ + HAL_NVIC_SetPriority(EXTI2_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(EXTI2_IRQn); + + HAL_NVIC_SetPriority(EXTI9_5_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); + + HAL_NVIC_SetPriority(EXTI15_10_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(EXTI15_10_IRQn); + +} + +/* USER CODE BEGIN 4 */ + +/* USER CODE END 4 */ + +/* USER CODE BEGIN Header_StartDefaultTask */ +/** + * @brief Function implementing the defaultTask thread. + * @param argument: Not used + * @retval None + */ +/* USER CODE END Header_StartDefaultTask */ +void StartDefaultTask(void const * argument) +{ + /* init code for USB_DEVICE */ + MX_USB_DEVICE_Init(); + /* USER CODE BEGIN 5 */ + + setup(); + + /* Infinite loop */ + for(;;) + { + loop(); + } + /* USER CODE END 5 */ +} + +/** + * @brief This function is executed in case of error occurrence. + * @retval None + */ +void Error_Handler(void) +{ + /* USER CODE BEGIN Error_Handler_Debug */ +#ifdef DEBUG + __asm__("BKPT"); +#else + NVIC_SystemReset(); +#endif + /* USER CODE END Error_Handler_Debug */ +} + +#ifdef USE_FULL_ASSERT +/** + * @brief Reports the name of the source file and the source line number + * where the assert_param error has occurred. + * @param file: pointer to the source file name + * @param line: assert_param error line source number + * @retval None + */ +void assert_failed(uint8_t *file, uint32_t line) +{ + /* USER CODE BEGIN 6 */ +#ifdef DEBUG + __asm__("BKPT"); +#else + NVIC_SystemReset(); +#endif + /* USER CODE END 6 */ +} +#endif /* USE_FULL_ASSERT */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ACDC/Core/Src/stm32h7xx_hal_msp.c b/ACDC/Core/Src/stm32h7xx_hal_msp.c new file mode 100644 index 00000000..3bb186c8 --- /dev/null +++ b/ACDC/Core/Src/stm32h7xx_hal_msp.c @@ -0,0 +1,1250 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32h7xx_hal_msp.c + * @brief This file provides code for the MSP Initialization + * and de-Initialization codes. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ +extern DMA_HandleTypeDef hdma_adc1; + +extern DMA_HandleTypeDef hdma_spi3_tx; + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN TD */ + +/* USER CODE END TD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN Define */ + +/* USER CODE END Define */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN Macro */ + +/* USER CODE END Macro */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* External functions --------------------------------------------------------*/ +/* USER CODE BEGIN ExternalFunctions */ + +/* USER CODE END ExternalFunctions */ + +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ +/** + * Initializes the Global MSP. + */ +void HAL_MspInit(void) +{ + /* USER CODE BEGIN MspInit 0 */ + + /* USER CODE END MspInit 0 */ + + __HAL_RCC_SYSCFG_CLK_ENABLE(); + + /* System interrupt init*/ + /* PendSV_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0); + + /* USER CODE BEGIN MspInit 1 */ + + /* USER CODE END MspInit 1 */ +} + +/** +* @brief ADC MSP Initialization +* This function configures the hardware resources used in this example +* @param hadc: ADC handle pointer +* @retval None +*/ +void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(hadc->Instance==ADC1) + { + /* USER CODE BEGIN ADC1_MspInit 0 */ + + /* USER CODE END ADC1_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_ADC12_CLK_ENABLE(); + + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**ADC1 GPIO Configuration + PC0 ------> ADC1_INP10 + PC1 ------> ADC1_INP11 + PA2 ------> ADC1_INP14 + PC5 ------> ADC1_INP8 + PB1 ------> ADC1_INP5 + PB0 ------> ADC1_INP9 + */ + GPIO_InitStruct.Pin = ADC1_Pin|ADC5_Pin|ADC4_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = ADC2_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(ADC2_GPIO_Port, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = ADC3_Pin|ADC7_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* ADC1 DMA Init */ + /* ADC1 Init */ + hdma_adc1.Instance = DMA1_Stream3; + hdma_adc1.Init.Request = DMA_REQUEST_ADC1; + hdma_adc1.Init.Direction = DMA_PERIPH_TO_MEMORY; + hdma_adc1.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_adc1.Init.MemInc = DMA_MINC_ENABLE; + hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; + hdma_adc1.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; + hdma_adc1.Init.Mode = DMA_CIRCULAR; + hdma_adc1.Init.Priority = DMA_PRIORITY_LOW; + hdma_adc1.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + if (HAL_DMA_Init(&hdma_adc1) != HAL_OK) + { + Error_Handler(); + } + + __HAL_LINKDMA(hadc,DMA_Handle,hdma_adc1); + + /* ADC1 interrupt Init */ + HAL_NVIC_SetPriority(ADC_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(ADC_IRQn); + /* USER CODE BEGIN ADC1_MspInit 1 */ + + /* USER CODE END ADC1_MspInit 1 */ + } + +} + +/** +* @brief ADC MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hadc: ADC handle pointer +* @retval None +*/ +void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) +{ + if(hadc->Instance==ADC1) + { + /* USER CODE BEGIN ADC1_MspDeInit 0 */ + + /* USER CODE END ADC1_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_ADC12_CLK_DISABLE(); + + /**ADC1 GPIO Configuration + PC0 ------> ADC1_INP10 + PC1 ------> ADC1_INP11 + PA2 ------> ADC1_INP14 + PC5 ------> ADC1_INP8 + PB1 ------> ADC1_INP5 + PB0 ------> ADC1_INP9 + */ + HAL_GPIO_DeInit(GPIOC, ADC1_Pin|ADC5_Pin|ADC4_Pin); + + HAL_GPIO_DeInit(ADC2_GPIO_Port, ADC2_Pin); + + HAL_GPIO_DeInit(GPIOB, ADC3_Pin|ADC7_Pin); + + /* ADC1 DMA DeInit */ + HAL_DMA_DeInit(hadc->DMA_Handle); + + /* ADC1 interrupt DeInit */ + HAL_NVIC_DisableIRQ(ADC_IRQn); + /* USER CODE BEGIN ADC1_MspDeInit 1 */ + + /* USER CODE END ADC1_MspDeInit 1 */ + } + +} + +/** +* @brief LPTIM MSP Initialization +* This function configures the hardware resources used in this example +* @param hlptim: LPTIM handle pointer +* @retval None +*/ +void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef* hlptim) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + if(hlptim->Instance==LPTIM1) + { + /* USER CODE BEGIN LPTIM1_MspInit 0 */ + + /* USER CODE END LPTIM1_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LPTIM1; + PeriphClkInitStruct.Lptim1ClockSelection = RCC_LPTIM1CLKSOURCE_D2PCLK1; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + + /* Peripheral clock enable */ + __HAL_RCC_LPTIM1_CLK_ENABLE(); + + __HAL_RCC_GPIOG_CLK_ENABLE(); + /**LPTIM1 GPIO Configuration + PG12 ------> LPTIM1_IN1 + PG11 ------> LPTIM1_IN2 + */ + GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_11; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF1_LPTIM1; + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + + /* USER CODE BEGIN LPTIM1_MspInit 1 */ + + /* USER CODE END LPTIM1_MspInit 1 */ + } + +} + +/** +* @brief LPTIM MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hlptim: LPTIM handle pointer +* @retval None +*/ +void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef* hlptim) +{ + if(hlptim->Instance==LPTIM1) + { + /* USER CODE BEGIN LPTIM1_MspDeInit 0 */ + + /* USER CODE END LPTIM1_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_LPTIM1_CLK_DISABLE(); + + /**LPTIM1 GPIO Configuration + PG12 ------> LPTIM1_IN1 + PG11 ------> LPTIM1_IN2 + */ + HAL_GPIO_DeInit(GPIOG, GPIO_PIN_12|GPIO_PIN_11); + + /* USER CODE BEGIN LPTIM1_MspDeInit 1 */ + + /* USER CODE END LPTIM1_MspDeInit 1 */ + } + +} + +/** +* @brief QSPI MSP Initialization +* This function configures the hardware resources used in this example +* @param hqspi: QSPI handle pointer +* @retval None +*/ +void HAL_QSPI_MspInit(QSPI_HandleTypeDef* hqspi) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + if(hqspi->Instance==QUADSPI) + { + /* USER CODE BEGIN QUADSPI_MspInit 0 */ + + /* USER CODE END QUADSPI_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_QSPI; + PeriphClkInitStruct.QspiClockSelection = RCC_QSPICLKSOURCE_D1HCLK; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + + /* Peripheral clock enable */ + __HAL_RCC_QSPI_CLK_ENABLE(); + + __HAL_RCC_GPIOE_CLK_ENABLE(); + __HAL_RCC_GPIOG_CLK_ENABLE(); + __HAL_RCC_GPIOF_CLK_ENABLE(); + /**QUADSPI GPIO Configuration + PE2 ------> QUADSPI_BK1_IO2 + PG6 ------> QUADSPI_BK1_NCS + PF6 ------> QUADSPI_BK1_IO3 + PF10 ------> QUADSPI_CLK + PF9 ------> QUADSPI_BK1_IO1 + PF8 ------> QUADSPI_BK1_IO0 + */ + GPIO_InitStruct.Pin = FLASH_DQ2_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI; + HAL_GPIO_Init(FLASH_DQ2_GPIO_Port, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = FLASH_NCS_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF10_QUADSPI; + HAL_GPIO_Init(FLASH_NCS_GPIO_Port, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = FLASH_DQ3_Pin|FLASH_CLK_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI; + HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = FLASH_DQ1_Pin|FLASH_DQ0_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF10_QUADSPI; + HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + + /* QUADSPI interrupt Init */ + HAL_NVIC_SetPriority(QUADSPI_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(QUADSPI_IRQn); + /* USER CODE BEGIN QUADSPI_MspInit 1 */ + + /* USER CODE END QUADSPI_MspInit 1 */ + } + +} + +/** +* @brief QSPI MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hqspi: QSPI handle pointer +* @retval None +*/ +void HAL_QSPI_MspDeInit(QSPI_HandleTypeDef* hqspi) +{ + if(hqspi->Instance==QUADSPI) + { + /* USER CODE BEGIN QUADSPI_MspDeInit 0 */ + + /* USER CODE END QUADSPI_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_QSPI_CLK_DISABLE(); + + /**QUADSPI GPIO Configuration + PE2 ------> QUADSPI_BK1_IO2 + PG6 ------> QUADSPI_BK1_NCS + PF6 ------> QUADSPI_BK1_IO3 + PF10 ------> QUADSPI_CLK + PF9 ------> QUADSPI_BK1_IO1 + PF8 ------> QUADSPI_BK1_IO0 + */ + HAL_GPIO_DeInit(FLASH_DQ2_GPIO_Port, FLASH_DQ2_Pin); + + HAL_GPIO_DeInit(FLASH_NCS_GPIO_Port, FLASH_NCS_Pin); + + HAL_GPIO_DeInit(GPIOF, FLASH_DQ3_Pin|FLASH_CLK_Pin|FLASH_DQ1_Pin|FLASH_DQ0_Pin); + + /* QUADSPI interrupt DeInit */ + HAL_NVIC_DisableIRQ(QUADSPI_IRQn); + /* USER CODE BEGIN QUADSPI_MspDeInit 1 */ + + /* USER CODE END QUADSPI_MspDeInit 1 */ + } + +} + +/** +* @brief SPI MSP Initialization +* This function configures the hardware resources used in this example +* @param hspi: SPI handle pointer +* @retval None +*/ +void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(hspi->Instance==SPI2) + { + /* USER CODE BEGIN SPI2_MspInit 0 */ + + /* USER CODE END SPI2_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_SPI2_CLK_ENABLE(); + + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**SPI2 GPIO Configuration + PC2_C ------> SPI2_MISO + PC3_C ------> SPI2_MOSI + PB10 ------> SPI2_SCK + */ + GPIO_InitStruct.Pin = ADC_SPI_MISO_Pin|ADC_SPI_MOSI_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF5_SPI2; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = ADC_SPI_CLK_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF5_SPI2; + HAL_GPIO_Init(ADC_SPI_CLK_GPIO_Port, &GPIO_InitStruct); + + /* USER CODE BEGIN SPI2_MspInit 1 */ + + /* USER CODE END SPI2_MspInit 1 */ + } + else if(hspi->Instance==SPI3) + { + /* USER CODE BEGIN SPI3_MspInit 0 */ + + /* USER CODE END SPI3_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_SPI3_CLK_ENABLE(); + + __HAL_RCC_GPIOC_CLK_ENABLE(); + /**SPI3 GPIO Configuration + PC12 ------> SPI3_MOSI + PC10 ------> SPI3_SCK + */ + GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_10; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF6_SPI3; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /* SPI3 DMA Init */ + /* SPI3_TX Init */ + hdma_spi3_tx.Instance = DMA1_Stream2; + hdma_spi3_tx.Init.Request = DMA_REQUEST_SPI3_TX; + hdma_spi3_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; + hdma_spi3_tx.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_spi3_tx.Init.MemInc = DMA_MINC_ENABLE; + hdma_spi3_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; + hdma_spi3_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; + hdma_spi3_tx.Init.Mode = DMA_NORMAL; + hdma_spi3_tx.Init.Priority = DMA_PRIORITY_LOW; + hdma_spi3_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + if (HAL_DMA_Init(&hdma_spi3_tx) != HAL_OK) + { + Error_Handler(); + } + + __HAL_LINKDMA(hspi,hdmatx,hdma_spi3_tx); + + /* SPI3 interrupt Init */ + HAL_NVIC_SetPriority(SPI3_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(SPI3_IRQn); + /* USER CODE BEGIN SPI3_MspInit 1 */ + + /* USER CODE END SPI3_MspInit 1 */ + } + +} + +/** +* @brief SPI MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hspi: SPI handle pointer +* @retval None +*/ +void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) +{ + if(hspi->Instance==SPI2) + { + /* USER CODE BEGIN SPI2_MspDeInit 0 */ + + /* USER CODE END SPI2_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_SPI2_CLK_DISABLE(); + + /**SPI2 GPIO Configuration + PC2_C ------> SPI2_MISO + PC3_C ------> SPI2_MOSI + PB10 ------> SPI2_SCK + */ + HAL_GPIO_DeInit(GPIOC, ADC_SPI_MISO_Pin|ADC_SPI_MOSI_Pin); + + HAL_GPIO_DeInit(ADC_SPI_CLK_GPIO_Port, ADC_SPI_CLK_Pin); + + /* USER CODE BEGIN SPI2_MspDeInit 1 */ + + /* USER CODE END SPI2_MspDeInit 1 */ + } + else if(hspi->Instance==SPI3) + { + /* USER CODE BEGIN SPI3_MspDeInit 0 */ + + /* USER CODE END SPI3_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_SPI3_CLK_DISABLE(); + + /**SPI3 GPIO Configuration + PC12 ------> SPI3_MOSI + PC10 ------> SPI3_SCK + */ + HAL_GPIO_DeInit(GPIOC, GPIO_PIN_12|GPIO_PIN_10); + + /* SPI3 DMA DeInit */ + HAL_DMA_DeInit(hspi->hdmatx); + + /* SPI3 interrupt DeInit */ + HAL_NVIC_DisableIRQ(SPI3_IRQn); + /* USER CODE BEGIN SPI3_MspDeInit 1 */ + + /* USER CODE END SPI3_MspDeInit 1 */ + } + +} + +/** +* @brief TIM_Encoder MSP Initialization +* This function configures the hardware resources used in this example +* @param htim_encoder: TIM_Encoder handle pointer +* @retval None +*/ +void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef* htim_encoder) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(htim_encoder->Instance==TIM2) + { + /* USER CODE BEGIN TIM2_MspInit 0 */ + + /* USER CODE END TIM2_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_TIM2_CLK_ENABLE(); + + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**TIM2 GPIO Configuration + PA15 (JTDI) ------> TIM2_CH1 + PA1 ------> TIM2_CH2 + */ + GPIO_InitStruct.Pin = GPIO_PIN_15|GPIO_PIN_1; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF1_TIM2; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* USER CODE BEGIN TIM2_MspInit 1 */ + + /* USER CODE END TIM2_MspInit 1 */ + } + else if(htim_encoder->Instance==TIM3) + { + /* USER CODE BEGIN TIM3_MspInit 0 */ + + /* USER CODE END TIM3_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_TIM3_CLK_ENABLE(); + + __HAL_RCC_GPIOC_CLK_ENABLE(); + /**TIM3 GPIO Configuration + PC7 ------> TIM3_CH2 + PC6 ------> TIM3_CH1 + */ + GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_6; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF2_TIM3; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /* USER CODE BEGIN TIM3_MspInit 1 */ + + /* USER CODE END TIM3_MspInit 1 */ + } + else if(htim_encoder->Instance==TIM4) + { + /* USER CODE BEGIN TIM4_MspInit 0 */ + + /* USER CODE END TIM4_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_TIM4_CLK_ENABLE(); + + __HAL_RCC_GPIOD_CLK_ENABLE(); + /**TIM4 GPIO Configuration + PD13 ------> TIM4_CH2 + PD12 ------> TIM4_CH1 + */ + GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_12; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_PULLUP; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF2_TIM4; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + /* TIM4 interrupt Init */ + HAL_NVIC_SetPriority(TIM4_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(TIM4_IRQn); + /* USER CODE BEGIN TIM4_MspInit 1 */ + + /* USER CODE END TIM4_MspInit 1 */ + } + +} + +/** +* @brief TIM_Encoder MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param htim_encoder: TIM_Encoder handle pointer +* @retval None +*/ +void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef* htim_encoder) +{ + if(htim_encoder->Instance==TIM2) + { + /* USER CODE BEGIN TIM2_MspDeInit 0 */ + + /* USER CODE END TIM2_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_TIM2_CLK_DISABLE(); + + /**TIM2 GPIO Configuration + PA15 (JTDI) ------> TIM2_CH1 + PA1 ------> TIM2_CH2 + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_15|GPIO_PIN_1); + + /* USER CODE BEGIN TIM2_MspDeInit 1 */ + + /* USER CODE END TIM2_MspDeInit 1 */ + } + else if(htim_encoder->Instance==TIM3) + { + /* USER CODE BEGIN TIM3_MspDeInit 0 */ + + /* USER CODE END TIM3_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_TIM3_CLK_DISABLE(); + + /**TIM3 GPIO Configuration + PC7 ------> TIM3_CH2 + PC6 ------> TIM3_CH1 + */ + HAL_GPIO_DeInit(GPIOC, GPIO_PIN_7|GPIO_PIN_6); + + /* USER CODE BEGIN TIM3_MspDeInit 1 */ + + /* USER CODE END TIM3_MspDeInit 1 */ + } + else if(htim_encoder->Instance==TIM4) + { + /* USER CODE BEGIN TIM4_MspDeInit 0 */ + + /* USER CODE END TIM4_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_TIM4_CLK_DISABLE(); + + /**TIM4 GPIO Configuration + PD13 ------> TIM4_CH2 + PD12 ------> TIM4_CH1 + */ + HAL_GPIO_DeInit(GPIOD, GPIO_PIN_13|GPIO_PIN_12); + + /* TIM4 interrupt DeInit */ + HAL_NVIC_DisableIRQ(TIM4_IRQn); + /* USER CODE BEGIN TIM4_MspDeInit 1 */ + + /* USER CODE END TIM4_MspDeInit 1 */ + } + +} + +/** +* @brief UART MSP Initialization +* This function configures the hardware resources used in this example +* @param huart: UART handle pointer +* @retval None +*/ +void HAL_UART_MspInit(UART_HandleTypeDef* huart) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + if(huart->Instance==UART5) + { + /* USER CODE BEGIN UART5_MspInit 0 */ + + /* USER CODE END UART5_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_UART5; + PeriphClkInitStruct.Usart234578ClockSelection = RCC_USART234578CLKSOURCE_D2PCLK1; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + + /* Peripheral clock enable */ + __HAL_RCC_UART5_CLK_ENABLE(); + + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**UART5 GPIO Configuration + PB5 ------> UART5_RX + PB6 ------> UART5_TX + */ + GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF14_UART5; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* USER CODE BEGIN UART5_MspInit 1 */ + + /* USER CODE END UART5_MspInit 1 */ + } + else if(huart->Instance==UART7) + { + /* USER CODE BEGIN UART7_MspInit 0 */ + + /* USER CODE END UART7_MspInit 0 */ + + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_UART7; + PeriphClkInitStruct.Usart234578ClockSelection = RCC_USART234578CLKSOURCE_D2PCLK1; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + + /* Peripheral clock enable */ + __HAL_RCC_UART7_CLK_ENABLE(); + + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOF_CLK_ENABLE(); + /**UART7 GPIO Configuration + PA8 ------> UART7_RX + PF7 ------> UART7_TX + */ + GPIO_InitStruct.Pin = GPIO_PIN_8; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF11_UART7; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF7_UART7; + HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + + /* USER CODE BEGIN UART7_MspInit 1 */ + + /* USER CODE END UART7_MspInit 1 */ + } + +} + +/** +* @brief UART MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param huart: UART handle pointer +* @retval None +*/ +void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) +{ + if(huart->Instance==UART5) + { + /* USER CODE BEGIN UART5_MspDeInit 0 */ + + /* USER CODE END UART5_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_UART5_CLK_DISABLE(); + + /**UART5 GPIO Configuration + PB5 ------> UART5_RX + PB6 ------> UART5_TX + */ + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_5|GPIO_PIN_6); + + /* USER CODE BEGIN UART5_MspDeInit 1 */ + + /* USER CODE END UART5_MspDeInit 1 */ + } + else if(huart->Instance==UART7) + { + /* USER CODE BEGIN UART7_MspDeInit 0 */ + + /* USER CODE END UART7_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_UART7_CLK_DISABLE(); + + /**UART7 GPIO Configuration + PA8 ------> UART7_RX + PF7 ------> UART7_TX + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_8); + + HAL_GPIO_DeInit(GPIOF, GPIO_PIN_7); + + /* USER CODE BEGIN UART7_MspDeInit 1 */ + + /* USER CODE END UART7_MspDeInit 1 */ + } + +} + +static uint32_t FMC_Initialized = 0; + +static void HAL_FMC_MspInit(void){ + /* USER CODE BEGIN FMC_MspInit 0 */ + + /* USER CODE END FMC_MspInit 0 */ + GPIO_InitTypeDef GPIO_InitStruct ={0}; + if (FMC_Initialized) { + return; + } + FMC_Initialized = 1; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_FMC; + PeriphClkInitStruct.FmcClockSelection = RCC_FMCCLKSOURCE_D1HCLK; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + + /* Peripheral clock enable */ + __HAL_RCC_FMC_CLK_ENABLE(); + + /** FMC GPIO Configuration + PE1 ------> FMC_NBL1 + PE0 ------> FMC_NBL0 + PG15 ------> FMC_SDNCAS + PD0 ------> FMC_D2 + PI7 ------> FMC_D29 + PI6 ------> FMC_D28 + PI5 ------> FMC_NBL3 + PD1 ------> FMC_D3 + PI3 ------> FMC_D27 + PI2 ------> FMC_D26 + PI9 ------> FMC_D30 + PI4 ------> FMC_NBL2 + PH15 ------> FMC_D23 + PI1 ------> FMC_D25 + PF0 ------> FMC_A0 + PI10 ------> FMC_D31 + PH13 ------> FMC_D21 + PH14 ------> FMC_D22 + PI0 ------> FMC_D24 + PH2 ------> FMC_SDCKE0 + PH3 ------> FMC_SDNE0 + PF2 ------> FMC_A2 + PF1 ------> FMC_A1 + PG8 ------> FMC_SDCLK + PF3 ------> FMC_A3 + PF4 ------> FMC_A4 + PH5 ------> FMC_SDNWE + PF5 ------> FMC_A5 + PH12 ------> FMC_D20 + PG5 ------> FMC_BA1 + PG4 ------> FMC_BA0 + PH11 ------> FMC_D19 + PH10 ------> FMC_D18 + PD15 ------> FMC_D1 + PG2 ------> FMC_A12 + PG1 ------> FMC_A11 + PH8 ------> FMC_D16 + PH9 ------> FMC_D17 + PD14 ------> FMC_D0 + PF13 ------> FMC_A7 + PG0 ------> FMC_A10 + PE13 ------> FMC_D10 + PD10 ------> FMC_D15 + PF12 ------> FMC_A6 + PF15 ------> FMC_A9 + PE8 ------> FMC_D5 + PE9 ------> FMC_D6 + PE11 ------> FMC_D8 + PE14 ------> FMC_D11 + PD9 ------> FMC_D14 + PD8 ------> FMC_D13 + PF11 ------> FMC_SDNRAS + PF14 ------> FMC_A8 + PE7 ------> FMC_D4 + PE10 ------> FMC_D7 + PE12 ------> FMC_D9 + PE15 ------> FMC_D12 + */ + GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_0|GPIO_PIN_13|GPIO_PIN_8 + |GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_14|GPIO_PIN_7 + |GPIO_PIN_10|GPIO_PIN_12|GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_15|GPIO_PIN_8|GPIO_PIN_5|GPIO_PIN_4 + |GPIO_PIN_2|GPIO_PIN_1|GPIO_PIN_0; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_15|GPIO_PIN_14 + |GPIO_PIN_10|GPIO_PIN_9|GPIO_PIN_8; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_6|GPIO_PIN_5|GPIO_PIN_3 + |GPIO_PIN_2|GPIO_PIN_9|GPIO_PIN_4|GPIO_PIN_1 + |GPIO_PIN_10|GPIO_PIN_0; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_15|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_2 + |GPIO_PIN_3|GPIO_PIN_5|GPIO_PIN_12|GPIO_PIN_11 + |GPIO_PIN_10|GPIO_PIN_8|GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_1|GPIO_PIN_3 + |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_13|GPIO_PIN_12 + |GPIO_PIN_15|GPIO_PIN_11|GPIO_PIN_14; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + + /* USER CODE BEGIN FMC_MspInit 1 */ + + /* USER CODE END FMC_MspInit 1 */ +} + +void HAL_SDRAM_MspInit(SDRAM_HandleTypeDef* hsdram){ + /* USER CODE BEGIN SDRAM_MspInit 0 */ + + /* USER CODE END SDRAM_MspInit 0 */ + HAL_FMC_MspInit(); + /* USER CODE BEGIN SDRAM_MspInit 1 */ + + /* USER CODE END SDRAM_MspInit 1 */ +} + +static uint32_t FMC_DeInitialized = 0; + +static void HAL_FMC_MspDeInit(void){ + /* USER CODE BEGIN FMC_MspDeInit 0 */ + + /* USER CODE END FMC_MspDeInit 0 */ + if (FMC_DeInitialized) { + return; + } + FMC_DeInitialized = 1; + /* Peripheral clock enable */ + __HAL_RCC_FMC_CLK_DISABLE(); + + /** FMC GPIO Configuration + PE1 ------> FMC_NBL1 + PE0 ------> FMC_NBL0 + PG15 ------> FMC_SDNCAS + PD0 ------> FMC_D2 + PI7 ------> FMC_D29 + PI6 ------> FMC_D28 + PI5 ------> FMC_NBL3 + PD1 ------> FMC_D3 + PI3 ------> FMC_D27 + PI2 ------> FMC_D26 + PI9 ------> FMC_D30 + PI4 ------> FMC_NBL2 + PH15 ------> FMC_D23 + PI1 ------> FMC_D25 + PF0 ------> FMC_A0 + PI10 ------> FMC_D31 + PH13 ------> FMC_D21 + PH14 ------> FMC_D22 + PI0 ------> FMC_D24 + PH2 ------> FMC_SDCKE0 + PH3 ------> FMC_SDNE0 + PF2 ------> FMC_A2 + PF1 ------> FMC_A1 + PG8 ------> FMC_SDCLK + PF3 ------> FMC_A3 + PF4 ------> FMC_A4 + PH5 ------> FMC_SDNWE + PF5 ------> FMC_A5 + PH12 ------> FMC_D20 + PG5 ------> FMC_BA1 + PG4 ------> FMC_BA0 + PH11 ------> FMC_D19 + PH10 ------> FMC_D18 + PD15 ------> FMC_D1 + PG2 ------> FMC_A12 + PG1 ------> FMC_A11 + PH8 ------> FMC_D16 + PH9 ------> FMC_D17 + PD14 ------> FMC_D0 + PF13 ------> FMC_A7 + PG0 ------> FMC_A10 + PE13 ------> FMC_D10 + PD10 ------> FMC_D15 + PF12 ------> FMC_A6 + PF15 ------> FMC_A9 + PE8 ------> FMC_D5 + PE9 ------> FMC_D6 + PE11 ------> FMC_D8 + PE14 ------> FMC_D11 + PD9 ------> FMC_D14 + PD8 ------> FMC_D13 + PF11 ------> FMC_SDNRAS + PF14 ------> FMC_A8 + PE7 ------> FMC_D4 + PE10 ------> FMC_D7 + PE12 ------> FMC_D9 + PE15 ------> FMC_D12 + */ + HAL_GPIO_DeInit(GPIOE, GPIO_PIN_1|GPIO_PIN_0|GPIO_PIN_13|GPIO_PIN_8 + |GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_14|GPIO_PIN_7 + |GPIO_PIN_10|GPIO_PIN_12|GPIO_PIN_15); + + HAL_GPIO_DeInit(GPIOG, GPIO_PIN_15|GPIO_PIN_8|GPIO_PIN_5|GPIO_PIN_4 + |GPIO_PIN_2|GPIO_PIN_1|GPIO_PIN_0); + + HAL_GPIO_DeInit(GPIOD, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_15|GPIO_PIN_14 + |GPIO_PIN_10|GPIO_PIN_9|GPIO_PIN_8); + + HAL_GPIO_DeInit(GPIOI, GPIO_PIN_7|GPIO_PIN_6|GPIO_PIN_5|GPIO_PIN_3 + |GPIO_PIN_2|GPIO_PIN_9|GPIO_PIN_4|GPIO_PIN_1 + |GPIO_PIN_10|GPIO_PIN_0); + + HAL_GPIO_DeInit(GPIOH, GPIO_PIN_15|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_2 + |GPIO_PIN_3|GPIO_PIN_5|GPIO_PIN_12|GPIO_PIN_11 + |GPIO_PIN_10|GPIO_PIN_8|GPIO_PIN_9); + + HAL_GPIO_DeInit(GPIOF, GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_1|GPIO_PIN_3 + |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_13|GPIO_PIN_12 + |GPIO_PIN_15|GPIO_PIN_11|GPIO_PIN_14); + + /* USER CODE BEGIN FMC_MspDeInit 1 */ + + /* USER CODE END FMC_MspDeInit 1 */ +} + +void HAL_SDRAM_MspDeInit(SDRAM_HandleTypeDef* hsdram){ + /* USER CODE BEGIN SDRAM_MspDeInit 0 */ + + /* USER CODE END SDRAM_MspDeInit 0 */ + HAL_FMC_MspDeInit(); + /* USER CODE BEGIN SDRAM_MspDeInit 1 */ + + /* USER CODE END SDRAM_MspDeInit 1 */ +} + +extern DMA_HandleTypeDef hdma_sai1_a; + +extern DMA_HandleTypeDef hdma_sai1_b; + +static uint32_t SAI1_client =0; + +void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) +{ + + GPIO_InitTypeDef GPIO_InitStruct; +/* SAI1 */ + if(hsai->Instance==SAI1_Block_A) + { + /* Peripheral clock enable */ + if (SAI1_client == 0) + { + __HAL_RCC_SAI1_CLK_ENABLE(); + + /* Peripheral interrupt init*/ + HAL_NVIC_SetPriority(SAI1_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(SAI1_IRQn); + } + SAI1_client ++; + + /**SAI1_A_Block_A GPIO Configuration + PE4 ------> SAI1_FS_A + PE5 ------> SAI1_SCK_A + PE6 ------> SAI1_SD_A + PG7 ------> SAI1_MCLK_A + */ + GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; + HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + + /* Peripheral DMA init*/ + + hdma_sai1_a.Instance = DMA1_Stream0; + hdma_sai1_a.Init.Request = DMA_REQUEST_SAI1_A; + hdma_sai1_a.Init.Direction = DMA_PERIPH_TO_MEMORY; + hdma_sai1_a.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_sai1_a.Init.MemInc = DMA_MINC_ENABLE; + hdma_sai1_a.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; + hdma_sai1_a.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; + hdma_sai1_a.Init.Mode = DMA_CIRCULAR; + hdma_sai1_a.Init.Priority = DMA_PRIORITY_VERY_HIGH; + hdma_sai1_a.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + if (HAL_DMA_Init(&hdma_sai1_a) != HAL_OK) + { + Error_Handler(); + } + + /* Several peripheral DMA handle pointers point to the same DMA handle. + Be aware that there is only one channel to perform all the requested DMAs. */ + __HAL_LINKDMA(hsai,hdmarx,hdma_sai1_a); + + __HAL_LINKDMA(hsai,hdmatx,hdma_sai1_a); + + } + if(hsai->Instance==SAI1_Block_B) + { + /* Peripheral clock enable */ + if (SAI1_client == 0) + { + __HAL_RCC_SAI1_CLK_ENABLE(); + + /* Peripheral interrupt init*/ + HAL_NVIC_SetPriority(SAI1_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(SAI1_IRQn); + } + SAI1_client ++; + + /**SAI1_B_Block_B GPIO Configuration + PE3 ------> SAI1_SD_B + */ + GPIO_InitStruct.Pin = GPIO_PIN_3; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; + HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + + /* Peripheral DMA init*/ + + hdma_sai1_b.Instance = DMA1_Stream1; + hdma_sai1_b.Init.Request = DMA_REQUEST_SAI1_B; + hdma_sai1_b.Init.Direction = DMA_MEMORY_TO_PERIPH; + hdma_sai1_b.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_sai1_b.Init.MemInc = DMA_MINC_ENABLE; + hdma_sai1_b.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; + hdma_sai1_b.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; + hdma_sai1_b.Init.Mode = DMA_CIRCULAR; + hdma_sai1_b.Init.Priority = DMA_PRIORITY_VERY_HIGH; + hdma_sai1_b.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + if (HAL_DMA_Init(&hdma_sai1_b) != HAL_OK) + { + Error_Handler(); + } + + /* Several peripheral DMA handle pointers point to the same DMA handle. + Be aware that there is only one channel to perform all the requested DMAs. */ + __HAL_LINKDMA(hsai,hdmarx,hdma_sai1_b); + __HAL_LINKDMA(hsai,hdmatx,hdma_sai1_b); + } +} + +void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) +{ +/* SAI1 */ + if(hsai->Instance==SAI1_Block_A) + { + SAI1_client --; + if (SAI1_client == 0) + { + /* Peripheral clock disable */ + __HAL_RCC_SAI1_CLK_DISABLE(); + HAL_NVIC_DisableIRQ(SAI1_IRQn); + } + + /**SAI1_A_Block_A GPIO Configuration + PE4 ------> SAI1_FS_A + PE5 ------> SAI1_SCK_A + PE6 ------> SAI1_SD_A + PG7 ------> SAI1_MCLK_A + */ + HAL_GPIO_DeInit(GPIOE, GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6); + + HAL_GPIO_DeInit(GPIOG, GPIO_PIN_7); + + HAL_DMA_DeInit(hsai->hdmarx); + HAL_DMA_DeInit(hsai->hdmatx); + } + if(hsai->Instance==SAI1_Block_B) + { + SAI1_client --; + if (SAI1_client == 0) + { + /* Peripheral clock disable */ + __HAL_RCC_SAI1_CLK_DISABLE(); + HAL_NVIC_DisableIRQ(SAI1_IRQn); + } + + /**SAI1_B_Block_B GPIO Configuration + PE3 ------> SAI1_SD_B + */ + HAL_GPIO_DeInit(GPIOE, GPIO_PIN_3); + + HAL_DMA_DeInit(hsai->hdmarx); + HAL_DMA_DeInit(hsai->hdmatx); + } +} + +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ACDC/Core/Src/stm32h7xx_it.c b/ACDC/Core/Src/stm32h7xx_it.c new file mode 100644 index 00000000..2015fed9 --- /dev/null +++ b/ACDC/Core/Src/stm32h7xx_it.c @@ -0,0 +1,296 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32h7xx_it.c + * @brief Interrupt Service Routines. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "stm32h7xx_it.h" +#include "FreeRTOS.h" +#include "task.h" +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN TD */ + +/* USER CODE END TD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ + +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* Private user code ---------------------------------------------------------*/ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* External variables --------------------------------------------------------*/ +extern PCD_HandleTypeDef hpcd_USB_OTG_FS; +extern DMA_HandleTypeDef hdma_adc1; +extern ADC_HandleTypeDef hadc1; +extern QSPI_HandleTypeDef hqspi; +extern DMA_HandleTypeDef hdma_sai1_a; +extern DMA_HandleTypeDef hdma_sai1_b; +extern SAI_HandleTypeDef hsai_BlockA1; +extern SAI_HandleTypeDef hsai_BlockB1; +extern DMA_HandleTypeDef hdma_spi3_tx; +extern SPI_HandleTypeDef hspi3; +extern TIM_HandleTypeDef htim4; +/* USER CODE BEGIN EV */ + +/* USER CODE END EV */ + +/******************************************************************************/ +/* Cortex Processor Interruption and Exception Handlers */ +/******************************************************************************/ +/** + * @brief This function handles System tick timer. + */ +void SysTick_Handler(void) +{ + /* USER CODE BEGIN SysTick_IRQn 0 */ + + /* USER CODE END SysTick_IRQn 0 */ + HAL_IncTick(); +#if (INCLUDE_xTaskGetSchedulerState == 1 ) + if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) + { +#endif /* INCLUDE_xTaskGetSchedulerState */ + xPortSysTickHandler(); +#if (INCLUDE_xTaskGetSchedulerState == 1 ) + } +#endif /* INCLUDE_xTaskGetSchedulerState */ + /* USER CODE BEGIN SysTick_IRQn 1 */ + + /* USER CODE END SysTick_IRQn 1 */ +} + +/******************************************************************************/ +/* STM32H7xx Peripheral Interrupt Handlers */ +/* Add here the Interrupt Handlers for the used peripherals. */ +/* For the available peripheral interrupt handler names, */ +/* please refer to the startup file (startup_stm32h7xx.s). */ +/******************************************************************************/ + +/** + * @brief This function handles EXTI line2 interrupt. + */ +void EXTI2_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI2_IRQn 0 */ + + /* USER CODE END EXTI2_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2); + /* USER CODE BEGIN EXTI2_IRQn 1 */ + + /* USER CODE END EXTI2_IRQn 1 */ +} + +/** + * @brief This function handles DMA1 stream0 global interrupt. + */ +void DMA1_Stream0_IRQHandler(void) +{ + /* USER CODE BEGIN DMA1_Stream0_IRQn 0 */ + + /* USER CODE END DMA1_Stream0_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_sai1_a); + /* USER CODE BEGIN DMA1_Stream0_IRQn 1 */ + + /* USER CODE END DMA1_Stream0_IRQn 1 */ +} + +/** + * @brief This function handles DMA1 stream1 global interrupt. + */ +void DMA1_Stream1_IRQHandler(void) +{ + /* USER CODE BEGIN DMA1_Stream1_IRQn 0 */ + + /* USER CODE END DMA1_Stream1_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_sai1_b); + /* USER CODE BEGIN DMA1_Stream1_IRQn 1 */ + + /* USER CODE END DMA1_Stream1_IRQn 1 */ +} + +/** + * @brief This function handles DMA1 stream2 global interrupt. + */ +void DMA1_Stream2_IRQHandler(void) +{ + /* USER CODE BEGIN DMA1_Stream2_IRQn 0 */ + + /* USER CODE END DMA1_Stream2_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_spi3_tx); + /* USER CODE BEGIN DMA1_Stream2_IRQn 1 */ + + /* USER CODE END DMA1_Stream2_IRQn 1 */ +} + +/** + * @brief This function handles DMA1 stream3 global interrupt. + */ +void DMA1_Stream3_IRQHandler(void) +{ + /* USER CODE BEGIN DMA1_Stream3_IRQn 0 */ + + /* USER CODE END DMA1_Stream3_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_adc1); + /* USER CODE BEGIN DMA1_Stream3_IRQn 1 */ + + /* USER CODE END DMA1_Stream3_IRQn 1 */ +} + +/** + * @brief This function handles ADC1 and ADC2 global interrupts. + */ +void ADC_IRQHandler(void) +{ + /* USER CODE BEGIN ADC_IRQn 0 */ + + /* USER CODE END ADC_IRQn 0 */ + HAL_ADC_IRQHandler(&hadc1); + /* USER CODE BEGIN ADC_IRQn 1 */ + + /* USER CODE END ADC_IRQn 1 */ +} + +/** + * @brief This function handles EXTI line[9:5] interrupts. + */ +void EXTI9_5_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI9_5_IRQn 0 */ + + /* USER CODE END EXTI9_5_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8); + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_9); + /* USER CODE BEGIN EXTI9_5_IRQn 1 */ + + /* USER CODE END EXTI9_5_IRQn 1 */ +} + +/** + * @brief This function handles TIM4 global interrupt. + */ +void TIM4_IRQHandler(void) +{ + /* USER CODE BEGIN TIM4_IRQn 0 */ + + /* USER CODE END TIM4_IRQn 0 */ + HAL_TIM_IRQHandler(&htim4); + /* USER CODE BEGIN TIM4_IRQn 1 */ + + /* USER CODE END TIM4_IRQn 1 */ +} + +/** + * @brief This function handles EXTI line[15:10] interrupts. + */ +void EXTI15_10_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI15_10_IRQn 0 */ + + /* USER CODE END EXTI15_10_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_13); + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_14); + /* USER CODE BEGIN EXTI15_10_IRQn 1 */ + + /* USER CODE END EXTI15_10_IRQn 1 */ +} + +/** + * @brief This function handles SPI3 global interrupt. + */ +void SPI3_IRQHandler(void) +{ + /* USER CODE BEGIN SPI3_IRQn 0 */ + + /* USER CODE END SPI3_IRQn 0 */ + HAL_SPI_IRQHandler(&hspi3); + /* USER CODE BEGIN SPI3_IRQn 1 */ + + /* USER CODE END SPI3_IRQn 1 */ +} + +/** + * @brief This function handles SAI1 global interrupt. + */ +void SAI1_IRQHandler(void) +{ + /* USER CODE BEGIN SAI1_IRQn 0 */ + + /* USER CODE END SAI1_IRQn 0 */ + HAL_SAI_IRQHandler(&hsai_BlockA1); + HAL_SAI_IRQHandler(&hsai_BlockB1); + /* USER CODE BEGIN SAI1_IRQn 1 */ + + /* USER CODE END SAI1_IRQn 1 */ +} + +/** + * @brief This function handles QUADSPI global interrupt. + */ +void QUADSPI_IRQHandler(void) +{ + /* USER CODE BEGIN QUADSPI_IRQn 0 */ + + /* USER CODE END QUADSPI_IRQn 0 */ + HAL_QSPI_IRQHandler(&hqspi); + /* USER CODE BEGIN QUADSPI_IRQn 1 */ + + /* USER CODE END QUADSPI_IRQn 1 */ +} + +/** + * @brief This function handles USB On The Go FS global interrupt. + */ +void OTG_FS_IRQHandler(void) +{ + /* USER CODE BEGIN OTG_FS_IRQn 0 */ + + /* USER CODE END OTG_FS_IRQn 0 */ + HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS); + /* USER CODE BEGIN OTG_FS_IRQn 1 */ + + /* USER CODE END OTG_FS_IRQn 1 */ +} + +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ACDC/Core/Src/system_stm32h7xx.c b/ACDC/Core/Src/system_stm32h7xx.c new file mode 100644 index 00000000..9ae8b842 --- /dev/null +++ b/ACDC/Core/Src/system_stm32h7xx.c @@ -0,0 +1,402 @@ +/** + ****************************************************************************** + * @file system_stm32h7xx.c + * @author MCD Application Team + * @brief CMSIS Cortex-Mx Device Peripheral Access Layer System Source File. + * + * This file provides two functions and one global variable to be called from + * user application: + * - SystemInit(): This function is called at startup just after reset and + * before branch to main program. This call is made inside + * the "startup_stm32h7xx.s" file. + * + * - SystemCoreClock variable: Contains the core clock, it can be used + * by the user application to setup the SysTick + * timer or configure other parameters. + * + * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must + * be called whenever the core clock is changed + * during program execution. + * + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup stm32h7xx_system + * @{ + */ + +/** @addtogroup STM32H7xx_System_Private_Includes + * @{ + */ + +#include "stm32h7xx.h" +#include +#if !defined (HSE_VALUE) +#define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (CSI_VALUE) + #define CSI_VALUE ((uint32_t)4000000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* CSI_VALUE */ + +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)64000000) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_Defines + * @{ + */ + +/************************* Miscellaneous Configuration ************************/ +/*!< Uncomment the following line if you need to use initialized data in D2 domain SRAM (AHB SRAM) */ +#define DATA_IN_D2_SRAM + +/******************************************************************************/ + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_Variables + * @{ + */ + /* This variable is updated in three ways: + 1) by calling CMSIS function SystemCoreClockUpdate() + 2) by calling HAL API function HAL_RCC_GetHCLKFreq() + 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency + Note: If you use this function to configure the system clock; then there + is no need to call the 2 first functions listed above, since SystemCoreClock + variable is updated automatically. + */ + uint32_t SystemCoreClock = 64000000; + uint32_t SystemD2Clock = 64000000; + const uint8_t D1CorePrescTable[16] = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, 8, 9}; + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32H7xx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system + * Initialize the FPU setting and vector table location + * configuration. + * @param None + * @retval None + */ +void SystemInit (void) +{ +#if defined (DATA_IN_D2_SRAM) + __IO uint32_t tmpreg; +#endif /* DATA_IN_D2_SRAM */ + + /* FPU settings ------------------------------------------------------------*/ + #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) + SCB->CPACR |= ((3UL << (10*2))|(3UL << (11*2))); /* set CP10 and CP11 Full Access */ + #endif + /* Reset the RCC clock configuration to the default reset state ------------*/ + + /* Increasing the CPU frequency */ + if(FLASH_LATENCY_DEFAULT > (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY))) + { + /* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */ + MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (uint32_t)(FLASH_LATENCY_DEFAULT)); + } + + /* Set HSION bit */ + RCC->CR |= RCC_CR_HSION; + + /* Reset CFGR register */ + RCC->CFGR = 0x00000000; + + /* Reset HSEON, HSECSSON, CSION, HSI48ON, CSIKERON, PLL1ON, PLL2ON and PLL3ON bits */ + RCC->CR &= 0xEAF6ED7FU; + + /* Decreasing the number of wait states because of lower CPU frequency */ + if(FLASH_LATENCY_DEFAULT < (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY))) + { + /* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */ + MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (uint32_t)(FLASH_LATENCY_DEFAULT)); + } + +#if defined(D3_SRAM_BASE) + /* Reset D1CFGR register */ + RCC->D1CFGR = 0x00000000; + + /* Reset D2CFGR register */ + RCC->D2CFGR = 0x00000000; + + /* Reset D3CFGR register */ + RCC->D3CFGR = 0x00000000; +#else + /* Reset CDCFGR1 register */ + RCC->CDCFGR1 = 0x00000000; + + /* Reset CDCFGR2 register */ + RCC->CDCFGR2 = 0x00000000; + + /* Reset SRDCFGR register */ + RCC->SRDCFGR = 0x00000000; +#endif + /* Reset PLLCKSELR register */ + RCC->PLLCKSELR = 0x02020200; + + /* Reset PLLCFGR register */ + RCC->PLLCFGR = 0x01FF0000; + /* Reset PLL1DIVR register */ + RCC->PLL1DIVR = 0x01010280; + /* Reset PLL1FRACR register */ + RCC->PLL1FRACR = 0x00000000; + + /* Reset PLL2DIVR register */ + RCC->PLL2DIVR = 0x01010280; + + /* Reset PLL2FRACR register */ + + RCC->PLL2FRACR = 0x00000000; + /* Reset PLL3DIVR register */ + RCC->PLL3DIVR = 0x01010280; + + /* Reset PLL3FRACR register */ + RCC->PLL3FRACR = 0x00000000; + + /* Reset HSEBYP bit */ + RCC->CR &= 0xFFFBFFFFU; + + /* Disable all interrupts */ + RCC->CIER = 0x00000000; + +#if (STM32H7_DEV_ID == 0x450UL) + /* dual core CM7 or single core line */ + if((DBGMCU->IDCODE & 0xFFFF0000U) < 0x20000000U) + { + /* if stm32h7 revY*/ + /* Change the switch matrix read issuing capability to 1 for the AXI SRAM target (Target 7) */ + *((__IO uint32_t*)0x51008108) = 0x000000001U; + } +#endif + +#if defined (DATA_IN_D2_SRAM) + /* in case of initialized data in D2 SRAM (AHB SRAM) , enable the D2 SRAM clock (AHB SRAM clock) */ +#if defined(RCC_AHB2ENR_D2SRAM3EN) + RCC->AHB2ENR |= (RCC_AHB2ENR_D2SRAM1EN | RCC_AHB2ENR_D2SRAM2EN | RCC_AHB2ENR_D2SRAM3EN); +#elif defined(RCC_AHB2ENR_D2SRAM2EN) + RCC->AHB2ENR |= (RCC_AHB2ENR_D2SRAM1EN | RCC_AHB2ENR_D2SRAM2EN); +#else + RCC->AHB2ENR |= (RCC_AHB2ENR_AHBSRAM1EN | RCC_AHB2ENR_AHBSRAM2EN); +#endif /* RCC_AHB2ENR_D2SRAM3EN */ + + tmpreg = RCC->AHB2ENR; + (void) tmpreg; +#endif /* DATA_IN_D2_SRAM */ + + /* + * Disable the FMC bank1 (enabled after reset). + * This, prevents CPU speculation access on this bank which blocks the use of FMC during + * 24us. During this time the others FMC master (such as LTDC) cannot use it! + */ + FMC_Bank1_R->BTCR[0] = 0x000030D2; + + /* Configure the Vector Table location add offset address for cortex-M7 ------------------*/ + extern char _ISR_VECTOR; + SCB->VTOR = (uint32_t)&_ISR_VECTOR; + +} + +/** + * @brief Update SystemCoreClock variable according to Clock Register Values. + * The SystemCoreClock variable contains the core clock , it can + * be used by the user application to setup the SysTick timer or configure + * other parameters. + * + * @note Each time the core clock changes, this function must be called + * to update SystemCoreClock variable value. Otherwise, any configuration + * based on this variable will be incorrect. + * + * @note - The system frequency computed by this function is not the real + * frequency in the chip. It is calculated based on the predefined + * constant and the selected clock source: + * + * - If SYSCLK source is CSI, SystemCoreClock will contain the CSI_VALUE(*) + * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(**) + * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(***) + * - If SYSCLK source is PLL, SystemCoreClock will contain the CSI_VALUE(*), + * HSI_VALUE(**) or HSE_VALUE(***) multiplied/divided by the PLL factors. + * + * (*) CSI_VALUE is a constant defined in stm32h7xx_hal.h file (default value + * 4 MHz) but the real value may vary depending on the variations + * in voltage and temperature. + * (**) HSI_VALUE is a constant defined in stm32h7xx_hal.h file (default value + * 64 MHz) but the real value may vary depending on the variations + * in voltage and temperature. + * + * (***)HSE_VALUE is a constant defined in stm32h7xx_hal.h file (default value + * 25 MHz), user has to ensure that HSE_VALUE is same as the real + * frequency of the crystal used. Otherwise, this function may + * have wrong result. + * + * - The result of this function could be not correct when using fractional + * value for HSE crystal. + * @param None + * @retval None + */ +void SystemCoreClockUpdate (void) +{ + uint32_t pllp, pllsource, pllm, pllfracen, hsivalue, tmp; + uint32_t common_system_clock; + float_t fracn1, pllvco; + + + /* Get SYSCLK source -------------------------------------------------------*/ + + switch (RCC->CFGR & RCC_CFGR_SWS) + { + case RCC_CFGR_SWS_HSI: /* HSI used as system clock source */ + common_system_clock = (uint32_t) (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)); + break; + + case RCC_CFGR_SWS_CSI: /* CSI used as system clock source */ + common_system_clock = CSI_VALUE; + break; + + case RCC_CFGR_SWS_HSE: /* HSE used as system clock source */ + common_system_clock = HSE_VALUE; + break; + + case RCC_CFGR_SWS_PLL1: /* PLL1 used as system clock source */ + + /* PLL_VCO = (HSE_VALUE or HSI_VALUE or CSI_VALUE/ PLLM) * PLLN + SYSCLK = PLL_VCO / PLLR + */ + pllsource = (RCC->PLLCKSELR & RCC_PLLCKSELR_PLLSRC); + pllm = ((RCC->PLLCKSELR & RCC_PLLCKSELR_DIVM1)>> 4) ; + pllfracen = ((RCC->PLLCFGR & RCC_PLLCFGR_PLL1FRACEN)>>RCC_PLLCFGR_PLL1FRACEN_Pos); + fracn1 = (float_t)(uint32_t)(pllfracen* ((RCC->PLL1FRACR & RCC_PLL1FRACR_FRACN1)>> 3)); + + if (pllm != 0U) + { + switch (pllsource) + { + case RCC_PLLCKSELR_PLLSRC_HSI: /* HSI used as PLL clock source */ + + hsivalue = (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)) ; + pllvco = ( (float_t)hsivalue / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 ); + + break; + + case RCC_PLLCKSELR_PLLSRC_CSI: /* CSI used as PLL clock source */ + pllvco = ((float_t)CSI_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 ); + break; + + case RCC_PLLCKSELR_PLLSRC_HSE: /* HSE used as PLL clock source */ + pllvco = ((float_t)HSE_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 ); + break; + + default: + hsivalue = (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)) ; + pllvco = ((float_t)hsivalue / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 ); + break; + } + pllp = (((RCC->PLL1DIVR & RCC_PLL1DIVR_P1) >>9) + 1U ) ; + common_system_clock = (uint32_t)(float_t)(pllvco/(float_t)pllp); + } + else + { + common_system_clock = 0U; + } + break; + + default: + common_system_clock = (uint32_t) (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)); + break; + } + + /* Compute SystemClock frequency --------------------------------------------------*/ +#if defined (RCC_D1CFGR_D1CPRE) + tmp = D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_D1CPRE)>> RCC_D1CFGR_D1CPRE_Pos]; + + /* common_system_clock frequency : CM7 CPU frequency */ + common_system_clock >>= tmp; + + /* SystemD2Clock frequency : CM4 CPU, AXI and AHBs Clock frequency */ + SystemD2Clock = (common_system_clock >> ((D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_HPRE)>> RCC_D1CFGR_HPRE_Pos]) & 0x1FU)); + +#else + tmp = D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_CDCPRE)>> RCC_CDCFGR1_CDCPRE_Pos]; + + /* common_system_clock frequency : CM7 CPU frequency */ + common_system_clock >>= tmp; + + /* SystemD2Clock frequency : AXI and AHBs Clock frequency */ + SystemD2Clock = (common_system_clock >> ((D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_HPRE)>> RCC_CDCFGR1_HPRE_Pos]) & 0x1FU)); + +#endif + +#if defined(DUAL_CORE) && defined(CORE_CM4) + SystemCoreClock = SystemD2Clock; +#else + SystemCoreClock = common_system_clock; +#endif /* DUAL_CORE && CORE_CM4 */ +} + + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ACDC/Makefile b/ACDC/Makefile new file mode 100644 index 00000000..1b0033b6 --- /dev/null +++ b/ACDC/Makefile @@ -0,0 +1,44 @@ +PROJECT = ACDC +BUILDROOT = . +OPENWARE ?= $(BUILDROOT)/.. + +LDSCRIPT = $(OPENWARE)/Hardware/xibeca.ld +include $(OPENWARE)/Hardware/owl3.mk + +C_SRC = $(wildcard Core/Src/*.c) +CPP_SRC = $(wildcard Core/Src/*.cpp) +C_SRC += $(OPENWARE)/Source/pcm3168a.c +C_SRC += $(OPENWARE)/Source/usbd_audio.c +# C_SRC += $(OPENWARE)/Source/sdram.c +C_SRC += $(OPENWARE)/Source/sdram-as4cXm32.c + +# CPP_SRC += $(OPENWARE)/Source/uart.cpp +# CPP_SRC += $(OPENWARE)/Source/MidiStreamReader.cpp + +S_SRC = $(BUILDROOT)/Core/Src/startup_stm32h743xx.s + +C_SRC += $(BUILDROOT)/USB_DEVICE/App/usb_device.c +C_SRC += $(BUILDROOT)/USB_DEVICE/App/usbd_desc.c +C_SRC += $(BUILDROOT)/USB_DEVICE/Target/usbd_conf.c + +# CPP_SRC += $(OPENWARE)/Source/usbh_midi.cpp +# C_SRC += $(BUILDROOT)/USB_HOST/Target/usbh_conf.c +# C_SRC += $(BUILDROOT)/USB_HOST/App/usb_host.c + +C_SRC += $(OPENWARE)/Source/flash.c + +include $(OPENWARE)/Hardware/sources.mk + +C_SRC += $(C_SRC_SAI) +# C_SRC += $(C_SRC_DAC) +C_SRC += $(C_SRC_SDRAM) +C_SRC += $(C_SRC_USBD) +# C_SRC += $(C_SRC_USBH) +C_SRC += $(C_SRC_DSP) +C_SRC += $(C_SRC_OS) +C_SRC += $(C_SRC_UART) +C_SRC += $(C_SRC_I2C) +C_SRC += $(C_SRC_QSPI) +C_SRC += $(C_SRC_MDMA) + +include $(OPENWARE)/Hardware/h7.mk diff --git a/ACDC/USB_DEVICE/App/usb_device.c b/ACDC/USB_DEVICE/App/usb_device.c new file mode 100644 index 00000000..9b34c972 --- /dev/null +++ b/ACDC/USB_DEVICE/App/usb_device.c @@ -0,0 +1,100 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usb_device.c + * @version : v1.0_Cube + * @brief : This file implements the USB Device + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ + +#include "usb_device.h" +#include "usbd_core.h" +#include "usbd_desc.h" + +/* USER CODE BEGIN Includes */ +#include "usbd_audio.h" +/* USER CODE END Includes */ + +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +/* USER CODE BEGIN PFP */ +/* Private function prototypes -----------------------------------------------*/ + +/* USER CODE END PFP */ + +/* USB Device Core handle declaration. */ +USBD_HandleTypeDef hUsbDeviceFS; + +/* + * -- Insert your variables declaration here -- + */ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* + * -- Insert your external function declaration here -- + */ +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ + +/** + * Init USB device Library, add supported class and start the library + * @retval None + */ +void MX_USB_DEVICE_Init(void) +{ + /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */ + + /* USER CODE END USB_DEVICE_Init_PreTreatment */ + + /* Init Device Library, add supported class and start the library. */ + if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK) + { + Error_Handler(); + } + if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_AUDIO) != USBD_OK) + { + Error_Handler(); + } + if (USBD_AUDIO_RegisterInterface(&hUsbDeviceFS, NULL) != USBD_OK) + { + Error_Handler(); + } + if (USBD_Start(&hUsbDeviceFS) != USBD_OK) + { + Error_Handler(); + } + + /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */ + + /* USER CODE END USB_DEVICE_Init_PostTreatment */ +} + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ACDC/USB_DEVICE/App/usb_device.h b/ACDC/USB_DEVICE/App/usb_device.h new file mode 100644 index 00000000..7c91b657 --- /dev/null +++ b/ACDC/USB_DEVICE/App/usb_device.h @@ -0,0 +1,105 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usb_device.h + * @version : v1.0_Cube + * @brief : Header for usb_device.c file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USB_DEVICE__H__ +#define __USB_DEVICE__H__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32h7xx.h" +#include "stm32h7xx_hal.h" +#include "usbd_def.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/** @addtogroup USBD_OTG_DRIVER + * @{ + */ + +/** @defgroup USBD_DEVICE USBD_DEVICE + * @brief Device file for Usb otg low level driver. + * @{ + */ + +/** @defgroup USBD_DEVICE_Exported_Variables USBD_DEVICE_Exported_Variables + * @brief Public variables. + * @{ + */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* + * -- Insert your variables declaration here -- + */ +/* USER CODE BEGIN VARIABLES */ + +/* USER CODE END VARIABLES */ +/** + * @} + */ + +/** @defgroup USBD_DEVICE_Exported_FunctionsPrototype USBD_DEVICE_Exported_FunctionsPrototype + * @brief Declaration of public functions for Usb device. + * @{ + */ + +/** USB Device initialization function. */ +void MX_USB_DEVICE_Init(void); + +/* + * -- Insert functions declaration here -- + */ +/* USER CODE BEGIN FD */ + +/* USER CODE END FD */ +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __USB_DEVICE__H__ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ACDC/USB_DEVICE/App/usbd_desc.c b/ACDC/USB_DEVICE/App/usbd_desc.c new file mode 100644 index 00000000..6ea9c473 --- /dev/null +++ b/ACDC/USB_DEVICE/App/usbd_desc.c @@ -0,0 +1,394 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : App/usbd_desc.c + * @version : v1.0_Cube + * @brief : This file implements the USB device descriptors. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "usbd_core.h" +#include "usbd_desc.h" +#include "usbd_conf.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ + +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY + * @{ + */ + +/** @addtogroup USBD_DESC + * @{ + */ + +/** @defgroup USBD_DESC_Private_TypesDefinitions USBD_DESC_Private_TypesDefinitions + * @brief Private types. + * @{ + */ + +/* USER CODE BEGIN PRIVATE_TYPES */ + +/* USER CODE END PRIVATE_TYPES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Defines USBD_DESC_Private_Defines + * @brief Private defines. + * @{ + */ + +#define USBD_VID 0x1209 +#define USBD_LANGID_STRING 1033 +#define USBD_MANUFACTURER_STRING "Rebel Technology" +#define USBD_PID_FS 0xDADA +#define USBD_PRODUCT_STRING_FS "OWL-XIBECA" +#define USBD_CONFIGURATION_STRING_FS "AUDIO Config" +#define USBD_INTERFACE_STRING_FS "AUDIO Interface" + +/* USER CODE BEGIN PRIVATE_DEFINES */ + +/* USER CODE END PRIVATE_DEFINES */ + +/** + * @} + */ + +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/** @defgroup USBD_DESC_Private_Macros USBD_DESC_Private_Macros + * @brief Private macros. + * @{ + */ + +/* USER CODE BEGIN PRIVATE_MACRO */ + +/* USER CODE END PRIVATE_MACRO */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes + * @brief Private functions declaration. + * @{ + */ + +static void Get_SerialNum(void); +static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len); + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes + * @brief Private functions declaration for FS. + * @{ + */ + +uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables + * @brief Private variables. + * @{ + */ + +USBD_DescriptorsTypeDef FS_Desc = +{ + USBD_FS_DeviceDescriptor +, USBD_FS_LangIDStrDescriptor +, USBD_FS_ManufacturerStrDescriptor +, USBD_FS_ProductStrDescriptor +, USBD_FS_SerialStrDescriptor +, USBD_FS_ConfigStrDescriptor +, USBD_FS_InterfaceStrDescriptor +}; + +#if defined ( __ICCARM__ ) /* IAR Compiler */ + #pragma data_alignment=4 +#endif /* defined ( __ICCARM__ ) */ +/** USB standard device descriptor. */ +__ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = +{ + 0x12, /*bLength */ + USB_DESC_TYPE_DEVICE, /*bDescriptorType*/ + 0x00, /*bcdUSB */ + 0x02, + 0x00, /*bDeviceClass*/ + 0x00, /*bDeviceSubClass*/ + 0x00, /*bDeviceProtocol*/ + USB_MAX_EP0_SIZE, /*bMaxPacketSize*/ + LOBYTE(USBD_VID), /*idVendor*/ + HIBYTE(USBD_VID), /*idVendor*/ + LOBYTE(USBD_PID_FS), /*idProduct*/ + HIBYTE(USBD_PID_FS), /*idProduct*/ + 0x00, /*bcdDevice rel. 2.00*/ + 0x02, + USBD_IDX_MFC_STR, /*Index of manufacturer string*/ + USBD_IDX_PRODUCT_STR, /*Index of product string*/ + USBD_IDX_SERIAL_STR, /*Index of serial number string*/ + USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/ +}; + +/* USB_DeviceDescriptor */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables + * @brief Private variables. + * @{ + */ + +#if defined ( __ICCARM__ ) /* IAR Compiler */ + #pragma data_alignment=4 +#endif /* defined ( __ICCARM__ ) */ + +/** USB lang indentifier descriptor. */ +__ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = +{ + USB_LEN_LANGID_STR_DESC, + USB_DESC_TYPE_STRING, + LOBYTE(USBD_LANGID_STRING), + HIBYTE(USBD_LANGID_STRING) +}; + +#if defined ( __ICCARM__ ) /* IAR Compiler */ + #pragma data_alignment=4 +#endif /* defined ( __ICCARM__ ) */ +/* Internal string descriptor. */ +__ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END; + +#if defined ( __ICCARM__ ) /*!< IAR Compiler */ + #pragma data_alignment=4 +#endif +__ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { + USB_SIZ_STRING_SERIAL, + USB_DESC_TYPE_STRING, +}; + +/** + * @} + */ + +/** @defgroup USBD_DESC_Private_Functions USBD_DESC_Private_Functions + * @brief Private functions. + * @{ + */ + +/** + * @brief Return the device descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = sizeof(USBD_FS_DeviceDesc); + return USBD_FS_DeviceDesc; +} + +/** + * @brief Return the LangID string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = sizeof(USBD_LangIDDesc); + return USBD_LangIDDesc; +} + +/** + * @brief Return the product string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == 0) + { + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +/** + * @brief Return the manufacturer string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length); + return USBD_StrDesc; +} + +/** + * @brief Return the serial number string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + UNUSED(speed); + *length = USB_SIZ_STRING_SERIAL; + + /* Update the serial number string descriptor with the data from the unique + * ID */ + Get_SerialNum(); + /* USER CODE BEGIN USBD_FS_SerialStrDescriptor */ + + /* USER CODE END USBD_FS_SerialStrDescriptor */ + return (uint8_t *) USBD_StringSerial; +} + +/** + * @brief Return the configuration string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == USBD_SPEED_HIGH) + { + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +/** + * @brief Return the interface string descriptor + * @param speed : Current device speed + * @param length : Pointer to data length variable + * @retval Pointer to descriptor buffer + */ +uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +{ + if(speed == 0) + { + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); + } + else + { + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); + } + return USBD_StrDesc; +} + +/** + * @brief Create the serial number string descriptor + * @param None + * @retval None + */ +static void Get_SerialNum(void) +{ + uint32_t deviceserial0, deviceserial1, deviceserial2; + + deviceserial0 = *(uint32_t *) DEVICE_ID1; + deviceserial1 = *(uint32_t *) DEVICE_ID2; + deviceserial2 = *(uint32_t *) DEVICE_ID3; + + deviceserial0 += deviceserial2; + + if (deviceserial0 != 0) + { + IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8); + IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4); + } +} + +/** + * @brief Convert Hex 32Bits value into char + * @param value: value to convert + * @param pbuf: pointer to the buffer + * @param len: buffer length + * @retval None + */ +static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len) +{ + uint8_t idx = 0; + + for (idx = 0; idx < len; idx++) + { + if (((value >> 28)) < 0xA) + { + pbuf[2 * idx] = (value >> 28) + '0'; + } + else + { + pbuf[2 * idx] = (value >> 28) + 'A' - 10; + } + + value = value << 4; + + pbuf[2 * idx + 1] = 0; + } +} +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ACDC/USB_DEVICE/App/usbd_desc.h b/ACDC/USB_DEVICE/App/usbd_desc.h new file mode 100644 index 00000000..51de9706 --- /dev/null +++ b/ACDC/USB_DEVICE/App/usbd_desc.h @@ -0,0 +1,145 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usbd_desc.c + * @version : v1.0_Cube + * @brief : Header for usbd_conf.c file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USBD_DESC__C__ +#define __USBD_DESC__C__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "usbd_def.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY + * @{ + */ + +/** @defgroup USBD_DESC USBD_DESC + * @brief Usb device descriptors module. + * @{ + */ + +/** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants + * @brief Constants. + * @{ + */ +#define DEVICE_ID1 (UID_BASE) +#define DEVICE_ID2 (UID_BASE + 0x4) +#define DEVICE_ID3 (UID_BASE + 0x8) + +#define USB_SIZ_STRING_SERIAL 0x1A + +/* USER CODE BEGIN EXPORTED_CONSTANTS */ + +/* USER CODE END EXPORTED_CONSTANTS */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_Defines USBD_DESC_Exported_Defines + * @brief Defines. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_DEFINES */ + +/* USER CODE END EXPORTED_DEFINES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_TypesDefinitions USBD_DESC_Exported_TypesDefinitions + * @brief Types. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_TYPES */ + +/* USER CODE END EXPORTED_TYPES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_Macros USBD_DESC_Exported_Macros + * @brief Aliases. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_MACRO */ + +/* USER CODE END EXPORTED_MACRO */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_Variables USBD_DESC_Exported_Variables + * @brief Public variables. + * @{ + */ + +/** Descriptor for the Usb device. */ +extern USBD_DescriptorsTypeDef FS_Desc; + +/* USER CODE BEGIN EXPORTED_VARIABLES */ + +/* USER CODE END EXPORTED_VARIABLES */ + +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_FunctionsPrototype USBD_DESC_Exported_FunctionsPrototype + * @brief Public functions declaration. + * @{ + */ + +/* USER CODE BEGIN EXPORTED_FUNCTIONS */ + +/* USER CODE END EXPORTED_FUNCTIONS */ + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __USBD_DESC__C__ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ACDC/USB_DEVICE/Target/usbd_conf.c b/ACDC/USB_DEVICE/Target/usbd_conf.c new file mode 100644 index 00000000..073b6145 --- /dev/null +++ b/ACDC/USB_DEVICE/Target/usbd_conf.c @@ -0,0 +1,680 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : Target/usbd_conf.c + * @version : v1.0_Cube + * @brief : This file implements the board support package for the USB device library + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "stm32h7xx.h" +#include "stm32h7xx_hal.h" +#include "usbd_def.h" +#include "usbd_core.h" + +/* USER CODE BEGIN Includes */ +#include "device.h" +uint8_t USBD_AUDIO_SetFiFos(PCD_HandleTypeDef *hpcd); +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ + +/* USER CODE BEGIN PV */ +/* Private variables ---------------------------------------------------------*/ + +/* USER CODE END PV */ + +PCD_HandleTypeDef hpcd_USB_OTG_FS; +void Error_Handler(void); + +/* External functions --------------------------------------------------------*/ + +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* USER CODE BEGIN PFP */ +/* Private function prototypes -----------------------------------------------*/ +USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status); + +/* USER CODE END PFP */ + +/* Private functions ---------------------------------------------------------*/ + +/* USER CODE BEGIN 1 */ +/* USER CODE END 1 */ + +/******************************************************************************* + LL Driver Callbacks (PCD -> USB Device Library) +*******************************************************************************/ +/* MSP Init */ + +void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + if(pcdHandle->Instance==USB_OTG_FS) + { + /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */ + + /* USER CODE END USB_OTG_FS_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB; + PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + /** Enable USB Voltage detector + */ + HAL_PWREx_EnableUSBVoltageDetector(); + + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**USB_OTG_FS GPIO Configuration + PA12 ------> USB_OTG_FS_DP + PA11 ------> USB_OTG_FS_DM + PA9 ------> USB_OTG_FS_VBUS + */ + GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_11; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF10_OTG1_FS; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* Peripheral clock enable */ + __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); + + /* Peripheral interrupt init */ + HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(OTG_FS_IRQn); + /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */ + + /* USER CODE END USB_OTG_FS_MspInit 1 */ + } +} + +void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) +{ + if(pcdHandle->Instance==USB_OTG_FS) + { + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */ + + /* USER CODE END USB_OTG_FS_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); + + /**USB_OTG_FS GPIO Configuration + PA12 ------> USB_OTG_FS_DP + PA11 ------> USB_OTG_FS_DM + PA9 ------> USB_OTG_FS_VBUS + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_12|GPIO_PIN_11|GPIO_PIN_9); + + /* Peripheral interrupt Deinit*/ + HAL_NVIC_DisableIRQ(OTG_FS_IRQn); + + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */ + + /* USER CODE END USB_OTG_FS_MspDeInit 1 */ + } +} + +/** + * @brief Setup stage callback + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_SetupStage((USBD_HandleTypeDef*)hpcd->pData, (uint8_t *)hpcd->Setup); +} + +/** + * @brief Data Out stage callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#else +void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_DataOutStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff); +} + +/** + * @brief Data In stage callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#else +void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_DataInStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff); +} + +/** + * @brief SOF callback. + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_SOFCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_SOF((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief Reset callback. + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ResetCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_SpeedTypeDef speed = USBD_SPEED_FULL; + + if ( hpcd->Init.speed == PCD_SPEED_HIGH) + { + speed = USBD_SPEED_HIGH; + } + else if ( hpcd->Init.speed == PCD_SPEED_FULL) + { + speed = USBD_SPEED_FULL; + } + else + { + Error_Handler(); + } + /* Set Speed. */ + USBD_LL_SetSpeed((USBD_HandleTypeDef*)hpcd->pData, speed); + + /* Reset Device. */ + USBD_LL_Reset((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief Suspend callback. + * When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it) + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + /* Inform USB library that core enters in suspend Mode. */ + USBD_LL_Suspend((USBD_HandleTypeDef*)hpcd->pData); + __HAL_PCD_GATE_PHYCLOCK(hpcd); + /* Enter in STOP mode. */ + /* USER CODE BEGIN 2 */ + if (hpcd->Init.low_power_enable) + { + /* Set SLEEPDEEP bit and SleepOnExit of Cortex System Control Register. */ + SCB->SCR |= (uint32_t)((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk)); + } + /* USER CODE END 2 */ +} + +/** + * @brief Resume callback. + * When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it) + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + /* USER CODE BEGIN 3 */ + + /* USER CODE END 3 */ + USBD_LL_Resume((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief ISOOUTIncomplete callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#else +void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_IsoOUTIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); +} + +/** + * @brief ISOINIncomplete callback. + * @param hpcd: PCD handle + * @param epnum: Endpoint number + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#else +void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_IsoINIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); +} + +/** + * @brief Connect callback. + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_DevConnected((USBD_HandleTypeDef*)hpcd->pData); +} + +/** + * @brief Disconnect callback. + * @param hpcd: PCD handle + * @retval None + */ +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) +static void PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) +#else +void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ +{ + USBD_LL_DevDisconnected((USBD_HandleTypeDef*)hpcd->pData); +} + +/******************************************************************************* + LL Driver Interface (USB Device Library --> PCD) +*******************************************************************************/ + +/** + * @brief Initializes the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) +{ + /* Init USB Ip. */ + if (pdev->id == DEVICE_FS) { + /* Link the driver to the stack. */ + hpcd_USB_OTG_FS.pData = pdev; + pdev->pData = &hpcd_USB_OTG_FS; + + hpcd_USB_OTG_FS.Instance = USB_OTG_FS; + hpcd_USB_OTG_FS.Init.dev_endpoints = 9; + hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; + hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; + hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; + hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; + hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; + hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; + hpcd_USB_OTG_FS.Init.battery_charging_enable = ENABLE; + hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE; + hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE; + if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) + { + Error_Handler( ); + } + +#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) + /* Register USB PCD CallBacks */ + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SOF_CB_ID, PCD_SOFCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SETUPSTAGE_CB_ID, PCD_SetupStageCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESET_CB_ID, PCD_ResetCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SUSPEND_CB_ID, PCD_SuspendCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESUME_CB_ID, PCD_ResumeCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_CONNECT_CB_ID, PCD_ConnectCallback); + HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_DISCONNECT_CB_ID, PCD_DisconnectCallback); + + HAL_PCD_RegisterDataOutStageCallback(&hpcd_USB_OTG_FS, PCD_DataOutStageCallback); + HAL_PCD_RegisterDataInStageCallback(&hpcd_USB_OTG_FS, PCD_DataInStageCallback); + HAL_PCD_RegisterIsoOutIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOOUTIncompleteCallback); + HAL_PCD_RegisterIsoInIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOINIncompleteCallback); +#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ + USBD_AUDIO_SetFiFos(&hpcd_USB_OTG_FS); + } + return USBD_OK; +} + +/** + * @brief De-Initializes the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_DeInit(pdev->pData); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Starts the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_Start(pdev->pData); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Stops the low level portion of the device driver. + * @param pdev: Device handle + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_Stop(pdev->pData); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Opens an endpoint of the low level driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @param ep_type: Endpoint type + * @param ep_mps: Endpoint max packet size + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Open(pdev->pData, ep_addr, ep_mps, ep_type); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Closes an endpoint of the low level driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Close(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Flushes an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Flush(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Sets a Stall condition on an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_SetStall(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Clears a Stall condition on an endpoint of the Low Level Driver. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_ClrStall(pdev->pData, ep_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Returns Stall condition. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval Stall (1: Yes, 0: No) + */ +uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef*) pdev->pData; + + if((ep_addr & 0x80) == 0x80) + { + return hpcd->IN_ep[ep_addr & 0x7F].is_stall; + } + else + { + return hpcd->OUT_ep[ep_addr & 0x7F].is_stall; + } +} + +/** + * @brief Assigns a USB address to the device. + * @param pdev: Device handle + * @param dev_addr: Device address + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_SetAddress(pdev->pData, dev_addr); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Transmits data over an endpoint. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @param pbuf: Pointer to data to be sent + * @param size: Data size + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Transmit(pdev->pData, ep_addr, pbuf, size); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Prepares an endpoint for reception. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @param pbuf: Pointer to data to be received + * @param size: Data size + * @retval USBD status + */ +USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size) +{ + HAL_StatusTypeDef hal_status = HAL_OK; + USBD_StatusTypeDef usb_status = USBD_OK; + + hal_status = HAL_PCD_EP_Receive(pdev->pData, ep_addr, pbuf, size); + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; +} + +/** + * @brief Returns the last transfered packet size. + * @param pdev: Device handle + * @param ep_addr: Endpoint number + * @retval Recived Data Size + */ +uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr) +{ + return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef*) pdev->pData, ep_addr); +} +/** + * @brief Static single allocation. + * @param size: Size of allocated memory + * @retval None + */ +/* void *USBD_static_malloc(uint32_t size) */ +/* { */ +/* static uint32_t mem[(sizeof(USBD_AUDIO_HandleTypeDef)/4)+1];/\* On 32-bit boundary *\/ */ +/* return mem; */ +/* } */ + +/** + * @brief Dummy memory free + * @param p: Pointer to allocated memory address + * @retval None + */ +void USBD_static_free(void *p) +{ + +} + +/** + * @brief Delays routine for the USB device library. + * @param Delay: Delay in ms + * @retval None + */ +void USBD_LL_Delay(uint32_t Delay) +{ + HAL_Delay(Delay); +} + +/** + * @brief Retuns the USB status depending on the HAL status: + * @param hal_status: HAL status + * @retval USB status + */ +USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status) +{ + USBD_StatusTypeDef usb_status = USBD_OK; + + switch (hal_status) + { + case HAL_OK : + usb_status = USBD_OK; + break; + case HAL_ERROR : + usb_status = USBD_FAIL; + break; + case HAL_BUSY : + usb_status = USBD_BUSY; + break; + case HAL_TIMEOUT : + usb_status = USBD_FAIL; + break; + default : + usb_status = USBD_FAIL; + break; + } + return usb_status; +} + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ACDC/USB_DEVICE/Target/usbd_conf.h b/ACDC/USB_DEVICE/Target/usbd_conf.h new file mode 100644 index 00000000..b8e568d2 --- /dev/null +++ b/ACDC/USB_DEVICE/Target/usbd_conf.h @@ -0,0 +1,176 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : usbd_conf.h + * @version : v1.0_Cube + * @brief : Header for usbd_conf.c file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __USBD_CONF__H__ +#define __USBD_CONF__H__ + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include +#include +#include +#include "main.h" +#include "stm32h7xx.h" +#include "stm32h7xx_hal.h" + +/* USER CODE BEGIN INCLUDE */ + +/* USER CODE END INCLUDE */ + +/** @addtogroup USBD_OTG_DRIVER + * @brief Driver for Usb device. + * @{ + */ + +/** @defgroup USBD_CONF USBD_CONF + * @brief Configuration file for Usb otg low level driver. + * @{ + */ + +/** @defgroup USBD_CONF_Exported_Variables USBD_CONF_Exported_Variables + * @brief Public variables. + * @{ + */ + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_Defines USBD_CONF_Exported_Defines + * @brief Defines for configuration of the Usb device. + * @{ + */ + +/*---------- -----------*/ +#define USBD_MAX_NUM_INTERFACES 1U +/*---------- -----------*/ +#define USBD_MAX_NUM_CONFIGURATION 1U +/*---------- -----------*/ +#define USBD_MAX_STR_DESC_SIZ 512U +/*---------- -----------*/ +#define USBD_DEBUG_LEVEL 0U +/*---------- -----------*/ +#define USBD_LPM_ENABLED 0U +/*---------- -----------*/ +#define USBD_SELF_POWERED 1U +/*---------- -----------*/ +#define USBD_AUDIO_FREQ 22100U + +/****************************************/ +/* #define for FS and HS identification */ +#define DEVICE_FS 0 +#define DEVICE_HS 1 + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_Macros USBD_CONF_Exported_Macros + * @brief Aliases. + * @{ + */ + +/* Memory management macros make sure to use static memory allocation */ +/** Alias for memory allocation. */ +#define USBD_malloc (void *)USBD_static_malloc + +/** Alias for memory release. */ +#define USBD_free USBD_static_free + +/** Alias for memory set. */ +#define USBD_memset memset + +/** Alias for memory copy. */ +#define USBD_memcpy memcpy + +/** Alias for delay. */ +#define USBD_Delay HAL_Delay + +/* DEBUG macros */ + +#if (USBD_DEBUG_LEVEL > 0) +#define USBD_UsrLog(...) printf(__VA_ARGS__);\ + printf("\n"); +#else +#define USBD_UsrLog(...) +#endif + +#if (USBD_DEBUG_LEVEL > 1) + +#define USBD_ErrLog(...) printf("ERROR: ") ;\ + printf(__VA_ARGS__);\ + printf("\n"); +#else +#define USBD_ErrLog(...) +#endif + +#if (USBD_DEBUG_LEVEL > 2) +#define USBD_DbgLog(...) printf("DEBUG : ") ;\ + printf(__VA_ARGS__);\ + printf("\n"); +#else +#define USBD_DbgLog(...) +#endif + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_Types USBD_CONF_Exported_Types + * @brief Types. + * @{ + */ + +/** + * @} + */ + +/** @defgroup USBD_CONF_Exported_FunctionsPrototype USBD_CONF_Exported_FunctionsPrototype + * @brief Declaration of public functions for Usb device. + * @{ + */ + +/* Exported functions -------------------------------------------------------*/ +void *USBD_static_malloc(uint32_t size); +void USBD_static_free(void *p); +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __USBD_CONF__H__ */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ From aea2035fcd45b7caed10eca793622e6061135be1 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 4 Nov 2021 15:31:40 +0100 Subject: [PATCH 167/286] updated configuration --- ACDC/ACDC.ioc | 22 ++++---- ACDC/Core/Inc/main.h | 8 +-- ACDC/Core/Inc/stm32h7xx_hal_conf.h | 1 + ACDC/Core/Src/ACDC.cpp | 2 +- ACDC/Core/Src/main.c | 84 +++++++++++------------------- ACDC/Core/Src/stm32h7xx_hal_msp.c | 16 ++++-- ACDC/USB_DEVICE/App/usbd_desc.c | 4 +- 7 files changed, 60 insertions(+), 77 deletions(-) diff --git a/ACDC/ACDC.ioc b/ACDC/ACDC.ioc index 9041930a..e5ce7246 100644 --- a/ACDC/ACDC.ioc +++ b/ACDC/ACDC.ioc @@ -1,13 +1,13 @@ #MicroXplorer Configuration settings - do not modify ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_10 -ADC1.Channel-1\#ChannelRegularConversion=ADC_CHANNEL_14 -ADC1.Channel-2\#ChannelRegularConversion=ADC_CHANNEL_5 -ADC1.Channel-3\#ChannelRegularConversion=ADC_CHANNEL_8 +ADC1.Channel-1\#ChannelRegularConversion=ADC_CHANNEL_11 +ADC1.Channel-2\#ChannelRegularConversion=ADC_CHANNEL_14 +ADC1.Channel-3\#ChannelRegularConversion=ADC_CHANNEL_3 ADC1.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV4 ADC1.ContinuousConvMode=ENABLE ADC1.ConversionDataManagement=ADC_CONVERSIONDATA_DMA_CIRCULAR ADC1.EOCSelection=ADC_EOC_SEQ_CONV -ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,NbrOfConversion,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,OffsetNumber-1\#ChannelRegularConversion,OffsetSignedSaturation-1\#ChannelRegularConversion,Rank-2\#ChannelRegularConversion,Channel-2\#ChannelRegularConversion,SamplingTime-2\#ChannelRegularConversion,OffsetNumber-2\#ChannelRegularConversion,OffsetSignedSaturation-2\#ChannelRegularConversion,Rank-3\#ChannelRegularConversion,Channel-3\#ChannelRegularConversion,SamplingTime-3\#ChannelRegularConversion,OffsetNumber-3\#ChannelRegularConversion,OffsetSignedSaturation-3\#ChannelRegularConversion,OversamplingMode,ContinuousConvMode,EOCSelection,Resolution,ClockPrescaler,master,ConversionDataManagement,Overrun +ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,OffsetNumber-0\#ChannelRegularConversion,OffsetSignedSaturation-0\#ChannelRegularConversion,NbrOfConversionFlag,NbrOfConversion,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,OffsetNumber-1\#ChannelRegularConversion,OffsetSignedSaturation-1\#ChannelRegularConversion,Rank-2\#ChannelRegularConversion,Channel-2\#ChannelRegularConversion,SamplingTime-2\#ChannelRegularConversion,OffsetNumber-2\#ChannelRegularConversion,OffsetSignedSaturation-2\#ChannelRegularConversion,Rank-3\#ChannelRegularConversion,Channel-3\#ChannelRegularConversion,SamplingTime-3\#ChannelRegularConversion,OffsetNumber-3\#ChannelRegularConversion,OffsetSignedSaturation-3\#ChannelRegularConversion,OversamplingMode,ContinuousConvMode,EOCSelection,Resolution,ClockPrescaler,ConversionDataManagement,Overrun,master ADC1.NbrOfConversion=4 ADC1.NbrOfConversionFlag=1 ADC1.OffsetNumber-0\#ChannelRegularConversion=ADC_OFFSET_NONE @@ -25,10 +25,10 @@ ADC1.Rank-1\#ChannelRegularConversion=2 ADC1.Rank-2\#ChannelRegularConversion=3 ADC1.Rank-3\#ChannelRegularConversion=4 ADC1.Resolution=ADC_RESOLUTION_12B -ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_387CYCLES_5 -ADC1.SamplingTime-1\#ChannelRegularConversion=ADC_SAMPLETIME_387CYCLES_5 -ADC1.SamplingTime-2\#ChannelRegularConversion=ADC_SAMPLETIME_387CYCLES_5 -ADC1.SamplingTime-3\#ChannelRegularConversion=ADC_SAMPLETIME_387CYCLES_5 +ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_64CYCLES_5 +ADC1.SamplingTime-1\#ChannelRegularConversion=ADC_SAMPLETIME_64CYCLES_5 +ADC1.SamplingTime-2\#ChannelRegularConversion=ADC_SAMPLETIME_64CYCLES_5 +ADC1.SamplingTime-3\#ChannelRegularConversion=ADC_SAMPLETIME_64CYCLES_5 ADC1.master=1 Dma.ADC1.3.Direction=DMA_PERIPH_TO_MEMORY Dma.ADC1.3.EventEnable=DISABLE @@ -313,8 +313,10 @@ PA2.GPIO_Label=ADC2 PA2.Signal=ADCx_INP14 PA3.Locked=true PA3.Signal=GPIO_Output +PA6.GPIOParameters=GPIO_Label +PA6.GPIO_Label=ADC6 PA6.Locked=true -PA6.Signal=GPIO_Input +PA6.Signal=ADCx_INP3 PA7.Locked=true PA7.Signal=GPIO_Output PA8.Mode=Asynchronous @@ -700,6 +702,8 @@ SH.ADCx_INP11.0=ADC1_INP11,IN11-Single-Ended SH.ADCx_INP11.ConfNb=1 SH.ADCx_INP14.0=ADC1_INP14,IN14-Single-Ended SH.ADCx_INP14.ConfNb=1 +SH.ADCx_INP3.0=ADC1_INP3,IN3-Single-Ended +SH.ADCx_INP3.ConfNb=1 SH.ADCx_INP5.0=ADC1_INP5,IN5-Single-Ended SH.ADCx_INP5.ConfNb=1 SH.ADCx_INP8.0=ADC1_INP8,IN8-Single-Ended diff --git a/ACDC/Core/Inc/main.h b/ACDC/Core/Inc/main.h index ee56745a..6a7b29b4 100644 --- a/ACDC/Core/Inc/main.h +++ b/ACDC/Core/Inc/main.h @@ -60,10 +60,6 @@ void Error_Handler(void); /* Private defines -----------------------------------------------------------*/ #define FLASH_DQ2_Pin GPIO_PIN_2 #define FLASH_DQ2_GPIO_Port GPIOE -#define OLED_CS_Pin GPIO_PIN_14 -#define OLED_CS_GPIO_Port GPIOG -#define OLED_DC_Pin GPIO_PIN_11 -#define OLED_DC_GPIO_Port GPIOC #define EXTI13_Pin GPIO_PIN_13 #define EXTI13_GPIO_Port GPIOC #define EXTI13_EXTI_IRQn EXTI15_10_IRQn @@ -90,10 +86,10 @@ void Error_Handler(void); #define ADC_SPI_MISO_GPIO_Port GPIOC #define ADC_SPI_MOSI_Pin GPIO_PIN_3 #define ADC_SPI_MOSI_GPIO_Port GPIOC -#define OLED_RST_Pin GPIO_PIN_4 -#define OLED_RST_GPIO_Port GPIOA #define ADC2_Pin GPIO_PIN_2 #define ADC2_GPIO_Port GPIOA +#define ADC6_Pin GPIO_PIN_6 +#define ADC6_GPIO_Port GPIOA #define ADC4_Pin GPIO_PIN_5 #define ADC4_GPIO_Port GPIOC #define ADC3_Pin GPIO_PIN_1 diff --git a/ACDC/Core/Inc/stm32h7xx_hal_conf.h b/ACDC/Core/Inc/stm32h7xx_hal_conf.h index 6348633e..66782786 100644 --- a/ACDC/Core/Inc/stm32h7xx_hal_conf.h +++ b/ACDC/Core/Inc/stm32h7xx_hal_conf.h @@ -65,6 +65,7 @@ #define HAL_LPTIM_MODULE_ENABLED /* #define HAL_LTDC_MODULE_ENABLED */ #define HAL_QSPI_MODULE_ENABLED +/* #define HAL_RAMECC_MODULE_ENABLED */ /* #define HAL_RNG_MODULE_ENABLED */ /* #define HAL_RTC_MODULE_ENABLED */ #define HAL_SAI_MODULE_ENABLED diff --git a/ACDC/Core/Src/ACDC.cpp b/ACDC/Core/Src/ACDC.cpp index 2ba2275a..c1532415 100644 --- a/ACDC/Core/Src/ACDC.cpp +++ b/ACDC/Core/Src/ACDC.cpp @@ -103,7 +103,7 @@ void setup(){ led_out2.outputMode(); led_out3.outputMode(); led_out4.outputMode(); - + // for(size_t i=1; i<=12; ++i) setLed(i, NO_COLOUR); diff --git a/ACDC/Core/Src/main.c b/ACDC/Core/Src/main.c index 1ffdf427..97a40bd0 100644 --- a/ACDC/Core/Src/main.c +++ b/ACDC/Core/Src/main.c @@ -21,6 +21,7 @@ #include "main.h" #include "cmsis_os.h" #include "usb_device.h" +#include "usb_device.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ @@ -366,7 +367,7 @@ static void MX_ADC1_Init(void) */ sConfig.Channel = ADC_CHANNEL_10; sConfig.Rank = ADC_REGULAR_RANK_1; - sConfig.SamplingTime = ADC_SAMPLETIME_387CYCLES_5; + sConfig.SamplingTime = ADC_SAMPLETIME_64CYCLES_5; sConfig.SingleDiff = ADC_SINGLE_ENDED; sConfig.OffsetNumber = ADC_OFFSET_NONE; sConfig.Offset = 0; @@ -377,7 +378,7 @@ static void MX_ADC1_Init(void) } /** Configure Regular Channel */ - sConfig.Channel = ADC_CHANNEL_14; + sConfig.Channel = ADC_CHANNEL_11; sConfig.Rank = ADC_REGULAR_RANK_2; if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) { @@ -385,7 +386,7 @@ static void MX_ADC1_Init(void) } /** Configure Regular Channel */ - sConfig.Channel = ADC_CHANNEL_5; + sConfig.Channel = ADC_CHANNEL_14; sConfig.Rank = ADC_REGULAR_RANK_3; if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) { @@ -393,7 +394,7 @@ static void MX_ADC1_Init(void) } /** Configure Regular Channel */ - sConfig.Channel = ADC_CHANNEL_8; + sConfig.Channel = ADC_CHANNEL_3; sConfig.Rank = ADC_REGULAR_RANK_4; if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) { @@ -939,24 +940,23 @@ static void MX_FMC_Init(void) hsdram1.Instance = FMC_SDRAM_DEVICE; /* hsdram1.Init */ hsdram1.Init.SDBank = FMC_SDRAM_BANK1; - hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_9; // 8; + hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8; hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_13; hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_32; hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4; - hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3; // 1; + hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_1; hsdram1.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE; - hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2; - /* hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_DISABLE; // PERIOD_2; */ - hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE; // DISABLE; + hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_DISABLE; + hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_DISABLE; hsdram1.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0; /* SdramTiming */ - SdramTiming.LoadToActiveDelay = 2; // 16; - SdramTiming.ExitSelfRefreshDelay = 7; // 16; - SdramTiming.SelfRefreshTime = 4; // 16; - SdramTiming.RowCycleDelay = 8; // 16; - SdramTiming.WriteRecoveryTime = 3; // 16; - SdramTiming.RPDelay = 1; // 0 causes assertion error; // 16; - SdramTiming.RCDDelay = 10; // 16; + SdramTiming.LoadToActiveDelay = 16; + SdramTiming.ExitSelfRefreshDelay = 16; + SdramTiming.SelfRefreshTime = 16; + SdramTiming.RowCycleDelay = 16; + SdramTiming.WriteRecoveryTime = 16; + SdramTiming.RPDelay = 16; + SdramTiming.RCDDelay = 16; if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK) { @@ -988,12 +988,6 @@ static void MX_GPIO_Init(void) __HAL_RCC_GPIOH_CLK_ENABLE(); __HAL_RCC_GPIOF_CLK_ENABLE(); - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOG, OLED_CS_Pin|ADC_RST_Pin, GPIO_PIN_RESET); - - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(OLED_DC_GPIO_Port, OLED_DC_Pin, GPIO_PIN_RESET); - /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOI, GPIO_PIN_11, GPIO_PIN_RESET); @@ -1001,7 +995,10 @@ static void MX_GPIO_Init(void) HAL_GPIO_WritePin(GPIOH, GPIO_PIN_4, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOA, OLED_RST_Pin|GPIO_PIN_3|GPIO_PIN_7, GPIO_PIN_RESET); + HAL_GPIO_WritePin(ADC_RST_GPIO_Port, ADC_RST_Pin, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(GPIOA, GPIO_PIN_3|GPIO_PIN_7, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(ADC_SPI_NCS_GPIO_Port, ADC_SPI_NCS_Pin, GPIO_PIN_RESET); @@ -1014,15 +1011,8 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - /*Configure GPIO pin : OLED_CS_Pin */ - GPIO_InitStruct.Pin = OLED_CS_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; - HAL_GPIO_Init(OLED_CS_GPIO_Port, &GPIO_InitStruct); - - /*Configure GPIO pins : PG13 PG9 */ - GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_9; + /*Configure GPIO pins : PG14 PG13 PG9 */ + GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_13|GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); @@ -1049,12 +1039,11 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); - /*Configure GPIO pin : OLED_DC_Pin */ - GPIO_InitStruct.Pin = OLED_DC_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + /*Configure GPIO pins : PC11 PC4 */ + GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_4; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; - HAL_GPIO_Init(OLED_DC_GPIO_Port, &GPIO_InitStruct); + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /*Configure GPIO pins : EXTI13_Pin EXTI14_Pin PC9 PC8 */ GPIO_InitStruct.Pin = EXTI13_Pin|EXTI14_Pin|GPIO_PIN_9|GPIO_PIN_8; @@ -1074,8 +1063,8 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); - /*Configure GPIO pins : PA10 PA5 */ - GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_5; + /*Configure GPIO pins : PA10 PA4 PA5 */ + GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_4|GPIO_PIN_5; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); @@ -1113,25 +1102,12 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); - /*Configure GPIO pins : PA0 PA6 */ - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_6; + /*Configure GPIO pin : PA0 */ + GPIO_InitStruct.Pin = GPIO_PIN_0; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - /*Configure GPIO pin : OLED_RST_Pin */ - GPIO_InitStruct.Pin = OLED_RST_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; - HAL_GPIO_Init(OLED_RST_GPIO_Port, &GPIO_InitStruct); - - /*Configure GPIO pin : PC4 */ - GPIO_InitStruct.Pin = GPIO_PIN_4; - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - /*Configure GPIO pins : PA3 PA7 */ GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_7; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; diff --git a/ACDC/Core/Src/stm32h7xx_hal_msp.c b/ACDC/Core/Src/stm32h7xx_hal_msp.c index 3bb186c8..d4499594 100644 --- a/ACDC/Core/Src/stm32h7xx_hal_msp.c +++ b/ACDC/Core/Src/stm32h7xx_hal_msp.c @@ -105,6 +105,7 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) PC0 ------> ADC1_INP10 PC1 ------> ADC1_INP11 PA2 ------> ADC1_INP14 + PA6 ------> ADC1_INP3 PC5 ------> ADC1_INP8 PB1 ------> ADC1_INP5 PB0 ------> ADC1_INP9 @@ -114,10 +115,10 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - GPIO_InitStruct.Pin = ADC2_Pin; + GPIO_InitStruct.Pin = ADC2_Pin|ADC6_Pin; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(ADC2_GPIO_Port, &GPIO_InitStruct); + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); GPIO_InitStruct.Pin = ADC3_Pin|ADC7_Pin; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; @@ -173,13 +174,14 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) PC0 ------> ADC1_INP10 PC1 ------> ADC1_INP11 PA2 ------> ADC1_INP14 + PA6 ------> ADC1_INP3 PC5 ------> ADC1_INP8 PB1 ------> ADC1_INP5 PB0 ------> ADC1_INP9 */ HAL_GPIO_DeInit(GPIOC, ADC1_Pin|ADC5_Pin|ADC4_Pin); - HAL_GPIO_DeInit(ADC2_GPIO_Port, ADC2_Pin); + HAL_GPIO_DeInit(GPIOA, ADC2_Pin|ADC6_Pin); HAL_GPIO_DeInit(GPIOB, ADC3_Pin|ADC7_Pin); @@ -1126,7 +1128,7 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); - /* Peripheral DMA init*/ + /* Peripheral DMA init*/ hdma_sai1_a.Instance = DMA1_Stream0; hdma_sai1_a.Init.Request = DMA_REQUEST_SAI1_A; @@ -1173,7 +1175,7 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); - /* Peripheral DMA init*/ + /* Peripheral DMA init*/ hdma_sai1_b.Instance = DMA1_Stream1; hdma_sai1_b.Init.Request = DMA_REQUEST_SAI1_B; @@ -1207,6 +1209,7 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) { /* Peripheral clock disable */ __HAL_RCC_SAI1_CLK_DISABLE(); + /* SAI1 interrupt DeInit */ HAL_NVIC_DisableIRQ(SAI1_IRQn); } @@ -1220,6 +1223,7 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) HAL_GPIO_DeInit(GPIOG, GPIO_PIN_7); + /* SAI1 DMA Deinit */ HAL_DMA_DeInit(hsai->hdmarx); HAL_DMA_DeInit(hsai->hdmatx); } @@ -1230,6 +1234,7 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) { /* Peripheral clock disable */ __HAL_RCC_SAI1_CLK_DISABLE(); + /* SAI1 interrupt DeInit */ HAL_NVIC_DisableIRQ(SAI1_IRQn); } @@ -1238,6 +1243,7 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) */ HAL_GPIO_DeInit(GPIOE, GPIO_PIN_3); + /* SAI1 DMA Deinit */ HAL_DMA_DeInit(hsai->hdmarx); HAL_DMA_DeInit(hsai->hdmatx); } diff --git a/ACDC/USB_DEVICE/App/usbd_desc.c b/ACDC/USB_DEVICE/App/usbd_desc.c index 6ea9c473..976791a4 100644 --- a/ACDC/USB_DEVICE/App/usbd_desc.c +++ b/ACDC/USB_DEVICE/App/usbd_desc.c @@ -67,7 +67,7 @@ #define USBD_LANGID_STRING 1033 #define USBD_MANUFACTURER_STRING "Rebel Technology" #define USBD_PID_FS 0xDADA -#define USBD_PRODUCT_STRING_FS "OWL-XIBECA" +#define USBD_PRODUCT_STRING_FS "OWL-ACDC" #define USBD_CONFIGURATION_STRING_FS "AUDIO Config" #define USBD_INTERFACE_STRING_FS "AUDIO Interface" @@ -182,7 +182,7 @@ __ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = #pragma data_alignment=4 #endif /* defined ( __ICCARM__ ) */ -/** USB lang indentifier descriptor. */ +/** USB lang identifier descriptor. */ __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = { USB_LEN_LANGID_STR_DESC, From bdf341d04c4ab333518d05b7f6d5f62ca82ce471 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 4 Nov 2021 16:19:48 +0100 Subject: [PATCH 168/286] updated SRAM settings --- ACDC/ACDC.ioc | 15 +++++++++++++++ ACDC/Core/Inc/hardware.h | 10 ++++++---- ACDC/Core/Src/ACDC.cpp | 7 ++++++- ACDC/Core/Src/main.c | 22 +++++++++++----------- 4 files changed, 38 insertions(+), 16 deletions(-) diff --git a/ACDC/ACDC.ioc b/ACDC/ACDC.ioc index e5ce7246..744ff7ec 100644 --- a/ACDC/ACDC.ioc +++ b/ACDC/ACDC.ioc @@ -107,6 +107,21 @@ Dma.SPI3_TX.2.SyncEnable=DISABLE Dma.SPI3_TX.2.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT Dma.SPI3_TX.2.SyncRequestNumber=1 Dma.SPI3_TX.2.SyncSignalID=NONE +FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_3 +FMC.ColumnBitsNumber1=FMC_SDRAM_COLUMN_BITS_NUM_9 +FMC.ExitSelfRefreshDelay1=7 +FMC.IPParameters=ColumnBitsNumber1,CASLatency1,SDClockPeriod1,SDClockPeriod2,ReadBurst1,ReadBurst2,LoadToActiveDelay1,ExitSelfRefreshDelay1,SelfRefreshTime1,RowCycleDelay1,RowCycleDelay2,WriteRecoveryTime1,RPDelay1,RPDelay2 +FMC.LoadToActiveDelay1=2 +FMC.RPDelay1=1 +FMC.RPDelay2=1 +FMC.ReadBurst1=FMC_SDRAM_RBURST_ENABLE +FMC.ReadBurst2=FMC_SDRAM_RBURST_ENABLE +FMC.RowCycleDelay1=8 +FMC.RowCycleDelay2=8 +FMC.SDClockPeriod1=FMC_SDRAM_CLOCK_PERIOD_2 +FMC.SDClockPeriod2=FMC_SDRAM_CLOCK_PERIOD_2 +FMC.SelfRefreshTime1=4 +FMC.WriteRecoveryTime1=3 FREERTOS.FootprintOK=true FREERTOS.INCLUDE_vTaskDelayUntil=1 FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configUSE_IDLE_HOOK,configUSE_TICK_HOOK,configUSE_MALLOC_FAILED_HOOK,INCLUDE_vTaskDelayUntil,configUSE_MUTEXES,configCHECK_FOR_STACK_OVERFLOW,FootprintOK diff --git a/ACDC/Core/Inc/hardware.h b/ACDC/Core/Inc/hardware.h index 7b7ccd5a..897b28d8 100644 --- a/ACDC/Core/Inc/hardware.h +++ b/ACDC/Core/Inc/hardware.h @@ -8,11 +8,13 @@ /* #define NO_CCM_RAM */ #define DMA_RAM __attribute__ ((section (".dmadata"))) #define USE_PLUS_RAM -/* #define USE_ICACHE */ -/* #define USE_DCACHE */ + +#ifdef NDEBUG +#define USE_ICACHE +#define USE_DCACHE +#endif #define ARM_CYCLES_PER_SAMPLE (480000000/AUDIO_SAMPLINGRATE) /* 480MHz / 48kHz */ -#define MAIN_LOOP_SLEEP_MS 20 // todo: quad SPI /* #define USE_SPI_FLASH */ @@ -35,7 +37,7 @@ #define USE_USBD_AUDIO #define USE_USBD_AUDIO_TX // microphone -/* #define USE_USBD_AUDIO_RX // speaker */ +#define USE_USBD_AUDIO_RX // speaker #define USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS /* #define USBD_MAX_POWER 100 // 200mA for iPad compatibility */ diff --git a/ACDC/Core/Src/ACDC.cpp b/ACDC/Core/Src/ACDC.cpp index c1532415..de79c14f 100644 --- a/ACDC/Core/Src/ACDC.cpp +++ b/ACDC/Core/Src/ACDC.cpp @@ -19,6 +19,11 @@ #define XIBECA_PIN13 GPIOA, GPIO_PIN_7 #define XIBECA_PIN14 GPIOA, GPIO_PIN_3 +#define XIBECA_PIN17 GPIOG, GPIO_PIN_12 +#define XIBECA_PIN18 GPIOG, GPIO_PIN_11 +#define XIBECA_PIN19 GPIOA, GPIO_PIN_15 +#define XIBECA_PIN20 GPIOA, GPIO_PIN_1 + #define XIBECA_PIN21 GPIOC, GPIO_PIN_6 #define XIBECA_PIN22 GPIOC, GPIO_PIN_7 #define XIBECA_PIN23 GPIOD, GPIO_PIN_12 @@ -103,7 +108,7 @@ void setup(){ led_out2.outputMode(); led_out3.outputMode(); led_out4.outputMode(); - // + for(size_t i=1; i<=12; ++i) setLed(i, NO_COLOUR); diff --git a/ACDC/Core/Src/main.c b/ACDC/Core/Src/main.c index 97a40bd0..0f90fdf8 100644 --- a/ACDC/Core/Src/main.c +++ b/ACDC/Core/Src/main.c @@ -940,23 +940,23 @@ static void MX_FMC_Init(void) hsdram1.Instance = FMC_SDRAM_DEVICE; /* hsdram1.Init */ hsdram1.Init.SDBank = FMC_SDRAM_BANK1; - hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8; + hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_9; // 8; hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_13; hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_32; hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4; - hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_1; + hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3; // 1; hsdram1.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE; - hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_DISABLE; - hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_DISABLE; + hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2; // DISABLE; + hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE; // DISABLE; hsdram1.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0; /* SdramTiming */ - SdramTiming.LoadToActiveDelay = 16; - SdramTiming.ExitSelfRefreshDelay = 16; - SdramTiming.SelfRefreshTime = 16; - SdramTiming.RowCycleDelay = 16; - SdramTiming.WriteRecoveryTime = 16; - SdramTiming.RPDelay = 16; - SdramTiming.RCDDelay = 16; + SdramTiming.LoadToActiveDelay = 2; // 16; + SdramTiming.ExitSelfRefreshDelay = 7; // 16; + SdramTiming.SelfRefreshTime = 4; // 16; + SdramTiming.RowCycleDelay = 8; // 16; + SdramTiming.WriteRecoveryTime = 3; // 16; + SdramTiming.RPDelay = 1; // 0 causes assertion error; // 16; + SdramTiming.RCDDelay = 10; // 16; if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK) { From f99e3767405eeddd2dab16bef69bef61091963a8 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 4 Nov 2021 17:23:44 +0100 Subject: [PATCH 169/286] led changes wip --- ACDC/ACDC.ioc | 273 +++++++++++------------- ACDC/Core/Inc/main.h | 8 +- ACDC/Core/Inc/stm32h7xx_hal_conf.h | 2 +- ACDC/Core/Inc/stm32h7xx_it.h | 3 - ACDC/Core/Src/ACDC.cpp | 106 +++++++--- ACDC/Core/Src/main.c | 329 +++++++++++++++-------------- ACDC/Core/Src/stm32h7xx_hal_msp.c | 270 +++++++++++------------ ACDC/Core/Src/stm32h7xx_it.c | 44 ---- 8 files changed, 508 insertions(+), 527 deletions(-) diff --git a/ACDC/ACDC.ioc b/ACDC/ACDC.ioc index 744ff7ec..42a3b90d 100644 --- a/ACDC/ACDC.ioc +++ b/ACDC/ACDC.ioc @@ -110,8 +110,9 @@ Dma.SPI3_TX.2.SyncSignalID=NONE FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_3 FMC.ColumnBitsNumber1=FMC_SDRAM_COLUMN_BITS_NUM_9 FMC.ExitSelfRefreshDelay1=7 -FMC.IPParameters=ColumnBitsNumber1,CASLatency1,SDClockPeriod1,SDClockPeriod2,ReadBurst1,ReadBurst2,LoadToActiveDelay1,ExitSelfRefreshDelay1,SelfRefreshTime1,RowCycleDelay1,RowCycleDelay2,WriteRecoveryTime1,RPDelay1,RPDelay2 +FMC.IPParameters=ColumnBitsNumber1,CASLatency1,SDClockPeriod1,SDClockPeriod2,ReadBurst1,ReadBurst2,LoadToActiveDelay1,ExitSelfRefreshDelay1,SelfRefreshTime1,RowCycleDelay1,RowCycleDelay2,WriteRecoveryTime1,RPDelay1,RPDelay2,RCDDelay1 FMC.LoadToActiveDelay1=2 +FMC.RCDDelay1=10 FMC.RPDelay1=1 FMC.RPDelay2=1 FMC.ReadBurst1=FMC_SDRAM_RBURST_ENABLE @@ -138,13 +139,13 @@ KeepUserPlacement=false Mcu.Family=STM32H7 Mcu.IP0=ADC1 Mcu.IP1=CORTEX_M7 -Mcu.IP10=SAI1 -Mcu.IP11=SPI2 -Mcu.IP12=SPI3 -Mcu.IP13=SYS -Mcu.IP14=TIM2 -Mcu.IP15=TIM3 -Mcu.IP16=TIM4 +Mcu.IP10=SPI2 +Mcu.IP11=SPI3 +Mcu.IP12=SYS +Mcu.IP13=TIM2 +Mcu.IP14=TIM4 +Mcu.IP15=TIM5 +Mcu.IP16=TIM8 Mcu.IP17=UART5 Mcu.IP18=UART7 Mcu.IP19=USB_DEVICE @@ -153,35 +154,31 @@ Mcu.IP20=USB_OTG_FS Mcu.IP3=DMA Mcu.IP4=FMC Mcu.IP5=FREERTOS -Mcu.IP6=LPTIM1 -Mcu.IP7=NVIC -Mcu.IP8=QUADSPI -Mcu.IP9=RCC +Mcu.IP6=NVIC +Mcu.IP7=QUADSPI +Mcu.IP8=RCC +Mcu.IP9=SAI1 Mcu.IPNb=21 Mcu.Name=STM32H743IIKx Mcu.Package=UFBGA176 Mcu.Pin0=PE3 Mcu.Pin1=PE2 Mcu.Pin10=PE4 -Mcu.Pin100=PE14 -Mcu.Pin101=PD9 -Mcu.Pin102=PD8 -Mcu.Pin103=PA3 -Mcu.Pin104=PA7 -Mcu.Pin105=PB1 -Mcu.Pin106=PB0 -Mcu.Pin107=PF11 -Mcu.Pin108=PF14 -Mcu.Pin109=PE7 +Mcu.Pin100=PA7 +Mcu.Pin101=PB1 +Mcu.Pin102=PB0 +Mcu.Pin103=PF11 +Mcu.Pin104=PF14 +Mcu.Pin105=PE7 +Mcu.Pin106=PE10 +Mcu.Pin107=PE12 +Mcu.Pin108=PE15 +Mcu.Pin109=PB10 Mcu.Pin11=PE5 -Mcu.Pin110=PE10 -Mcu.Pin111=PE12 -Mcu.Pin112=PE15 -Mcu.Pin113=PB10 -Mcu.Pin114=PB11 -Mcu.Pin115=VP_FREERTOS_VS_CMSIS_V1 -Mcu.Pin116=VP_SYS_VS_Systick -Mcu.Pin117=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS +Mcu.Pin110=PB11 +Mcu.Pin111=VP_FREERTOS_VS_CMSIS_V1 +Mcu.Pin112=VP_SYS_VS_Systick +Mcu.Pin113=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS Mcu.Pin12=PE6 Mcu.Pin13=PB7 Mcu.Pin14=PB6 @@ -204,81 +201,81 @@ Mcu.Pin29=PC13 Mcu.Pin3=PE0 Mcu.Pin30=PI9 Mcu.Pin31=PI4 -Mcu.Pin32=PD2 -Mcu.Pin33=PH15 -Mcu.Pin34=PI1 -Mcu.Pin35=PC14-OSC32_IN (OSC32_IN) -Mcu.Pin36=PF0 -Mcu.Pin37=PI10 -Mcu.Pin38=PI11 -Mcu.Pin39=PH13 +Mcu.Pin32=PH15 +Mcu.Pin33=PI1 +Mcu.Pin34=PF0 +Mcu.Pin35=PI10 +Mcu.Pin36=PH13 +Mcu.Pin37=PH14 +Mcu.Pin38=PI0 +Mcu.Pin39=PA9 Mcu.Pin4=PB5 -Mcu.Pin40=PH14 -Mcu.Pin41=PI0 -Mcu.Pin42=PA9 -Mcu.Pin43=PC15-OSC32_OUT (OSC32_OUT) -Mcu.Pin44=PH2 -Mcu.Pin45=PC9 -Mcu.Pin46=PA8 -Mcu.Pin47=PH0-OSC_IN (PH0) -Mcu.Pin48=PH3 -Mcu.Pin49=PC8 +Mcu.Pin40=PC15-OSC32_OUT (OSC32_OUT) +Mcu.Pin41=PH2 +Mcu.Pin42=PC9 +Mcu.Pin43=PA8 +Mcu.Pin44=PH0-OSC_IN (PH0) +Mcu.Pin45=PH3 +Mcu.Pin46=PC7 +Mcu.Pin47=PH1-OSC_OUT (PH1) +Mcu.Pin48=PF2 +Mcu.Pin49=PF1 Mcu.Pin5=PB3 (JTDO/TRACESWO) -Mcu.Pin50=PC7 -Mcu.Pin51=PH1-OSC_OUT (PH1) -Mcu.Pin52=PF2 -Mcu.Pin53=PF1 -Mcu.Pin54=PH4 -Mcu.Pin55=PG8 -Mcu.Pin56=PC6 -Mcu.Pin57=PF3 -Mcu.Pin58=PF4 -Mcu.Pin59=PH5 +Mcu.Pin50=PH4 +Mcu.Pin51=PG8 +Mcu.Pin52=PC6 +Mcu.Pin53=PF3 +Mcu.Pin54=PF4 +Mcu.Pin55=PH5 +Mcu.Pin56=PG7 +Mcu.Pin57=PG6 +Mcu.Pin58=PF7 +Mcu.Pin59=PF6 Mcu.Pin6=PC12 -Mcu.Pin60=PG7 -Mcu.Pin61=PG6 -Mcu.Pin62=PF7 -Mcu.Pin63=PF6 -Mcu.Pin64=PF5 -Mcu.Pin65=PH12 -Mcu.Pin66=PG5 -Mcu.Pin67=PG4 -Mcu.Pin68=PG3 -Mcu.Pin69=PF10 +Mcu.Pin60=PF5 +Mcu.Pin61=PH12 +Mcu.Pin62=PG5 +Mcu.Pin63=PG4 +Mcu.Pin64=PG3 +Mcu.Pin65=PF10 +Mcu.Pin66=PF9 +Mcu.Pin67=PF8 +Mcu.Pin68=PH11 +Mcu.Pin69=PH10 Mcu.Pin7=PA15 (JTDI) -Mcu.Pin70=PF9 -Mcu.Pin71=PF8 -Mcu.Pin72=PH11 -Mcu.Pin73=PH10 -Mcu.Pin74=PD15 -Mcu.Pin75=PG2 -Mcu.Pin76=PC0 -Mcu.Pin77=PC1 -Mcu.Pin78=PC2_C -Mcu.Pin79=PC3_C +Mcu.Pin70=PD15 +Mcu.Pin71=PG2 +Mcu.Pin72=PC0 +Mcu.Pin73=PC1 +Mcu.Pin74=PC2_C +Mcu.Pin75=PC3_C +Mcu.Pin76=PG1 +Mcu.Pin77=PH8 +Mcu.Pin78=PH9 +Mcu.Pin79=PD14 Mcu.Pin8=PA14 (JTCK/SWCLK) -Mcu.Pin80=PG1 -Mcu.Pin81=PH8 -Mcu.Pin82=PH9 -Mcu.Pin83=PD14 -Mcu.Pin84=PD13 -Mcu.Pin85=PA1 -Mcu.Pin86=PA0 -Mcu.Pin87=PF13 -Mcu.Pin88=PG0 -Mcu.Pin89=PE13 +Mcu.Pin80=PD13 +Mcu.Pin81=PA1 +Mcu.Pin82=PA0 +Mcu.Pin83=PF13 +Mcu.Pin84=PG0 +Mcu.Pin85=PE13 +Mcu.Pin86=PD12 +Mcu.Pin87=PD10 +Mcu.Pin88=PA2 +Mcu.Pin89=PA6 Mcu.Pin9=PA13 (JTMS/SWDIO) -Mcu.Pin90=PD12 -Mcu.Pin91=PD10 -Mcu.Pin92=PA2 -Mcu.Pin93=PA6 -Mcu.Pin94=PC5 -Mcu.Pin95=PF12 -Mcu.Pin96=PF15 -Mcu.Pin97=PE8 -Mcu.Pin98=PE9 -Mcu.Pin99=PE11 -Mcu.PinsNb=118 +Mcu.Pin90=PC5 +Mcu.Pin91=PF12 +Mcu.Pin92=PF15 +Mcu.Pin93=PE8 +Mcu.Pin94=PE9 +Mcu.Pin95=PE11 +Mcu.Pin96=PE14 +Mcu.Pin97=PD9 +Mcu.Pin98=PD8 +Mcu.Pin99=PA3 +Mcu.PinsNb=114 Mcu.ThirdPartyNb=0 Mcu.UserConstants= Mcu.UserName=STM32H743IIKx @@ -291,9 +288,6 @@ NVIC.DMA1_Stream1_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true NVIC.DMA1_Stream2_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true NVIC.DMA1_Stream3_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false -NVIC.EXTI15_10_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -NVIC.EXTI2_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -NVIC.EXTI9_5_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true NVIC.ForceEnableDMAVector=true NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false @@ -312,7 +306,7 @@ NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:false\:true NVIC.TIM4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false PA0.Locked=true -PA0.Signal=GPIO_Input +PA0.Signal=S_TIM5_CH1 PA1.Signal=S_TIM2_CH2 PA11.Mode=Device_Only PA11.Signal=USB_OTG_FS_DM @@ -378,14 +372,8 @@ PC12.GPIO_Speed=GPIO_SPEED_FREQ_HIGH PC12.Locked=true PC12.Signal=SharedStack_PC12 PC12.Stacked=true -PC13.GPIOParameters=GPIO_Label -PC13.GPIO_Label=EXTI13 PC13.Locked=true -PC13.Signal=GPXTI13 -PC14-OSC32_IN\ (OSC32_IN).GPIOParameters=GPIO_Label -PC14-OSC32_IN\ (OSC32_IN).GPIO_Label=EXTI14 -PC14-OSC32_IN\ (OSC32_IN).Locked=true -PC14-OSC32_IN\ (OSC32_IN).Signal=GPXTI14 +PC13.Signal=GPIO_Output PC15-OSC32_OUT\ (OSC32_OUT).Locked=true PC15-OSC32_OUT\ (OSC32_OUT).Signal=GPIO_Input PC2_C.GPIOParameters=GPIO_Speed,GPIO_Label @@ -401,13 +389,8 @@ PC3_C.Signal=SPI2_MOSI PC5.GPIOParameters=GPIO_Label PC5.GPIO_Label=ADC4 PC5.Signal=ADCx_INP8 -PC6.Signal=S_TIM3_CH1 -PC7.Signal=S_TIM3_CH2 -PC8.GPIOParameters=GPIO_Label -PC8.GPIO_Label=EXTI8 -PC8.Locked=true -PC8.Signal=SharedStack_PC8 -PC8.Stacked=true +PC6.Signal=S_TIM8_CH1 +PC7.Signal=S_TIM8_CH2 PC9.GPIOParameters=GPIO_Label PC9.GPIO_Label=EXTI9 PC9.Locked=true @@ -424,11 +407,6 @@ PD13.GPIO_PuPd=GPIO_PULLUP PD13.Signal=S_TIM4_CH2 PD14.Signal=FMC_D0_DA0 PD15.Signal=FMC_D1_DA1 -PD2.GPIOParameters=GPIO_Label -PD2.GPIO_Label=EXTI2 -PD2.Locked=true -PD2.Signal=SharedStack_PD2 -PD2.Stacked=true PD8.Signal=FMC_D13_DA13 PD9.Signal=FMC_D14_DA14 PE0.Signal=FMC_NBL0 @@ -500,10 +478,10 @@ PG0.Signal=FMC_A10 PG1.Signal=FMC_A11 PG10.Locked=true PG10.Signal=GPIO_Input -PG11.Mode=Encoder_mode_occur1 -PG11.Signal=LPTIM1_IN2 -PG12.Mode=Encoder_mode_occur1 -PG12.Signal=LPTIM1_IN1 +PG11.Locked=true +PG11.Signal=GPIO_Output +PG12.Locked=true +PG12.Signal=GPIO_Output PG15.Signal=FMC_SDNCAS PG2.Signal=FMC_A12 PG3.GPIOParameters=GPIO_Label @@ -544,8 +522,6 @@ PH9.Signal=FMC_D17 PI0.Signal=FMC_D24 PI1.Signal=FMC_D25 PI10.Signal=FMC_D31 -PI11.Locked=true -PI11.Signal=GPIO_Output PI2.Signal=FMC_D26 PI3.Signal=FMC_D27 PI4.Signal=FMC_NBL2 @@ -582,7 +558,7 @@ ProjectManager.StackSize=0x400 ProjectManager.TargetToolchain=Other Toolchains (GPDSC) ProjectManager.ToolChainLocation= ProjectManager.UnderRoot=false -ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_QUADSPI_Init-QUADSPI-false-HAL-true,5-MX_FMC_Init-FMC-false-HAL-true,6-MX_SAI1_Init-SAI1-false-HAL-true,7-MX_ADC1_Init-ADC1-false-HAL-true,8-MX_SPI2_Init-SPI2-false-HAL-true,9-MX_SPI3_Init-SPI3-false-HAL-true,10-MX_TIM2_Init-TIM2-false-HAL-true,11-MX_TIM3_Init-TIM3-false-HAL-true,12-MX_TIM4_Init-TIM4-false-HAL-true,13-MX_UART5_Init-UART5-false-HAL-true,14-MX_UART7_Init-UART7-false-HAL-true,15-MX_LPTIM1_Init-LPTIM1-false-HAL-true,16-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_QUADSPI_Init-QUADSPI-false-HAL-true,5-MX_FMC_Init-FMC-false-HAL-true,6-MX_SAI1_Init-SAI1-false-HAL-true,7-MX_ADC1_Init-ADC1-false-HAL-true,8-MX_SPI2_Init-SPI2-false-HAL-true,9-MX_SPI3_Init-SPI3-false-HAL-true,10-MX_TIM2_Init-TIM2-false-HAL-true,11-MX_TIM4_Init-TIM4-false-HAL-true,12-MX_UART5_Init-UART5-false-HAL-true,13-MX_UART7_Init-UART7-false-HAL-true,14-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,15-MX_TIM5_Init-TIM5-false-HAL-true,16-MX_TIM8_Init-TIM8-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true QUADSPI.ClockPrescaler=9 QUADSPI.FifoThreshold=4 QUADSPI.FlashSize=22 @@ -835,37 +811,32 @@ SH.FMC_SDNRAS.0=FMC_SDNRAS,13b-sda1 SH.FMC_SDNRAS.ConfNb=1 SH.FMC_SDNWE.0=FMC_SDNWE,13b-sda1 SH.FMC_SDNWE.ConfNb=1 -SH.GPXTI13.0=GPIO_EXTI13 -SH.GPXTI13.ConfNb=1 -SH.GPXTI14.0=GPIO_EXTI14 -SH.GPXTI14.ConfNb=1 -SH.S_TIM2_CH1.0=TIM2_CH1,Encoder_Interface +SH.S_TIM2_CH1.0=TIM2_CH1,PWM Generation1 CH1 SH.S_TIM2_CH1.ConfNb=1 -SH.S_TIM2_CH2.0=TIM2_CH2,Encoder_Interface +SH.S_TIM2_CH2.0=TIM2_CH2,PWM Generation2 CH2 SH.S_TIM2_CH2.ConfNb=1 -SH.S_TIM3_CH1.0=TIM3_CH1,Encoder_Interface -SH.S_TIM3_CH1.ConfNb=1 -SH.S_TIM3_CH2.0=TIM3_CH2,Encoder_Interface -SH.S_TIM3_CH2.ConfNb=1 SH.S_TIM4_CH1.0=TIM4_CH1,Encoder_Interface SH.S_TIM4_CH1.ConfNb=1 SH.S_TIM4_CH2.0=TIM4_CH2,Encoder_Interface SH.S_TIM4_CH2.ConfNb=1 +SH.S_TIM5_CH1.0=TIM5_CH1,PWM Generation1 CH1 +SH.S_TIM5_CH1.ConfNb=1 +SH.S_TIM8_CH1.0=TIM8_CH1,PWM Generation1 CH1 +SH.S_TIM8_CH1.ConfNb=1 +SH.S_TIM8_CH2.0=TIM8_CH2,PWM Generation2 CH2 +SH.S_TIM8_CH2.ConfNb=1 SH.SharedStack_PC10.0=SDMMC1_D2 SH.SharedStack_PC10.1=SPI3_SCK,TX_Only_Simplex_Unidirect_Master SH.SharedStack_PC10.ConfNb=2 SH.SharedStack_PC12.0=SDMMC1_CK SH.SharedStack_PC12.1=SPI3_MOSI,TX_Only_Simplex_Unidirect_Master SH.SharedStack_PC12.ConfNb=2 -SH.SharedStack_PC8.0=SDMMC1_D0 -SH.SharedStack_PC8.1=GPIO_EXTI8 -SH.SharedStack_PC8.ConfNb=2 SH.SharedStack_PC9.0=SDMMC1_D1 -SH.SharedStack_PC9.1=GPIO_EXTI9 -SH.SharedStack_PC9.ConfNb=2 -SH.SharedStack_PD2.0=SDMMC1_CMD -SH.SharedStack_PD2.1=GPIO_EXTI2 -SH.SharedStack_PD2.ConfNb=2 +SH.SharedStack_PC9.1=GPIO_EXTI9+0 +SH.SharedStack_PC9.2=TIM3_CH4 +SH.SharedStack_PC9.3=TIM8_CH4 +SH.SharedStack_PC9.4=GPIO_Output+0 +SH.SharedStack_PC9.ConfNb=5 SPI2.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_256 SPI2.CLKPhase=SPI_PHASE_2EDGE SPI2.CLKPolarity=SPI_POLARITY_HIGH @@ -884,10 +855,18 @@ SPI3.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,DataSize,BaudRate SPI3.Mode=SPI_MODE_MASTER SPI3.NSSPMode=SPI_NSS_PULSE_DISABLE SPI3.VirtualType=VM_MASTER +TIM2.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 +TIM2.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2 +TIM2.IPParameters=Channel-PWM Generation2 CH2,Channel-PWM Generation1 CH1 TIM4.EncoderMode=TIM_ENCODERMODE_TI12 TIM4.IC1Filter=4 TIM4.IC2Filter=4 TIM4.IPParameters=EncoderMode,IC1Filter,IC2Filter +TIM5.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 +TIM5.IPParameters=Channel-PWM Generation1 CH1 +TIM8.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 +TIM8.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2 +TIM8.IPParameters=Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2 USB_DEVICE.CLASS_NAME_FS=AUDIO USB_DEVICE.IPParameters=VirtualMode-AUDIO_FS,VirtualModeFS,CLASS_NAME_FS,VID-AUDIO_FS,MANUFACTURER_STRING-AUDIO_FS,PID_AUDIO_FS,PRODUCT_STRING_AUDIO_FS USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology diff --git a/ACDC/Core/Inc/main.h b/ACDC/Core/Inc/main.h index 6a7b29b4..36925edc 100644 --- a/ACDC/Core/Inc/main.h +++ b/ACDC/Core/Inc/main.h @@ -50,6 +50,8 @@ extern "C" { /* USER CODE END EM */ +void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); + /* Exported functions prototypes ---------------------------------------------*/ void Error_Handler(void); @@ -60,12 +62,6 @@ void Error_Handler(void); /* Private defines -----------------------------------------------------------*/ #define FLASH_DQ2_Pin GPIO_PIN_2 #define FLASH_DQ2_GPIO_Port GPIOE -#define EXTI13_Pin GPIO_PIN_13 -#define EXTI13_GPIO_Port GPIOC -#define EXTI13_EXTI_IRQn EXTI15_10_IRQn -#define EXTI14_Pin GPIO_PIN_14 -#define EXTI14_GPIO_Port GPIOC -#define EXTI14_EXTI_IRQn EXTI15_10_IRQn #define FLASH_NCS_Pin GPIO_PIN_6 #define FLASH_NCS_GPIO_Port GPIOG #define FLASH_DQ3_Pin GPIO_PIN_6 diff --git a/ACDC/Core/Inc/stm32h7xx_hal_conf.h b/ACDC/Core/Inc/stm32h7xx_hal_conf.h index 66782786..1a9f1d21 100644 --- a/ACDC/Core/Inc/stm32h7xx_hal_conf.h +++ b/ACDC/Core/Inc/stm32h7xx_hal_conf.h @@ -62,7 +62,7 @@ /* #define HAL_I2S_MODULE_ENABLED */ /* #define HAL_SMBUS_MODULE_ENABLED */ /* #define HAL_IWDG_MODULE_ENABLED */ -#define HAL_LPTIM_MODULE_ENABLED +/* #define HAL_LPTIM_MODULE_ENABLED */ /* #define HAL_LTDC_MODULE_ENABLED */ #define HAL_QSPI_MODULE_ENABLED /* #define HAL_RAMECC_MODULE_ENABLED */ diff --git a/ACDC/Core/Inc/stm32h7xx_it.h b/ACDC/Core/Inc/stm32h7xx_it.h index 8bfa4d85..dbb0e22d 100644 --- a/ACDC/Core/Inc/stm32h7xx_it.h +++ b/ACDC/Core/Inc/stm32h7xx_it.h @@ -48,15 +48,12 @@ /* Exported functions prototypes ---------------------------------------------*/ void SysTick_Handler(void); -void EXTI2_IRQHandler(void); void DMA1_Stream0_IRQHandler(void); void DMA1_Stream1_IRQHandler(void); void DMA1_Stream2_IRQHandler(void); void DMA1_Stream3_IRQHandler(void); void ADC_IRQHandler(void); -void EXTI9_5_IRQHandler(void); void TIM4_IRQHandler(void); -void EXTI15_10_IRQHandler(void); void SPI3_IRQHandler(void); void SAI1_IRQHandler(void); void QUADSPI_IRQHandler(void); diff --git a/ACDC/Core/Src/ACDC.cpp b/ACDC/Core/Src/ACDC.cpp index de79c14f..fafe614a 100644 --- a/ACDC/Core/Src/ACDC.cpp +++ b/ACDC/Core/Src/ACDC.cpp @@ -45,43 +45,55 @@ Pin led_out3(XIBECA_PIN23); Pin led_out4(XIBECA_PIN24); void setLed(uint8_t led, uint32_t rgb){ - bool value = rgb; + uint32_t pwm = 0xFFFFFFFFU - __USAT(rgb>>10, 10); switch(led){ case 1: - led_in1.set(value); + if(rgb == RED_COLOUR){ + led_in1.high(); + led_clip1.low(); + }else{ + led_in1.low(); + led_clip1.high(); + } break; case 2: - led_in2.set(value); + if(rgb == RED_COLOUR){ + led_in2.high(); + led_clip2.low(); + }else{ + led_in2.low(); + led_clip2.high(); + } break; case 3: - led_in3.set(value); + if(rgb == RED_COLOUR){ + led_clip3.low(); + TIM2->CCR1 = 0xFFFFFFFFU; + }else{ + led_clip3.high(); + TIM2->CCR1 = pwm; + } break; case 4: - led_in4.set(value); + if(rgb == RED_COLOUR){ + led_clip4.low(); + TIM2->CCR2 = 0xFFFFFFFFU; + }else{ + led_clip4.high(); + TIM2->CCR2 = pwm; + } break; case 5: - led_clip1.set(value); + TIM8->CCR1 = pwm; break; case 6: - led_clip2.set(value); + TIM8->CCR2 = pwm; break; case 7: - led_clip3.set(value); + TIM4->CCR1 = pwm; break; case 8: - led_clip4.set(value); - break; - case 9: - led_out1.set(value); - break; - case 10: - led_out2.set(value); - break; - case 11: - led_out3.set(value); - break; - case 12: - led_out4.set(value); + TIM4->CCR2 = pwm; break; } } @@ -93,28 +105,56 @@ void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* parameter_values[3] = (parameter_values[3]*3 + adc_values[ADC_D])>>2; } -void setup(){ +void initLed(){ + extern TIM_HandleTypeDef htim2; + extern TIM_HandleTypeDef htim4; + // extern TIM_HandleTypeDef htim5; + extern TIM_HandleTypeDef htim8; + HAL_TIM_Base_Start(&htim2); + HAL_TIM_Base_Start(&htim4); + // HAL_TIM_Base_Start(&htim5); + HAL_TIM_Base_Start(&htim8); + HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1); // in3 + HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2); // in4 + HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_1); // out3 + HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_2); // out4 + // HAL_TIM_PWM_Start(&htim5, TIM_CHANNEL_1); // clip1 + HAL_TIM_PWM_Start(&htim8, TIM_CHANNEL_1); // out1 + HAL_TIM_PWM_Start(&htim8, TIM_CHANNEL_1); // out2 + led_in1.outputMode(); led_in2.outputMode(); - led_in3.outputMode(); - led_in4.outputMode(); led_clip1.outputMode(); led_clip2.outputMode(); led_clip3.outputMode(); led_clip4.outputMode(); +} - led_out1.outputMode(); - led_out2.outputMode(); - led_out3.outputMode(); - led_out4.outputMode(); +void onSetup(){ + initLed(); + // led_in1.outputMode(); + // led_in2.outputMode(); + // led_in3.outputMode(); + // led_in4.outputMode(); - for(size_t i=1; i<=12; ++i) - setLed(i, NO_COLOUR); + // led_clip1.outputMode(); + // led_clip2.outputMode(); + // led_clip3.outputMode(); + // led_clip4.outputMode(); + + // led_out1.outputMode(); + // led_out2.outputMode(); + // led_out3.outputMode(); + // led_out4.outputMode(); - owl.setup(); + for(size_t i=1; i<=8; ++i) + setLed(i, NO_COLOUR); } -void loop(void){ - owl.loop(); +void onLoop(void){ + for(size_t i=0; i<4; ++i){ + setLed(i+1, getParameterValue(PARAMETER_AA+i)); + setLed(i+4, getParameterValue(PARAMETER_BA+i)); + } } diff --git a/ACDC/Core/Src/main.c b/ACDC/Core/Src/main.c index 0f90fdf8..0c95520c 100644 --- a/ACDC/Core/Src/main.c +++ b/ACDC/Core/Src/main.c @@ -47,8 +47,6 @@ ADC_HandleTypeDef hadc1; DMA_HandleTypeDef hdma_adc1; -LPTIM_HandleTypeDef hlptim1; - QSPI_HandleTypeDef hqspi; SAI_HandleTypeDef hsai_BlockA1; @@ -61,8 +59,9 @@ SPI_HandleTypeDef hspi3; DMA_HandleTypeDef hdma_spi3_tx; TIM_HandleTypeDef htim2; -TIM_HandleTypeDef htim3; TIM_HandleTypeDef htim4; +TIM_HandleTypeDef htim5; +TIM_HandleTypeDef htim8; UART_HandleTypeDef huart5; UART_HandleTypeDef huart7; @@ -86,11 +85,11 @@ static void MX_ADC1_Init(void); static void MX_SPI2_Init(void); static void MX_SPI3_Init(void); static void MX_TIM2_Init(void); -static void MX_TIM3_Init(void); static void MX_TIM4_Init(void); static void MX_UART5_Init(void); static void MX_UART7_Init(void); -static void MX_LPTIM1_Init(void); +static void MX_TIM5_Init(void); +static void MX_TIM8_Init(void); void StartDefaultTask(void const * argument); /* USER CODE BEGIN PFP */ @@ -169,11 +168,11 @@ int main(void) MX_SPI2_Init(); MX_SPI3_Init(); MX_TIM2_Init(); - MX_TIM3_Init(); MX_TIM4_Init(); MX_UART5_Init(); MX_UART7_Init(); - MX_LPTIM1_Init(); + MX_TIM5_Init(); + MX_TIM8_Init(); /* USER CODE BEGIN 2 */ #ifdef USE_EXTERNAL_RAM @@ -406,42 +405,6 @@ static void MX_ADC1_Init(void) } -/** - * @brief LPTIM1 Initialization Function - * @param None - * @retval None - */ -static void MX_LPTIM1_Init(void) -{ - - /* USER CODE BEGIN LPTIM1_Init 0 */ - - /* USER CODE END LPTIM1_Init 0 */ - - /* USER CODE BEGIN LPTIM1_Init 1 */ - - /* USER CODE END LPTIM1_Init 1 */ - hlptim1.Instance = LPTIM1; - hlptim1.Init.Clock.Source = LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC; - hlptim1.Init.Clock.Prescaler = LPTIM_PRESCALER_DIV1; - hlptim1.Init.UltraLowPowerClock.Polarity = LPTIM_CLOCKPOLARITY_RISING; - hlptim1.Init.UltraLowPowerClock.SampleTime = LPTIM_CLOCKSAMPLETIME_DIRECTTRANSITION; - hlptim1.Init.Trigger.Source = LPTIM_TRIGSOURCE_SOFTWARE; - hlptim1.Init.OutputPolarity = LPTIM_OUTPUTPOLARITY_HIGH; - hlptim1.Init.UpdateMode = LPTIM_UPDATE_IMMEDIATE; - hlptim1.Init.CounterSource = LPTIM_COUNTERSOURCE_EXTERNAL; - hlptim1.Init.Input1Source = LPTIM_INPUT1SOURCE_GPIO; - hlptim1.Init.Input2Source = LPTIM_INPUT2SOURCE_GPIO; - if (HAL_LPTIM_Init(&hlptim1) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN LPTIM1_Init 2 */ - - /* USER CODE END LPTIM1_Init 2 */ - -} - /** * @brief QUADSPI Initialization Function * @param None @@ -665,8 +628,8 @@ static void MX_TIM2_Init(void) /* USER CODE END TIM2_Init 0 */ - TIM_Encoder_InitTypeDef sConfig = {0}; TIM_MasterConfigTypeDef sMasterConfig = {0}; + TIM_OC_InitTypeDef sConfigOC = {0}; /* USER CODE BEGIN TIM2_Init 1 */ @@ -677,16 +640,7 @@ static void MX_TIM2_Init(void) htim2.Init.Period = 4294967295; htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; - sConfig.EncoderMode = TIM_ENCODERMODE_TI1; - sConfig.IC1Polarity = TIM_ICPOLARITY_RISING; - sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI; - sConfig.IC1Prescaler = TIM_ICPSC_DIV1; - sConfig.IC1Filter = 0; - sConfig.IC2Polarity = TIM_ICPOLARITY_RISING; - sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI; - sConfig.IC2Prescaler = TIM_ICPSC_DIV1; - sConfig.IC2Filter = 0; - if (HAL_TIM_Encoder_Init(&htim2, &sConfig) != HAL_OK) + if (HAL_TIM_PWM_Init(&htim2) != HAL_OK) { Error_Handler(); } @@ -696,58 +650,22 @@ static void MX_TIM2_Init(void) { Error_Handler(); } - /* USER CODE BEGIN TIM2_Init 2 */ - - /* USER CODE END TIM2_Init 2 */ - -} - -/** - * @brief TIM3 Initialization Function - * @param None - * @retval None - */ -static void MX_TIM3_Init(void) -{ - - /* USER CODE BEGIN TIM3_Init 0 */ - - /* USER CODE END TIM3_Init 0 */ - - TIM_Encoder_InitTypeDef sConfig = {0}; - TIM_MasterConfigTypeDef sMasterConfig = {0}; - - /* USER CODE BEGIN TIM3_Init 1 */ - - /* USER CODE END TIM3_Init 1 */ - htim3.Instance = TIM3; - htim3.Init.Prescaler = 0; - htim3.Init.CounterMode = TIM_COUNTERMODE_UP; - htim3.Init.Period = 65535; - htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; - htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; - sConfig.EncoderMode = TIM_ENCODERMODE_TI1; - sConfig.IC1Polarity = TIM_ICPOLARITY_RISING; - sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI; - sConfig.IC1Prescaler = TIM_ICPSC_DIV1; - sConfig.IC1Filter = 0; - sConfig.IC2Polarity = TIM_ICPOLARITY_RISING; - sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI; - sConfig.IC2Prescaler = TIM_ICPSC_DIV1; - sConfig.IC2Filter = 0; - if (HAL_TIM_Encoder_Init(&htim3, &sConfig) != HAL_OK) + sConfigOC.OCMode = TIM_OCMODE_PWM1; + sConfigOC.Pulse = 0; + sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; + sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; + if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) { Error_Handler(); } - sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; - sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; - if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK) + if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_2) != HAL_OK) { Error_Handler(); } - /* USER CODE BEGIN TIM3_Init 2 */ + /* USER CODE BEGIN TIM2_Init 2 */ - /* USER CODE END TIM3_Init 2 */ + /* USER CODE END TIM2_Init 2 */ + HAL_TIM_MspPostInit(&htim2); } @@ -800,6 +718,129 @@ static void MX_TIM4_Init(void) } +/** + * @brief TIM5 Initialization Function + * @param None + * @retval None + */ +static void MX_TIM5_Init(void) +{ + + /* USER CODE BEGIN TIM5_Init 0 */ + + /* USER CODE END TIM5_Init 0 */ + + TIM_MasterConfigTypeDef sMasterConfig = {0}; + TIM_OC_InitTypeDef sConfigOC = {0}; + + /* USER CODE BEGIN TIM5_Init 1 */ + + /* USER CODE END TIM5_Init 1 */ + htim5.Instance = TIM5; + htim5.Init.Prescaler = 0; + htim5.Init.CounterMode = TIM_COUNTERMODE_UP; + htim5.Init.Period = 4294967295; + htim5.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; + htim5.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; + if (HAL_TIM_PWM_Init(&htim5) != HAL_OK) + { + Error_Handler(); + } + sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; + sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; + if (HAL_TIMEx_MasterConfigSynchronization(&htim5, &sMasterConfig) != HAL_OK) + { + Error_Handler(); + } + sConfigOC.OCMode = TIM_OCMODE_PWM1; + sConfigOC.Pulse = 0; + sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; + sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; + if (HAL_TIM_PWM_ConfigChannel(&htim5, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN TIM5_Init 2 */ + + /* USER CODE END TIM5_Init 2 */ + HAL_TIM_MspPostInit(&htim5); + +} + +/** + * @brief TIM8 Initialization Function + * @param None + * @retval None + */ +static void MX_TIM8_Init(void) +{ + + /* USER CODE BEGIN TIM8_Init 0 */ + + /* USER CODE END TIM8_Init 0 */ + + TIM_MasterConfigTypeDef sMasterConfig = {0}; + TIM_OC_InitTypeDef sConfigOC = {0}; + TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig = {0}; + + /* USER CODE BEGIN TIM8_Init 1 */ + + /* USER CODE END TIM8_Init 1 */ + htim8.Instance = TIM8; + htim8.Init.Prescaler = 0; + htim8.Init.CounterMode = TIM_COUNTERMODE_UP; + htim8.Init.Period = 65535; + htim8.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; + htim8.Init.RepetitionCounter = 0; + htim8.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; + if (HAL_TIM_PWM_Init(&htim8) != HAL_OK) + { + Error_Handler(); + } + sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; + sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_RESET; + sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; + if (HAL_TIMEx_MasterConfigSynchronization(&htim8, &sMasterConfig) != HAL_OK) + { + Error_Handler(); + } + sConfigOC.OCMode = TIM_OCMODE_PWM1; + sConfigOC.Pulse = 0; + sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; + sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH; + sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; + sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET; + sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET; + if (HAL_TIM_PWM_ConfigChannel(&htim8, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) + { + Error_Handler(); + } + if (HAL_TIM_PWM_ConfigChannel(&htim8, &sConfigOC, TIM_CHANNEL_2) != HAL_OK) + { + Error_Handler(); + } + sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE; + sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE; + sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF; + sBreakDeadTimeConfig.DeadTime = 0; + sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE; + sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH; + sBreakDeadTimeConfig.BreakFilter = 0; + sBreakDeadTimeConfig.Break2State = TIM_BREAK2_DISABLE; + sBreakDeadTimeConfig.Break2Polarity = TIM_BREAK2POLARITY_HIGH; + sBreakDeadTimeConfig.Break2Filter = 0; + sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE; + if (HAL_TIMEx_ConfigBreakDeadTime(&htim8, &sBreakDeadTimeConfig) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN TIM8_Init 2 */ + + /* USER CODE END TIM8_Init 2 */ + HAL_TIM_MspPostInit(&htim8); + +} + /** * @brief UART5 Initialization Function * @param None @@ -940,23 +981,23 @@ static void MX_FMC_Init(void) hsdram1.Instance = FMC_SDRAM_DEVICE; /* hsdram1.Init */ hsdram1.Init.SDBank = FMC_SDRAM_BANK1; - hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_9; // 8; + hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_9; hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_13; hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_32; hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4; - hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3; // 1; + hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3; hsdram1.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE; - hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2; // DISABLE; - hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE; // DISABLE; + hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2; + hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE; hsdram1.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0; /* SdramTiming */ - SdramTiming.LoadToActiveDelay = 2; // 16; - SdramTiming.ExitSelfRefreshDelay = 7; // 16; - SdramTiming.SelfRefreshTime = 4; // 16; - SdramTiming.RowCycleDelay = 8; // 16; - SdramTiming.WriteRecoveryTime = 3; // 16; - SdramTiming.RPDelay = 1; // 0 causes assertion error; // 16; - SdramTiming.RCDDelay = 10; // 16; + SdramTiming.LoadToActiveDelay = 2; + SdramTiming.ExitSelfRefreshDelay = 7; + SdramTiming.SelfRefreshTime = 4; + SdramTiming.RowCycleDelay = 8; + SdramTiming.WriteRecoveryTime = 3; + SdramTiming.RPDelay = 1; + SdramTiming.RCDDelay = 10; if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK) { @@ -989,13 +1030,13 @@ static void MX_GPIO_Init(void) __HAL_RCC_GPIOF_CLK_ENABLE(); /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOI, GPIO_PIN_11, GPIO_PIN_RESET); + HAL_GPIO_WritePin(GPIOG, GPIO_PIN_12|GPIO_PIN_11|ADC_RST_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOH, GPIO_PIN_4, GPIO_PIN_RESET); + HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(ADC_RST_GPIO_Port, ADC_RST_Pin, GPIO_PIN_RESET); + HAL_GPIO_WritePin(GPIOH, GPIO_PIN_4, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOA, GPIO_PIN_3|GPIO_PIN_7, GPIO_PIN_RESET); @@ -1018,9 +1059,9 @@ static void MX_GPIO_Init(void) HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); /*Configure GPIO pins : PD7 PD6 PD5 PD4 - PD3 PD11 */ + PD3 PD2 PD11 */ GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_6|GPIO_PIN_5|GPIO_PIN_4 - |GPIO_PIN_3|GPIO_PIN_11; + |GPIO_PIN_3|GPIO_PIN_2|GPIO_PIN_11; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); @@ -1033,49 +1074,44 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Alternate = GPIO_AF4_I2C1; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + /*Configure GPIO pins : PG12 PG11 ADC_RST_Pin */ + GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_11|ADC_RST_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + /*Configure GPIO pin : PG10 */ GPIO_InitStruct.Pin = GPIO_PIN_10; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); - /*Configure GPIO pins : PC11 PC4 */ - GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_4; + /*Configure GPIO pins : PC11 PC14 PC8 PC4 */ + GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_14|GPIO_PIN_8|GPIO_PIN_4; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - /*Configure GPIO pins : EXTI13_Pin EXTI14_Pin PC9 PC8 */ - GPIO_InitStruct.Pin = EXTI13_Pin|EXTI14_Pin|GPIO_PIN_9|GPIO_PIN_8; - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + /*Configure GPIO pin : PC13 */ + GPIO_InitStruct.Pin = GPIO_PIN_13; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - /*Configure GPIO pin : PI8 */ - GPIO_InitStruct.Pin = GPIO_PIN_8; + /*Configure GPIO pins : PI8 PI11 */ + GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_11; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); - /*Configure GPIO pin : PD2 */ - GPIO_InitStruct.Pin = GPIO_PIN_2; - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); - /*Configure GPIO pins : PA10 PA4 PA5 */ GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_4|GPIO_PIN_5; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - /*Configure GPIO pin : PI11 */ - GPIO_InitStruct.Pin = GPIO_PIN_11; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); - /*Configure GPIO pin : PC15 */ GPIO_InitStruct.Pin = GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; @@ -1089,25 +1125,12 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); - /*Configure GPIO pin : ADC_RST_Pin */ - GPIO_InitStruct.Pin = ADC_RST_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(ADC_RST_GPIO_Port, &GPIO_InitStruct); - /*Configure GPIO pins : PH6 PH7 */ GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); - /*Configure GPIO pin : PA0 */ - GPIO_InitStruct.Pin = GPIO_PIN_0; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - /*Configure GPIO pins : PA3 PA7 */ GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_7; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; @@ -1122,16 +1145,6 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(ADC_SPI_NCS_GPIO_Port, &GPIO_InitStruct); - /* EXTI interrupt init*/ - HAL_NVIC_SetPriority(EXTI2_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(EXTI2_IRQn); - - HAL_NVIC_SetPriority(EXTI9_5_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); - - HAL_NVIC_SetPriority(EXTI15_10_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(EXTI15_10_IRQn); - } /* USER CODE BEGIN 4 */ diff --git a/ACDC/Core/Src/stm32h7xx_hal_msp.c b/ACDC/Core/Src/stm32h7xx_hal_msp.c index d4499594..748b054d 100644 --- a/ACDC/Core/Src/stm32h7xx_hal_msp.c +++ b/ACDC/Core/Src/stm32h7xx_hal_msp.c @@ -61,7 +61,9 @@ extern DMA_HandleTypeDef hdma_spi3_tx; /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ -/** + +void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); + /** * Initializes the Global MSP. */ void HAL_MspInit(void) @@ -197,81 +199,6 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) } -/** -* @brief LPTIM MSP Initialization -* This function configures the hardware resources used in this example -* @param hlptim: LPTIM handle pointer -* @retval None -*/ -void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef* hlptim) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; - if(hlptim->Instance==LPTIM1) - { - /* USER CODE BEGIN LPTIM1_MspInit 0 */ - - /* USER CODE END LPTIM1_MspInit 0 */ - /** Initializes the peripherals clock - */ - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LPTIM1; - PeriphClkInitStruct.Lptim1ClockSelection = RCC_LPTIM1CLKSOURCE_D2PCLK1; - if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) - { - Error_Handler(); - } - - /* Peripheral clock enable */ - __HAL_RCC_LPTIM1_CLK_ENABLE(); - - __HAL_RCC_GPIOG_CLK_ENABLE(); - /**LPTIM1 GPIO Configuration - PG12 ------> LPTIM1_IN1 - PG11 ------> LPTIM1_IN2 - */ - GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_11; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF1_LPTIM1; - HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); - - /* USER CODE BEGIN LPTIM1_MspInit 1 */ - - /* USER CODE END LPTIM1_MspInit 1 */ - } - -} - -/** -* @brief LPTIM MSP De-Initialization -* This function freeze the hardware resources used in this example -* @param hlptim: LPTIM handle pointer -* @retval None -*/ -void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef* hlptim) -{ - if(hlptim->Instance==LPTIM1) - { - /* USER CODE BEGIN LPTIM1_MspDeInit 0 */ - - /* USER CODE END LPTIM1_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_LPTIM1_CLK_DISABLE(); - - /**LPTIM1 GPIO Configuration - PG12 ------> LPTIM1_IN1 - PG11 ------> LPTIM1_IN2 - */ - HAL_GPIO_DeInit(GPIOG, GPIO_PIN_12|GPIO_PIN_11); - - /* USER CODE BEGIN LPTIM1_MspDeInit 1 */ - - /* USER CODE END LPTIM1_MspDeInit 1 */ - } - -} - /** * @brief QSPI MSP Initialization * This function configures the hardware resources used in this example @@ -534,63 +461,59 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) } /** -* @brief TIM_Encoder MSP Initialization +* @brief TIM_PWM MSP Initialization * This function configures the hardware resources used in this example -* @param htim_encoder: TIM_Encoder handle pointer +* @param htim_pwm: TIM_PWM handle pointer * @retval None */ -void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef* htim_encoder) +void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm) { - GPIO_InitTypeDef GPIO_InitStruct = {0}; - if(htim_encoder->Instance==TIM2) + if(htim_pwm->Instance==TIM2) { /* USER CODE BEGIN TIM2_MspInit 0 */ /* USER CODE END TIM2_MspInit 0 */ /* Peripheral clock enable */ __HAL_RCC_TIM2_CLK_ENABLE(); - - __HAL_RCC_GPIOA_CLK_ENABLE(); - /**TIM2 GPIO Configuration - PA15 (JTDI) ------> TIM2_CH1 - PA1 ------> TIM2_CH2 - */ - GPIO_InitStruct.Pin = GPIO_PIN_15|GPIO_PIN_1; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF1_TIM2; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - /* USER CODE BEGIN TIM2_MspInit 1 */ /* USER CODE END TIM2_MspInit 1 */ } - else if(htim_encoder->Instance==TIM3) + else if(htim_pwm->Instance==TIM5) { - /* USER CODE BEGIN TIM3_MspInit 0 */ + /* USER CODE BEGIN TIM5_MspInit 0 */ - /* USER CODE END TIM3_MspInit 0 */ + /* USER CODE END TIM5_MspInit 0 */ /* Peripheral clock enable */ - __HAL_RCC_TIM3_CLK_ENABLE(); + __HAL_RCC_TIM5_CLK_ENABLE(); + /* USER CODE BEGIN TIM5_MspInit 1 */ - __HAL_RCC_GPIOC_CLK_ENABLE(); - /**TIM3 GPIO Configuration - PC7 ------> TIM3_CH2 - PC6 ------> TIM3_CH1 - */ - GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_6; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF2_TIM3; - HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + /* USER CODE END TIM5_MspInit 1 */ + } + else if(htim_pwm->Instance==TIM8) + { + /* USER CODE BEGIN TIM8_MspInit 0 */ - /* USER CODE BEGIN TIM3_MspInit 1 */ + /* USER CODE END TIM8_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_TIM8_CLK_ENABLE(); + /* USER CODE BEGIN TIM8_MspInit 1 */ - /* USER CODE END TIM3_MspInit 1 */ + /* USER CODE END TIM8_MspInit 1 */ } - else if(htim_encoder->Instance==TIM4) + +} + +/** +* @brief TIM_Encoder MSP Initialization +* This function configures the hardware resources used in this example +* @param htim_encoder: TIM_Encoder handle pointer +* @retval None +*/ +void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef* htim_encoder) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(htim_encoder->Instance==TIM4) { /* USER CODE BEGIN TIM4_MspInit 0 */ @@ -620,51 +543,128 @@ void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef* htim_encoder) } +void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(htim->Instance==TIM2) + { + /* USER CODE BEGIN TIM2_MspPostInit 0 */ + + /* USER CODE END TIM2_MspPostInit 0 */ + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**TIM2 GPIO Configuration + PA15 (JTDI) ------> TIM2_CH1 + PA1 ------> TIM2_CH2 + */ + GPIO_InitStruct.Pin = GPIO_PIN_15|GPIO_PIN_1; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF1_TIM2; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* USER CODE BEGIN TIM2_MspPostInit 1 */ + + /* USER CODE END TIM2_MspPostInit 1 */ + } + else if(htim->Instance==TIM5) + { + /* USER CODE BEGIN TIM5_MspPostInit 0 */ + + /* USER CODE END TIM5_MspPostInit 0 */ + + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**TIM5 GPIO Configuration + PA0 ------> TIM5_CH1 + */ + GPIO_InitStruct.Pin = GPIO_PIN_0; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF2_TIM5; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* USER CODE BEGIN TIM5_MspPostInit 1 */ + + /* USER CODE END TIM5_MspPostInit 1 */ + } + else if(htim->Instance==TIM8) + { + /* USER CODE BEGIN TIM8_MspPostInit 0 */ + + /* USER CODE END TIM8_MspPostInit 0 */ + + __HAL_RCC_GPIOC_CLK_ENABLE(); + /**TIM8 GPIO Configuration + PC7 ------> TIM8_CH2 + PC6 ------> TIM8_CH1 + */ + GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_6; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF3_TIM8; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /* USER CODE BEGIN TIM8_MspPostInit 1 */ + + /* USER CODE END TIM8_MspPostInit 1 */ + } + +} /** -* @brief TIM_Encoder MSP De-Initialization +* @brief TIM_PWM MSP De-Initialization * This function freeze the hardware resources used in this example -* @param htim_encoder: TIM_Encoder handle pointer +* @param htim_pwm: TIM_PWM handle pointer * @retval None */ -void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef* htim_encoder) +void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm) { - if(htim_encoder->Instance==TIM2) + if(htim_pwm->Instance==TIM2) { /* USER CODE BEGIN TIM2_MspDeInit 0 */ /* USER CODE END TIM2_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_TIM2_CLK_DISABLE(); - - /**TIM2 GPIO Configuration - PA15 (JTDI) ------> TIM2_CH1 - PA1 ------> TIM2_CH2 - */ - HAL_GPIO_DeInit(GPIOA, GPIO_PIN_15|GPIO_PIN_1); - /* USER CODE BEGIN TIM2_MspDeInit 1 */ /* USER CODE END TIM2_MspDeInit 1 */ } - else if(htim_encoder->Instance==TIM3) + else if(htim_pwm->Instance==TIM5) { - /* USER CODE BEGIN TIM3_MspDeInit 0 */ + /* USER CODE BEGIN TIM5_MspDeInit 0 */ - /* USER CODE END TIM3_MspDeInit 0 */ + /* USER CODE END TIM5_MspDeInit 0 */ /* Peripheral clock disable */ - __HAL_RCC_TIM3_CLK_DISABLE(); + __HAL_RCC_TIM5_CLK_DISABLE(); + /* USER CODE BEGIN TIM5_MspDeInit 1 */ - /**TIM3 GPIO Configuration - PC7 ------> TIM3_CH2 - PC6 ------> TIM3_CH1 - */ - HAL_GPIO_DeInit(GPIOC, GPIO_PIN_7|GPIO_PIN_6); + /* USER CODE END TIM5_MspDeInit 1 */ + } + else if(htim_pwm->Instance==TIM8) + { + /* USER CODE BEGIN TIM8_MspDeInit 0 */ - /* USER CODE BEGIN TIM3_MspDeInit 1 */ + /* USER CODE END TIM8_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_TIM8_CLK_DISABLE(); + /* USER CODE BEGIN TIM8_MspDeInit 1 */ - /* USER CODE END TIM3_MspDeInit 1 */ + /* USER CODE END TIM8_MspDeInit 1 */ } - else if(htim_encoder->Instance==TIM4) + +} + +/** +* @brief TIM_Encoder MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param htim_encoder: TIM_Encoder handle pointer +* @retval None +*/ +void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef* htim_encoder) +{ + if(htim_encoder->Instance==TIM4) { /* USER CODE BEGIN TIM4_MspDeInit 0 */ diff --git a/ACDC/Core/Src/stm32h7xx_it.c b/ACDC/Core/Src/stm32h7xx_it.c index 2015fed9..18755c38 100644 --- a/ACDC/Core/Src/stm32h7xx_it.c +++ b/ACDC/Core/Src/stm32h7xx_it.c @@ -105,20 +105,6 @@ void SysTick_Handler(void) /* please refer to the startup file (startup_stm32h7xx.s). */ /******************************************************************************/ -/** - * @brief This function handles EXTI line2 interrupt. - */ -void EXTI2_IRQHandler(void) -{ - /* USER CODE BEGIN EXTI2_IRQn 0 */ - - /* USER CODE END EXTI2_IRQn 0 */ - HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2); - /* USER CODE BEGIN EXTI2_IRQn 1 */ - - /* USER CODE END EXTI2_IRQn 1 */ -} - /** * @brief This function handles DMA1 stream0 global interrupt. */ @@ -189,21 +175,6 @@ void ADC_IRQHandler(void) /* USER CODE END ADC_IRQn 1 */ } -/** - * @brief This function handles EXTI line[9:5] interrupts. - */ -void EXTI9_5_IRQHandler(void) -{ - /* USER CODE BEGIN EXTI9_5_IRQn 0 */ - - /* USER CODE END EXTI9_5_IRQn 0 */ - HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8); - HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_9); - /* USER CODE BEGIN EXTI9_5_IRQn 1 */ - - /* USER CODE END EXTI9_5_IRQn 1 */ -} - /** * @brief This function handles TIM4 global interrupt. */ @@ -218,21 +189,6 @@ void TIM4_IRQHandler(void) /* USER CODE END TIM4_IRQn 1 */ } -/** - * @brief This function handles EXTI line[15:10] interrupts. - */ -void EXTI15_10_IRQHandler(void) -{ - /* USER CODE BEGIN EXTI15_10_IRQn 0 */ - - /* USER CODE END EXTI15_10_IRQn 0 */ - HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_13); - HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_14); - /* USER CODE BEGIN EXTI15_10_IRQn 1 */ - - /* USER CODE END EXTI15_10_IRQn 1 */ -} - /** * @brief This function handles SPI3 global interrupt. */ From e0b7fe7ff4fb271f0b0ed9657d403fbf4c83d4d7 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 4 Nov 2021 17:24:21 +0100 Subject: [PATCH 170/286] fixed logic to check if patch is running --- Source/Owl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Owl.cpp b/Source/Owl.cpp index 9e7b3594..c7af523a 100644 --- a/Source/Owl.cpp +++ b/Source/Owl.cpp @@ -215,7 +215,7 @@ void Owl::setOperationMode(OperationMode mode){ } void Owl::loop(){ - if(program.isProgramRunning()){ + if(!program.isProgramRunning()){ midi_tx.transmit(); midi_rx.receive(); // push queued up MIDI messages through to patch } From 64f26c72ed2763d5a9d82fdd9127f43ea088409b Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 4 Nov 2021 18:12:58 +0100 Subject: [PATCH 171/286] disable USBD audio rx --- ACDC/Core/Inc/hardware.h | 7 +++++-- Libraries | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ACDC/Core/Inc/hardware.h b/ACDC/Core/Inc/hardware.h index 897b28d8..92ef8bb7 100644 --- a/ACDC/Core/Inc/hardware.h +++ b/ACDC/Core/Inc/hardware.h @@ -19,6 +19,8 @@ // todo: quad SPI /* #define USE_SPI_FLASH */ +/* #define AUDIO_OUTPUT_GAIN 112 in/out gain not working?*/ + #define USE_CODEC #define USE_PCM3168A /* #define CODEC_HP_FILTER */ @@ -36,11 +38,12 @@ #define USBD_AUDIO_TX_CHANNELS 4 #define USE_USBD_AUDIO +#define USE_USBD_AUDIO_FEATURES #define USE_USBD_AUDIO_TX // microphone -#define USE_USBD_AUDIO_RX // speaker +/* #define USE_USBD_RX_FB */ +/* #define USE_USBD_AUDIO_RX // speaker */ #define USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS -/* #define USBD_MAX_POWER 100 // 200mA for iPad compatibility */ /* #define USE_UART_MIDI_RX */ /* #define USE_UART_MIDI_TX */ diff --git a/Libraries b/Libraries index 1a54c805..fc02729c 160000 --- a/Libraries +++ b/Libraries @@ -1 +1 @@ -Subproject commit 1a54c8057d4056ac235f9b0ca0c4e4c99ecf0bc0 +Subproject commit fc02729cafd3a3581e8faa06184d04a4ea88044c From 657197a0898cf12bb2ce2f0dd1235c4519feb828 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 5 Nov 2021 15:50:15 +0100 Subject: [PATCH 172/286] configured to support 4 channels audio --- ACDC/Core/Inc/hardware.h | 6 +++--- ACDC/Core/Src/main.c | 24 ++++++++++++++++++++++-- Source/pcm3168a.c | 34 ++++++++++++++++++++++++++-------- 3 files changed, 51 insertions(+), 13 deletions(-) diff --git a/ACDC/Core/Inc/hardware.h b/ACDC/Core/Inc/hardware.h index 92ef8bb7..4a1e6aab 100644 --- a/ACDC/Core/Inc/hardware.h +++ b/ACDC/Core/Inc/hardware.h @@ -29,13 +29,13 @@ /* USB audio settings */ #define AUDIO_BITS_PER_SAMPLE 16 #define AUDIO_BYTES_PER_SAMPLE (AUDIO_BITS_PER_SAMPLE/8) -#define AUDIO_CHANNELS 8 +#define AUDIO_CHANNELS 4 /* #define AUDIO_INT32_TO_SAMPLE(x) (__REV16((x)>>8)) */ /* #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(__REV16(x))<<8) */ #define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) -#define USBD_AUDIO_RX_CHANNELS 4 -#define USBD_AUDIO_TX_CHANNELS 4 +/* #define USBD_AUDIO_RX_CHANNELS 4 */ +/* #define USBD_AUDIO_TX_CHANNELS 4 */ #define USE_USBD_AUDIO #define USE_USBD_AUDIO_FEATURES diff --git a/ACDC/Core/Src/main.c b/ACDC/Core/Src/main.c index 0c95520c..d31c0a8a 100644 --- a/ACDC/Core/Src/main.c +++ b/ACDC/Core/Src/main.c @@ -480,7 +480,17 @@ static void MX_SAI1_Init(void) hsai_BlockA1.SlotInit.FirstBitOffset = 0; hsai_BlockA1.SlotInit.SlotSize = SAI_SLOTSIZE_32B; hsai_BlockA1.SlotInit.SlotNumber = 8; - hsai_BlockA1.SlotInit.SlotActive = 0x0000FFFF; +#if AUDIO_CHANNELS == 8 + hsai_BlockA1.SlotInit.SlotActive = SAI_SLOTACTIVE_ALL; +#elif AUDIO_CHANNELS == 6 + hsai_BlockA1.SlotInit.SlotActive = SAI_SLOTACTIVE_6; +#elif AUDIO_CHANNELS == 4 + hsai_BlockA1.SlotInit.SlotActive = SAI_SLOTACTIVE_4; +#elif AUDIO_CHANNELS == 2 + hsai_BlockA1.SlotInit.SlotActive = SAI_SLOTACTIVE_2; +#else +#error "Unsupported AUDIO_CHANNELS" +#endif if (HAL_SAI_Init(&hsai_BlockA1) != HAL_OK) { Error_Handler(); @@ -509,7 +519,17 @@ static void MX_SAI1_Init(void) hsai_BlockB1.SlotInit.FirstBitOffset = 0; hsai_BlockB1.SlotInit.SlotSize = SAI_SLOTSIZE_32B; hsai_BlockB1.SlotInit.SlotNumber = 8; - hsai_BlockB1.SlotInit.SlotActive = 0x0000FFFF; +#if AUDIO_CHANNELS == 8 + hsai_BlockB1.SlotInit.SlotActive = SAI_SLOTACTIVE_ALL; +#elif AUDIO_CHANNELS == 6 + hsai_BlockB1.SlotInit.SlotActive = SAI_SLOTACTIVE_6; +#elif AUDIO_CHANNELS == 4 + hsai_BlockB1.SlotInit.SlotActive = SAI_SLOTACTIVE_4; +#elif AUDIO_CHANNELS == 2 + hsai_BlockB1.SlotInit.SlotActive = SAI_SLOTACTIVE_2; +#else +#error "Unsupported AUDIO_CHANNELS" +#endif if (HAL_SAI_Init(&hsai_BlockB1) != HAL_OK) { Error_Handler(); diff --git a/Source/pcm3168a.c b/Source/pcm3168a.c index c7e1bc36..12cd87f2 100644 --- a/Source/pcm3168a.c +++ b/Source/pcm3168a.c @@ -70,12 +70,23 @@ void codec_init(){ delay(10); codec_write(64, 0b11000001); // Normal operation, Single rate - codec_write(65, 0b00000110); // Power Save Enable, Slave mode, 24-bit I2S mode TDM format - /* codec_write(65, 0b10000110); // Power Save Disable, Slave mode, 24-bit I2S mode TDM format */ /* Register: DAC Control 1 */ - codec_write(65, 0b10000110); // Power Save Disable, Slave mode, 24-bit I2S mode TDM format + codec_write(65, 0b00000110); // Power Save Enable, Slave mode, 24-bit I2S mode TDM format + /* codec_write(65, 0b10000110); // Power Save Disable, Slave mode, 24-bit I2S mode TDM format */ + /* codec_write(65, 0b10000110); // Power Save Disable, Slave mode, 24-bit I2S mode TDM format */ /* codec_write(65, 0b10000111); // 24-bit left-justified mode TDM format */ + + /* Register: DAC Control 2 */ +#if AUDIO_CHANNELS == 4 + codec_write(66, 0b11000000); // disable DAC channels 7/8 and 5/6 +#elif AUDIO_CHANNELS == 6 + codec_write(66, 0b10000000); // disable DAC channels 7/8 +/* These bits control the DAC operation mode. In operation disable mode, the DAC output is cut off from DIN with a fade-out */ +/* sequence, and the internal DAC data is reset. DAC output is forced into VCOMDA if PSMDA = 1, or DAC output is forced */ +/* into AGNDDA and goes into a power-down state if PSMDA = 0. For normal operating mode, a fade-in sequence is */ +/* applied on the DAC output in resume process. The serial mode control is effective during operation disable mode */ +#endif /* Register: DAC Output Phase */ /* codec_write(67, 0xff); // phase invert all DAC channels */ @@ -95,16 +106,23 @@ void codec_init(){ codec_write(81, 0b00000110); // Slave mode 24-bit I2S mode TDM format /* codec_write(81, 0b00000111); // Slave mode 24-bit left-justified mode TDM format */ + uint8_t value; +#if AUDIO_CHANNELS == 4 + value = 0b01000000; // disable ADC channels 5/6 +#else + value = 0b00000000; +#endif #ifndef CODEC_HP_FILTER - /* Register: ADC Control 2 */ - codec_write(82, 0b00000111); // disable HPF for all ADC channels + value |= 0b00000111; // disable HPF for all ADC channels #endif + /* Register: ADC Control 2 */ + codec_write(82, value); /* Register: ADC Input Configuration */ - /* codec_write(83, 0b00111111); // singled ended inputs on all ADC channels */ + codec_write(83, 0b00111111); // singled ended inputs on all ADC channels - /* Register: ADC Input Phase */ - /* codec_write(83, 0b00111111); // phase invert all ADC channels */ + /* Register: ADC Input Phase */ + codec_write(84, 0b00111111); // phase invert all ADC channels /* Register: ADC Overflow Flag */ /* ADC Overflow flag (read-only) */ From e38bdd502bdab2e6ebf0e9bd4613287a9431013c Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 5 Nov 2021 16:15:45 +0100 Subject: [PATCH 173/286] fix SlotActive settings --- ACDC/Core/Src/main.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ACDC/Core/Src/main.c b/ACDC/Core/Src/main.c index d31c0a8a..ce6fe6c4 100644 --- a/ACDC/Core/Src/main.c +++ b/ACDC/Core/Src/main.c @@ -481,13 +481,13 @@ static void MX_SAI1_Init(void) hsai_BlockA1.SlotInit.SlotSize = SAI_SLOTSIZE_32B; hsai_BlockA1.SlotInit.SlotNumber = 8; #if AUDIO_CHANNELS == 8 - hsai_BlockA1.SlotInit.SlotActive = SAI_SLOTACTIVE_ALL; + hsai_BlockA1.SlotInit.SlotActive = 0xff; #elif AUDIO_CHANNELS == 6 - hsai_BlockA1.SlotInit.SlotActive = SAI_SLOTACTIVE_6; + hsai_BlockA1.SlotInit.SlotActive = 0x3f; #elif AUDIO_CHANNELS == 4 - hsai_BlockA1.SlotInit.SlotActive = SAI_SLOTACTIVE_4; + hsai_BlockA1.SlotInit.SlotActive = 0x0f; #elif AUDIO_CHANNELS == 2 - hsai_BlockA1.SlotInit.SlotActive = SAI_SLOTACTIVE_2; + hsai_BlockA1.SlotInit.SlotActive = 0x03; #else #error "Unsupported AUDIO_CHANNELS" #endif @@ -520,13 +520,13 @@ static void MX_SAI1_Init(void) hsai_BlockB1.SlotInit.SlotSize = SAI_SLOTSIZE_32B; hsai_BlockB1.SlotInit.SlotNumber = 8; #if AUDIO_CHANNELS == 8 - hsai_BlockB1.SlotInit.SlotActive = SAI_SLOTACTIVE_ALL; + hsai_BlockB1.SlotInit.SlotActive = 0xff; #elif AUDIO_CHANNELS == 6 - hsai_BlockB1.SlotInit.SlotActive = SAI_SLOTACTIVE_6; + hsai_BlockB1.SlotInit.SlotActive = 0x3f; #elif AUDIO_CHANNELS == 4 - hsai_BlockB1.SlotInit.SlotActive = SAI_SLOTACTIVE_4; + hsai_BlockB1.SlotInit.SlotActive = 0x0f; #elif AUDIO_CHANNELS == 2 - hsai_BlockB1.SlotInit.SlotActive = SAI_SLOTACTIVE_2; + hsai_BlockB1.SlotInit.SlotActive = 0x03; #else #error "Unsupported AUDIO_CHANNELS" #endif From bebdaeee5e95415a88f849b4711db5735b52831c Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 8 Nov 2021 16:31:36 +0100 Subject: [PATCH 174/286] config and led changes --- ACDC/Core/Inc/hardware.h | 10 +++------- ACDC/Core/Src/ACDC.cpp | 6 ++++++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ACDC/Core/Inc/hardware.h b/ACDC/Core/Inc/hardware.h index 4a1e6aab..d49ab7f1 100644 --- a/ACDC/Core/Inc/hardware.h +++ b/ACDC/Core/Inc/hardware.h @@ -30,18 +30,14 @@ #define AUDIO_BITS_PER_SAMPLE 16 #define AUDIO_BYTES_PER_SAMPLE (AUDIO_BITS_PER_SAMPLE/8) #define AUDIO_CHANNELS 4 -/* #define AUDIO_INT32_TO_SAMPLE(x) (__REV16((x)>>8)) */ -/* #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(__REV16(x))<<8) */ #define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) -/* #define USBD_AUDIO_RX_CHANNELS 4 */ -/* #define USBD_AUDIO_TX_CHANNELS 4 */ #define USE_USBD_AUDIO -#define USE_USBD_AUDIO_FEATURES +/* #define USE_USBD_AUDIO_FEATURES */ #define USE_USBD_AUDIO_TX // microphone -/* #define USE_USBD_RX_FB */ -/* #define USE_USBD_AUDIO_RX // speaker */ +#define USE_USBD_AUDIO_RX // speaker +#define USE_USBD_RX_FB #define USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS diff --git a/ACDC/Core/Src/ACDC.cpp b/ACDC/Core/Src/ACDC.cpp index fafe614a..247342e8 100644 --- a/ACDC/Core/Src/ACDC.cpp +++ b/ACDC/Core/Src/ACDC.cpp @@ -51,6 +51,9 @@ void setLed(uint8_t led, uint32_t rgb){ if(rgb == RED_COLOUR){ led_in1.high(); led_clip1.low(); + }else if(rgb == NO_COLOUR){ + led_in1.high(); + led_clip1.high(); }else{ led_in1.low(); led_clip1.high(); @@ -60,6 +63,9 @@ void setLed(uint8_t led, uint32_t rgb){ if(rgb == RED_COLOUR){ led_in2.high(); led_clip2.low(); + }else if(rgb == NO_COLOUR){ + led_in2.high(); + led_clip2.high(); }else{ led_in2.low(); led_clip2.high(); From b62d52fd537ddece9918d7bd26177ca753b35924 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 8 Nov 2021 16:38:50 +0100 Subject: [PATCH 175/286] use ParameterController::getParameters() --- Source/ProgramManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ProgramManager.cpp b/Source/ProgramManager.cpp index 15065297..90d1f928 100644 --- a/Source/ProgramManager.cpp +++ b/Source/ProgramManager.cpp @@ -279,7 +279,7 @@ void onProgramReady(){ midi_rx.receive(); #ifdef USE_ADC #ifdef USE_SCREEN - updateParameters(graphics.params.parameters, NOF_PARAMETERS, adc_values, NOF_ADC_VALUES); + updateParameters(graphics.params->getParameters(), NOF_PARAMETERS, adc_values, NOF_ADC_VALUES); #else updateParameters(parameter_values, NOF_PARAMETERS, adc_values, NOF_ADC_VALUES); #endif From 39c274e00d5097d7a664f0778d36b5d5c63bc38b Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 8 Nov 2021 16:39:11 +0100 Subject: [PATCH 176/286] changed to use Tx SAI callbacks --- Source/Codec.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Codec.cpp b/Source/Codec.cpp index dda01c26..d250dcc9 100644 --- a/Source/Codec.cpp +++ b/Source/Codec.cpp @@ -262,10 +262,10 @@ extern "C"{ #if defined USE_CS4271 || defined USE_PCM3168A extern "C" { - void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai){ + void HAL_SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai){ audioCallback(codec_rxbuf, codec_txbuf, codec_blocksize); } - void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai){ + void HAL_SAI_RxCpltCallback(SAI_HandleTypeDef *hsai){ audioCallback(codec_rxbuf+codec_blocksize*AUDIO_CHANNELS, codec_txbuf+codec_blocksize*AUDIO_CHANNELS, codec_blocksize); } void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai){ From 8c8d786aeaafc907f39e1585ee9df9401a6b4726 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 9 Nov 2021 16:04:39 +0100 Subject: [PATCH 177/286] use previous encoder value as remainder to change by one --- Genius/Inc/GeniusParameterController.hpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Genius/Inc/GeniusParameterController.hpp b/Genius/Inc/GeniusParameterController.hpp index a52234fd..35af4174 100644 --- a/Genius/Inc/GeniusParameterController.hpp +++ b/Genius/Inc/GeniusParameterController.hpp @@ -42,7 +42,7 @@ class Page { // virtual void updateEncoders(int16_t* data, uint8_t size){} virtual void enter(){} virtual void exit(){} - virtual void encoderChanged(uint8_t encoder, int32_t delta){} + virtual void encoderChanged(uint8_t encoder, int32_t delta, int32_t previous){} }; class GeniusParameterController : public ParameterController { @@ -73,16 +73,16 @@ class GeniusParameterController : public ParameterController { } void updateEncoders(int16_t* data, uint8_t size){ if(data[0] != encoders[0]){ - encoderChanged(0, data[0] - encoders[0]); + encoderChanged(0, data[0] - encoders[0], encoders[0]); encoders[0] = data[0]; } if(data[1] != encoders[1]){ - encoderChanged(1, data[1] - encoders[1]); + encoderChanged(1, data[1] - encoders[1], encoders[1]); encoders[1] = data[1]; } } - void encoderChanged(uint8_t encoder, int32_t delta){ - page->encoderChanged(encoder, delta); + void encoderChanged(uint8_t encoder, int32_t delta, int32_t previous){ + page->encoderChanged(encoder, delta, previous); } // update value with encoder void setUserValue(uint8_t ch, int16_t value){ @@ -128,9 +128,9 @@ class SelectControlPage : public Page { void enter(){ counter = 0; } - void encoderChanged(uint8_t encoder, int32_t delta){ + void encoderChanged(uint8_t encoder, int32_t delta, int32_t previous){ if(encoder == ctrl){ - // select = max(0, min(NOF_PARAMETERS-1, select+delta)); + delta = (delta + (previous & 0x03)) / 4; if(delta > 0) select = min(NOF_PARAMETERS-1, select+1); else if(delta < 0) @@ -226,7 +226,7 @@ class ExitPage : public Page { class StatsPage : public Page { public: - void encoderChanged(uint8_t encoder, int32_t delta){} + void encoderChanged(uint8_t encoder, int32_t delta, int32_t previous){} void draw(ScreenBuffer& screen){ if(sw1() || sw2()){ setDisplayMode(EXIT_DISPLAY_MODE); @@ -277,7 +277,8 @@ class AssignPage : public Page { uint8_t assign; static constexpr const char* assignations[] = {"CV A In", "CV B In", "CV A Out", "CV B Out"}; public: - void encoderChanged(uint8_t encoder, int32_t delta){ + void encoderChanged(uint8_t encoder, int32_t delta, int32_t previous){ + delta = (delta + (previous & 0x03)) / 4; if(encoder == 0){ if(delta > 0) select = min(3, select+1); @@ -310,7 +311,7 @@ class AssignPage : public Page { class StandardPage : public Page { public: - void encoderChanged(uint8_t encoder, int32_t delta){ + void encoderChanged(uint8_t encoder, int32_t delta, int32_t previous){ int select = encoder == 0 ? selectOnePage.select : selectTwoPage.select; if(delta > 0) delta = 20 << (delta/2); From 5c59101389a10d8c70256898573757d1e5536c80 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 9 Nov 2021 16:05:23 +0100 Subject: [PATCH 178/286] use tx/rx callback depending on which one is slave --- Source/Codec.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Source/Codec.cpp b/Source/Codec.cpp index d250dcc9..995e8a5e 100644 --- a/Source/Codec.cpp +++ b/Source/Codec.cpp @@ -262,12 +262,21 @@ extern "C"{ #if defined USE_CS4271 || defined USE_PCM3168A extern "C" { +#ifdef USE_CS4271 void HAL_SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai){ audioCallback(codec_rxbuf, codec_txbuf, codec_blocksize); } void HAL_SAI_RxCpltCallback(SAI_HandleTypeDef *hsai){ audioCallback(codec_rxbuf+codec_blocksize*AUDIO_CHANNELS, codec_txbuf+codec_blocksize*AUDIO_CHANNELS, codec_blocksize); } +#else // PCM3168A: TX is slave + void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai){ + audioCallback(codec_rxbuf, codec_txbuf, codec_blocksize); + } + void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai){ + audioCallback(codec_rxbuf+codec_blocksize*AUDIO_CHANNELS, codec_txbuf+codec_blocksize*AUDIO_CHANNELS, codec_blocksize); + } +#endif void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai){ error(CONFIG_ERROR, "SAI DMA Error"); } From 070d4ff32fab77e0a34e9c0de222c25bb8ed4aaa Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 9 Nov 2021 16:05:56 +0100 Subject: [PATCH 179/286] updated attenuation settings --- Source/pcm3168a.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/pcm3168a.c b/Source/pcm3168a.c index 12cd87f2..ed1fde3a 100644 --- a/Source/pcm3168a.c +++ b/Source/pcm3168a.c @@ -98,6 +98,7 @@ void codec_init(){ /* Each DAC channel (VOUTx) has a digital attenuator function. The attenuation level can be set from 0 dB to –100 dB in */ /* 0.5-dB steps, and also can be set to infinite attenuation (mute). The attenuation level change from current value to target */ /* value is performed by incrementing or decrementing with s-curve responses and a time set by ATSPDA. */ + codec_write(70, 0b1000000); // ATMDDA=1 All channels with preset (independent) data + master (common) data in decibel number /* Data formats, see Table 11 p.33 */ @@ -134,6 +135,7 @@ void codec_init(){ /* Each ADC channel has a digital attenuator function with 20-dB gain. The attenuation level can be set from 20 dB to –100 */ /* dB in 0.5-dB steps, and also can be set to infinite attenuation (mute). The attenuation level change from current value to */ /* target value is performed by increment or decrement with s-curve response and time set by ATSPAD. */ + codec_write(87, 0b1000000); // ATMDAD=1 All channels with preset (independent) data + master (common) data in decibel number /* codec_reset(); */ @@ -157,7 +159,7 @@ void codec_mute(bool mute){ void codec_set_gain_in(int8_t level){ /* Register 88: ADC Digital attenuation level setting */ uint8_t value = level+128; - codec_write(88, value); // + codec_write(88, value); // set master attenuation level ATAD0[7:0] } /** @@ -166,6 +168,6 @@ void codec_set_gain_in(int8_t level){ void codec_set_gain_out(int8_t level){ /* Register 71: DAC Digital attenuation level setting */ uint8_t value = level+128; - codec_write(71, value); // + codec_write(71, value); // set master attenuation level ATDA0[7:0] } From 667b95cff0efd4dd8ae73e439eef46ef132eb6da Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 9 Nov 2021 16:06:30 +0100 Subject: [PATCH 180/286] set correct descriptor length --- Source/usbd_audio.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/usbd_audio.cpp b/Source/usbd_audio.cpp index 03a10dba..ed656da7 100644 --- a/Source/usbd_audio.cpp +++ b/Source/usbd_audio.cpp @@ -318,7 +318,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL #ifdef USE_USBD_AUDIO_FEATURES /* Feature Unit Descriptor*/ - 0x0a, // bLength + USBD_AUDIO_RX_AF_DESC_LEN, // bLength 0x24, // bDescriptorType 0x06, // bDescriptorSubtype 0x02, // bUnitID @@ -383,7 +383,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL #ifdef USE_USBD_AUDIO_FEATURES /* Feature Unit Descriptor*/ - 0x0a, // bLength + USBD_AUDIO_TX_AF_DESC_LEN, // bLength 0x24, // bDescriptorType 0x06, // bDescriptorSubtype 0x05, // bUnitID From 288e18858ed1840d5a7651ce7edb32c1317f4e78 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 15 Nov 2021 18:10:35 +0100 Subject: [PATCH 181/286] split out TakeoverControls --- Source/TakeoverControls.h | 40 +++++++++++++++++++++++++++++++++++++++ Witch/Src/Witch.cpp | 40 +-------------------------------------- 2 files changed, 41 insertions(+), 39 deletions(-) create mode 100644 Source/TakeoverControls.h diff --git a/Source/TakeoverControls.h b/Source/TakeoverControls.h new file mode 100644 index 00000000..810dc4b9 --- /dev/null +++ b/Source/TakeoverControls.h @@ -0,0 +1,40 @@ +#include + +template +class TakeoverControls { +private: + value_t values[SIZE]; + bool takeover[SIZE]; +public: + TakeoverControls(){ + reset(true); + } + value_t get(uint8_t index){ + return values[index]; + } + void set(uint8_t index, value_t value){ + values[index] = value; + } + void update(uint8_t index, value_t value, value_t threshold){ + if(takeover[index]){ + values[index] = value; + }else if(abs(values[index] - value) < threshold){ + takeover[index] = true; + values[index] = value; + } + } + bool taken(uint8_t index){ + return takeover[index]; + } + /** + * If @param state is true, then the control is taken. + * If the control is taken it reflects the current knob setting. + */ + void reset(uint8_t index, bool state){ + takeover[index] = state; + } + void reset(bool state){ + for(size_t i=0; i -class TakeoverControls { -private: - value_t values[SIZE]; - bool takeover[SIZE]; -public: - TakeoverControls(){ - reset(true); - } - value_t get(uint8_t index){ - return values[index]; - } - void set(uint8_t index, value_t value){ - values[index] = value; - } - void update(uint8_t index, value_t value, value_t threshold){ - if(takeover[index]){ - values[index] = value; - }else if(abs(values[index] - value) < threshold){ - takeover[index] = true; - values[index] = value; - } - } - bool taken(uint8_t index){ - return takeover[index]; - } - /** - * If @param state is true, then the control is taken. - * If the control is taken it reflects the current knob setting. - */ - void reset(uint8_t index, bool state){ - takeover[index] = state; - } - void reset(bool state){ - for(size_t i=0; i takeover; int16_t dac_values[2] = {0, 0}; bool button_led_values[4] = {false}; From 0b1eb3e6d35623cf1140f530d6da2582b0204f86 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 15 Nov 2021 20:17:24 +0100 Subject: [PATCH 182/286] configuration mode wip --- OwlPedal2/Inc/hardware.h | 26 ++++----- OwlPedal2/Inc/main.h | 2 + OwlPedal2/Inc/usbd_conf.h | 1 + OwlPedal2/OwlPedal2.ioc | 107 +++++++++++++++++++------------------ OwlPedal2/Src/OwlPedal.cpp | 97 +++++++++++++++++++++++++++------ OwlPedal2/Src/main.c | 26 +++++---- 6 files changed, 164 insertions(+), 95 deletions(-) diff --git a/OwlPedal2/Inc/hardware.h b/OwlPedal2/Inc/hardware.h index c0efeb7c..88516bce 100644 --- a/OwlPedal2/Inc/hardware.h +++ b/OwlPedal2/Inc/hardware.h @@ -1,23 +1,23 @@ #include "main.h" #include "stm32f4xx_hal.h" -#define DEBUG_STACK - #define OWL_PEDAL_MKII #define HARDWARE_ID OWL_PEDAL_HARDWARE #define HARDWARE_VERSION "OWL Pedal mkII" -#define USE_USBD_FS -#define USBD_DESC FS_Desc -#define USBD_HSFS DEVICE_FS -#define USBD_HANDLE hUsbDeviceFS -#define USBD_PCD_HANDLE hpcd_USB_OTG_FS - -/* #define USE_USBD_HS */ -/* #define USBD_DESC HS_Desc */ -/* #define USBD_HSFS DEVICE_HS */ -/* #define USBD_HANDLE hUsbDeviceHS */ -/* #define USBD_PCD_HANDLE hpcd_USB_OTG_HS */ +#define USE_SPI_FLASH + +/* #define USE_USBD_FS */ +/* #define USBD_DESC FS_Desc */ +/* #define USBD_HSFS DEVICE_FS */ +/* #define USBD_HANDLE hUsbDeviceFS */ +/* #define USBD_PCD_HANDLE hpcd_USB_OTG_FS */ + +#define USE_USBD_HS +#define USBD_DESC HS_Desc +#define USBD_HSFS DEVICE_HS +#define USBD_HANDLE hUsbDeviceHS +#define USBD_PCD_HANDLE hpcd_USB_OTG_HS #define USE_USBD_AUDIO #define USE_USBD_RX_FB diff --git a/OwlPedal2/Inc/main.h b/OwlPedal2/Inc/main.h index f1bd2d37..0b20e4af 100644 --- a/OwlPedal2/Inc/main.h +++ b/OwlPedal2/Inc/main.h @@ -127,6 +127,8 @@ void Error_Handler(void); #define FLASH_HOLD_GPIO_Port GPIOC #define FLASH_nCS_Pin GPIO_PIN_5 #define FLASH_nCS_GPIO_Port GPIOC +#define FLASH_WP_Pin GPIO_PIN_0 +#define FLASH_WP_GPIO_Port GPIOB #define EXP_RING_Pin GPIO_PIN_1 #define EXP_RING_GPIO_Port GPIOB #define EXP_TIP_Pin GPIO_PIN_2 diff --git a/OwlPedal2/Inc/usbd_conf.h b/OwlPedal2/Inc/usbd_conf.h index 387bb83f..ddc83566 100644 --- a/OwlPedal2/Inc/usbd_conf.h +++ b/OwlPedal2/Inc/usbd_conf.h @@ -36,6 +36,7 @@ #include "stm32f4xx_hal.h" /* USER CODE BEGIN INCLUDE */ +#include "device.h" #ifdef DEBUG #define DEBUG_LEVEL 3 #else diff --git a/OwlPedal2/OwlPedal2.ioc b/OwlPedal2/OwlPedal2.ioc index c8ba298b..68fda8c9 100644 --- a/OwlPedal2/OwlPedal2.ioc +++ b/OwlPedal2/OwlPedal2.ioc @@ -143,64 +143,65 @@ Mcu.Pin23=PA6 Mcu.Pin24=PA7 Mcu.Pin25=PC4 Mcu.Pin26=PC5 -Mcu.Pin27=PB1 -Mcu.Pin28=PB2/BOOT1 -Mcu.Pin29=PF11 +Mcu.Pin27=PB0 +Mcu.Pin28=PB1 +Mcu.Pin29=PB2/BOOT1 Mcu.Pin3=PE5 -Mcu.Pin30=PF12 -Mcu.Pin31=PF13 -Mcu.Pin32=PF14 -Mcu.Pin33=PF15 -Mcu.Pin34=PG0 -Mcu.Pin35=PG1 -Mcu.Pin36=PE7 -Mcu.Pin37=PE8 -Mcu.Pin38=PE9 -Mcu.Pin39=PE10 +Mcu.Pin30=PF11 +Mcu.Pin31=PF12 +Mcu.Pin32=PF13 +Mcu.Pin33=PF14 +Mcu.Pin34=PF15 +Mcu.Pin35=PG0 +Mcu.Pin36=PG1 +Mcu.Pin37=PE7 +Mcu.Pin38=PE8 +Mcu.Pin39=PE9 Mcu.Pin4=PE6 -Mcu.Pin40=PE11 -Mcu.Pin41=PE12 -Mcu.Pin42=PE13 -Mcu.Pin43=PE14 -Mcu.Pin44=PE15 -Mcu.Pin45=PB10 -Mcu.Pin46=PB11 -Mcu.Pin47=PB13 -Mcu.Pin48=PB14 -Mcu.Pin49=PB15 +Mcu.Pin40=PE10 +Mcu.Pin41=PE11 +Mcu.Pin42=PE12 +Mcu.Pin43=PE13 +Mcu.Pin44=PE14 +Mcu.Pin45=PE15 +Mcu.Pin46=PB10 +Mcu.Pin47=PB11 +Mcu.Pin48=PB13 +Mcu.Pin49=PB14 Mcu.Pin5=PC15/OSC32_OUT -Mcu.Pin50=PD8 -Mcu.Pin51=PD9 -Mcu.Pin52=PD10 -Mcu.Pin53=PD14 -Mcu.Pin54=PD15 -Mcu.Pin55=PG4 -Mcu.Pin56=PG5 -Mcu.Pin57=PG8 -Mcu.Pin58=PA9 -Mcu.Pin59=PA11 +Mcu.Pin50=PB15 +Mcu.Pin51=PD8 +Mcu.Pin52=PD9 +Mcu.Pin53=PD10 +Mcu.Pin54=PD14 +Mcu.Pin55=PD15 +Mcu.Pin56=PG4 +Mcu.Pin57=PG5 +Mcu.Pin58=PG8 +Mcu.Pin59=PA9 Mcu.Pin6=PF0 -Mcu.Pin60=PA12 -Mcu.Pin61=PA13 -Mcu.Pin62=PA14 -Mcu.Pin63=PD0 -Mcu.Pin64=PD1 -Mcu.Pin65=PD2 -Mcu.Pin66=PD6 -Mcu.Pin67=PG9 -Mcu.Pin68=PG15 -Mcu.Pin69=PB3 +Mcu.Pin60=PA11 +Mcu.Pin61=PA12 +Mcu.Pin62=PA13 +Mcu.Pin63=PA14 +Mcu.Pin64=PD0 +Mcu.Pin65=PD1 +Mcu.Pin66=PD2 +Mcu.Pin67=PD6 +Mcu.Pin68=PG9 +Mcu.Pin69=PG15 Mcu.Pin7=PF1 -Mcu.Pin70=PB5 -Mcu.Pin71=PB6 -Mcu.Pin72=PE0 -Mcu.Pin73=PE1 -Mcu.Pin74=VP_FREERTOS_VS_CMSIS_V1 -Mcu.Pin75=VP_RTC_VS_RTC_Activate -Mcu.Pin76=VP_SYS_VS_Systick +Mcu.Pin70=PB3 +Mcu.Pin71=PB5 +Mcu.Pin72=PB6 +Mcu.Pin73=PE0 +Mcu.Pin74=PE1 +Mcu.Pin75=VP_FREERTOS_VS_CMSIS_V1 +Mcu.Pin76=VP_RTC_VS_RTC_Activate +Mcu.Pin77=VP_SYS_VS_Systick Mcu.Pin8=PF2 Mcu.Pin9=PF3 -Mcu.PinsNb=77 +Mcu.PinsNb=78 Mcu.ThirdPartyNb=0 Mcu.UserConstants= Mcu.UserName=STM32F427ZITx @@ -263,6 +264,10 @@ PA9.GPIOParameters=GPIO_Label PA9.GPIO_Label=USBD_VBUS PA9.Mode=Activate_VBUS PA9.Signal=USB_OTG_FS_VBUS +PB0.GPIOParameters=GPIO_Label +PB0.GPIO_Label=FLASH_WP +PB0.Locked=true +PB0.Signal=GPIO_Output PB1.GPIOParameters=GPIO_Label PB1.GPIO_Label=EXP_RING PB1.Locked=true diff --git a/OwlPedal2/Src/OwlPedal.cpp b/OwlPedal2/Src/OwlPedal.cpp index a21cd726..0d6e99cd 100644 --- a/OwlPedal2/Src/OwlPedal.cpp +++ b/OwlPedal2/Src/OwlPedal.cpp @@ -1,12 +1,22 @@ #include "Owl.h" -#include "device.h" #include "errorhandlers.h" +#include "Codec.h" #include "MidiController.h" +#include "ProgramManager.h" +#include "ApplicationSettings.h" #include "OpenWareMidiControl.h" +#include "PatchRegistry.h" #include "Pin.h" #include "usb_device.h" #define PATCH_RESET_COUNTER (1000/MAIN_LOOP_SLEEP_MS) +#define PATCH_CONFIG_COUNTER (3000/MAIN_LOOP_SLEEP_MS) + +static int16_t knobvalues[2]; +static uint8_t patchselect; +#define PATCH_CONFIG_KNOB_THRESHOLD (4096/4) +#define PATCH_CONFIG_PROGRAM_CONTROL 0 +#define PATCH_CONFIG_VOLUME_CONTROL 3 // Pin footswitch_pin(GPIOA, GPIO_PIN_0); Pin bypass_pin(GPIOA, GPIO_PIN_0); @@ -58,12 +68,12 @@ void onChangePin(uint16_t pin){ bool state = HAL_GPIO_ReadPin(SW1_GPIO_Port, SW1_Pin) == GPIO_PIN_RESET; setButtonValue(PUSHBUTTON, state); setButtonValue(BUTTON_A, state); - // midi_tx.sendCc(PATCH_BUTTON, state ? 127 : 0); - // setLed(0, state ? RED_COLOUR : GREEN_COLOUR); - if(state){ - // toggle buffered bypass - setBufferedBypass(!getBufferedBypass()); - } + setLed(0, state ? RED_COLOUR : GREEN_COLOUR); + midi_tx.sendCc(PATCH_BUTTON, state ? 127 : 0); + // if(state){ + // // toggle buffered bypass + // setBufferedBypass(!getBufferedBypass()); + // } break; } case SW2_Pin: { // mode button @@ -104,7 +114,7 @@ void setGateValue(uint8_t ch, int16_t value){ } } -void setup(){ +void onSetup(){ bypass_pin.outputMode(); bypass_pin.low(); bufpass_pin.outputMode(); @@ -116,34 +126,87 @@ void setup(){ led_red_pin.outputMode(); setLed(0, RED_COLOUR); - owl.setup(); MX_USB_DEVICE_Init(); setBufferedBypass(false); } -void loop(){ - static uint32_t counter = PATCH_RESET_COUNTER; +bool isPushbuttonPressed(){ + return HAL_GPIO_ReadPin(SW1_GPIO_Port, SW1_Pin) == GPIO_PIN_RESET; +} + +static uint32_t counter = 0; +void onChangeMode(OperationMode new_mode, OperationMode old_mode){ + counter = 0; + if(new_mode == CONFIGURE_MODE){ + knobvalues[0] = getAnalogValue(PATCH_CONFIG_PROGRAM_CONTROL); + knobvalues[1] = getAnalogValue(PATCH_CONFIG_VOLUME_CONTROL); + patchselect = program.getProgramIndex(); + // }else if(old_mode == CONFIGURE_MODE && new_mode == RUN_MODE){ + }else if(new_mode == RUN_MODE){ + setLed(0, getButtonValue(0) ? NO_COLOUR : GREEN_COLOUR); // set green led if not in bypass mode + } +} + + +void onLoop(){ switch(owl.getOperationMode()){ case STARTUP_MODE: case LOAD_MODE: + case STREAM_MODE: setLed(0, counter > PATCH_RESET_COUNTER/2 ? GREEN_COLOUR : NO_COLOUR); + if(counter-- == 0) + counter = PATCH_RESET_COUNTER; break; case RUN_MODE: if(getErrorStatus() != NO_ERROR) owl.setOperationMode(ERROR_MODE); + if(isPushbuttonPressed()){ + if(counter-- == 0){ + owl.setOperationMode(CONFIGURE_MODE); + }else if(counter < PATCH_RESET_COUNTER){ + setLed(0, counter > PATCH_RESET_COUNTER/2 ? GREEN_COLOUR : NO_COLOUR); + } + }else{ + counter = PATCH_CONFIG_COUNTER; + } break; case CONFIGURE_MODE: - owl.setOperationMode(RUN_MODE); + if(isPushbuttonPressed()){ + if(abs(knobvalues[0] - getAnalogValue(PATCH_CONFIG_PROGRAM_CONTROL)) >= PATCH_CONFIG_KNOB_THRESHOLD){ + knobvalues[0] = -PATCH_CONFIG_KNOB_THRESHOLD; + uint8_t idx = 1 + (getAnalogValue(PATCH_CONFIG_PROGRAM_CONTROL) * registry.getNumberOfPatches()) / 4096; + if(registry.hasPatch(idx)){ + patchselect = idx; + midi_tx.sendPc(idx); + setLed(0, idx & 0x01 ? RED_COLOUR : GREEN_COLOUR); + } + } + if(abs(knobvalues[1] - getAnalogValue(PATCH_CONFIG_VOLUME_CONTROL)) >= PATCH_CONFIG_KNOB_THRESHOLD){ + knobvalues[1] = -PATCH_CONFIG_KNOB_THRESHOLD; + uint8_t value = (getAnalogValue(PATCH_CONFIG_VOLUME_CONTROL) >> 6) + 63; + if(settings.audio_output_gain != value){ + settings.audio_output_gain = value; + codec.setOutputGain(value); + midi_tx.sendCc(MIDI_CC_VOLUME, value); + } + } + }else{ + if(program.getProgramIndex() != patchselect && + registry.hasPatch(patchselect)){ + // change patch on mode button release + program.loadProgram(patchselect); // enters load mode (calls onChangeMode) + program.resetProgram(false); + }else{ + owl.setOperationMode(RUN_MODE); + } + } break; - case STREAM_MODE: case ERROR_MODE: setLed(0, counter > PATCH_RESET_COUNTER/2 ? RED_COLOUR : NO_COLOUR); + if(counter-- == 0) + counter = PATCH_RESET_COUNTER; break; } - if(--counter == 0) - counter = PATCH_RESET_COUNTER; - - owl.loop(); } diff --git a/OwlPedal2/Src/main.c b/OwlPedal2/Src/main.c index 829f3037..706352b7 100644 --- a/OwlPedal2/Src/main.c +++ b/OwlPedal2/Src/main.c @@ -54,6 +54,8 @@ /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ +#include "errorhandlers.h" + /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -786,7 +788,7 @@ static void MX_GPIO_Init(void) HAL_GPIO_WritePin(GPIOC, EXTSPI_nCS_Pin|FLASH_HOLD_Pin|FLASH_nCS_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOB, EXP_TIP_Pin|CS_nCS_Pin|CS_nRST_Pin, GPIO_PIN_RESET); + HAL_GPIO_WritePin(GPIOB, FLASH_WP_Pin|EXP_TIP_Pin|CS_nCS_Pin|CS_nRST_Pin, GPIO_PIN_RESET); /*Configure GPIO pins : PC13 PC14 PC6 PC7 PC8 PC9 PC10 PC11 @@ -831,19 +833,19 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(FOOTSWITCH_GPIO_Port, &GPIO_InitStruct); - /*Configure GPIO pins : PB0 PB12 PB4 PB7 - PB8 PB9 */ - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_12|GPIO_PIN_4|GPIO_PIN_7 - |GPIO_PIN_8|GPIO_PIN_9; - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + /*Configure GPIO pins : FLASH_WP_Pin EXP_TIP_Pin CS_nCS_Pin CS_nRST_Pin */ + GPIO_InitStruct.Pin = FLASH_WP_Pin|EXP_TIP_Pin|CS_nCS_Pin|CS_nRST_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - /*Configure GPIO pins : EXP_TIP_Pin CS_nCS_Pin CS_nRST_Pin */ - GPIO_InitStruct.Pin = EXP_TIP_Pin|CS_nCS_Pin|CS_nRST_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + /*Configure GPIO pins : PB12 PB4 PB7 PB8 + PB9 */ + GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_4|GPIO_PIN_7|GPIO_PIN_8 + |GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /*Configure GPIO pins : PD11 PD12 PD13 PD3 @@ -908,7 +910,6 @@ void StartDefaultTask(void const * argument) for(;;) { loop(); - /* osDelay(1); */ } /* USER CODE END 5 */ } @@ -920,7 +921,6 @@ void StartDefaultTask(void const * argument) void Error_Handler(void) { /* USER CODE BEGIN Error_Handler_Debug */ - /* User can add his own implementation to report the HAL error return state */ #ifdef DEBUG __asm__("BKPT"); #else @@ -940,8 +940,6 @@ void Error_Handler(void) void assert_failed(uint8_t *file, uint32_t line) { /* USER CODE BEGIN 6 */ - /* User can add his own implementation to report the file name and line number, - ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ #ifdef DEBUG __asm__("BKPT"); #else From 9e2f415ce635ca6eb7ff26b077df554f2e97ba5f Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 18 Nov 2021 13:48:03 +0100 Subject: [PATCH 183/286] added OWL2 Pedal configuration --- MidiBoot/Inc/hardware.h | 12 ++++++++++++ MidiBoot/Makefile | 3 +++ 2 files changed, 15 insertions(+) diff --git a/MidiBoot/Inc/hardware.h b/MidiBoot/Inc/hardware.h index e463d92b..48d1fc76 100644 --- a/MidiBoot/Inc/hardware.h +++ b/MidiBoot/Inc/hardware.h @@ -63,6 +63,18 @@ #define LED2_Pin GPIO_PIN_1 #define LED2_GPIO_Port GPIOA #define APPLICATION_ADDRESS 0x08010000 +#elif defined OWL_PEDAL + #define HARDWARE_VERSION "OWL Pedal Boot" + #define HARDWARE_ID OWL_PEDAL_HARDWARE + #define USE_BOOT1_PIN + #define BOOT1_Pin GPIO_PIN_10 // only valid for green/Rev04 + #define BOOT1_GPIO_Port GPIOG + #define USE_LED + #define LED1_Pin GPIO_PIN_8 + #define LED1_GPIO_Port GPIOB + #define LED2_Pin GPIO_PIN_9 + #define LED2_GPIO_Port GPIOB + #define APPLICATION_ADDRESS 0x08010000 #elif defined OWL_NOCTUA #define HARDWARE_VERSION "OWL Noctua Boot" #define HARDWARE_ID NOCTUA_HARDWARE diff --git a/MidiBoot/Makefile b/MidiBoot/Makefile index 7c02a97b..e3bf4d02 100644 --- a/MidiBoot/Makefile +++ b/MidiBoot/Makefile @@ -43,6 +43,9 @@ else ifeq ($(PLATFORM),Alchemist) else ifeq ($(PLATFORM),Wizard) CPPFLAGS += -Iusbd-hs -DOWL_WIZARD -DUSE_USBD_HS vpath %.c usbd-hs +else ifeq ($(PLATFORM),Pedal) + CPPFLAGS += -Iusbd-hs -DOWL_PEDAL -DUSE_USBD_HS + vpath %.c usbd-hs else ifeq ($(PLATFORM),EuroWizard) CPPFLAGS += -Iusbd-fs -DOWL_WIZARD -DUSE_USBD_FS vpath %.c usbd-fs From a61bcc36ed3460e903238a7eaaecbec30407f5d1 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 18 Nov 2021 13:48:35 +0100 Subject: [PATCH 184/286] configure ADC_E (and usb audio rx) --- OwlPedal/Inc/hardware.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OwlPedal/Inc/hardware.h b/OwlPedal/Inc/hardware.h index e52fb889..bd0750bc 100644 --- a/OwlPedal/Inc/hardware.h +++ b/OwlPedal/Inc/hardware.h @@ -26,7 +26,7 @@ #define USE_USBD_FS #define USE_USBD_AUDIO #define USE_USBD_AUDIO_TX // microphone -/* #define USE_USBD_AUDIO_RX // speaker */ +#define USE_USBD_AUDIO_RX // speaker #define USBD_HANDLE hUsbDeviceFS #define AUDIO_BITS_PER_SAMPLE 16 #define AUDIO_BYTES_PER_SAMPLE (AUDIO_BITS_PER_SAMPLE/8) @@ -44,6 +44,7 @@ #define ADC_B 1 #define ADC_C 2 #define ADC_D 3 +#define ADC_E 4 #endif #define NOF_PARAMETERS 40 From 48c586c943f85026e657eabaf8065fa652fbe96b Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 18 Nov 2021 13:49:14 +0100 Subject: [PATCH 185/286] use alternative pushbutton pin --- OwlPedal2/Inc/hardware.h | 4 ++-- OwlPedal2/Inc/main.h | 3 +++ OwlPedal2/Inc/stm32f4xx_it.h | 1 + OwlPedal2/OwlPedal2.ioc | 32 ++++++++++++++++++++----------- OwlPedal2/Src/OwlPedal.cpp | 27 +++++++++++++++++--------- OwlPedal2/Src/main.c | 15 ++++++++------- OwlPedal2/Src/stm32f4xx_hal_msp.c | 4 ++-- OwlPedal2/Src/stm32f4xx_it.c | 14 ++++++++++++++ 8 files changed, 69 insertions(+), 31 deletions(-) diff --git a/OwlPedal2/Inc/hardware.h b/OwlPedal2/Inc/hardware.h index 88516bce..0b6ff646 100644 --- a/OwlPedal2/Inc/hardware.h +++ b/OwlPedal2/Inc/hardware.h @@ -5,7 +5,7 @@ #define HARDWARE_ID OWL_PEDAL_HARDWARE #define HARDWARE_VERSION "OWL Pedal mkII" -#define USE_SPI_FLASH +/* #define USE_SPI_FLASH */ /* #define USE_USBD_FS */ /* #define USBD_DESC FS_Desc */ @@ -52,7 +52,7 @@ #define ADC_E 4 #define USE_CODEC #define USE_CS4271 -/* #define CODEC_HP_FILTER */ +#define CODEC_HP_FILTER #define CODEC_SPI hspi4 #define NOF_ADC_VALUES 5 diff --git a/OwlPedal2/Inc/main.h b/OwlPedal2/Inc/main.h index 0b20e4af..b68c305b 100644 --- a/OwlPedal2/Inc/main.h +++ b/OwlPedal2/Inc/main.h @@ -151,6 +151,9 @@ void Error_Handler(void); #define SW2_Pin GPIO_PIN_9 #define SW2_GPIO_Port GPIOG #define SW2_EXTI_IRQn EXTI9_5_IRQn +#define SW1_ALT_Pin GPIO_PIN_10 +#define SW1_ALT_GPIO_Port GPIOG +#define SW1_ALT_EXTI_IRQn EXTI15_10_IRQn #define FLASH_SCK_Pin GPIO_PIN_3 #define FLASH_SCK_GPIO_Port GPIOB /* USER CODE BEGIN Private defines */ diff --git a/OwlPedal2/Inc/stm32f4xx_it.h b/OwlPedal2/Inc/stm32f4xx_it.h index cc7e46bd..1c8b5a32 100644 --- a/OwlPedal2/Inc/stm32f4xx_it.h +++ b/OwlPedal2/Inc/stm32f4xx_it.h @@ -67,6 +67,7 @@ void EXTI1_IRQHandler(void); void EXTI2_IRQHandler(void); void ADC_IRQHandler(void); void EXTI9_5_IRQHandler(void); +void EXTI15_10_IRQHandler(void); void DMA2_Stream1_IRQHandler(void); void DMA2_Stream3_IRQHandler(void); void DMA2_Stream4_IRQHandler(void); diff --git a/OwlPedal2/OwlPedal2.ioc b/OwlPedal2/OwlPedal2.ioc index 68fda8c9..89f44f71 100644 --- a/OwlPedal2/OwlPedal2.ioc +++ b/OwlPedal2/OwlPedal2.ioc @@ -189,30 +189,32 @@ Mcu.Pin65=PD1 Mcu.Pin66=PD2 Mcu.Pin67=PD6 Mcu.Pin68=PG9 -Mcu.Pin69=PG15 +Mcu.Pin69=PG10 Mcu.Pin7=PF1 -Mcu.Pin70=PB3 -Mcu.Pin71=PB5 -Mcu.Pin72=PB6 -Mcu.Pin73=PE0 -Mcu.Pin74=PE1 -Mcu.Pin75=VP_FREERTOS_VS_CMSIS_V1 -Mcu.Pin76=VP_RTC_VS_RTC_Activate -Mcu.Pin77=VP_SYS_VS_Systick +Mcu.Pin70=PG15 +Mcu.Pin71=PB3 +Mcu.Pin72=PB5 +Mcu.Pin73=PB6 +Mcu.Pin74=PE0 +Mcu.Pin75=PE1 +Mcu.Pin76=VP_FREERTOS_VS_CMSIS_V1 +Mcu.Pin77=VP_RTC_VS_RTC_Activate +Mcu.Pin78=VP_SYS_VS_Systick Mcu.Pin8=PF2 Mcu.Pin9=PF3 -Mcu.PinsNb=78 +Mcu.PinsNb=79 Mcu.ThirdPartyNb=0 Mcu.UserConstants= Mcu.UserName=STM32F427ZITx MxCube.Version=6.3.0 MxDb.Version=DB.6.0.30 -NVIC.ADC_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.ADC_IRQn=true\:10\:0\:true\:false\:true\:true\:true\:true NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false NVIC.DMA2_Stream1_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true NVIC.DMA2_Stream3_IRQn=true\:5\:0\:false\:false\:true\:false\:false\:true NVIC.DMA2_Stream4_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.EXTI15_10_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true NVIC.EXTI1_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true NVIC.EXTI2_IRQn=true\:15\:0\:true\:false\:true\:false\:true\:true NVIC.EXTI9_5_IRQn=true\:15\:0\:true\:false\:true\:false\:true\:true @@ -402,6 +404,12 @@ PF8.Locked=true PF8.Signal=GPXTI8 PG0.Signal=FMC_A10 PG1.Signal=FMC_A11 +PG10.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PG10.GPIO_Label=SW1_ALT +PG10.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PG10.GPIO_PuPd=GPIO_PULLUP +PG10.Locked=true +PG10.Signal=GPXTI10 PG15.Signal=FMC_SDNCAS PG4.Signal=FMC_A14_BA0 PG5.Signal=FMC_A15_BA1 @@ -620,6 +628,8 @@ SH.FMC_SDNWE.0=FMC_SDNWE,12b-sda1 SH.FMC_SDNWE.ConfNb=1 SH.GPXTI1.0=GPIO_EXTI1 SH.GPXTI1.ConfNb=1 +SH.GPXTI10.0=GPIO_EXTI10 +SH.GPXTI10.ConfNb=1 SH.GPXTI2.0=GPIO_EXTI2 SH.GPXTI2.ConfNb=1 SH.GPXTI7.0=GPIO_EXTI7 diff --git a/OwlPedal2/Src/OwlPedal.cpp b/OwlPedal2/Src/OwlPedal.cpp index 0d6e99cd..36673b22 100644 --- a/OwlPedal2/Src/OwlPedal.cpp +++ b/OwlPedal2/Src/OwlPedal.cpp @@ -56,16 +56,25 @@ void setBufferedBypass(bool value){ bufpass_pin.set(!value); } +bool isPushbuttonPressed(){ + return HAL_GPIO_ReadPin(SW1_GPIO_Port, SW1_Pin) == GPIO_PIN_RESET || + HAL_GPIO_ReadPin(SW1_ALT_GPIO_Port, SW1_ALT_Pin) == GPIO_PIN_RESET; +} + void onChangePin(uint16_t pin){ switch(pin){ - case FOOTSWITCH_Pin: { // stomp switch + case FOOTSWITCH_Pin: { // bypass / stomp switch bool state = HAL_GPIO_ReadPin(FOOTSWITCH_GPIO_Port, FOOTSWITCH_Pin) == GPIO_PIN_RESET; setButtonValue(0, state); setLed(0, state ? NO_COLOUR : GREEN_COLOUR); + + // todo: save LED state + // todo: only allow config mode in bypass? break; } - case SW1_Pin: { // pushbutton - bool state = HAL_GPIO_ReadPin(SW1_GPIO_Port, SW1_Pin) == GPIO_PIN_RESET; + case SW1_Pin: + case SW1_ALT_Pin: { // pushbutton + bool state = isPushbuttonPressed(); setButtonValue(PUSHBUTTON, state); setButtonValue(BUTTON_A, state); setLed(0, state ? RED_COLOUR : GREEN_COLOUR); @@ -132,10 +141,6 @@ void onSetup(){ setBufferedBypass(false); } -bool isPushbuttonPressed(){ - return HAL_GPIO_ReadPin(SW1_GPIO_Port, SW1_Pin) == GPIO_PIN_RESET; -} - static uint32_t counter = 0; void onChangeMode(OperationMode new_mode, OperationMode old_mode){ counter = 0; @@ -153,12 +158,16 @@ void onChangeMode(OperationMode new_mode, OperationMode old_mode){ void onLoop(){ switch(owl.getOperationMode()){ case STARTUP_MODE: - case LOAD_MODE: case STREAM_MODE: setLed(0, counter > PATCH_RESET_COUNTER/2 ? GREEN_COLOUR : NO_COLOUR); if(counter-- == 0) counter = PATCH_RESET_COUNTER; break; + case LOAD_MODE: + setLed(0, counter > PATCH_RESET_COUNTER/10 ? GREEN_COLOUR : NO_COLOUR); + if(counter-- == 0) + counter = PATCH_RESET_COUNTER; + break; case RUN_MODE: if(getErrorStatus() != NO_ERROR) owl.setOperationMode(ERROR_MODE); @@ -166,7 +175,7 @@ void onLoop(){ if(counter-- == 0){ owl.setOperationMode(CONFIGURE_MODE); }else if(counter < PATCH_RESET_COUNTER){ - setLed(0, counter > PATCH_RESET_COUNTER/2 ? GREEN_COLOUR : NO_COLOUR); + setLed(0, counter > PATCH_RESET_COUNTER/10 ? GREEN_COLOUR : NO_COLOUR); } }else{ counter = PATCH_CONFIG_COUNTER; diff --git a/OwlPedal2/Src/main.c b/OwlPedal2/Src/main.c index 706352b7..976476ba 100644 --- a/OwlPedal2/Src/main.c +++ b/OwlPedal2/Src/main.c @@ -857,11 +857,9 @@ static void MX_GPIO_Init(void) HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); /*Configure GPIO pins : PG2 PG3 PG6 PG7 - PG10 PG11 PG12 PG13 - PG14 */ + PG11 PG12 PG13 PG14 */ GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_6|GPIO_PIN_7 - |GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13 - |GPIO_PIN_14; + |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); @@ -872,11 +870,11 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(SW1_GPIO_Port, &GPIO_InitStruct); - /*Configure GPIO pin : SW2_Pin */ - GPIO_InitStruct.Pin = SW2_Pin; + /*Configure GPIO pins : SW2_Pin SW1_ALT_Pin */ + GPIO_InitStruct.Pin = SW2_Pin|SW1_ALT_Pin; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; GPIO_InitStruct.Pull = GPIO_PULLUP; - HAL_GPIO_Init(SW2_GPIO_Port, &GPIO_InitStruct); + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); /* EXTI interrupt init*/ HAL_NVIC_SetPriority(EXTI1_IRQn, 15, 0); @@ -888,6 +886,9 @@ static void MX_GPIO_Init(void) HAL_NVIC_SetPriority(EXTI9_5_IRQn, 15, 0); HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); + HAL_NVIC_SetPriority(EXTI15_10_IRQn, 15, 0); + HAL_NVIC_EnableIRQ(EXTI15_10_IRQn); + } /* USER CODE BEGIN 4 */ diff --git a/OwlPedal2/Src/stm32f4xx_hal_msp.c b/OwlPedal2/Src/stm32f4xx_hal_msp.c index 83400d01..3894c08c 100644 --- a/OwlPedal2/Src/stm32f4xx_hal_msp.c +++ b/OwlPedal2/Src/stm32f4xx_hal_msp.c @@ -146,7 +146,7 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) HAL_GPIO_Init(EXP_RING_GPIO_Port, &GPIO_InitStruct); /* ADC1 interrupt Init */ - HAL_NVIC_SetPriority(ADC_IRQn, 5, 0); + HAL_NVIC_SetPriority(ADC_IRQn, 10, 0); HAL_NVIC_EnableIRQ(ADC_IRQn); /* USER CODE BEGIN ADC1_MspInit 1 */ @@ -205,7 +205,7 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) __HAL_LINKDMA(hadc,DMA_Handle,hdma_adc3); /* ADC3 interrupt Init */ - HAL_NVIC_SetPriority(ADC_IRQn, 5, 0); + HAL_NVIC_SetPriority(ADC_IRQn, 10, 0); HAL_NVIC_EnableIRQ(ADC_IRQn); /* USER CODE BEGIN ADC3_MspInit 1 */ diff --git a/OwlPedal2/Src/stm32f4xx_it.c b/OwlPedal2/Src/stm32f4xx_it.c index 836603ab..c4121b26 100644 --- a/OwlPedal2/Src/stm32f4xx_it.c +++ b/OwlPedal2/Src/stm32f4xx_it.c @@ -178,6 +178,20 @@ void EXTI9_5_IRQHandler(void) /* USER CODE END EXTI9_5_IRQn 1 */ } +/** + * @brief This function handles EXTI line[15:10] interrupts. + */ +void EXTI15_10_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI15_10_IRQn 0 */ + + /* USER CODE END EXTI15_10_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_10); + /* USER CODE BEGIN EXTI15_10_IRQn 1 */ + + /* USER CODE END EXTI15_10_IRQn 1 */ +} + /** * @brief This function handles DMA2 stream1 global interrupt. */ From 7b93b6a4abfb57bb3209099b23f10aef9af197a8 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 18 Nov 2021 14:27:52 +0100 Subject: [PATCH 186/286] fixed LED pwm --- ACDC/ACDC.ioc | 54 ++++++-------- ACDC/Core/Inc/stm32h7xx_it.h | 1 - ACDC/Core/Src/ACDC.cpp | 6 +- ACDC/Core/Src/main.c | 92 +++++++---------------- ACDC/Core/Src/stm32h7xx_hal_msp.c | 117 ++++++------------------------ ACDC/Core/Src/stm32h7xx_it.c | 15 ---- 6 files changed, 76 insertions(+), 209 deletions(-) diff --git a/ACDC/ACDC.ioc b/ACDC/ACDC.ioc index 42a3b90d..ecafa878 100644 --- a/ACDC/ACDC.ioc +++ b/ACDC/ACDC.ioc @@ -144,13 +144,12 @@ Mcu.IP11=SPI3 Mcu.IP12=SYS Mcu.IP13=TIM2 Mcu.IP14=TIM4 -Mcu.IP15=TIM5 -Mcu.IP16=TIM8 -Mcu.IP17=UART5 -Mcu.IP18=UART7 -Mcu.IP19=USB_DEVICE +Mcu.IP15=TIM8 +Mcu.IP16=UART5 +Mcu.IP17=UART7 +Mcu.IP18=USB_DEVICE +Mcu.IP19=USB_OTG_FS Mcu.IP2=DEBUG -Mcu.IP20=USB_OTG_FS Mcu.IP3=DMA Mcu.IP4=FMC Mcu.IP5=FREERTOS @@ -158,7 +157,7 @@ Mcu.IP6=NVIC Mcu.IP7=QUADSPI Mcu.IP8=RCC Mcu.IP9=SAI1 -Mcu.IPNb=21 +Mcu.IPNb=20 Mcu.Name=STM32H743IIKx Mcu.Package=UFBGA176 Mcu.Pin0=PE3 @@ -303,10 +302,9 @@ NVIC.SavedPendsvIrqHandlerGenerated=true NVIC.SavedSvcallIrqHandlerGenerated=true NVIC.SavedSystickIrqHandlerGenerated=true NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:false\:true -NVIC.TIM4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false PA0.Locked=true -PA0.Signal=S_TIM5_CH1 +PA0.Signal=GPIO_Output PA1.Signal=S_TIM2_CH2 PA11.Mode=Device_Only PA11.Signal=USB_OTG_FS_DM @@ -399,11 +397,7 @@ PC9.Stacked=true PD0.Signal=FMC_D2_DA2 PD1.Signal=FMC_D3_DA3 PD10.Signal=FMC_D15_DA15 -PD12.GPIOParameters=GPIO_PuPd -PD12.GPIO_PuPd=GPIO_PULLUP PD12.Signal=S_TIM4_CH1 -PD13.GPIOParameters=GPIO_PuPd -PD13.GPIO_PuPd=GPIO_PULLUP PD13.Signal=S_TIM4_CH2 PD14.Signal=FMC_D0_DA0 PD15.Signal=FMC_D1_DA1 @@ -815,12 +809,10 @@ SH.S_TIM2_CH1.0=TIM2_CH1,PWM Generation1 CH1 SH.S_TIM2_CH1.ConfNb=1 SH.S_TIM2_CH2.0=TIM2_CH2,PWM Generation2 CH2 SH.S_TIM2_CH2.ConfNb=1 -SH.S_TIM4_CH1.0=TIM4_CH1,Encoder_Interface +SH.S_TIM4_CH1.0=TIM4_CH1,PWM Generation1 CH1 SH.S_TIM4_CH1.ConfNb=1 -SH.S_TIM4_CH2.0=TIM4_CH2,Encoder_Interface +SH.S_TIM4_CH2.0=TIM4_CH2,PWM Generation2 CH2 SH.S_TIM4_CH2.ConfNb=1 -SH.S_TIM5_CH1.0=TIM5_CH1,PWM Generation1 CH1 -SH.S_TIM5_CH1.ConfNb=1 SH.S_TIM8_CH1.0=TIM8_CH1,PWM Generation1 CH1 SH.S_TIM8_CH1.ConfNb=1 SH.S_TIM8_CH2.0=TIM8_CH2,PWM Generation2 CH2 @@ -832,11 +824,10 @@ SH.SharedStack_PC12.0=SDMMC1_CK SH.SharedStack_PC12.1=SPI3_MOSI,TX_Only_Simplex_Unidirect_Master SH.SharedStack_PC12.ConfNb=2 SH.SharedStack_PC9.0=SDMMC1_D1 -SH.SharedStack_PC9.1=GPIO_EXTI9+0 -SH.SharedStack_PC9.2=TIM3_CH4 -SH.SharedStack_PC9.3=TIM8_CH4 -SH.SharedStack_PC9.4=GPIO_Output+0 -SH.SharedStack_PC9.ConfNb=5 +SH.SharedStack_PC9.1=TIM3_CH4 +SH.SharedStack_PC9.2=TIM8_CH4 +SH.SharedStack_PC9.3=GPIO_EXTI9 +SH.SharedStack_PC9.ConfNb=4 SPI2.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_256 SPI2.CLKPhase=SPI_PHASE_2EDGE SPI2.CLKPolarity=SPI_POLARITY_HIGH @@ -857,16 +848,19 @@ SPI3.NSSPMode=SPI_NSS_PULSE_DISABLE SPI3.VirtualType=VM_MASTER TIM2.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 TIM2.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2 -TIM2.IPParameters=Channel-PWM Generation2 CH2,Channel-PWM Generation1 CH1 -TIM4.EncoderMode=TIM_ENCODERMODE_TI12 -TIM4.IC1Filter=4 -TIM4.IC2Filter=4 -TIM4.IPParameters=EncoderMode,IC1Filter,IC2Filter -TIM5.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 -TIM5.IPParameters=Channel-PWM Generation1 CH1 +TIM2.IPParameters=Channel-PWM Generation2 CH2,Channel-PWM Generation1 CH1,Prescaler,Period +TIM2.Period=1023 +TIM2.Prescaler=100 +TIM4.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 +TIM4.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2 +TIM4.IPParameters=Channel-PWM Generation2 CH2,Channel-PWM Generation1 CH1,Period,Prescaler +TIM4.Period=1023 +TIM4.Prescaler=100 TIM8.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 TIM8.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2 -TIM8.IPParameters=Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2 +TIM8.IPParameters=Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2,Period,Prescaler +TIM8.Period=1023 +TIM8.Prescaler=100 USB_DEVICE.CLASS_NAME_FS=AUDIO USB_DEVICE.IPParameters=VirtualMode-AUDIO_FS,VirtualModeFS,CLASS_NAME_FS,VID-AUDIO_FS,MANUFACTURER_STRING-AUDIO_FS,PID_AUDIO_FS,PRODUCT_STRING_AUDIO_FS USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology diff --git a/ACDC/Core/Inc/stm32h7xx_it.h b/ACDC/Core/Inc/stm32h7xx_it.h index dbb0e22d..ef57fd7d 100644 --- a/ACDC/Core/Inc/stm32h7xx_it.h +++ b/ACDC/Core/Inc/stm32h7xx_it.h @@ -53,7 +53,6 @@ void DMA1_Stream1_IRQHandler(void); void DMA1_Stream2_IRQHandler(void); void DMA1_Stream3_IRQHandler(void); void ADC_IRQHandler(void); -void TIM4_IRQHandler(void); void SPI3_IRQHandler(void); void SAI1_IRQHandler(void); void QUADSPI_IRQHandler(void); diff --git a/ACDC/Core/Src/ACDC.cpp b/ACDC/Core/Src/ACDC.cpp index 247342e8..b3357f57 100644 --- a/ACDC/Core/Src/ACDC.cpp +++ b/ACDC/Core/Src/ACDC.cpp @@ -45,7 +45,7 @@ Pin led_out3(XIBECA_PIN23); Pin led_out4(XIBECA_PIN24); void setLed(uint8_t led, uint32_t rgb){ - uint32_t pwm = 0xFFFFFFFFU - __USAT(rgb>>10, 10); + uint32_t pwm = 1023 - (__USAT(rgb>>2, 10)); // expects 12-bit parameter value switch(led){ case 1: if(rgb == RED_COLOUR){ @@ -126,7 +126,7 @@ void initLed(){ HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_2); // out4 // HAL_TIM_PWM_Start(&htim5, TIM_CHANNEL_1); // clip1 HAL_TIM_PWM_Start(&htim8, TIM_CHANNEL_1); // out1 - HAL_TIM_PWM_Start(&htim8, TIM_CHANNEL_1); // out2 + HAL_TIM_PWM_Start(&htim8, TIM_CHANNEL_2); // out2 led_in1.outputMode(); led_in2.outputMode(); @@ -161,6 +161,6 @@ void onSetup(){ void onLoop(void){ for(size_t i=0; i<4; ++i){ setLed(i+1, getParameterValue(PARAMETER_AA+i)); - setLed(i+4, getParameterValue(PARAMETER_BA+i)); + setLed(i+5, getParameterValue(PARAMETER_BA+i)); } } diff --git a/ACDC/Core/Src/main.c b/ACDC/Core/Src/main.c index ce6fe6c4..dacc0df9 100644 --- a/ACDC/Core/Src/main.c +++ b/ACDC/Core/Src/main.c @@ -60,7 +60,6 @@ DMA_HandleTypeDef hdma_spi3_tx; TIM_HandleTypeDef htim2; TIM_HandleTypeDef htim4; -TIM_HandleTypeDef htim5; TIM_HandleTypeDef htim8; UART_HandleTypeDef huart5; @@ -88,7 +87,6 @@ static void MX_TIM2_Init(void); static void MX_TIM4_Init(void); static void MX_UART5_Init(void); static void MX_UART7_Init(void); -static void MX_TIM5_Init(void); static void MX_TIM8_Init(void); void StartDefaultTask(void const * argument); @@ -171,7 +169,6 @@ int main(void) MX_TIM4_Init(); MX_UART5_Init(); MX_UART7_Init(); - MX_TIM5_Init(); MX_TIM8_Init(); /* USER CODE BEGIN 2 */ @@ -655,9 +652,9 @@ static void MX_TIM2_Init(void) /* USER CODE END TIM2_Init 1 */ htim2.Instance = TIM2; - htim2.Init.Prescaler = 0; + htim2.Init.Prescaler = 100; htim2.Init.CounterMode = TIM_COUNTERMODE_UP; - htim2.Init.Period = 4294967295; + htim2.Init.Period = 1023; htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; if (HAL_TIM_PWM_Init(&htim2) != HAL_OK) @@ -701,28 +698,19 @@ static void MX_TIM4_Init(void) /* USER CODE END TIM4_Init 0 */ - TIM_Encoder_InitTypeDef sConfig = {0}; TIM_MasterConfigTypeDef sMasterConfig = {0}; + TIM_OC_InitTypeDef sConfigOC = {0}; /* USER CODE BEGIN TIM4_Init 1 */ /* USER CODE END TIM4_Init 1 */ htim4.Instance = TIM4; - htim4.Init.Prescaler = 0; + htim4.Init.Prescaler = 100; htim4.Init.CounterMode = TIM_COUNTERMODE_UP; - htim4.Init.Period = 65535; + htim4.Init.Period = 1023; htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; htim4.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; - sConfig.EncoderMode = TIM_ENCODERMODE_TI12; - sConfig.IC1Polarity = TIM_ICPOLARITY_RISING; - sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI; - sConfig.IC1Prescaler = TIM_ICPSC_DIV1; - sConfig.IC1Filter = 4; - sConfig.IC2Polarity = TIM_ICPOLARITY_RISING; - sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI; - sConfig.IC2Prescaler = TIM_ICPSC_DIV1; - sConfig.IC2Filter = 4; - if (HAL_TIM_Encoder_Init(&htim4, &sConfig) != HAL_OK) + if (HAL_TIM_PWM_Init(&htim4) != HAL_OK) { Error_Handler(); } @@ -732,58 +720,22 @@ static void MX_TIM4_Init(void) { Error_Handler(); } - /* USER CODE BEGIN TIM4_Init 2 */ - - /* USER CODE END TIM4_Init 2 */ - -} - -/** - * @brief TIM5 Initialization Function - * @param None - * @retval None - */ -static void MX_TIM5_Init(void) -{ - - /* USER CODE BEGIN TIM5_Init 0 */ - - /* USER CODE END TIM5_Init 0 */ - - TIM_MasterConfigTypeDef sMasterConfig = {0}; - TIM_OC_InitTypeDef sConfigOC = {0}; - - /* USER CODE BEGIN TIM5_Init 1 */ - - /* USER CODE END TIM5_Init 1 */ - htim5.Instance = TIM5; - htim5.Init.Prescaler = 0; - htim5.Init.CounterMode = TIM_COUNTERMODE_UP; - htim5.Init.Period = 4294967295; - htim5.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; - htim5.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; - if (HAL_TIM_PWM_Init(&htim5) != HAL_OK) - { - Error_Handler(); - } - sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; - sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; - if (HAL_TIMEx_MasterConfigSynchronization(&htim5, &sMasterConfig) != HAL_OK) - { - Error_Handler(); - } sConfigOC.OCMode = TIM_OCMODE_PWM1; sConfigOC.Pulse = 0; sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; - if (HAL_TIM_PWM_ConfigChannel(&htim5, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) + if (HAL_TIM_PWM_ConfigChannel(&htim4, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) { Error_Handler(); } - /* USER CODE BEGIN TIM5_Init 2 */ + if (HAL_TIM_PWM_ConfigChannel(&htim4, &sConfigOC, TIM_CHANNEL_2) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN TIM4_Init 2 */ - /* USER CODE END TIM5_Init 2 */ - HAL_TIM_MspPostInit(&htim5); + /* USER CODE END TIM4_Init 2 */ + HAL_TIM_MspPostInit(&htim4); } @@ -807,9 +759,9 @@ static void MX_TIM8_Init(void) /* USER CODE END TIM8_Init 1 */ htim8.Instance = TIM8; - htim8.Init.Prescaler = 0; + htim8.Init.Prescaler = 100; htim8.Init.CounterMode = TIM_COUNTERMODE_UP; - htim8.Init.Period = 65535; + htim8.Init.Period = 1023; htim8.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; htim8.Init.RepetitionCounter = 0; htim8.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; @@ -1059,7 +1011,7 @@ static void MX_GPIO_Init(void) HAL_GPIO_WritePin(GPIOH, GPIO_PIN_4, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOA, GPIO_PIN_3|GPIO_PIN_7, GPIO_PIN_RESET); + HAL_GPIO_WritePin(GPIOA, GPIO_PIN_0|GPIO_PIN_3|GPIO_PIN_7, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(ADC_SPI_NCS_GPIO_Port, ADC_SPI_NCS_Pin, GPIO_PIN_RESET); @@ -1138,6 +1090,12 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + /*Configure GPIO pin : PC9 */ + GPIO_InitStruct.Pin = GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + /*Configure GPIO pin : PH4 */ GPIO_InitStruct.Pin = GPIO_PIN_4; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; @@ -1151,8 +1109,8 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); - /*Configure GPIO pins : PA3 PA7 */ - GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_7; + /*Configure GPIO pins : PA0 PA3 PA7 */ + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_3|GPIO_PIN_7; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; diff --git a/ACDC/Core/Src/stm32h7xx_hal_msp.c b/ACDC/Core/Src/stm32h7xx_hal_msp.c index 748b054d..6f56e7a2 100644 --- a/ACDC/Core/Src/stm32h7xx_hal_msp.c +++ b/ACDC/Core/Src/stm32h7xx_hal_msp.c @@ -479,16 +479,16 @@ void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm) /* USER CODE END TIM2_MspInit 1 */ } - else if(htim_pwm->Instance==TIM5) + else if(htim_pwm->Instance==TIM4) { - /* USER CODE BEGIN TIM5_MspInit 0 */ + /* USER CODE BEGIN TIM4_MspInit 0 */ - /* USER CODE END TIM5_MspInit 0 */ + /* USER CODE END TIM4_MspInit 0 */ /* Peripheral clock enable */ - __HAL_RCC_TIM5_CLK_ENABLE(); - /* USER CODE BEGIN TIM5_MspInit 1 */ + __HAL_RCC_TIM4_CLK_ENABLE(); + /* USER CODE BEGIN TIM4_MspInit 1 */ - /* USER CODE END TIM5_MspInit 1 */ + /* USER CODE END TIM4_MspInit 1 */ } else if(htim_pwm->Instance==TIM8) { @@ -504,45 +504,6 @@ void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm) } -/** -* @brief TIM_Encoder MSP Initialization -* This function configures the hardware resources used in this example -* @param htim_encoder: TIM_Encoder handle pointer -* @retval None -*/ -void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef* htim_encoder) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - if(htim_encoder->Instance==TIM4) - { - /* USER CODE BEGIN TIM4_MspInit 0 */ - - /* USER CODE END TIM4_MspInit 0 */ - /* Peripheral clock enable */ - __HAL_RCC_TIM4_CLK_ENABLE(); - - __HAL_RCC_GPIOD_CLK_ENABLE(); - /**TIM4 GPIO Configuration - PD13 ------> TIM4_CH2 - PD12 ------> TIM4_CH1 - */ - GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_12; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_PULLUP; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF2_TIM4; - HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); - - /* TIM4 interrupt Init */ - HAL_NVIC_SetPriority(TIM4_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(TIM4_IRQn); - /* USER CODE BEGIN TIM4_MspInit 1 */ - - /* USER CODE END TIM4_MspInit 1 */ - } - -} - void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) { GPIO_InitTypeDef GPIO_InitStruct = {0}; @@ -567,26 +528,27 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) /* USER CODE END TIM2_MspPostInit 1 */ } - else if(htim->Instance==TIM5) + else if(htim->Instance==TIM4) { - /* USER CODE BEGIN TIM5_MspPostInit 0 */ + /* USER CODE BEGIN TIM4_MspPostInit 0 */ - /* USER CODE END TIM5_MspPostInit 0 */ + /* USER CODE END TIM4_MspPostInit 0 */ - __HAL_RCC_GPIOA_CLK_ENABLE(); - /**TIM5 GPIO Configuration - PA0 ------> TIM5_CH1 + __HAL_RCC_GPIOD_CLK_ENABLE(); + /**TIM4 GPIO Configuration + PD13 ------> TIM4_CH2 + PD12 ------> TIM4_CH1 */ - GPIO_InitStruct.Pin = GPIO_PIN_0; + GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_12; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF2_TIM5; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + GPIO_InitStruct.Alternate = GPIO_AF2_TIM4; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); - /* USER CODE BEGIN TIM5_MspPostInit 1 */ + /* USER CODE BEGIN TIM4_MspPostInit 1 */ - /* USER CODE END TIM5_MspPostInit 1 */ + /* USER CODE END TIM4_MspPostInit 1 */ } else if(htim->Instance==TIM8) { @@ -631,16 +593,16 @@ void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm) /* USER CODE END TIM2_MspDeInit 1 */ } - else if(htim_pwm->Instance==TIM5) + else if(htim_pwm->Instance==TIM4) { - /* USER CODE BEGIN TIM5_MspDeInit 0 */ + /* USER CODE BEGIN TIM4_MspDeInit 0 */ - /* USER CODE END TIM5_MspDeInit 0 */ + /* USER CODE END TIM4_MspDeInit 0 */ /* Peripheral clock disable */ - __HAL_RCC_TIM5_CLK_DISABLE(); - /* USER CODE BEGIN TIM5_MspDeInit 1 */ + __HAL_RCC_TIM4_CLK_DISABLE(); + /* USER CODE BEGIN TIM4_MspDeInit 1 */ - /* USER CODE END TIM5_MspDeInit 1 */ + /* USER CODE END TIM4_MspDeInit 1 */ } else if(htim_pwm->Instance==TIM8) { @@ -656,37 +618,6 @@ void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm) } -/** -* @brief TIM_Encoder MSP De-Initialization -* This function freeze the hardware resources used in this example -* @param htim_encoder: TIM_Encoder handle pointer -* @retval None -*/ -void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef* htim_encoder) -{ - if(htim_encoder->Instance==TIM4) - { - /* USER CODE BEGIN TIM4_MspDeInit 0 */ - - /* USER CODE END TIM4_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_TIM4_CLK_DISABLE(); - - /**TIM4 GPIO Configuration - PD13 ------> TIM4_CH2 - PD12 ------> TIM4_CH1 - */ - HAL_GPIO_DeInit(GPIOD, GPIO_PIN_13|GPIO_PIN_12); - - /* TIM4 interrupt DeInit */ - HAL_NVIC_DisableIRQ(TIM4_IRQn); - /* USER CODE BEGIN TIM4_MspDeInit 1 */ - - /* USER CODE END TIM4_MspDeInit 1 */ - } - -} - /** * @brief UART MSP Initialization * This function configures the hardware resources used in this example diff --git a/ACDC/Core/Src/stm32h7xx_it.c b/ACDC/Core/Src/stm32h7xx_it.c index 18755c38..aedaacf9 100644 --- a/ACDC/Core/Src/stm32h7xx_it.c +++ b/ACDC/Core/Src/stm32h7xx_it.c @@ -68,7 +68,6 @@ extern SAI_HandleTypeDef hsai_BlockA1; extern SAI_HandleTypeDef hsai_BlockB1; extern DMA_HandleTypeDef hdma_spi3_tx; extern SPI_HandleTypeDef hspi3; -extern TIM_HandleTypeDef htim4; /* USER CODE BEGIN EV */ /* USER CODE END EV */ @@ -175,20 +174,6 @@ void ADC_IRQHandler(void) /* USER CODE END ADC_IRQn 1 */ } -/** - * @brief This function handles TIM4 global interrupt. - */ -void TIM4_IRQHandler(void) -{ - /* USER CODE BEGIN TIM4_IRQn 0 */ - - /* USER CODE END TIM4_IRQn 0 */ - HAL_TIM_IRQHandler(&htim4); - /* USER CODE BEGIN TIM4_IRQn 1 */ - - /* USER CODE END TIM4_IRQn 1 */ -} - /** * @brief This function handles SPI3 global interrupt. */ From 0a882e6c09df6a9e4210be9b355030323cf9b6c0 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 19 Nov 2021 11:59:19 +0100 Subject: [PATCH 187/286] invert ADC and DAC --- ACDC/Core/Inc/hardware.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ACDC/Core/Inc/hardware.h b/ACDC/Core/Inc/hardware.h index d49ab7f1..94ce6782 100644 --- a/ACDC/Core/Inc/hardware.h +++ b/ACDC/Core/Inc/hardware.h @@ -23,6 +23,8 @@ #define USE_CODEC #define USE_PCM3168A +#define CODEC_ADC_INVERT +#define CODEC_DAC_INVERT /* #define CODEC_HP_FILTER */ #define CODEC_SPI hspi2 From 831ef0f8720f7d1c13391f19224342beddd0fa7d Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 19 Nov 2021 11:59:51 +0100 Subject: [PATCH 188/286] allow phase inverted ADC and DAC configuration --- Source/pcm3168a.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/pcm3168a.c b/Source/pcm3168a.c index ed1fde3a..0eae7633 100644 --- a/Source/pcm3168a.c +++ b/Source/pcm3168a.c @@ -89,7 +89,9 @@ void codec_init(){ #endif /* Register: DAC Output Phase */ - /* codec_write(67, 0xff); // phase invert all DAC channels */ +#ifdef CODEC_DAC_INVERT + codec_write(67, 0xff); // phase invert all DAC channels +#endif /* Register: DAC Soft Mute Control */ /* codec_write(68, 0xff); // enable soft mute for all DAC channels */ @@ -123,7 +125,9 @@ void codec_init(){ codec_write(83, 0b00111111); // singled ended inputs on all ADC channels /* Register: ADC Input Phase */ +#ifdef CODEC_ADC_INVERT codec_write(84, 0b00111111); // phase invert all ADC channels +#endif /* Register: ADC Overflow Flag */ /* ADC Overflow flag (read-only) */ From 07755bdf71e0961338799a8c510326419ef091a0 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 19 Nov 2021 12:00:08 +0100 Subject: [PATCH 189/286] set channel config --- Source/usbd_audio.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/Source/usbd_audio.cpp b/Source/usbd_audio.cpp index ed656da7..d1b2fefa 100644 --- a/Source/usbd_audio.cpp +++ b/Source/usbd_audio.cpp @@ -235,6 +235,15 @@ static void get_usb_full_speed_rate(unsigned int rate, uint8_t* buf){ #define USBD_MIDI_NUM_INTERFACES 0 #endif +#if AUDIO_CHANNELS >= 4 +#define USBD_AUDIO_CHANNEL_CONFIG 0x0603 /* Side L/R and Front L/R */ +#elif AUDIO_CHANNELS >= 2 +#define USBD_AUDIO_CHANNEL_CONFIG 0x0003 /* L/R */ +#else +#define USBD_AUDIO_CHANNEL_CONFIG 0x0000 /* Unassigned */ +#endif + + // not including Audio Control AC interface #define AUDIO_NUM_INTERFACES (USBD_AUDIO_RX_NUM_INTERFACES+USBD_AUDIO_TX_NUM_INTERFACES+USBD_MIDI_NUM_INTERFACES) @@ -306,12 +315,8 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x01, // wTerminalType 0x03, // bAssocTerminal USBD_AUDIO_RX_CHANNELS, // bNrChannels -#if USBD_AUDIO_RX_CHANNELS == 1 - 0x00, // wChannelConfig 0x00 sets Mono, no position bits -#else - 0x03, // wChannelConfig 0x03 sets stereo channels left and right -#endif - 0x00, // wChannelConfig + LOBYTE(USBD_AUDIO_CHANNEL_CONFIG), // wChannelConfig + HIBYTE(USBD_AUDIO_CHANNEL_CONFIG), // wChannelConfig 0x00, // iChannelNames 0x00, // iTerminal Unused /* 12 byte */ @@ -375,8 +380,8 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x02, // wTerminalType Terminal is Microphone (0x0201) 0x06, // bAssocTerminal USBD_AUDIO_TX_CHANNELS, // bNrChannels - 0x03, // wChannelConfig - 0x00, // wChannelConfig Mono sets no position bits + LOBYTE(USBD_AUDIO_CHANNEL_CONFIG), // wChannelConfig + HIBYTE(USBD_AUDIO_CHANNEL_CONFIG), // wChannelConfig 0x00, // iChannelNames Unused 0x00, // iTerminal Unused /* 12 bytes */ @@ -486,7 +491,6 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x09, /* bLength */ USB_DESC_TYPE_ENDPOINT, /* bDescriptorType */ AUDIO_RX_EP, /* bEndpointAddress 1 out endpoint*/ - // USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_ADAPT, /* bmAttributes */ USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_ASYNC, /* bmAttributes */ LOBYTE(AUDIO_RX_MAX_PACKET_SIZE), /* wMaxPacketSize in bytes */ HIBYTE(AUDIO_RX_MAX_PACKET_SIZE), @@ -586,8 +590,9 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USBD_AUDIO_CONFIG_DESC_SIZ] __AL 0x09, // Size of the descriptor, in bytes (bLength) 0x05, // ENDPOINT descriptor (bDescriptorType) AUDIO_TX_EP, // IN Endpoint 1. (bEndpointAddress) - USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_ASYNC, // bmAttributes - // USBD_EP_TYPE_ISOC, // bmAttributes (device not recognised in Windows if sync or async) + // BADD 4.2.3: Basic Audio Functions shall support the same Synchronization Type on all of their streaming endpoints. Only Synchronous or Asynchronous Synchronization Types are allowed. + // USBD_EP_TYPE_ISOC|USBD_EP_ATTR_ISOC_ASYNC, // bmAttributes + USBD_EP_TYPE_ISOC, // bmAttributes (device not recognised in Windows if sync or async) LOBYTE(AUDIO_TX_MAX_PACKET_SIZE), // wMaxPacketSize in bytes HIBYTE(AUDIO_TX_MAX_PACKET_SIZE), 0x01, // Polling interval 1kHz. (bInterval) From 464a6e9aa5705b5f1764115e092ed93992927c13 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 19 Nov 2021 12:22:13 +0100 Subject: [PATCH 190/286] reversed expression tip/ring, added adc channel --- OwlPedal2/Inc/hardware.h | 3 +- OwlPedal2/Inc/main.h | 2 - OwlPedal2/OwlPedal2.ioc | 74 +++++++++++------------- OwlPedal2/Src/OwlPedal.cpp | 13 ++++- OwlPedal2/Src/main.c | 93 ++++++++----------------------- OwlPedal2/Src/stm32f4xx_hal_msp.c | 85 +++------------------------- OwlPedal2/Src/stm32f4xx_it.c | 2 - 7 files changed, 77 insertions(+), 195 deletions(-) diff --git a/OwlPedal2/Inc/hardware.h b/OwlPedal2/Inc/hardware.h index 0b6ff646..b3a326ad 100644 --- a/OwlPedal2/Inc/hardware.h +++ b/OwlPedal2/Inc/hardware.h @@ -50,11 +50,12 @@ #define ADC_C 2 #define ADC_D 3 #define ADC_E 4 +#define ADC_F 5 #define USE_CODEC #define USE_CS4271 #define CODEC_HP_FILTER #define CODEC_SPI hspi4 -#define NOF_ADC_VALUES 5 +#define NOF_ADC_VALUES 6 #define NOF_PARAMETERS 40 #define NOF_BUTTONS (2+4) diff --git a/OwlPedal2/Inc/main.h b/OwlPedal2/Inc/main.h index b68c305b..7f6aaef3 100644 --- a/OwlPedal2/Inc/main.h +++ b/OwlPedal2/Inc/main.h @@ -129,8 +129,6 @@ void Error_Handler(void); #define FLASH_nCS_GPIO_Port GPIOC #define FLASH_WP_Pin GPIO_PIN_0 #define FLASH_WP_GPIO_Port GPIOB -#define EXP_RING_Pin GPIO_PIN_1 -#define EXP_RING_GPIO_Port GPIOB #define EXP_TIP_Pin GPIO_PIN_2 #define EXP_TIP_GPIO_Port GPIOB #define CS_nCS_Pin GPIO_PIN_10 diff --git a/OwlPedal2/OwlPedal2.ioc b/OwlPedal2/OwlPedal2.ioc index 89f44f71..cd6a3533 100644 --- a/OwlPedal2/OwlPedal2.ioc +++ b/OwlPedal2/OwlPedal2.ioc @@ -1,21 +1,10 @@ #MicroXplorer Configuration settings - do not modify -ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_9 -ADC1.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV8 -ADC1.ContinuousConvMode=ENABLE -ADC1.DMAContinuousRequests=DISABLE -ADC1.EOCSelection=ADC_EOC_SEQ_CONV -ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,NbrOfConversionFlag,master,ClockPrescaler,ScanConvMode,ContinuousConvMode,DMAContinuousRequests,EOCSelection,NbrOfConversion -ADC1.NbrOfConversion=1 -ADC1.NbrOfConversionFlag=1 -ADC1.Rank-0\#ChannelRegularConversion=1 -ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -ADC1.ScanConvMode=ENABLE -ADC1.master=1 ADC3.Channel-31\#ChannelRegularConversion=ADC_CHANNEL_13 ADC3.Channel-32\#ChannelRegularConversion=ADC_CHANNEL_12 ADC3.Channel-33\#ChannelRegularConversion=ADC_CHANNEL_11 ADC3.Channel-34\#ChannelRegularConversion=ADC_CHANNEL_8 -ADC3.Channel-35\#ChannelRegularConversion=ADC_CHANNEL_3 +ADC3.Channel-35\#ChannelRegularConversion=ADC_CHANNEL_2 +ADC3.Channel-36\#ChannelRegularConversion=ADC_CHANNEL_3 ADC3.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV8 ADC3.ContinuousConvMode=ENABLE ADC3.DMAContinuousRequests=ENABLE @@ -25,21 +14,23 @@ ADC3.EOCSelection=ADC_EOC_SEQ_CONV ADC3.EnableAnalogWatchDog=false ADC3.ExternalTrigConv=ADC_SOFTWARE_START ADC3.ExternalTrigConvEdge=ADC_EXTERNALTRIGCONVEDGE_NONE -ADC3.IPParameters=Rank-31\#ChannelRegularConversion,Channel-31\#ChannelRegularConversion,SamplingTime-31\#ChannelRegularConversion,NbrOfConversionFlag,ScanConvMode,ContinuousConvMode,DMAContinuousRequests,EOCSelection,InjNumberOfConversion,EnableAnalogWatchDog,ExternalTrigConv,Rank-32\#ChannelRegularConversion,Channel-32\#ChannelRegularConversion,SamplingTime-32\#ChannelRegularConversion,Rank-33\#ChannelRegularConversion,Channel-33\#ChannelRegularConversion,SamplingTime-33\#ChannelRegularConversion,Rank-34\#ChannelRegularConversion,Channel-34\#ChannelRegularConversion,SamplingTime-34\#ChannelRegularConversion,NbrOfConversion,ClockPrescaler,Resolution,DataAlign,DiscontinuousConvMode,ExternalTrigConvEdge,Rank-35\#ChannelRegularConversion,Channel-35\#ChannelRegularConversion,SamplingTime-35\#ChannelRegularConversion +ADC3.IPParameters=Rank-31\#ChannelRegularConversion,Channel-31\#ChannelRegularConversion,SamplingTime-31\#ChannelRegularConversion,NbrOfConversionFlag,ScanConvMode,ContinuousConvMode,DMAContinuousRequests,EOCSelection,InjNumberOfConversion,EnableAnalogWatchDog,ExternalTrigConv,Rank-32\#ChannelRegularConversion,Channel-32\#ChannelRegularConversion,SamplingTime-32\#ChannelRegularConversion,Rank-33\#ChannelRegularConversion,Channel-33\#ChannelRegularConversion,SamplingTime-33\#ChannelRegularConversion,Rank-34\#ChannelRegularConversion,Channel-34\#ChannelRegularConversion,SamplingTime-34\#ChannelRegularConversion,NbrOfConversion,ClockPrescaler,Resolution,DataAlign,DiscontinuousConvMode,ExternalTrigConvEdge,Rank-35\#ChannelRegularConversion,Channel-35\#ChannelRegularConversion,SamplingTime-35\#ChannelRegularConversion,Rank-36\#ChannelRegularConversion,Channel-36\#ChannelRegularConversion,SamplingTime-36\#ChannelRegularConversion ADC3.InjNumberOfConversion=0 -ADC3.NbrOfConversion=5 +ADC3.NbrOfConversion=6 ADC3.NbrOfConversionFlag=1 ADC3.Rank-31\#ChannelRegularConversion=1 ADC3.Rank-32\#ChannelRegularConversion=2 ADC3.Rank-33\#ChannelRegularConversion=3 ADC3.Rank-34\#ChannelRegularConversion=4 ADC3.Rank-35\#ChannelRegularConversion=5 +ADC3.Rank-36\#ChannelRegularConversion=6 ADC3.Resolution=ADC_RESOLUTION_12B ADC3.SamplingTime-31\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES ADC3.SamplingTime-32\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES ADC3.SamplingTime-33\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES ADC3.SamplingTime-34\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES ADC3.SamplingTime-35\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-36\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES ADC3.ScanConvMode=ENABLE Dma.ADC3.0.Direction=DMA_PERIPH_TO_MEMORY Dma.ADC3.0.FIFOMode=DMA_FIFOMODE_DISABLE @@ -106,21 +97,20 @@ File.Version=6 GPIO.groupedBy=Group By Peripherals KeepUserPlacement=false Mcu.Family=STM32F4 -Mcu.IP0=ADC1 -Mcu.IP1=ADC3 -Mcu.IP10=SPI4 -Mcu.IP11=SYS -Mcu.IP12=USB_OTG_FS -Mcu.IP13=USB_OTG_HS -Mcu.IP2=DMA -Mcu.IP3=FMC -Mcu.IP4=FREERTOS -Mcu.IP5=NVIC -Mcu.IP6=RCC -Mcu.IP7=RTC -Mcu.IP8=SAI1 -Mcu.IP9=SPI1 -Mcu.IPNb=14 +Mcu.IP0=ADC3 +Mcu.IP1=DMA +Mcu.IP10=SYS +Mcu.IP11=USB_OTG_FS +Mcu.IP12=USB_OTG_HS +Mcu.IP2=FMC +Mcu.IP3=FREERTOS +Mcu.IP4=NVIC +Mcu.IP5=RCC +Mcu.IP6=RTC +Mcu.IP7=SAI1 +Mcu.IP8=SPI1 +Mcu.IP9=SPI4 +Mcu.IPNb=13 Mcu.Name=STM32F427Z(G-I)Tx Mcu.Package=LQFP144 Mcu.Pin0=PE2 @@ -138,13 +128,13 @@ Mcu.Pin19=PC2 Mcu.Pin2=PE4 Mcu.Pin20=PC3 Mcu.Pin21=PA1 -Mcu.Pin22=PA3 -Mcu.Pin23=PA6 -Mcu.Pin24=PA7 -Mcu.Pin25=PC4 -Mcu.Pin26=PC5 -Mcu.Pin27=PB0 -Mcu.Pin28=PB1 +Mcu.Pin22=PA2 +Mcu.Pin23=PA3 +Mcu.Pin24=PA6 +Mcu.Pin25=PA7 +Mcu.Pin26=PC4 +Mcu.Pin27=PC5 +Mcu.Pin28=PB0 Mcu.Pin29=PB2/BOOT1 Mcu.Pin3=PE5 Mcu.Pin30=PF11 @@ -251,6 +241,8 @@ PA13.Mode=Serial_Wire PA13.Signal=SYS_JTMS-SWDIO PA14.Mode=Serial_Wire PA14.Signal=SYS_JTCK-SWCLK +PA2.Locked=true +PA2.Signal=ADCx_IN2 PA3.GPIOParameters=GPIO_Label PA3.GPIO_Label=EXP PA3.Signal=ADCx_IN3 @@ -270,10 +262,6 @@ PB0.GPIOParameters=GPIO_Label PB0.GPIO_Label=FLASH_WP PB0.Locked=true PB0.Signal=GPIO_Output -PB1.GPIOParameters=GPIO_Label -PB1.GPIO_Label=EXP_RING -PB1.Locked=true -PB1.Signal=ADCx_IN9 PB10.GPIOParameters=GPIO_Label PB10.GPIO_Label=CS_nCS PB10.Locked=true @@ -550,10 +538,10 @@ SH.ADCx_IN12.ConfNb=2 SH.ADCx_IN13.0=ADC3_IN13,IN13 SH.ADCx_IN13.1=ADC1_IN13 SH.ADCx_IN13.ConfNb=2 +SH.ADCx_IN2.0=ADC3_IN2,IN2 +SH.ADCx_IN2.ConfNb=1 SH.ADCx_IN3.0=ADC3_IN3,IN3 SH.ADCx_IN3.ConfNb=1 -SH.ADCx_IN9.0=ADC1_IN9,IN9 -SH.ADCx_IN9.ConfNb=1 SH.FMC_A0.0=FMC_A0,12b-sda1 SH.FMC_A0.ConfNb=1 SH.FMC_A1.0=FMC_A1,12b-sda1 diff --git a/OwlPedal2/Src/OwlPedal.cpp b/OwlPedal2/Src/OwlPedal.cpp index 36673b22..a4c8ab2f 100644 --- a/OwlPedal2/Src/OwlPedal.cpp +++ b/OwlPedal2/Src/OwlPedal.cpp @@ -21,7 +21,8 @@ static uint8_t patchselect; // Pin footswitch_pin(GPIOA, GPIO_PIN_0); Pin bypass_pin(GPIOA, GPIO_PIN_0); Pin bufpass_pin(GPIOF, GPIO_PIN_9); // high is bypass -Pin exp1_ring_pin(GPIOA, GPIO_PIN_2); +Pin exp1_tip_pin(GPIOA, GPIO_PIN_2); +Pin exp1_ring_pin(GPIOA, GPIO_PIN_3); Pin led_green_pin(GPIOB, GPIO_PIN_8); Pin led_red_pin(GPIOB, GPIO_PIN_9); @@ -123,13 +124,23 @@ void setGateValue(uint8_t ch, int16_t value){ } } +void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* adc_values, size_t adc_len){ + parameter_values[0] = (parameter_values[0]*3 + adc_values[ADC_A])>>2; + parameter_values[1] = (parameter_values[1]*3 + adc_values[ADC_B])>>2; + parameter_values[2] = (parameter_values[2]*3 + adc_values[ADC_C])>>2; + parameter_values[3] = (parameter_values[3]*3 + adc_values[ADC_D])>>2; + parameter_values[4] = (parameter_values[4]*3 + 4095-adc_values[ADC_E])>>2; +} + void onSetup(){ bypass_pin.outputMode(); bypass_pin.low(); bufpass_pin.outputMode(); bufpass_pin.low(); + // Ring is available on ADC_F exp1_ring_pin.outputMode(); exp1_ring_pin.high(); + // exp1_tip_pin.analogMode(); led_green_pin.outputMode(); led_red_pin.outputMode(); diff --git a/OwlPedal2/Src/main.c b/OwlPedal2/Src/main.c index 976476ba..c5864a64 100644 --- a/OwlPedal2/Src/main.c +++ b/OwlPedal2/Src/main.c @@ -74,7 +74,6 @@ /* USER CODE END PM */ /* Private variables ---------------------------------------------------------*/ -ADC_HandleTypeDef hadc1; ADC_HandleTypeDef hadc3; DMA_HandleTypeDef hdma_adc3; @@ -110,7 +109,6 @@ static void MX_SAI1_Init(void); static void MX_SPI1_Init(void); static void MX_SPI4_Init(void); static void MX_RTC_Init(void); -static void MX_ADC1_Init(void); static void MX_USB_OTG_HS_PCD_Init(void); static void MX_USB_OTG_FS_PCD_Init(void); void StartDefaultTask(void const * argument); @@ -173,7 +171,6 @@ int main(void) MX_SPI1_Init(); MX_SPI4_Init(); MX_RTC_Init(); - MX_ADC1_Init(); MX_USB_OTG_HS_PCD_Init(); MX_USB_OTG_FS_PCD_Init(); /* USER CODE BEGIN 2 */ @@ -318,56 +315,6 @@ void PeriphCommonClock_Config(void) } } -/** - * @brief ADC1 Initialization Function - * @param None - * @retval None - */ -static void MX_ADC1_Init(void) -{ - - /* USER CODE BEGIN ADC1_Init 0 */ - - /* USER CODE END ADC1_Init 0 */ - - ADC_ChannelConfTypeDef sConfig = {0}; - - /* USER CODE BEGIN ADC1_Init 1 */ - - /* USER CODE END ADC1_Init 1 */ - /** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion) - */ - hadc1.Instance = ADC1; - hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV8; - hadc1.Init.Resolution = ADC_RESOLUTION_12B; - hadc1.Init.ScanConvMode = ENABLE; - hadc1.Init.ContinuousConvMode = ENABLE; - hadc1.Init.DiscontinuousConvMode = DISABLE; - hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; - hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START; - hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT; - hadc1.Init.NbrOfConversion = 1; - hadc1.Init.DMAContinuousRequests = DISABLE; - hadc1.Init.EOCSelection = ADC_EOC_SEQ_CONV; - if (HAL_ADC_Init(&hadc1) != HAL_OK) - { - Error_Handler(); - } - /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. - */ - sConfig.Channel = ADC_CHANNEL_9; - sConfig.Rank = 1; - sConfig.SamplingTime = ADC_SAMPLETIME_144CYCLES; - if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN ADC1_Init 2 */ - - /* USER CODE END ADC1_Init 2 */ - -} - /** * @brief ADC3 Initialization Function * @param None @@ -396,7 +343,7 @@ static void MX_ADC3_Init(void) hadc3.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; hadc3.Init.ExternalTrigConv = ADC_SOFTWARE_START; hadc3.Init.DataAlign = ADC_DATAALIGN_RIGHT; - hadc3.Init.NbrOfConversion = 5; + hadc3.Init.NbrOfConversion = 6; hadc3.Init.DMAContinuousRequests = ENABLE; hadc3.Init.EOCSelection = ADC_EOC_SEQ_CONV; if (HAL_ADC_Init(&hadc3) != HAL_OK) @@ -438,12 +385,20 @@ static void MX_ADC3_Init(void) } /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. */ - sConfig.Channel = ADC_CHANNEL_3; + sConfig.Channel = ADC_CHANNEL_2; sConfig.Rank = 5; if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK) { Error_Handler(); } + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + */ + sConfig.Channel = ADC_CHANNEL_3; + sConfig.Rank = 6; + if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK) + { + Error_Handler(); + } /* USER CODE BEGIN ADC3_Init 2 */ /* USER CODE END ADC3_Init 2 */ @@ -790,12 +745,12 @@ static void MX_GPIO_Init(void) /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOB, FLASH_WP_Pin|EXP_TIP_Pin|CS_nCS_Pin|CS_nRST_Pin, GPIO_PIN_RESET); - /*Configure GPIO pins : PC13 PC14 PC6 PC7 - PC8 PC9 PC10 PC11 - PC12 */ - GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_6|GPIO_PIN_7 - |GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11 - |GPIO_PIN_12; + /*Configure GPIO pins : PC13 PC14 ADC3_Pin ADC2_Pin + ADC1_Pin PC6 PC7 PC8 + PC9 PC10 PC11 PC12 */ + GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|ADC3_Pin|ADC2_Pin + |ADC1_Pin|GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8 + |GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); @@ -819,10 +774,10 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); - /*Configure GPIO pins : PA0 PA2 PA4 PA5 - PA8 PA10 PA15 */ - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_4|GPIO_PIN_5 - |GPIO_PIN_8|GPIO_PIN_10|GPIO_PIN_15; + /*Configure GPIO pins : PA0 PA4 PA5 PA8 + PA10 PA15 */ + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_8 + |GPIO_PIN_10|GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); @@ -840,10 +795,10 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - /*Configure GPIO pins : PB12 PB4 PB7 PB8 - PB9 */ - GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_4|GPIO_PIN_7|GPIO_PIN_8 - |GPIO_PIN_9; + /*Configure GPIO pins : PB1 PB12 PB4 PB7 + PB8 PB9 */ + GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_12|GPIO_PIN_4|GPIO_PIN_7 + |GPIO_PIN_8|GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); diff --git a/OwlPedal2/Src/stm32f4xx_hal_msp.c b/OwlPedal2/Src/stm32f4xx_hal_msp.c index 3894c08c..8464b3ea 100644 --- a/OwlPedal2/Src/stm32f4xx_hal_msp.c +++ b/OwlPedal2/Src/stm32f4xx_hal_msp.c @@ -119,40 +119,7 @@ void HAL_MspInit(void) void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) { GPIO_InitTypeDef GPIO_InitStruct = {0}; - if(hadc->Instance==ADC1) - { - /* USER CODE BEGIN ADC1_MspInit 0 */ - - /* USER CODE END ADC1_MspInit 0 */ - /* Peripheral clock enable */ - __HAL_RCC_ADC1_CLK_ENABLE(); - - __HAL_RCC_GPIOC_CLK_ENABLE(); - __HAL_RCC_GPIOB_CLK_ENABLE(); - /**ADC1 GPIO Configuration - PC1 ------> ADC1_IN11 - PC2 ------> ADC1_IN12 - PC3 ------> ADC1_IN13 - PB1 ------> ADC1_IN9 - */ - GPIO_InitStruct.Pin = ADC3_Pin|ADC2_Pin|ADC1_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = EXP_RING_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(EXP_RING_GPIO_Port, &GPIO_InitStruct); - - /* ADC1 interrupt Init */ - HAL_NVIC_SetPriority(ADC_IRQn, 10, 0); - HAL_NVIC_EnableIRQ(ADC_IRQn); - /* USER CODE BEGIN ADC1_MspInit 1 */ - - /* USER CODE END ADC1_MspInit 1 */ - } - else if(hadc->Instance==ADC3) + if(hadc->Instance==ADC3) { /* USER CODE BEGIN ADC3_MspInit 0 */ @@ -168,6 +135,7 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) PC1 ------> ADC3_IN11 PC2 ------> ADC3_IN12 PC3 ------> ADC3_IN13 + PA2 ------> ADC3_IN2 PA3 ------> ADC3_IN3 */ GPIO_InitStruct.Pin = ADC4_Pin; @@ -180,10 +148,10 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - GPIO_InitStruct.Pin = EXP_Pin; + GPIO_InitStruct.Pin = GPIO_PIN_2|EXP_Pin; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(EXP_GPIO_Port, &GPIO_InitStruct); + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* ADC3 DMA Init */ /* ADC3 Init */ @@ -222,38 +190,7 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) */ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) { - if(hadc->Instance==ADC1) - { - /* USER CODE BEGIN ADC1_MspDeInit 0 */ - - /* USER CODE END ADC1_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_ADC1_CLK_DISABLE(); - - /**ADC1 GPIO Configuration - PC1 ------> ADC1_IN11 - PC2 ------> ADC1_IN12 - PC3 ------> ADC1_IN13 - PB1 ------> ADC1_IN9 - */ - HAL_GPIO_DeInit(GPIOC, ADC3_Pin|ADC2_Pin|ADC1_Pin); - - HAL_GPIO_DeInit(EXP_RING_GPIO_Port, EXP_RING_Pin); - - /* ADC1 interrupt DeInit */ - /* USER CODE BEGIN ADC1:ADC_IRQn disable */ - /** - * Uncomment the line below to disable the "ADC_IRQn" interrupt - * Be aware, disabling shared interrupt may affect other IPs - */ - /* HAL_NVIC_DisableIRQ(ADC_IRQn); */ - /* USER CODE END ADC1:ADC_IRQn disable */ - - /* USER CODE BEGIN ADC1_MspDeInit 1 */ - - /* USER CODE END ADC1_MspDeInit 1 */ - } - else if(hadc->Instance==ADC3) + if(hadc->Instance==ADC3) { /* USER CODE BEGIN ADC3_MspDeInit 0 */ @@ -266,26 +203,20 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) PC1 ------> ADC3_IN11 PC2 ------> ADC3_IN12 PC3 ------> ADC3_IN13 + PA2 ------> ADC3_IN2 PA3 ------> ADC3_IN3 */ HAL_GPIO_DeInit(ADC4_GPIO_Port, ADC4_Pin); HAL_GPIO_DeInit(GPIOC, ADC3_Pin|ADC2_Pin|ADC1_Pin); - HAL_GPIO_DeInit(EXP_GPIO_Port, EXP_Pin); + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|EXP_Pin); /* ADC3 DMA DeInit */ HAL_DMA_DeInit(hadc->DMA_Handle); /* ADC3 interrupt DeInit */ - /* USER CODE BEGIN ADC3:ADC_IRQn disable */ - /** - * Uncomment the line below to disable the "ADC_IRQn" interrupt - * Be aware, disabling shared interrupt may affect other IPs - */ - /* HAL_NVIC_DisableIRQ(ADC_IRQn); */ - /* USER CODE END ADC3:ADC_IRQn disable */ - + HAL_NVIC_DisableIRQ(ADC_IRQn); /* USER CODE BEGIN ADC3_MspDeInit 1 */ /* USER CODE END ADC3_MspDeInit 1 */ diff --git a/OwlPedal2/Src/stm32f4xx_it.c b/OwlPedal2/Src/stm32f4xx_it.c index c4121b26..3a63a2e7 100644 --- a/OwlPedal2/Src/stm32f4xx_it.c +++ b/OwlPedal2/Src/stm32f4xx_it.c @@ -75,7 +75,6 @@ /* External variables --------------------------------------------------------*/ extern DMA_HandleTypeDef hdma_adc3; -extern ADC_HandleTypeDef hadc1; extern ADC_HandleTypeDef hadc3; extern DMA_HandleTypeDef hdma_sai1_a; extern DMA_HandleTypeDef hdma_sai1_b; @@ -155,7 +154,6 @@ void ADC_IRQHandler(void) /* USER CODE BEGIN ADC_IRQn 0 */ /* USER CODE END ADC_IRQn 0 */ - HAL_ADC_IRQHandler(&hadc1); HAL_ADC_IRQHandler(&hadc3); /* USER CODE BEGIN ADC_IRQn 1 */ From 4f2e50fab9bfcacaf825a7b32d722cd8d07aa5c0 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 19 Nov 2021 21:26:00 +0100 Subject: [PATCH 191/286] set bypass state on run mode --- OwlPedal2/Src/OwlPedal.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OwlPedal2/Src/OwlPedal.cpp b/OwlPedal2/Src/OwlPedal.cpp index a4c8ab2f..01ef730a 100644 --- a/OwlPedal2/Src/OwlPedal.cpp +++ b/OwlPedal2/Src/OwlPedal.cpp @@ -155,13 +155,17 @@ void onSetup(){ static uint32_t counter = 0; void onChangeMode(OperationMode new_mode, OperationMode old_mode){ counter = 0; + setLed(0, NO_COLOUR); if(new_mode == CONFIGURE_MODE){ knobvalues[0] = getAnalogValue(PATCH_CONFIG_PROGRAM_CONTROL); knobvalues[1] = getAnalogValue(PATCH_CONFIG_VOLUME_CONTROL); patchselect = program.getProgramIndex(); - // }else if(old_mode == CONFIGURE_MODE && new_mode == RUN_MODE){ }else if(new_mode == RUN_MODE){ - setLed(0, getButtonValue(0) ? NO_COLOUR : GREEN_COLOUR); // set green led if not in bypass mode + if(HAL_GPIO_ReadPin(FOOTSWITCH_GPIO_Port, FOOTSWITCH_Pin) == GPIO_PIN_RESET){ + setButtonValue(0, true); + }else{ + setLed(0, GREEN_COLOUR); // todo: restore to saved state + } } } From 2a113f4a486b3d4d370e520d4770b97560792c93 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 22 Nov 2021 11:50:30 +0100 Subject: [PATCH 192/286] encoder handling changes --- Genius/Inc/GeniusParameterController.hpp | 41 ++++++++++++++---------- Genius/Src/main.c | 10 +++--- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/Genius/Inc/GeniusParameterController.hpp b/Genius/Inc/GeniusParameterController.hpp index 35af4174..e5d4414e 100644 --- a/Genius/Inc/GeniusParameterController.hpp +++ b/Genius/Inc/GeniusParameterController.hpp @@ -42,7 +42,7 @@ class Page { // virtual void updateEncoders(int16_t* data, uint8_t size){} virtual void enter(){} virtual void exit(){} - virtual void encoderChanged(uint8_t encoder, int32_t delta, int32_t previous){} + virtual void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){} }; class GeniusParameterController : public ParameterController { @@ -73,16 +73,16 @@ class GeniusParameterController : public ParameterController { } void updateEncoders(int16_t* data, uint8_t size){ if(data[0] != encoders[0]){ - encoderChanged(0, data[0] - encoders[0], encoders[0]); + encoderChanged(0, data[0], encoders[0]); encoders[0] = data[0]; } if(data[1] != encoders[1]){ - encoderChanged(1, data[1] - encoders[1], encoders[1]); + encoderChanged(1, data[1], encoders[1]); encoders[1] = data[1]; } } - void encoderChanged(uint8_t encoder, int32_t delta, int32_t previous){ - page->encoderChanged(encoder, delta, previous); + void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ + page->encoderChanged(encoder, current, previous); } // update value with encoder void setUserValue(uint8_t ch, int16_t value){ @@ -122,18 +122,21 @@ class SelectControlPage : public Page { const uint8_t ctrl; size_t counter; // ticks since switch was pressed down static constexpr size_t TOGGLE_LIMIT = (400/SCREEN_LOOP_SLEEP_MS); + int8_t remainder = 0; public: int8_t select; SelectControlPage(uint8_t ctrl, int8_t select): ctrl(ctrl), select(select){} void enter(){ counter = 0; } - void encoderChanged(uint8_t encoder, int32_t delta, int32_t previous){ + void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ if(encoder == ctrl){ - delta = (delta + (previous & 0x03)) / 4; - if(delta > 0) + int32_t delta = current - previous + remainder; + int32_t value = delta / 4; // or use `struct div_t std::div(int, int)` + remainder = delta - value * 4; // ARM Cortex SDIV instruction discards remainder + if(value > 0) select = min(NOF_PARAMETERS-1, select+1); - else if(delta < 0) + else if(value < 0) select = max(0, select-1); } } @@ -226,7 +229,7 @@ class ExitPage : public Page { class StatsPage : public Page { public: - void encoderChanged(uint8_t encoder, int32_t delta, int32_t previous){} + void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){} void draw(ScreenBuffer& screen){ if(sw1() || sw2()){ setDisplayMode(EXIT_DISPLAY_MODE); @@ -275,19 +278,22 @@ class AssignPage : public Page { private: uint8_t select; uint8_t assign; + int8_t remainder = 0; static constexpr const char* assignations[] = {"CV A In", "CV B In", "CV A Out", "CV B Out"}; public: - void encoderChanged(uint8_t encoder, int32_t delta, int32_t previous){ - delta = (delta + (previous & 0x03)) / 4; + void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ + int32_t delta = current - previous + remainder; + int32_t value = delta / 4; + remainder = delta - value * 4; // ARM Cortex SDIV instruction discards remainder if(encoder == 0){ - if(delta > 0) + if(value > 0) select = min(3, select+1); - else if(delta < 0) + else if(value < 0) select = max(0, select-1); }else{ - if(delta > 0) + if(value > 0) assign = min(NOF_PARAMETERS-1, assign+1); - else if(delta < 0) + else if(value < 0) assign = max(0, assign-1); } } @@ -311,7 +317,8 @@ class AssignPage : public Page { class StandardPage : public Page { public: - void encoderChanged(uint8_t encoder, int32_t delta, int32_t previous){ + void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ + int32_t delta = current - previous; int select = encoder == 0 ? selectOnePage.select : selectTwoPage.select; if(delta > 0) delta = 20 << (delta/2); diff --git a/Genius/Src/main.c b/Genius/Src/main.c index 6a674eb6..b4c1de71 100644 --- a/Genius/Src/main.c +++ b/Genius/Src/main.c @@ -519,7 +519,7 @@ static void MX_SPI2_Init(void) hspi2.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; hspi2.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE; hspi2.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE; - hspi2.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE; + hspi2.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE; hspi2.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE; hspi2.Init.IOSwap = SPI_IO_SWAP_DISABLE; if (HAL_SPI_Init(&hspi2) != HAL_OK) @@ -656,11 +656,11 @@ static void MX_TIM2_Init(void) sConfig.IC1Polarity = TIM_ICPOLARITY_RISING; sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI; sConfig.IC1Prescaler = TIM_ICPSC_DIV1; - sConfig.IC1Filter = 8; + sConfig.IC1Filter = 0; sConfig.IC2Polarity = TIM_ICPOLARITY_RISING; sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI; sConfig.IC2Prescaler = TIM_ICPSC_DIV1; - sConfig.IC2Filter = 8; + sConfig.IC2Filter = 0; if (HAL_TIM_Encoder_Init(&htim2, &sConfig) != HAL_OK) { Error_Handler(); @@ -705,11 +705,11 @@ static void MX_TIM3_Init(void) sConfig.IC1Polarity = TIM_ICPOLARITY_RISING; sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI; sConfig.IC1Prescaler = TIM_ICPSC_DIV1; - sConfig.IC1Filter = 8; + sConfig.IC1Filter = 0; sConfig.IC2Polarity = TIM_ICPOLARITY_RISING; sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI; sConfig.IC2Prescaler = TIM_ICPSC_DIV1; - sConfig.IC2Filter = 8; + sConfig.IC2Filter = 0; if (HAL_TIM_Encoder_Init(&htim3, &sConfig) != HAL_OK) { Error_Handler(); From aba31c9490bdd1d6b7ca2323c8244fd30f66dfa6 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 25 Nov 2021 22:17:19 +0100 Subject: [PATCH 193/286] optional PWM LED control --- OwlPedal2/Inc/main.h | 2 + OwlPedal2/Inc/stm32f4xx_hal_conf.h | 2 +- OwlPedal2/OwlPedal2.ioc | 39 +++++--- OwlPedal2/Src/OwlPedal.cpp | 138 +++++++++++++++++++++-------- OwlPedal2/Src/main.c | 64 ++++++++++++- OwlPedal2/Src/stm32f4xx_hal_msp.c | 75 +++++++++++++++- 6 files changed, 267 insertions(+), 53 deletions(-) diff --git a/OwlPedal2/Inc/main.h b/OwlPedal2/Inc/main.h index 7f6aaef3..0948f1f9 100644 --- a/OwlPedal2/Inc/main.h +++ b/OwlPedal2/Inc/main.h @@ -80,6 +80,8 @@ extern "C" { /* USER CODE END EM */ +void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); + /* Exported functions prototypes ---------------------------------------------*/ void Error_Handler(void); diff --git a/OwlPedal2/Inc/stm32f4xx_hal_conf.h b/OwlPedal2/Inc/stm32f4xx_hal_conf.h index 396890ad..2ea0e68a 100644 --- a/OwlPedal2/Inc/stm32f4xx_hal_conf.h +++ b/OwlPedal2/Inc/stm32f4xx_hal_conf.h @@ -62,7 +62,7 @@ /* #define HAL_SD_MODULE_ENABLED */ /* #define HAL_MMC_MODULE_ENABLED */ #define HAL_SPI_MODULE_ENABLED -/* #define HAL_TIM_MODULE_ENABLED */ +#define HAL_TIM_MODULE_ENABLED /* #define HAL_UART_MODULE_ENABLED */ /* #define HAL_USART_MODULE_ENABLED */ /* #define HAL_IRDA_MODULE_ENABLED */ diff --git a/OwlPedal2/OwlPedal2.ioc b/OwlPedal2/OwlPedal2.ioc index cd6a3533..d0c234cb 100644 --- a/OwlPedal2/OwlPedal2.ioc +++ b/OwlPedal2/OwlPedal2.ioc @@ -100,8 +100,9 @@ Mcu.Family=STM32F4 Mcu.IP0=ADC3 Mcu.IP1=DMA Mcu.IP10=SYS -Mcu.IP11=USB_OTG_FS -Mcu.IP12=USB_OTG_HS +Mcu.IP11=TIM4 +Mcu.IP12=USB_OTG_FS +Mcu.IP13=USB_OTG_HS Mcu.IP2=FMC Mcu.IP3=FREERTOS Mcu.IP4=NVIC @@ -110,7 +111,7 @@ Mcu.IP6=RTC Mcu.IP7=SAI1 Mcu.IP8=SPI1 Mcu.IP9=SPI4 -Mcu.IPNb=13 +Mcu.IPNb=14 Mcu.Name=STM32F427Z(G-I)Tx Mcu.Package=LQFP144 Mcu.Pin0=PE2 @@ -185,14 +186,16 @@ Mcu.Pin70=PG15 Mcu.Pin71=PB3 Mcu.Pin72=PB5 Mcu.Pin73=PB6 -Mcu.Pin74=PE0 -Mcu.Pin75=PE1 -Mcu.Pin76=VP_FREERTOS_VS_CMSIS_V1 -Mcu.Pin77=VP_RTC_VS_RTC_Activate -Mcu.Pin78=VP_SYS_VS_Systick +Mcu.Pin74=PB8 +Mcu.Pin75=PB9 +Mcu.Pin76=PE0 +Mcu.Pin77=PE1 +Mcu.Pin78=VP_FREERTOS_VS_CMSIS_V1 +Mcu.Pin79=VP_RTC_VS_RTC_Activate Mcu.Pin8=PF2 +Mcu.Pin80=VP_SYS_VS_Systick Mcu.Pin9=PF3 -Mcu.PinsNb=79 +Mcu.PinsNb=81 Mcu.ThirdPartyNb=0 Mcu.UserConstants= Mcu.UserName=STM32F427ZITx @@ -289,6 +292,12 @@ PB5.Mode=SdramChipSelect2_1 PB5.Signal=FMC_SDCKE1 PB6.Mode=SdramChipSelect2_1 PB6.Signal=FMC_SDNE1 +PB8.GPIOParameters=GPIO_Speed +PB8.GPIO_Speed=GPIO_SPEED_FREQ_HIGH +PB8.Signal=S_TIM4_CH3 +PB9.GPIOParameters=GPIO_Speed +PB9.GPIO_Speed=GPIO_SPEED_FREQ_HIGH +PB9.Signal=S_TIM4_CH4 PC0.Signal=FMC_SDNWE PC1.GPIOParameters=GPIO_Label PC1.GPIO_Label=ADC3 @@ -440,7 +449,7 @@ ProjectManager.StackSize=0x400 ProjectManager.TargetToolchain=Other Toolchains (GPDSC) ProjectManager.ToolChainLocation= ProjectManager.UnderRoot=false -ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-SystemClock_Config-RCC-false-HAL-true,9-MX_RTC_Init-RTC-false-HAL-true,10-MX_ADC1_Init-ADC1-false-HAL-true,11-MX_USB_OTG_HS_PCD_Init-USB_OTG_HS-false-HAL-true,12-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-false-HAL-true +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-SystemClock_Config-RCC-false-HAL-true,9-MX_RTC_Init-RTC-false-HAL-true,10-MX_USB_OTG_HS_PCD_Init-USB_OTG_HS-false-HAL-true,11-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-false-HAL-true,12-MX_TIM4_Init-TIM4-false-HAL-true RCC.48MHZClocksFreq_Value=48000000 RCC.AHBFreq_Value=168000000 RCC.APB1CLKDivider=RCC_HCLK_DIV4 @@ -626,6 +635,10 @@ SH.GPXTI8.0=GPIO_EXTI8 SH.GPXTI8.ConfNb=1 SH.GPXTI9.0=GPIO_EXTI9 SH.GPXTI9.ConfNb=1 +SH.S_TIM4_CH3.0=TIM4_CH3,PWM Generation3 CH3 +SH.S_TIM4_CH3.ConfNb=1 +SH.S_TIM4_CH4.0=TIM4_CH4,PWM Generation4 CH4 +SH.S_TIM4_CH4.ConfNb=1 SPI1.CalculateBaudRate=42.0 MBits/s SPI1.Direction=SPI_DIRECTION_2LINES SPI1.IPParameters=Mode,CalculateBaudRate,VirtualType,Direction @@ -637,6 +650,12 @@ SPI4.Direction=SPI_DIRECTION_2LINES SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,VirtualType,Direction SPI4.Mode=SPI_MODE_MASTER SPI4.VirtualType=VM_MASTER +TIM4.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3 +TIM4.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4 +TIM4.IPParameters=Channel-PWM Generation3 CH3,Channel-PWM Generation4 CH4,Period,Prescaler,OCPolarity_4 +TIM4.OCPolarity_4=TIM_OCPOLARITY_LOW +TIM4.Period=1023 +TIM4.Prescaler=100 USB_OTG_FS.IPParameters=VirtualMode USB_OTG_FS.VirtualMode=Device_Only USB_OTG_HS.IPParameters=VirtualMode-Device_Only_FS diff --git a/OwlPedal2/Src/OwlPedal.cpp b/OwlPedal2/Src/OwlPedal.cpp index 01ef730a..5a7a4070 100644 --- a/OwlPedal2/Src/OwlPedal.cpp +++ b/OwlPedal2/Src/OwlPedal.cpp @@ -9,8 +9,9 @@ #include "Pin.h" #include "usb_device.h" -#define PATCH_RESET_COUNTER (1000/MAIN_LOOP_SLEEP_MS) -#define PATCH_CONFIG_COUNTER (3000/MAIN_LOOP_SLEEP_MS) +#define PATCH_RESET_COUNTER (1024/MAIN_LOOP_SLEEP_MS) +#define PATCH_CONFIG_COUNTER (3072/MAIN_LOOP_SLEEP_MS) +#define PATCH_INDICATOR_COUNTER (128/MAIN_LOOP_SLEEP_MS) static int16_t knobvalues[2]; static uint8_t patchselect; @@ -31,7 +32,25 @@ Pin led_red_pin(GPIOB, GPIO_PIN_9); #define SW4_Pin EXP2_R_Pin #define SW4_GPIO_Port EXP2_R_GPIO_Port +void initLed(){ +#ifdef OWL_PEDAL_PWM_LEDS + extern TIM_HandleTypeDef htim4; + HAL_TIM_Base_Start(&htim4); + HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_3); + HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_4); +#else + led_green_pin.outputMode(); + led_red_pin.outputMode(); +#endif +} + void setLed(uint8_t led, uint32_t rgb){ +#ifdef OWL_PEDAL_PWM_LEDS + uint32_t r = 1023 - ((rgb>>20) & 0x3ff); + uint32_t g = 1023 - ((rgb>>10) & 0x3ff); + TIM4->CCR3 = r; + TIM4->CCR4 = g; +#else switch(rgb){ case RED_COLOUR: led_green_pin.low(); @@ -45,7 +64,10 @@ void setLed(uint8_t led, uint32_t rgb){ led_green_pin.low(); led_red_pin.low(); break; + default: + break; } +#endif } bool getBufferedBypass(){ @@ -57,6 +79,10 @@ void setBufferedBypass(bool value){ bufpass_pin.set(!value); } +bool isBypassed(){ + return HAL_GPIO_ReadPin(FOOTSWITCH_GPIO_Port, FOOTSWITCH_Pin) == GPIO_PIN_RESET; +} + bool isPushbuttonPressed(){ return HAL_GPIO_ReadPin(SW1_GPIO_Port, SW1_Pin) == GPIO_PIN_RESET || HAL_GPIO_ReadPin(SW1_ALT_GPIO_Port, SW1_ALT_Pin) == GPIO_PIN_RESET; @@ -65,10 +91,9 @@ bool isPushbuttonPressed(){ void onChangePin(uint16_t pin){ switch(pin){ case FOOTSWITCH_Pin: { // bypass / stomp switch - bool state = HAL_GPIO_ReadPin(FOOTSWITCH_GPIO_Port, FOOTSWITCH_Pin) == GPIO_PIN_RESET; + bool state = isBypassed(); setButtonValue(0, state); setLed(0, state ? NO_COLOUR : GREEN_COLOUR); - // todo: save LED state // todo: only allow config mode in bypass? break; @@ -80,10 +105,10 @@ void onChangePin(uint16_t pin){ setButtonValue(BUTTON_A, state); setLed(0, state ? RED_COLOUR : GREEN_COLOUR); midi_tx.sendCc(PATCH_BUTTON, state ? 127 : 0); - // if(state){ - // // toggle buffered bypass - // setBufferedBypass(!getBufferedBypass()); - // } + if(state && owl.getOperationMode() == CONFIGURE_MODE){ + // exit configure mode + owl.setOperationMode(RUN_MODE); + } break; } case SW2_Pin: { // mode button @@ -108,9 +133,6 @@ void setGateValue(uint8_t ch, int16_t value){ switch(ch){ case PUSHBUTTON: setLed(0, value ? RED_COLOUR : GREEN_COLOUR); -#ifdef OWL_MODULAR - HAL_GPIO_WritePin(PUSH_GATE_OUT_GPIO_Port, PUSH_GATE_OUT_Pin, value ? GPIO_PIN_RESET : GPIO_PIN_SET); -#endif break; case GREEN_BUTTON: setLed(0, value ? GREEN_COLOUR : NO_COLOUR); @@ -133,6 +155,7 @@ void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* } void onSetup(){ + initLed(); bypass_pin.outputMode(); bypass_pin.low(); bufpass_pin.outputMode(); @@ -142,9 +165,6 @@ void onSetup(){ exp1_ring_pin.high(); // exp1_tip_pin.analogMode(); - led_green_pin.outputMode(); - led_red_pin.outputMode(); - setLed(0, RED_COLOUR); MX_USB_DEVICE_Init(); @@ -160,16 +180,24 @@ void onChangeMode(OperationMode new_mode, OperationMode old_mode){ knobvalues[0] = getAnalogValue(PATCH_CONFIG_PROGRAM_CONTROL); knobvalues[1] = getAnalogValue(PATCH_CONFIG_VOLUME_CONTROL); patchselect = program.getProgramIndex(); + counter = PATCH_RESET_COUNTER; + }else if(new_mode == BYPASS_MODE){ + setLed(0, NO_COLOUR); // todo: save LED state }else if(new_mode == RUN_MODE){ - if(HAL_GPIO_ReadPin(FOOTSWITCH_GPIO_Port, FOOTSWITCH_Pin) == GPIO_PIN_RESET){ - setButtonValue(0, true); - }else{ - setLed(0, GREEN_COLOUR); // todo: restore to saved state + if(old_mode == CONFIGURE_MODE){ + if(program.getProgramIndex() != patchselect && + registry.hasPatch(patchselect)){ + // change patch on mode button release + program.loadProgram(patchselect); // enters load mode (calls onChangeMode) + program.resetProgram(true); // true if setOperationMode() is called from button IRQ + // }else{ + // owl.setOperationMode(RUN_MODE); + } } + setLed(0, GREEN_COLOUR); // todo: restore to saved state } } - void onLoop(){ switch(owl.getOperationMode()){ case STARTUP_MODE: @@ -179,33 +207,54 @@ void onLoop(){ counter = PATCH_RESET_COUNTER; break; case LOAD_MODE: - setLed(0, counter > PATCH_RESET_COUNTER/10 ? GREEN_COLOUR : NO_COLOUR); + setLed(0, counter > PATCH_INDICATOR_COUNTER/2 ? GREEN_COLOUR : NO_COLOUR); + // todo: use setProgress()? if(counter-- == 0) counter = PATCH_RESET_COUNTER; break; + case BYPASS_MODE: + if(!isBypassed()){ + owl.setOperationMode(RUN_MODE); + }else if(isPushbuttonPressed()){ + if(counter-- == 0){ + owl.setOperationMode(CONFIGURE_MODE); + }else if(counter % 100 == 0){ + led_green_pin.toggle(); + led_red_pin.toggle(); + } + }else{ + counter = PATCH_RESET_COUNTER; + } + break; case RUN_MODE: - if(getErrorStatus() != NO_ERROR) + if(getErrorStatus() != NO_ERROR){ owl.setOperationMode(ERROR_MODE); - if(isPushbuttonPressed()){ + }else if(isBypassed()){ + owl.setOperationMode(BYPASS_MODE); + }else if(isPushbuttonPressed()){ if(counter-- == 0){ owl.setOperationMode(CONFIGURE_MODE); - }else if(counter < PATCH_RESET_COUNTER){ - setLed(0, counter > PATCH_RESET_COUNTER/10 ? GREEN_COLOUR : NO_COLOUR); + }else if(counter < PATCH_RESET_COUNTER && counter % 100 == 0){ + led_green_pin.toggle(); + led_red_pin.toggle(); } }else{ counter = PATCH_CONFIG_COUNTER; } break; case CONFIGURE_MODE: - if(isPushbuttonPressed()){ + // if(isPushbuttonPressed()){ if(abs(knobvalues[0] - getAnalogValue(PATCH_CONFIG_PROGRAM_CONTROL)) >= PATCH_CONFIG_KNOB_THRESHOLD){ knobvalues[0] = -PATCH_CONFIG_KNOB_THRESHOLD; - uint8_t idx = 1 + (getAnalogValue(PATCH_CONFIG_PROGRAM_CONTROL) * registry.getNumberOfPatches()) / 4096; - if(registry.hasPatch(idx)){ + float idx = 1 + (getAnalogValue(PATCH_CONFIG_PROGRAM_CONTROL) * registry.getNumberOfPatches()) / 4096.0f; + if(abs(patchselect - idx) > 0.6 && registry.hasPatch(idx)){ // ensure a small dead zone patchselect = idx; midi_tx.sendPc(idx); - setLed(0, idx & 0x01 ? RED_COLOUR : GREEN_COLOUR); + // setLed(0, idx & 0x01 ? RED_COLOUR : GREEN_COLOUR); } + // }else{ + // led_green_pin.toggle(); + // led_red_pin.toggle(); } if(abs(knobvalues[1] - getAnalogValue(PATCH_CONFIG_VOLUME_CONTROL)) >= PATCH_CONFIG_KNOB_THRESHOLD){ knobvalues[1] = -PATCH_CONFIG_KNOB_THRESHOLD; @@ -216,16 +265,31 @@ void onLoop(){ midi_tx.sendCc(MIDI_CC_VOLUME, value); } } - }else{ - if(program.getProgramIndex() != patchselect && - registry.hasPatch(patchselect)){ - // change patch on mode button release - program.loadProgram(patchselect); // enters load mode (calls onChangeMode) - program.resetProgram(false); - }else{ - owl.setOperationMode(RUN_MODE); + if(counter-- == 0){ + counter = PATCH_RESET_COUNTER + PATCH_INDICATOR_COUNTER + PATCH_INDICATOR_COUNTER*2*patchselect; + setLed(0, NO_COLOUR); + }else if(counter <= PATCH_RESET_COUNTER){ + // toggle rapidly during 1 second for yellow-ish LED + led_red_pin.set(led_green_pin.get()); + led_green_pin.toggle(); + }else if(counter % PATCH_INDICATOR_COUNTER == 0){ + if(counter >= PATCH_RESET_COUNTER + 5*2*PATCH_INDICATOR_COUNTER){ + counter -= 4*PATCH_INDICATOR_COUNTER; + led_red_pin.toggle(); + }else{ + led_green_pin.toggle(); + } } - } + // if(isPushbuttonPressed()){ // exit configure mode + // if(program.getProgramIndex() != patchselect && + // registry.hasPatch(patchselect)){ + // // change patch on mode button release + // program.loadProgram(patchselect); // enters load mode (calls onChangeMode) + // program.resetProgram(false); + // }else{ + // owl.setOperationMode(RUN_MODE); + // } + // } break; case ERROR_MODE: setLed(0, counter > PATCH_RESET_COUNTER/2 ? RED_COLOUR : NO_COLOUR); diff --git a/OwlPedal2/Src/main.c b/OwlPedal2/Src/main.c index c5864a64..9ef28244 100644 --- a/OwlPedal2/Src/main.c +++ b/OwlPedal2/Src/main.c @@ -87,6 +87,8 @@ DMA_HandleTypeDef hdma_sai1_b; SPI_HandleTypeDef hspi1; SPI_HandleTypeDef hspi4; +TIM_HandleTypeDef htim4; + PCD_HandleTypeDef hpcd_USB_OTG_FS; PCD_HandleTypeDef hpcd_USB_OTG_HS; @@ -111,6 +113,7 @@ static void MX_SPI4_Init(void); static void MX_RTC_Init(void); static void MX_USB_OTG_HS_PCD_Init(void); static void MX_USB_OTG_FS_PCD_Init(void); +static void MX_TIM4_Init(void); void StartDefaultTask(void const * argument); /* USER CODE BEGIN PFP */ @@ -173,6 +176,7 @@ int main(void) MX_RTC_Init(); MX_USB_OTG_HS_PCD_Init(); MX_USB_OTG_FS_PCD_Init(); + MX_TIM4_Init(); /* USER CODE BEGIN 2 */ HAL_SAI_DeInit(&hsai_BlockA1); @@ -580,6 +584,60 @@ static void MX_SPI4_Init(void) } +/** + * @brief TIM4 Initialization Function + * @param None + * @retval None + */ +static void MX_TIM4_Init(void) +{ + + /* USER CODE BEGIN TIM4_Init 0 */ + + /* USER CODE END TIM4_Init 0 */ + + TIM_MasterConfigTypeDef sMasterConfig = {0}; + TIM_OC_InitTypeDef sConfigOC = {0}; + + /* USER CODE BEGIN TIM4_Init 1 */ + + /* USER CODE END TIM4_Init 1 */ + htim4.Instance = TIM4; + htim4.Init.Prescaler = 4; + htim4.Init.CounterMode = TIM_COUNTERMODE_UP; + htim4.Init.Period = 1023; + htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; + htim4.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; + if (HAL_TIM_PWM_Init(&htim4) != HAL_OK) + { + Error_Handler(); + } + sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; + sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; + if (HAL_TIMEx_MasterConfigSynchronization(&htim4, &sMasterConfig) != HAL_OK) + { + Error_Handler(); + } + sConfigOC.OCMode = TIM_OCMODE_PWM1; + sConfigOC.Pulse = 0; + sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; + sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; + if (HAL_TIM_PWM_ConfigChannel(&htim4, &sConfigOC, TIM_CHANNEL_3) != HAL_OK) + { + Error_Handler(); + } + sConfigOC.OCPolarity = TIM_OCPOLARITY_LOW; + if (HAL_TIM_PWM_ConfigChannel(&htim4, &sConfigOC, TIM_CHANNEL_4) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN TIM4_Init 2 */ + + /* USER CODE END TIM4_Init 2 */ + HAL_TIM_MspPostInit(&htim4); + +} + /** * @brief USB_OTG_FS Initialization Function * @param None @@ -795,10 +853,8 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - /*Configure GPIO pins : PB1 PB12 PB4 PB7 - PB8 PB9 */ - GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_12|GPIO_PIN_4|GPIO_PIN_7 - |GPIO_PIN_8|GPIO_PIN_9; + /*Configure GPIO pins : PB1 PB12 PB4 PB7 */ + GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_12|GPIO_PIN_4|GPIO_PIN_7; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); diff --git a/OwlPedal2/Src/stm32f4xx_hal_msp.c b/OwlPedal2/Src/stm32f4xx_hal_msp.c index 8464b3ea..db99b0c9 100644 --- a/OwlPedal2/Src/stm32f4xx_hal_msp.c +++ b/OwlPedal2/Src/stm32f4xx_hal_msp.c @@ -89,7 +89,9 @@ extern DMA_HandleTypeDef hdma_adc3; /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ -/** + +void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); + /** * Initializes the Global MSP. */ void HAL_MspInit(void) @@ -397,6 +399,77 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) } +/** +* @brief TIM_PWM MSP Initialization +* This function configures the hardware resources used in this example +* @param htim_pwm: TIM_PWM handle pointer +* @retval None +*/ +void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm) +{ + if(htim_pwm->Instance==TIM4) + { + /* USER CODE BEGIN TIM4_MspInit 0 */ + + /* USER CODE END TIM4_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_TIM4_CLK_ENABLE(); + /* USER CODE BEGIN TIM4_MspInit 1 */ + + /* USER CODE END TIM4_MspInit 1 */ + } + +} + +void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(htim->Instance==TIM4) + { + /* USER CODE BEGIN TIM4_MspPostInit 0 */ + + /* USER CODE END TIM4_MspPostInit 0 */ + + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**TIM4 GPIO Configuration + PB8 ------> TIM4_CH3 + PB9 ------> TIM4_CH4 + */ + GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF2_TIM4; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* USER CODE BEGIN TIM4_MspPostInit 1 */ + + /* USER CODE END TIM4_MspPostInit 1 */ + } + +} +/** +* @brief TIM_PWM MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param htim_pwm: TIM_PWM handle pointer +* @retval None +*/ +void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm) +{ + if(htim_pwm->Instance==TIM4) + { + /* USER CODE BEGIN TIM4_MspDeInit 0 */ + + /* USER CODE END TIM4_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_TIM4_CLK_DISABLE(); + /* USER CODE BEGIN TIM4_MspDeInit 1 */ + + /* USER CODE END TIM4_MspDeInit 1 */ + } + +} + /** * @brief PCD MSP Initialization * This function configures the hardware resources used in this example From ed003e97dbe48610e956e7b9e07e3f7f49e1edfc Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 29 Nov 2021 20:07:32 +0100 Subject: [PATCH 194/286] reassigned LED in1/2 TIMs and pins --- ACDC/ACDC.ioc | 234 ++++----- ACDC/Core/Inc/hardware.h | 6 +- ACDC/Core/Src/ACDC.cpp | 60 +-- ACDC/Core/Src/main.c | 112 +++-- ACDC/Core/Src/startup_stm32h743xx.s | 749 ++++++++++++++++++++++++++++ ACDC/Core/Src/stm32h7xx_hal_msp.c | 48 +- 6 files changed, 1010 insertions(+), 199 deletions(-) create mode 100644 ACDC/Core/Src/startup_stm32h743xx.s diff --git a/ACDC/ACDC.ioc b/ACDC/ACDC.ioc index ecafa878..1f8cc8c3 100644 --- a/ACDC/ACDC.ioc +++ b/ACDC/ACDC.ioc @@ -143,13 +143,14 @@ Mcu.IP10=SPI2 Mcu.IP11=SPI3 Mcu.IP12=SYS Mcu.IP13=TIM2 -Mcu.IP14=TIM4 -Mcu.IP15=TIM8 -Mcu.IP16=UART5 -Mcu.IP17=UART7 -Mcu.IP18=USB_DEVICE -Mcu.IP19=USB_OTG_FS +Mcu.IP14=TIM3 +Mcu.IP15=TIM4 +Mcu.IP16=TIM8 +Mcu.IP17=UART5 +Mcu.IP18=UART7 +Mcu.IP19=USB_DEVICE Mcu.IP2=DEBUG +Mcu.IP20=USB_OTG_FS Mcu.IP3=DMA Mcu.IP4=FMC Mcu.IP5=FREERTOS @@ -157,124 +158,122 @@ Mcu.IP6=NVIC Mcu.IP7=QUADSPI Mcu.IP8=RCC Mcu.IP9=SAI1 -Mcu.IPNb=20 +Mcu.IPNb=21 Mcu.Name=STM32H743IIKx Mcu.Package=UFBGA176 Mcu.Pin0=PE3 Mcu.Pin1=PE2 Mcu.Pin10=PE4 -Mcu.Pin100=PA7 -Mcu.Pin101=PB1 -Mcu.Pin102=PB0 -Mcu.Pin103=PF11 -Mcu.Pin104=PF14 -Mcu.Pin105=PE7 -Mcu.Pin106=PE10 -Mcu.Pin107=PE12 -Mcu.Pin108=PE15 -Mcu.Pin109=PB10 +Mcu.Pin100=PB0 +Mcu.Pin101=PF11 +Mcu.Pin102=PF14 +Mcu.Pin103=PE7 +Mcu.Pin104=PE10 +Mcu.Pin105=PE12 +Mcu.Pin106=PE15 +Mcu.Pin107=PB10 +Mcu.Pin108=PB11 +Mcu.Pin109=VP_FREERTOS_VS_CMSIS_V1 Mcu.Pin11=PE5 -Mcu.Pin110=PB11 -Mcu.Pin111=VP_FREERTOS_VS_CMSIS_V1 -Mcu.Pin112=VP_SYS_VS_Systick -Mcu.Pin113=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS +Mcu.Pin110=VP_SYS_VS_Systick +Mcu.Pin111=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS Mcu.Pin12=PE6 Mcu.Pin13=PB7 Mcu.Pin14=PB6 Mcu.Pin15=PG15 -Mcu.Pin16=PG12 -Mcu.Pin17=PG11 -Mcu.Pin18=PG10 -Mcu.Pin19=PD0 +Mcu.Pin16=PG10 +Mcu.Pin17=PD0 +Mcu.Pin18=PC10 +Mcu.Pin19=PA12 Mcu.Pin2=PE1 -Mcu.Pin20=PC10 -Mcu.Pin21=PA12 -Mcu.Pin22=PI7 -Mcu.Pin23=PI6 -Mcu.Pin24=PI5 -Mcu.Pin25=PD1 -Mcu.Pin26=PI3 -Mcu.Pin27=PI2 -Mcu.Pin28=PA11 -Mcu.Pin29=PC13 +Mcu.Pin20=PI7 +Mcu.Pin21=PI6 +Mcu.Pin22=PI5 +Mcu.Pin23=PD1 +Mcu.Pin24=PI3 +Mcu.Pin25=PI2 +Mcu.Pin26=PA11 +Mcu.Pin27=PC13 +Mcu.Pin28=PI9 +Mcu.Pin29=PI4 Mcu.Pin3=PE0 -Mcu.Pin30=PI9 -Mcu.Pin31=PI4 -Mcu.Pin32=PH15 -Mcu.Pin33=PI1 -Mcu.Pin34=PF0 -Mcu.Pin35=PI10 -Mcu.Pin36=PH13 -Mcu.Pin37=PH14 -Mcu.Pin38=PI0 -Mcu.Pin39=PA9 +Mcu.Pin30=PH15 +Mcu.Pin31=PI1 +Mcu.Pin32=PF0 +Mcu.Pin33=PI10 +Mcu.Pin34=PH13 +Mcu.Pin35=PH14 +Mcu.Pin36=PI0 +Mcu.Pin37=PA9 +Mcu.Pin38=PC15-OSC32_OUT (OSC32_OUT) +Mcu.Pin39=PH2 Mcu.Pin4=PB5 -Mcu.Pin40=PC15-OSC32_OUT (OSC32_OUT) -Mcu.Pin41=PH2 -Mcu.Pin42=PC9 -Mcu.Pin43=PA8 -Mcu.Pin44=PH0-OSC_IN (PH0) -Mcu.Pin45=PH3 -Mcu.Pin46=PC7 -Mcu.Pin47=PH1-OSC_OUT (PH1) -Mcu.Pin48=PF2 -Mcu.Pin49=PF1 +Mcu.Pin40=PC9 +Mcu.Pin41=PA8 +Mcu.Pin42=PH0-OSC_IN (PH0) +Mcu.Pin43=PH3 +Mcu.Pin44=PC7 +Mcu.Pin45=PH1-OSC_OUT (PH1) +Mcu.Pin46=PF2 +Mcu.Pin47=PF1 +Mcu.Pin48=PH4 +Mcu.Pin49=PG8 Mcu.Pin5=PB3 (JTDO/TRACESWO) -Mcu.Pin50=PH4 -Mcu.Pin51=PG8 -Mcu.Pin52=PC6 -Mcu.Pin53=PF3 -Mcu.Pin54=PF4 -Mcu.Pin55=PH5 -Mcu.Pin56=PG7 -Mcu.Pin57=PG6 -Mcu.Pin58=PF7 -Mcu.Pin59=PF6 +Mcu.Pin50=PC6 +Mcu.Pin51=PF3 +Mcu.Pin52=PF4 +Mcu.Pin53=PH5 +Mcu.Pin54=PG7 +Mcu.Pin55=PG6 +Mcu.Pin56=PF7 +Mcu.Pin57=PF6 +Mcu.Pin58=PF5 +Mcu.Pin59=PH12 Mcu.Pin6=PC12 -Mcu.Pin60=PF5 -Mcu.Pin61=PH12 -Mcu.Pin62=PG5 -Mcu.Pin63=PG4 -Mcu.Pin64=PG3 -Mcu.Pin65=PF10 -Mcu.Pin66=PF9 -Mcu.Pin67=PF8 -Mcu.Pin68=PH11 -Mcu.Pin69=PH10 +Mcu.Pin60=PG5 +Mcu.Pin61=PG4 +Mcu.Pin62=PG3 +Mcu.Pin63=PF10 +Mcu.Pin64=PF9 +Mcu.Pin65=PF8 +Mcu.Pin66=PH11 +Mcu.Pin67=PH10 +Mcu.Pin68=PD15 +Mcu.Pin69=PG2 Mcu.Pin7=PA15 (JTDI) -Mcu.Pin70=PD15 -Mcu.Pin71=PG2 -Mcu.Pin72=PC0 -Mcu.Pin73=PC1 -Mcu.Pin74=PC2_C -Mcu.Pin75=PC3_C -Mcu.Pin76=PG1 -Mcu.Pin77=PH8 -Mcu.Pin78=PH9 -Mcu.Pin79=PD14 +Mcu.Pin70=PC0 +Mcu.Pin71=PC1 +Mcu.Pin72=PC2_C +Mcu.Pin73=PC3_C +Mcu.Pin74=PG1 +Mcu.Pin75=PH8 +Mcu.Pin76=PH9 +Mcu.Pin77=PD14 +Mcu.Pin78=PD13 +Mcu.Pin79=PA1 Mcu.Pin8=PA14 (JTCK/SWCLK) -Mcu.Pin80=PD13 -Mcu.Pin81=PA1 -Mcu.Pin82=PA0 -Mcu.Pin83=PF13 -Mcu.Pin84=PG0 -Mcu.Pin85=PE13 -Mcu.Pin86=PD12 -Mcu.Pin87=PD10 -Mcu.Pin88=PA2 -Mcu.Pin89=PA6 +Mcu.Pin80=PA0 +Mcu.Pin81=PF13 +Mcu.Pin82=PG0 +Mcu.Pin83=PE13 +Mcu.Pin84=PD12 +Mcu.Pin85=PD10 +Mcu.Pin86=PA2 +Mcu.Pin87=PA6 +Mcu.Pin88=PC5 +Mcu.Pin89=PF12 Mcu.Pin9=PA13 (JTMS/SWDIO) -Mcu.Pin90=PC5 -Mcu.Pin91=PF12 -Mcu.Pin92=PF15 -Mcu.Pin93=PE8 -Mcu.Pin94=PE9 -Mcu.Pin95=PE11 -Mcu.Pin96=PE14 -Mcu.Pin97=PD9 -Mcu.Pin98=PD8 -Mcu.Pin99=PA3 -Mcu.PinsNb=114 +Mcu.Pin90=PF15 +Mcu.Pin91=PE8 +Mcu.Pin92=PE9 +Mcu.Pin93=PE11 +Mcu.Pin94=PE14 +Mcu.Pin95=PD9 +Mcu.Pin96=PD8 +Mcu.Pin97=PA3 +Mcu.Pin98=PA7 +Mcu.Pin99=PB1 +Mcu.PinsNb=112 Mcu.ThirdPartyNb=0 Mcu.UserConstants= Mcu.UserName=STM32H743IIKx @@ -318,14 +317,12 @@ PA15\ (JTDI).Signal=S_TIM2_CH1 PA2.GPIOParameters=GPIO_Label PA2.GPIO_Label=ADC2 PA2.Signal=ADCx_INP14 -PA3.Locked=true -PA3.Signal=GPIO_Output +PA3.Signal=S_TIM2_CH4 PA6.GPIOParameters=GPIO_Label PA6.GPIO_Label=ADC6 PA6.Locked=true PA6.Signal=ADCx_INP3 -PA7.Locked=true -PA7.Signal=GPIO_Output +PA7.Signal=S_TIM3_CH2 PA8.Mode=Asynchronous PA8.Signal=UART7_RX PA9.Mode=Activate_VBUS @@ -472,10 +469,6 @@ PG0.Signal=FMC_A10 PG1.Signal=FMC_A11 PG10.Locked=true PG10.Signal=GPIO_Input -PG11.Locked=true -PG11.Signal=GPIO_Output -PG12.Locked=true -PG12.Signal=GPIO_Output PG15.Signal=FMC_SDNCAS PG2.Signal=FMC_A12 PG3.GPIOParameters=GPIO_Label @@ -552,7 +545,7 @@ ProjectManager.StackSize=0x400 ProjectManager.TargetToolchain=Other Toolchains (GPDSC) ProjectManager.ToolChainLocation= ProjectManager.UnderRoot=false -ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_QUADSPI_Init-QUADSPI-false-HAL-true,5-MX_FMC_Init-FMC-false-HAL-true,6-MX_SAI1_Init-SAI1-false-HAL-true,7-MX_ADC1_Init-ADC1-false-HAL-true,8-MX_SPI2_Init-SPI2-false-HAL-true,9-MX_SPI3_Init-SPI3-false-HAL-true,10-MX_TIM2_Init-TIM2-false-HAL-true,11-MX_TIM4_Init-TIM4-false-HAL-true,12-MX_UART5_Init-UART5-false-HAL-true,13-MX_UART7_Init-UART7-false-HAL-true,14-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,15-MX_TIM5_Init-TIM5-false-HAL-true,16-MX_TIM8_Init-TIM8-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_QUADSPI_Init-QUADSPI-false-HAL-true,5-MX_FMC_Init-FMC-false-HAL-true,6-MX_SAI1_Init-SAI1-false-HAL-true,7-MX_ADC1_Init-ADC1-false-HAL-true,8-MX_SPI2_Init-SPI2-false-HAL-true,9-MX_SPI3_Init-SPI3-false-HAL-true,10-MX_TIM2_Init-TIM2-false-HAL-true,11-MX_TIM4_Init-TIM4-false-HAL-true,12-MX_UART5_Init-UART5-false-HAL-true,13-MX_UART7_Init-UART7-false-HAL-true,14-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,15-MX_TIM8_Init-TIM8-false-HAL-true,16-MX_TIM3_Init-TIM3-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true QUADSPI.ClockPrescaler=9 QUADSPI.FifoThreshold=4 QUADSPI.FlashSize=22 @@ -809,6 +802,10 @@ SH.S_TIM2_CH1.0=TIM2_CH1,PWM Generation1 CH1 SH.S_TIM2_CH1.ConfNb=1 SH.S_TIM2_CH2.0=TIM2_CH2,PWM Generation2 CH2 SH.S_TIM2_CH2.ConfNb=1 +SH.S_TIM2_CH4.0=TIM2_CH4,PWM Generation4 CH4 +SH.S_TIM2_CH4.ConfNb=1 +SH.S_TIM3_CH2.0=TIM3_CH2,PWM Generation2 CH2 +SH.S_TIM3_CH2.ConfNb=1 SH.S_TIM4_CH1.0=TIM4_CH1,PWM Generation1 CH1 SH.S_TIM4_CH1.ConfNb=1 SH.S_TIM4_CH2.0=TIM4_CH2,PWM Generation2 CH2 @@ -848,9 +845,14 @@ SPI3.NSSPMode=SPI_NSS_PULSE_DISABLE SPI3.VirtualType=VM_MASTER TIM2.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 TIM2.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2 -TIM2.IPParameters=Channel-PWM Generation2 CH2,Channel-PWM Generation1 CH1,Prescaler,Period +TIM2.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4 +TIM2.IPParameters=Channel-PWM Generation2 CH2,Channel-PWM Generation1 CH1,Prescaler,Period,Channel-PWM Generation4 CH4 TIM2.Period=1023 TIM2.Prescaler=100 +TIM3.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2 +TIM3.IPParameters=Channel-PWM Generation2 CH2,Prescaler,Period +TIM3.Period=1023 +TIM3.Prescaler=100 TIM4.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 TIM4.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2 TIM4.IPParameters=Channel-PWM Generation2 CH2,Channel-PWM Generation1 CH1,Period,Prescaler diff --git a/ACDC/Core/Inc/hardware.h b/ACDC/Core/Inc/hardware.h index 94ce6782..7a17d540 100644 --- a/ACDC/Core/Inc/hardware.h +++ b/ACDC/Core/Inc/hardware.h @@ -36,10 +36,10 @@ #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) #define USE_USBD_AUDIO -/* #define USE_USBD_AUDIO_FEATURES */ +#define USE_USBD_AUDIO_FEATURES #define USE_USBD_AUDIO_TX // microphone -#define USE_USBD_AUDIO_RX // speaker -#define USE_USBD_RX_FB +/* #define USE_USBD_AUDIO_RX // speaker */ +/* #define USE_USBD_RX_FB */ #define USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS diff --git a/ACDC/Core/Src/ACDC.cpp b/ACDC/Core/Src/ACDC.cpp index b3357f57..74f1834c 100644 --- a/ACDC/Core/Src/ACDC.cpp +++ b/ACDC/Core/Src/ACDC.cpp @@ -29,46 +29,40 @@ #define XIBECA_PIN23 GPIOD, GPIO_PIN_12 #define XIBECA_PIN24 GPIOD, GPIO_PIN_13 -Pin led_in1(XIBECA_PIN17); -Pin led_in2(XIBECA_PIN18); -Pin led_in3(XIBECA_PIN19); -Pin led_in4(XIBECA_PIN20); +// Pin led_in1(XIBECA_PIN13); +// Pin led_in2(XIBECA_PIN14); +// Pin led_in3(XIBECA_PIN19); +// Pin led_in4(XIBECA_PIN20); Pin led_clip1(XIBECA_PIN10); Pin led_clip2(XIBECA_PIN7); Pin led_clip3(XIBECA_PIN8); Pin led_clip4(XIBECA_PIN5); -Pin led_out1(XIBECA_PIN21); -Pin led_out2(XIBECA_PIN22); -Pin led_out3(XIBECA_PIN23); -Pin led_out4(XIBECA_PIN24); +// Pin led_out1(XIBECA_PIN21); +// Pin led_out2(XIBECA_PIN22); +// Pin led_out3(XIBECA_PIN23); +// Pin led_out4(XIBECA_PIN24); void setLed(uint8_t led, uint32_t rgb){ uint32_t pwm = 1023 - (__USAT(rgb>>2, 10)); // expects 12-bit parameter value switch(led){ case 1: if(rgb == RED_COLOUR){ - led_in1.high(); led_clip1.low(); - }else if(rgb == NO_COLOUR){ - led_in1.high(); - led_clip1.high(); + TIM3->CCR2 = 0xFFFFFFFFU; }else{ - led_in1.low(); led_clip1.high(); - } + TIM3->CCR2 = pwm; + } break; case 2: if(rgb == RED_COLOUR){ - led_in2.high(); led_clip2.low(); - }else if(rgb == NO_COLOUR){ - led_in2.high(); - led_clip2.high(); + TIM2->CCR4 = 0xFFFFFFFFU; }else{ - led_in2.low(); led_clip2.high(); + TIM2->CCR4 = pwm; } break; case 3: @@ -113,24 +107,22 @@ void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* void initLed(){ extern TIM_HandleTypeDef htim2; + extern TIM_HandleTypeDef htim3; extern TIM_HandleTypeDef htim4; - // extern TIM_HandleTypeDef htim5; extern TIM_HandleTypeDef htim8; HAL_TIM_Base_Start(&htim2); + HAL_TIM_Base_Start(&htim3); HAL_TIM_Base_Start(&htim4); - // HAL_TIM_Base_Start(&htim5); HAL_TIM_Base_Start(&htim8); HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1); // in3 HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2); // in4 + HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_4); // in2 + HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_2); // in1 HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_1); // out3 HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_2); // out4 - // HAL_TIM_PWM_Start(&htim5, TIM_CHANNEL_1); // clip1 HAL_TIM_PWM_Start(&htim8, TIM_CHANNEL_1); // out1 HAL_TIM_PWM_Start(&htim8, TIM_CHANNEL_2); // out2 - led_in1.outputMode(); - led_in2.outputMode(); - led_clip1.outputMode(); led_clip2.outputMode(); led_clip3.outputMode(); @@ -139,28 +131,14 @@ void initLed(){ void onSetup(){ initLed(); - // led_in1.outputMode(); - // led_in2.outputMode(); - // led_in3.outputMode(); - // led_in4.outputMode(); - - // led_clip1.outputMode(); - // led_clip2.outputMode(); - // led_clip3.outputMode(); - // led_clip4.outputMode(); - - // led_out1.outputMode(); - // led_out2.outputMode(); - // led_out3.outputMode(); - // led_out4.outputMode(); - for(size_t i=1; i<=8; ++i) setLed(i, NO_COLOUR); } void onLoop(void){ for(size_t i=0; i<4; ++i){ - setLed(i+1, getParameterValue(PARAMETER_AA+i)); + int16_t value = getParameterValue(PARAMETER_AA+i); + setLed(i+1, value >= 4095 ? RED_COLOUR : value); setLed(i+5, getParameterValue(PARAMETER_BA+i)); } } diff --git a/ACDC/Core/Src/main.c b/ACDC/Core/Src/main.c index dacc0df9..fb0b0157 100644 --- a/ACDC/Core/Src/main.c +++ b/ACDC/Core/Src/main.c @@ -59,6 +59,7 @@ SPI_HandleTypeDef hspi3; DMA_HandleTypeDef hdma_spi3_tx; TIM_HandleTypeDef htim2; +TIM_HandleTypeDef htim3; TIM_HandleTypeDef htim4; TIM_HandleTypeDef htim8; @@ -88,6 +89,7 @@ static void MX_TIM4_Init(void); static void MX_UART5_Init(void); static void MX_UART7_Init(void); static void MX_TIM8_Init(void); +static void MX_TIM3_Init(void); void StartDefaultTask(void const * argument); /* USER CODE BEGIN PFP */ @@ -170,6 +172,7 @@ int main(void) MX_UART5_Init(); MX_UART7_Init(); MX_TIM8_Init(); + MX_TIM3_Init(); /* USER CODE BEGIN 2 */ #ifdef USE_EXTERNAL_RAM @@ -477,17 +480,7 @@ static void MX_SAI1_Init(void) hsai_BlockA1.SlotInit.FirstBitOffset = 0; hsai_BlockA1.SlotInit.SlotSize = SAI_SLOTSIZE_32B; hsai_BlockA1.SlotInit.SlotNumber = 8; -#if AUDIO_CHANNELS == 8 - hsai_BlockA1.SlotInit.SlotActive = 0xff; -#elif AUDIO_CHANNELS == 6 - hsai_BlockA1.SlotInit.SlotActive = 0x3f; -#elif AUDIO_CHANNELS == 4 - hsai_BlockA1.SlotInit.SlotActive = 0x0f; -#elif AUDIO_CHANNELS == 2 - hsai_BlockA1.SlotInit.SlotActive = 0x03; -#else -#error "Unsupported AUDIO_CHANNELS" -#endif + hsai_BlockA1.SlotInit.SlotActive = 0x0000FFFF; if (HAL_SAI_Init(&hsai_BlockA1) != HAL_OK) { Error_Handler(); @@ -516,17 +509,7 @@ static void MX_SAI1_Init(void) hsai_BlockB1.SlotInit.FirstBitOffset = 0; hsai_BlockB1.SlotInit.SlotSize = SAI_SLOTSIZE_32B; hsai_BlockB1.SlotInit.SlotNumber = 8; -#if AUDIO_CHANNELS == 8 - hsai_BlockB1.SlotInit.SlotActive = 0xff; -#elif AUDIO_CHANNELS == 6 - hsai_BlockB1.SlotInit.SlotActive = 0x3f; -#elif AUDIO_CHANNELS == 4 - hsai_BlockB1.SlotInit.SlotActive = 0x0f; -#elif AUDIO_CHANNELS == 2 - hsai_BlockB1.SlotInit.SlotActive = 0x03; -#else -#error "Unsupported AUDIO_CHANNELS" -#endif + hsai_BlockB1.SlotInit.SlotActive = 0x0000FFFF; if (HAL_SAI_Init(&hsai_BlockB1) != HAL_OK) { Error_Handler(); @@ -679,6 +662,10 @@ static void MX_TIM2_Init(void) { Error_Handler(); } + if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_4) != HAL_OK) + { + Error_Handler(); + } /* USER CODE BEGIN TIM2_Init 2 */ /* USER CODE END TIM2_Init 2 */ @@ -686,6 +673,55 @@ static void MX_TIM2_Init(void) } +/** + * @brief TIM3 Initialization Function + * @param None + * @retval None + */ +static void MX_TIM3_Init(void) +{ + + /* USER CODE BEGIN TIM3_Init 0 */ + + /* USER CODE END TIM3_Init 0 */ + + TIM_MasterConfigTypeDef sMasterConfig = {0}; + TIM_OC_InitTypeDef sConfigOC = {0}; + + /* USER CODE BEGIN TIM3_Init 1 */ + + /* USER CODE END TIM3_Init 1 */ + htim3.Instance = TIM3; + htim3.Init.Prescaler = 100; + htim3.Init.CounterMode = TIM_COUNTERMODE_UP; + htim3.Init.Period = 1023; + htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; + htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; + if (HAL_TIM_PWM_Init(&htim3) != HAL_OK) + { + Error_Handler(); + } + sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; + sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; + if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK) + { + Error_Handler(); + } + sConfigOC.OCMode = TIM_OCMODE_PWM1; + sConfigOC.Pulse = 0; + sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; + sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; + if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_2) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN TIM3_Init 2 */ + + /* USER CODE END TIM3_Init 2 */ + HAL_TIM_MspPostInit(&htim3); + +} + /** * @brief TIM4 Initialization Function * @param None @@ -1001,9 +1037,6 @@ static void MX_GPIO_Init(void) __HAL_RCC_GPIOH_CLK_ENABLE(); __HAL_RCC_GPIOF_CLK_ENABLE(); - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOG, GPIO_PIN_12|GPIO_PIN_11|ADC_RST_Pin, GPIO_PIN_RESET); - /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_RESET); @@ -1011,7 +1044,10 @@ static void MX_GPIO_Init(void) HAL_GPIO_WritePin(GPIOH, GPIO_PIN_4, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOA, GPIO_PIN_0|GPIO_PIN_3|GPIO_PIN_7, GPIO_PIN_RESET); + HAL_GPIO_WritePin(ADC_RST_GPIO_Port, ADC_RST_Pin, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(GPIOA, GPIO_PIN_0, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(ADC_SPI_NCS_GPIO_Port, ADC_SPI_NCS_Pin, GPIO_PIN_RESET); @@ -1024,8 +1060,10 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - /*Configure GPIO pins : PG14 PG13 PG9 */ - GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_13|GPIO_PIN_9; + /*Configure GPIO pins : PG14 PG13 PG12 PG11 + PG9 */ + GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_13|GPIO_PIN_12|GPIO_PIN_11 + |GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); @@ -1046,13 +1084,6 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Alternate = GPIO_AF4_I2C1; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - /*Configure GPIO pins : PG12 PG11 ADC_RST_Pin */ - GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_11|ADC_RST_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); - /*Configure GPIO pin : PG10 */ GPIO_InitStruct.Pin = GPIO_PIN_10; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; @@ -1103,14 +1134,21 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); + /*Configure GPIO pin : ADC_RST_Pin */ + GPIO_InitStruct.Pin = ADC_RST_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(ADC_RST_GPIO_Port, &GPIO_InitStruct); + /*Configure GPIO pins : PH6 PH7 */ GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); - /*Configure GPIO pins : PA0 PA3 PA7 */ - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_3|GPIO_PIN_7; + /*Configure GPIO pin : PA0 */ + GPIO_InitStruct.Pin = GPIO_PIN_0; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; diff --git a/ACDC/Core/Src/startup_stm32h743xx.s b/ACDC/Core/Src/startup_stm32h743xx.s new file mode 100644 index 00000000..2b1034a6 --- /dev/null +++ b/ACDC/Core/Src/startup_stm32h743xx.s @@ -0,0 +1,749 @@ +/** + ****************************************************************************** + * @file startup_stm32h743xx.s + * @author MCD Application Team + * @brief STM32H743xx Devices vector table for GCC based toolchain. + * This module performs: + * - Set the initial SP + * - Set the initial PC == Reset_Handler, + * - Set the vector table entries with the exceptions ISR address + * - Branches to main in the C library (which eventually + * calls main()). + * After Reset the Cortex-M processor is in Thread mode, + * priority is Privileged, and the Stack is set to Main. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + + .syntax unified + .cpu cortex-m7 + .fpu softvfp + .thumb + +.global g_pfnVectors +.global Default_Handler + +/* start address for the initialization values of the .data section. +defined in linker script */ +.word _sidata +/* start address for the .data section. defined in linker script */ +.word _sdata +/* end address for the .data section. defined in linker script */ +.word _edata +/* start address for the .bss section. defined in linker script */ +.word _sbss +/* end address for the .bss section. defined in linker script */ +.word _ebss +/* stack used for SystemInit_ExtMemCtl; always internal RAM used */ + +/** + * @brief This is the code that gets called when the processor first + * starts execution following a reset event. Only the absolutely + * necessary set is performed, after which the application + * supplied main() routine is called. + * @param None + * @retval : None +*/ + + .section .text.Reset_Handler + .weak Reset_Handler + .type Reset_Handler, %function +Reset_Handler: + ldr sp, =_estack /* set stack pointer */ + +/* Call the clock system intitialization function.*/ + bl SystemInit + +/* Copy the data segment initializers from flash to SRAM */ + movs r1, #0 + b LoopCopyDataInit + +CopyDataInit: + ldr r3, =_sidata + ldr r3, [r3, r1] + str r3, [r0, r1] + adds r1, r1, #4 + +LoopCopyDataInit: + ldr r0, =_sdata + ldr r3, =_edata + adds r2, r0, r1 + cmp r2, r3 + bcc CopyDataInit + ldr r2, =_sbss + b LoopFillZerobss +/* Zero fill the bss segment. */ +FillZerobss: + movs r3, #0 + str r3, [r2], #4 + +LoopFillZerobss: + ldr r3, = _ebss + cmp r2, r3 + bcc FillZerobss + +/* Call static constructors */ + bl __libc_init_array +/* Call the application's entry point.*/ + bl main + bx lr +.size Reset_Handler, .-Reset_Handler + +/** + * @brief This is the code that gets called when the processor receives an + * unexpected interrupt. This simply enters an infinite loop, preserving + * the system state for examination by a debugger. + * @param None + * @retval None +*/ + .section .text.Default_Handler,"ax",%progbits +Default_Handler: +Infinite_Loop: + b Infinite_Loop + .size Default_Handler, .-Default_Handler +/****************************************************************************** +* +* The minimal vector table for a Cortex M. Note that the proper constructs +* must be placed on this to ensure that it ends up at physical address +* 0x0000.0000. +* +*******************************************************************************/ + .section .isr_vector,"a",%progbits + .type g_pfnVectors, %object + .size g_pfnVectors, .-g_pfnVectors + + +g_pfnVectors: + .word _estack + .word Reset_Handler + + .word NMI_Handler + .word HardFault_Handler + .word MemManage_Handler + .word BusFault_Handler + .word UsageFault_Handler + .word 0 + .word 0 + .word 0 + .word 0 + .word SVC_Handler + .word DebugMon_Handler + .word 0 + .word PendSV_Handler + .word SysTick_Handler + + /* External Interrupts */ + .word WWDG_IRQHandler /* Window WatchDog */ + .word PVD_AVD_IRQHandler /* PVD/AVD through EXTI Line detection */ + .word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */ + .word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */ + .word FLASH_IRQHandler /* FLASH */ + .word RCC_IRQHandler /* RCC */ + .word EXTI0_IRQHandler /* EXTI Line0 */ + .word EXTI1_IRQHandler /* EXTI Line1 */ + .word EXTI2_IRQHandler /* EXTI Line2 */ + .word EXTI3_IRQHandler /* EXTI Line3 */ + .word EXTI4_IRQHandler /* EXTI Line4 */ + .word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */ + .word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */ + .word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */ + .word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */ + .word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */ + .word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */ + .word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */ + .word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */ + .word FDCAN1_IT0_IRQHandler /* FDCAN1 interrupt line 0 */ + .word FDCAN2_IT0_IRQHandler /* FDCAN2 interrupt line 0 */ + .word FDCAN1_IT1_IRQHandler /* FDCAN1 interrupt line 1 */ + .word FDCAN2_IT1_IRQHandler /* FDCAN2 interrupt line 1 */ + .word EXTI9_5_IRQHandler /* External Line[9:5]s */ + .word TIM1_BRK_IRQHandler /* TIM1 Break interrupt */ + .word TIM1_UP_IRQHandler /* TIM1 Update interrupt */ + .word TIM1_TRG_COM_IRQHandler /* TIM1 Trigger and Commutation interrupt */ + .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */ + .word TIM2_IRQHandler /* TIM2 */ + .word TIM3_IRQHandler /* TIM3 */ + .word TIM4_IRQHandler /* TIM4 */ + .word I2C1_EV_IRQHandler /* I2C1 Event */ + .word I2C1_ER_IRQHandler /* I2C1 Error */ + .word I2C2_EV_IRQHandler /* I2C2 Event */ + .word I2C2_ER_IRQHandler /* I2C2 Error */ + .word SPI1_IRQHandler /* SPI1 */ + .word SPI2_IRQHandler /* SPI2 */ + .word USART1_IRQHandler /* USART1 */ + .word USART2_IRQHandler /* USART2 */ + .word USART3_IRQHandler /* USART3 */ + .word EXTI15_10_IRQHandler /* External Line[15:10]s */ + .word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */ + .word 0 /* Reserved */ + .word TIM8_BRK_TIM12_IRQHandler /* TIM8 Break and TIM12 */ + .word TIM8_UP_TIM13_IRQHandler /* TIM8 Update and TIM13 */ + .word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */ + .word TIM8_CC_IRQHandler /* TIM8 Capture Compare */ + .word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */ + .word FMC_IRQHandler /* FMC */ + .word SDMMC1_IRQHandler /* SDMMC1 */ + .word TIM5_IRQHandler /* TIM5 */ + .word SPI3_IRQHandler /* SPI3 */ + .word UART4_IRQHandler /* UART4 */ + .word UART5_IRQHandler /* UART5 */ + .word TIM6_DAC_IRQHandler /* TIM6 and DAC1&2 underrun errors */ + .word TIM7_IRQHandler /* TIM7 */ + .word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */ + .word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */ + .word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */ + .word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */ + .word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */ + .word ETH_IRQHandler /* Ethernet */ + .word ETH_WKUP_IRQHandler /* Ethernet Wakeup through EXTI line */ + .word FDCAN_CAL_IRQHandler /* FDCAN calibration unit interrupt*/ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */ + .word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */ + .word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */ + .word USART6_IRQHandler /* USART6 */ + .word I2C3_EV_IRQHandler /* I2C3 event */ + .word I2C3_ER_IRQHandler /* I2C3 error */ + .word OTG_HS_EP1_OUT_IRQHandler /* USB OTG HS End Point 1 Out */ + .word OTG_HS_EP1_IN_IRQHandler /* USB OTG HS End Point 1 In */ + .word OTG_HS_WKUP_IRQHandler /* USB OTG HS Wakeup through EXTI */ + .word OTG_HS_IRQHandler /* USB OTG HS */ + .word DCMI_IRQHandler /* DCMI */ + .word 0 /* Reserved */ + .word RNG_IRQHandler /* Rng */ + .word FPU_IRQHandler /* FPU */ + .word UART7_IRQHandler /* UART7 */ + .word UART8_IRQHandler /* UART8 */ + .word SPI4_IRQHandler /* SPI4 */ + .word SPI5_IRQHandler /* SPI5 */ + .word SPI6_IRQHandler /* SPI6 */ + .word SAI1_IRQHandler /* SAI1 */ + .word LTDC_IRQHandler /* LTDC */ + .word LTDC_ER_IRQHandler /* LTDC error */ + .word DMA2D_IRQHandler /* DMA2D */ + .word SAI2_IRQHandler /* SAI2 */ + .word QUADSPI_IRQHandler /* QUADSPI */ + .word LPTIM1_IRQHandler /* LPTIM1 */ + .word CEC_IRQHandler /* HDMI_CEC */ + .word I2C4_EV_IRQHandler /* I2C4 Event */ + .word I2C4_ER_IRQHandler /* I2C4 Error */ + .word SPDIF_RX_IRQHandler /* SPDIF_RX */ + .word OTG_FS_EP1_OUT_IRQHandler /* USB OTG FS End Point 1 Out */ + .word OTG_FS_EP1_IN_IRQHandler /* USB OTG FS End Point 1 In */ + .word OTG_FS_WKUP_IRQHandler /* USB OTG FS Wakeup through EXTI */ + .word OTG_FS_IRQHandler /* USB OTG FS */ + .word DMAMUX1_OVR_IRQHandler /* DMAMUX1 Overrun interrupt */ + .word HRTIM1_Master_IRQHandler /* HRTIM Master Timer global Interrupt */ + .word HRTIM1_TIMA_IRQHandler /* HRTIM Timer A global Interrupt */ + .word HRTIM1_TIMB_IRQHandler /* HRTIM Timer B global Interrupt */ + .word HRTIM1_TIMC_IRQHandler /* HRTIM Timer C global Interrupt */ + .word HRTIM1_TIMD_IRQHandler /* HRTIM Timer D global Interrupt */ + .word HRTIM1_TIME_IRQHandler /* HRTIM Timer E global Interrupt */ + .word HRTIM1_FLT_IRQHandler /* HRTIM Fault global Interrupt */ + .word DFSDM1_FLT0_IRQHandler /* DFSDM Filter0 Interrupt */ + .word DFSDM1_FLT1_IRQHandler /* DFSDM Filter1 Interrupt */ + .word DFSDM1_FLT2_IRQHandler /* DFSDM Filter2 Interrupt */ + .word DFSDM1_FLT3_IRQHandler /* DFSDM Filter3 Interrupt */ + .word SAI3_IRQHandler /* SAI3 global Interrupt */ + .word SWPMI1_IRQHandler /* Serial Wire Interface 1 global interrupt */ + .word TIM15_IRQHandler /* TIM15 global Interrupt */ + .word TIM16_IRQHandler /* TIM16 global Interrupt */ + .word TIM17_IRQHandler /* TIM17 global Interrupt */ + .word MDIOS_WKUP_IRQHandler /* MDIOS Wakeup Interrupt */ + .word MDIOS_IRQHandler /* MDIOS global Interrupt */ + .word JPEG_IRQHandler /* JPEG global Interrupt */ + .word MDMA_IRQHandler /* MDMA global Interrupt */ + .word 0 /* Reserved */ + .word SDMMC2_IRQHandler /* SDMMC2 global Interrupt */ + .word HSEM1_IRQHandler /* HSEM1 global Interrupt */ + .word 0 /* Reserved */ + .word ADC3_IRQHandler /* ADC3 global Interrupt */ + .word DMAMUX2_OVR_IRQHandler /* DMAMUX Overrun interrupt */ + .word BDMA_Channel0_IRQHandler /* BDMA Channel 0 global Interrupt */ + .word BDMA_Channel1_IRQHandler /* BDMA Channel 1 global Interrupt */ + .word BDMA_Channel2_IRQHandler /* BDMA Channel 2 global Interrupt */ + .word BDMA_Channel3_IRQHandler /* BDMA Channel 3 global Interrupt */ + .word BDMA_Channel4_IRQHandler /* BDMA Channel 4 global Interrupt */ + .word BDMA_Channel5_IRQHandler /* BDMA Channel 5 global Interrupt */ + .word BDMA_Channel6_IRQHandler /* BDMA Channel 6 global Interrupt */ + .word BDMA_Channel7_IRQHandler /* BDMA Channel 7 global Interrupt */ + .word COMP1_IRQHandler /* COMP1 global Interrupt */ + .word LPTIM2_IRQHandler /* LP TIM2 global interrupt */ + .word LPTIM3_IRQHandler /* LP TIM3 global interrupt */ + .word LPTIM4_IRQHandler /* LP TIM4 global interrupt */ + .word LPTIM5_IRQHandler /* LP TIM5 global interrupt */ + .word LPUART1_IRQHandler /* LP UART1 interrupt */ + .word 0 /* Reserved */ + .word CRS_IRQHandler /* Clock Recovery Global Interrupt */ + .word ECC_IRQHandler /* ECC diagnostic Global Interrupt */ + .word SAI4_IRQHandler /* SAI4 global interrupt */ + .word 0 /* Reserved */ + .word 0 /* Reserved */ + .word WAKEUP_PIN_IRQHandler /* Interrupt for all 6 wake-up pins */ + +/******************************************************************************* +* +* Provide weak aliases for each Exception handler to the Default_Handler. +* As they are weak aliases, any function with the same name will override +* this definition. +* +*******************************************************************************/ + .weak NMI_Handler + .thumb_set NMI_Handler,Default_Handler + + .weak HardFault_Handler + .thumb_set HardFault_Handler,Default_Handler + + .weak MemManage_Handler + .thumb_set MemManage_Handler,Default_Handler + + .weak BusFault_Handler + .thumb_set BusFault_Handler,Default_Handler + + .weak UsageFault_Handler + .thumb_set UsageFault_Handler,Default_Handler + + .weak SVC_Handler + .thumb_set SVC_Handler,Default_Handler + + .weak DebugMon_Handler + .thumb_set DebugMon_Handler,Default_Handler + + .weak PendSV_Handler + .thumb_set PendSV_Handler,Default_Handler + + .weak SysTick_Handler + .thumb_set SysTick_Handler,Default_Handler + + .weak WWDG_IRQHandler + .thumb_set WWDG_IRQHandler,Default_Handler + + .weak PVD_AVD_IRQHandler + .thumb_set PVD_AVD_IRQHandler,Default_Handler + + .weak TAMP_STAMP_IRQHandler + .thumb_set TAMP_STAMP_IRQHandler,Default_Handler + + .weak RTC_WKUP_IRQHandler + .thumb_set RTC_WKUP_IRQHandler,Default_Handler + + .weak FLASH_IRQHandler + .thumb_set FLASH_IRQHandler,Default_Handler + + .weak RCC_IRQHandler + .thumb_set RCC_IRQHandler,Default_Handler + + .weak EXTI0_IRQHandler + .thumb_set EXTI0_IRQHandler,Default_Handler + + .weak EXTI1_IRQHandler + .thumb_set EXTI1_IRQHandler,Default_Handler + + .weak EXTI2_IRQHandler + .thumb_set EXTI2_IRQHandler,Default_Handler + + .weak EXTI3_IRQHandler + .thumb_set EXTI3_IRQHandler,Default_Handler + + .weak EXTI4_IRQHandler + .thumb_set EXTI4_IRQHandler,Default_Handler + + .weak DMA1_Stream0_IRQHandler + .thumb_set DMA1_Stream0_IRQHandler,Default_Handler + + .weak DMA1_Stream1_IRQHandler + .thumb_set DMA1_Stream1_IRQHandler,Default_Handler + + .weak DMA1_Stream2_IRQHandler + .thumb_set DMA1_Stream2_IRQHandler,Default_Handler + + .weak DMA1_Stream3_IRQHandler + .thumb_set DMA1_Stream3_IRQHandler,Default_Handler + + .weak DMA1_Stream4_IRQHandler + .thumb_set DMA1_Stream4_IRQHandler,Default_Handler + + .weak DMA1_Stream5_IRQHandler + .thumb_set DMA1_Stream5_IRQHandler,Default_Handler + + .weak DMA1_Stream6_IRQHandler + .thumb_set DMA1_Stream6_IRQHandler,Default_Handler + + .weak ADC_IRQHandler + .thumb_set ADC_IRQHandler,Default_Handler + + .weak FDCAN1_IT0_IRQHandler + .thumb_set FDCAN1_IT0_IRQHandler,Default_Handler + + .weak FDCAN2_IT0_IRQHandler + .thumb_set FDCAN2_IT0_IRQHandler,Default_Handler + + .weak FDCAN1_IT1_IRQHandler + .thumb_set FDCAN1_IT1_IRQHandler,Default_Handler + + .weak FDCAN2_IT1_IRQHandler + .thumb_set FDCAN2_IT1_IRQHandler,Default_Handler + + .weak EXTI9_5_IRQHandler + .thumb_set EXTI9_5_IRQHandler,Default_Handler + + .weak TIM1_BRK_IRQHandler + .thumb_set TIM1_BRK_IRQHandler,Default_Handler + + .weak TIM1_UP_IRQHandler + .thumb_set TIM1_UP_IRQHandler,Default_Handler + + .weak TIM1_TRG_COM_IRQHandler + .thumb_set TIM1_TRG_COM_IRQHandler,Default_Handler + + .weak TIM1_CC_IRQHandler + .thumb_set TIM1_CC_IRQHandler,Default_Handler + + .weak TIM2_IRQHandler + .thumb_set TIM2_IRQHandler,Default_Handler + + .weak TIM3_IRQHandler + .thumb_set TIM3_IRQHandler,Default_Handler + + .weak TIM4_IRQHandler + .thumb_set TIM4_IRQHandler,Default_Handler + + .weak I2C1_EV_IRQHandler + .thumb_set I2C1_EV_IRQHandler,Default_Handler + + .weak I2C1_ER_IRQHandler + .thumb_set I2C1_ER_IRQHandler,Default_Handler + + .weak I2C2_EV_IRQHandler + .thumb_set I2C2_EV_IRQHandler,Default_Handler + + .weak I2C2_ER_IRQHandler + .thumb_set I2C2_ER_IRQHandler,Default_Handler + + .weak SPI1_IRQHandler + .thumb_set SPI1_IRQHandler,Default_Handler + + .weak SPI2_IRQHandler + .thumb_set SPI2_IRQHandler,Default_Handler + + .weak USART1_IRQHandler + .thumb_set USART1_IRQHandler,Default_Handler + + .weak USART2_IRQHandler + .thumb_set USART2_IRQHandler,Default_Handler + + .weak USART3_IRQHandler + .thumb_set USART3_IRQHandler,Default_Handler + + .weak EXTI15_10_IRQHandler + .thumb_set EXTI15_10_IRQHandler,Default_Handler + + .weak RTC_Alarm_IRQHandler + .thumb_set RTC_Alarm_IRQHandler,Default_Handler + + .weak TIM8_BRK_TIM12_IRQHandler + .thumb_set TIM8_BRK_TIM12_IRQHandler,Default_Handler + + .weak TIM8_UP_TIM13_IRQHandler + .thumb_set TIM8_UP_TIM13_IRQHandler,Default_Handler + + .weak TIM8_TRG_COM_TIM14_IRQHandler + .thumb_set TIM8_TRG_COM_TIM14_IRQHandler,Default_Handler + + .weak TIM8_CC_IRQHandler + .thumb_set TIM8_CC_IRQHandler,Default_Handler + + .weak DMA1_Stream7_IRQHandler + .thumb_set DMA1_Stream7_IRQHandler,Default_Handler + + .weak FMC_IRQHandler + .thumb_set FMC_IRQHandler,Default_Handler + + .weak SDMMC1_IRQHandler + .thumb_set SDMMC1_IRQHandler,Default_Handler + + .weak TIM5_IRQHandler + .thumb_set TIM5_IRQHandler,Default_Handler + + .weak SPI3_IRQHandler + .thumb_set SPI3_IRQHandler,Default_Handler + + .weak UART4_IRQHandler + .thumb_set UART4_IRQHandler,Default_Handler + + .weak UART5_IRQHandler + .thumb_set UART5_IRQHandler,Default_Handler + + .weak TIM6_DAC_IRQHandler + .thumb_set TIM6_DAC_IRQHandler,Default_Handler + + .weak TIM7_IRQHandler + .thumb_set TIM7_IRQHandler,Default_Handler + + .weak DMA2_Stream0_IRQHandler + .thumb_set DMA2_Stream0_IRQHandler,Default_Handler + + .weak DMA2_Stream1_IRQHandler + .thumb_set DMA2_Stream1_IRQHandler,Default_Handler + + .weak DMA2_Stream2_IRQHandler + .thumb_set DMA2_Stream2_IRQHandler,Default_Handler + + .weak DMA2_Stream3_IRQHandler + .thumb_set DMA2_Stream3_IRQHandler,Default_Handler + + .weak DMA2_Stream4_IRQHandler + .thumb_set DMA2_Stream4_IRQHandler,Default_Handler + + .weak ETH_IRQHandler + .thumb_set ETH_IRQHandler,Default_Handler + + .weak ETH_WKUP_IRQHandler + .thumb_set ETH_WKUP_IRQHandler,Default_Handler + + .weak FDCAN_CAL_IRQHandler + .thumb_set FDCAN_CAL_IRQHandler,Default_Handler + + .weak DMA2_Stream5_IRQHandler + .thumb_set DMA2_Stream5_IRQHandler,Default_Handler + + .weak DMA2_Stream6_IRQHandler + .thumb_set DMA2_Stream6_IRQHandler,Default_Handler + + .weak DMA2_Stream7_IRQHandler + .thumb_set DMA2_Stream7_IRQHandler,Default_Handler + + .weak USART6_IRQHandler + .thumb_set USART6_IRQHandler,Default_Handler + + .weak I2C3_EV_IRQHandler + .thumb_set I2C3_EV_IRQHandler,Default_Handler + + .weak I2C3_ER_IRQHandler + .thumb_set I2C3_ER_IRQHandler,Default_Handler + + .weak OTG_HS_EP1_OUT_IRQHandler + .thumb_set OTG_HS_EP1_OUT_IRQHandler,Default_Handler + + .weak OTG_HS_EP1_IN_IRQHandler + .thumb_set OTG_HS_EP1_IN_IRQHandler,Default_Handler + + .weak OTG_HS_WKUP_IRQHandler + .thumb_set OTG_HS_WKUP_IRQHandler,Default_Handler + + .weak OTG_HS_IRQHandler + .thumb_set OTG_HS_IRQHandler,Default_Handler + + .weak DCMI_IRQHandler + .thumb_set DCMI_IRQHandler,Default_Handler + + .weak RNG_IRQHandler + .thumb_set RNG_IRQHandler,Default_Handler + + .weak FPU_IRQHandler + .thumb_set FPU_IRQHandler,Default_Handler + + .weak UART7_IRQHandler + .thumb_set UART7_IRQHandler,Default_Handler + + .weak UART8_IRQHandler + .thumb_set UART8_IRQHandler,Default_Handler + + .weak SPI4_IRQHandler + .thumb_set SPI4_IRQHandler,Default_Handler + + .weak SPI5_IRQHandler + .thumb_set SPI5_IRQHandler,Default_Handler + + .weak SPI6_IRQHandler + .thumb_set SPI6_IRQHandler,Default_Handler + + .weak SAI1_IRQHandler + .thumb_set SAI1_IRQHandler,Default_Handler + + .weak LTDC_IRQHandler + .thumb_set LTDC_IRQHandler,Default_Handler + + .weak LTDC_ER_IRQHandler + .thumb_set LTDC_ER_IRQHandler,Default_Handler + + .weak DMA2D_IRQHandler + .thumb_set DMA2D_IRQHandler,Default_Handler + + .weak SAI2_IRQHandler + .thumb_set SAI2_IRQHandler,Default_Handler + + .weak QUADSPI_IRQHandler + .thumb_set QUADSPI_IRQHandler,Default_Handler + + .weak LPTIM1_IRQHandler + .thumb_set LPTIM1_IRQHandler,Default_Handler + + .weak CEC_IRQHandler + .thumb_set CEC_IRQHandler,Default_Handler + + .weak I2C4_EV_IRQHandler + .thumb_set I2C4_EV_IRQHandler,Default_Handler + + .weak I2C4_ER_IRQHandler + .thumb_set I2C4_ER_IRQHandler,Default_Handler + + .weak SPDIF_RX_IRQHandler + .thumb_set SPDIF_RX_IRQHandler,Default_Handler + + .weak OTG_FS_EP1_OUT_IRQHandler + .thumb_set OTG_FS_EP1_OUT_IRQHandler,Default_Handler + + .weak OTG_FS_EP1_IN_IRQHandler + .thumb_set OTG_FS_EP1_IN_IRQHandler,Default_Handler + + .weak OTG_FS_WKUP_IRQHandler + .thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler + + .weak OTG_FS_IRQHandler + .thumb_set OTG_FS_IRQHandler,Default_Handler + + .weak DMAMUX1_OVR_IRQHandler + .thumb_set DMAMUX1_OVR_IRQHandler,Default_Handler + + .weak HRTIM1_Master_IRQHandler + .thumb_set HRTIM1_Master_IRQHandler,Default_Handler + + .weak HRTIM1_TIMA_IRQHandler + .thumb_set HRTIM1_TIMA_IRQHandler,Default_Handler + + .weak HRTIM1_TIMB_IRQHandler + .thumb_set HRTIM1_TIMB_IRQHandler,Default_Handler + + .weak HRTIM1_TIMC_IRQHandler + .thumb_set HRTIM1_TIMC_IRQHandler,Default_Handler + + .weak HRTIM1_TIMD_IRQHandler + .thumb_set HRTIM1_TIMD_IRQHandler,Default_Handler + + .weak HRTIM1_TIME_IRQHandler + .thumb_set HRTIM1_TIME_IRQHandler,Default_Handler + + .weak HRTIM1_FLT_IRQHandler + .thumb_set HRTIM1_FLT_IRQHandler,Default_Handler + + .weak DFSDM1_FLT0_IRQHandler + .thumb_set DFSDM1_FLT0_IRQHandler,Default_Handler + + .weak DFSDM1_FLT1_IRQHandler + .thumb_set DFSDM1_FLT1_IRQHandler,Default_Handler + + .weak DFSDM1_FLT2_IRQHandler + .thumb_set DFSDM1_FLT2_IRQHandler,Default_Handler + + .weak DFSDM1_FLT3_IRQHandler + .thumb_set DFSDM1_FLT3_IRQHandler,Default_Handler + + .weak SAI3_IRQHandler + .thumb_set SAI3_IRQHandler,Default_Handler + + .weak SWPMI1_IRQHandler + .thumb_set SWPMI1_IRQHandler,Default_Handler + + .weak TIM15_IRQHandler + .thumb_set TIM15_IRQHandler,Default_Handler + + .weak TIM16_IRQHandler + .thumb_set TIM16_IRQHandler,Default_Handler + + .weak TIM17_IRQHandler + .thumb_set TIM17_IRQHandler,Default_Handler + + .weak MDIOS_WKUP_IRQHandler + .thumb_set MDIOS_WKUP_IRQHandler,Default_Handler + + .weak MDIOS_IRQHandler + .thumb_set MDIOS_IRQHandler,Default_Handler + + .weak JPEG_IRQHandler + .thumb_set JPEG_IRQHandler,Default_Handler + + .weak MDMA_IRQHandler + .thumb_set MDMA_IRQHandler,Default_Handler + + .weak SDMMC2_IRQHandler + .thumb_set SDMMC2_IRQHandler,Default_Handler + + .weak HSEM1_IRQHandler + .thumb_set HSEM1_IRQHandler,Default_Handler + + .weak ADC3_IRQHandler + .thumb_set ADC3_IRQHandler,Default_Handler + + .weak DMAMUX2_OVR_IRQHandler + .thumb_set DMAMUX2_OVR_IRQHandler,Default_Handler + + .weak BDMA_Channel0_IRQHandler + .thumb_set BDMA_Channel0_IRQHandler,Default_Handler + + .weak BDMA_Channel1_IRQHandler + .thumb_set BDMA_Channel1_IRQHandler,Default_Handler + + .weak BDMA_Channel2_IRQHandler + .thumb_set BDMA_Channel2_IRQHandler,Default_Handler + + .weak BDMA_Channel3_IRQHandler + .thumb_set BDMA_Channel3_IRQHandler,Default_Handler + + .weak BDMA_Channel4_IRQHandler + .thumb_set BDMA_Channel4_IRQHandler,Default_Handler + + .weak BDMA_Channel5_IRQHandler + .thumb_set BDMA_Channel5_IRQHandler,Default_Handler + + .weak BDMA_Channel6_IRQHandler + .thumb_set BDMA_Channel6_IRQHandler,Default_Handler + + .weak BDMA_Channel7_IRQHandler + .thumb_set BDMA_Channel7_IRQHandler,Default_Handler + + .weak COMP1_IRQHandler + .thumb_set COMP1_IRQHandler,Default_Handler + + .weak LPTIM2_IRQHandler + .thumb_set LPTIM2_IRQHandler,Default_Handler + + .weak LPTIM3_IRQHandler + .thumb_set LPTIM3_IRQHandler,Default_Handler + + .weak LPTIM4_IRQHandler + .thumb_set LPTIM4_IRQHandler,Default_Handler + + .weak LPTIM5_IRQHandler + .thumb_set LPTIM5_IRQHandler,Default_Handler + + .weak LPUART1_IRQHandler + .thumb_set LPUART1_IRQHandler,Default_Handler + + .weak CRS_IRQHandler + .thumb_set CRS_IRQHandler,Default_Handler + + .weak ECC_IRQHandler + .thumb_set ECC_IRQHandler,Default_Handler + + .weak SAI4_IRQHandler + .thumb_set SAI4_IRQHandler,Default_Handler + + .weak WAKEUP_PIN_IRQHandler + .thumb_set WAKEUP_PIN_IRQHandler,Default_Handler + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ + diff --git a/ACDC/Core/Src/stm32h7xx_hal_msp.c b/ACDC/Core/Src/stm32h7xx_hal_msp.c index 6f56e7a2..f3d67835 100644 --- a/ACDC/Core/Src/stm32h7xx_hal_msp.c +++ b/ACDC/Core/Src/stm32h7xx_hal_msp.c @@ -63,7 +63,7 @@ extern DMA_HandleTypeDef hdma_spi3_tx; /* USER CODE END 0 */ void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); - /** + /** * Initializes the Global MSP. */ void HAL_MspInit(void) @@ -479,6 +479,17 @@ void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm) /* USER CODE END TIM2_MspInit 1 */ } + else if(htim_pwm->Instance==TIM3) + { + /* USER CODE BEGIN TIM3_MspInit 0 */ + + /* USER CODE END TIM3_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_TIM3_CLK_ENABLE(); + /* USER CODE BEGIN TIM3_MspInit 1 */ + + /* USER CODE END TIM3_MspInit 1 */ + } else if(htim_pwm->Instance==TIM4) { /* USER CODE BEGIN TIM4_MspInit 0 */ @@ -516,8 +527,9 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) /**TIM2 GPIO Configuration PA15 (JTDI) ------> TIM2_CH1 PA1 ------> TIM2_CH2 + PA3 ------> TIM2_CH4 */ - GPIO_InitStruct.Pin = GPIO_PIN_15|GPIO_PIN_1; + GPIO_InitStruct.Pin = GPIO_PIN_15|GPIO_PIN_1|GPIO_PIN_3; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; @@ -528,6 +540,27 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) /* USER CODE END TIM2_MspPostInit 1 */ } + else if(htim->Instance==TIM3) + { + /* USER CODE BEGIN TIM3_MspPostInit 0 */ + + /* USER CODE END TIM3_MspPostInit 0 */ + + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**TIM3 GPIO Configuration + PA7 ------> TIM3_CH2 + */ + GPIO_InitStruct.Pin = GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF2_TIM3; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* USER CODE BEGIN TIM3_MspPostInit 1 */ + + /* USER CODE END TIM3_MspPostInit 1 */ + } else if(htim->Instance==TIM4) { /* USER CODE BEGIN TIM4_MspPostInit 0 */ @@ -593,6 +626,17 @@ void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm) /* USER CODE END TIM2_MspDeInit 1 */ } + else if(htim_pwm->Instance==TIM3) + { + /* USER CODE BEGIN TIM3_MspDeInit 0 */ + + /* USER CODE END TIM3_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_TIM3_CLK_DISABLE(); + /* USER CODE BEGIN TIM3_MspDeInit 1 */ + + /* USER CODE END TIM3_MspDeInit 1 */ + } else if(htim_pwm->Instance==TIM4) { /* USER CODE BEGIN TIM4_MspDeInit 0 */ From c6375fc724051ea450afdfc2af20eba126ec27f0 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 2 Dec 2021 05:00:29 +0100 Subject: [PATCH 195/286] encoder changes --- Genius/Inc/GeniusParameterController.hpp | 77 +++++++++++++----------- Genius/Src/main.c | 8 +-- 2 files changed, 46 insertions(+), 39 deletions(-) diff --git a/Genius/Inc/GeniusParameterController.hpp b/Genius/Inc/GeniusParameterController.hpp index e5d4414e..c2d64a01 100644 --- a/Genius/Inc/GeniusParameterController.hpp +++ b/Genius/Inc/GeniusParameterController.hpp @@ -3,6 +3,7 @@ #include #include +#include #include "device.h" #include "errorhandlers.h" #include "ProgramVector.h" @@ -37,12 +38,32 @@ enum DisplayMode { void setDisplayMode(DisplayMode mode); class Page { +protected: + static constexpr int16_t encoder_sensitivity = 1; + static constexpr int16_t encoder_mask = 0x01; public: virtual void draw(ScreenBuffer& screen){} // virtual void updateEncoders(int16_t* data, uint8_t size){} virtual void enter(){} virtual void exit(){} virtual void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){} + int16_t getDiscreteEncoderValue(int16_t current, int16_t previous){ + int32_t delta = (current - previous) * encoder_sensitivity; + if(delta > 0 && (current & encoder_mask) == encoder_mask) + return 1; + if(delta < 0 && (current & encoder_mask) == encoder_mask) + return -1; + return 0; + } + + int16_t getContinuousEncoderValue(int16_t current, int16_t previous){ + int32_t delta = (current - previous) * encoder_sensitivity; + if(delta > 0) + delta = 20 << (delta/2); + else + delta = -20 << (-delta/2); + return delta; + } }; class GeniusParameterController : public ParameterController { @@ -54,8 +75,10 @@ class GeniusParameterController : public ParameterController { // for assignable CV / modulations // int16_t user[NOF_PARAMETERS]; // user set values (ie by encoder or MIDI) GeniusParameterController() { - encoders[0] = INT16_MAX/2; - encoders[1] = INT16_MAX/2; + // encoders[0] = INT16_MAX/2; + // encoders[1] = INT16_MAX/2; + encoders[0] = 0; + encoders[1] = 0; reset(); setDisplayMode(PROGRESS_DISPLAY_MODE); } @@ -73,11 +96,11 @@ class GeniusParameterController : public ParameterController { } void updateEncoders(int16_t* data, uint8_t size){ if(data[0] != encoders[0]){ - encoderChanged(0, data[0], encoders[0]); + page->encoderChanged(0, data[0], encoders[0]); encoders[0] = data[0]; } if(data[1] != encoders[1]){ - encoderChanged(1, data[1], encoders[1]); + page->encoderChanged(1, data[1], encoders[1]); encoders[1] = data[1]; } } @@ -122,7 +145,6 @@ class SelectControlPage : public Page { const uint8_t ctrl; size_t counter; // ticks since switch was pressed down static constexpr size_t TOGGLE_LIMIT = (400/SCREEN_LOOP_SLEEP_MS); - int8_t remainder = 0; public: int8_t select; SelectControlPage(uint8_t ctrl, int8_t select): ctrl(ctrl), select(select){} @@ -130,16 +152,9 @@ class SelectControlPage : public Page { counter = 0; } void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ - if(encoder == ctrl){ - int32_t delta = current - previous + remainder; - int32_t value = delta / 4; // or use `struct div_t std::div(int, int)` - remainder = delta - value * 4; // ARM Cortex SDIV instruction discards remainder - if(value > 0) - select = min(NOF_PARAMETERS-1, select+1); - else if(value < 0) - select = max(0, select-1); + if(encoder == ctrl) + select = std::clamp(select + getDiscreteEncoderValue(current, previous), 0, NOF_PARAMETERS-1); } - } void draw(ScreenBuffer& screen){ if(!sw(ctrl)){ // encoder switch released @@ -278,24 +293,17 @@ class AssignPage : public Page { private: uint8_t select; uint8_t assign; - int8_t remainder = 0; static constexpr const char* assignations[] = {"CV A In", "CV B In", "CV A Out", "CV B Out"}; + int16_t enc, del; public: void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ - int32_t delta = current - previous + remainder; - int32_t value = delta / 4; - remainder = delta - value * 4; // ARM Cortex SDIV instruction discards remainder if(encoder == 0){ - if(value > 0) - select = min(3, select+1); - else if(value < 0) - select = max(0, select-1); + select = std::clamp(select + getDiscreteEncoderValue(current, previous), 0, 3); }else{ - if(value > 0) - assign = min(NOF_PARAMETERS-1, assign+1); - else if(value < 0) - assign = max(0, assign-1); + assign = std::clamp(assign + getDiscreteEncoderValue(current, previous), 0, NOF_PARAMETERS-1); } + enc = current; + del = current - previous; } void enter(){ select = 0; @@ -311,6 +319,10 @@ class AssignPage : public Page { screen.print(1, 26, assignations[select]); screen.print(": "); screen.print(params.getName(assign)); + screen.setCursor(1, 36); + screen.print(enc); + screen.setCursor(1, 46); + screen.print(del); } } }; @@ -318,15 +330,10 @@ class AssignPage : public Page { class StandardPage : public Page { public: void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ - int32_t delta = current - previous; - int select = encoder == 0 ? selectOnePage.select : selectTwoPage.select; - if(delta > 0) - delta = 20 << (delta/2); - else - delta = -20 << (-delta/2); - // delta = min(819, max(-819, delta)); // max rate of change +/- 20% - // delta = min(1229, max(-1229, delta)); // max rate of change +/- 30% - params.setUserValue(select, min(4095, max(0, params.getUserValue(select) + delta))); + uint8_t select = encoder == 0 ? selectOnePage.select : selectTwoPage.select; + int16_t value = getContinuousEncoderValue(current, previous); + value = std::clamp(params.getUserValue(select) + value, 0, 4095); + params.setUserValue(select, value); } void draw(ScreenBuffer& screen){ if(sw1()){ diff --git a/Genius/Src/main.c b/Genius/Src/main.c index b4c1de71..0d5e5940 100644 --- a/Genius/Src/main.c +++ b/Genius/Src/main.c @@ -656,11 +656,11 @@ static void MX_TIM2_Init(void) sConfig.IC1Polarity = TIM_ICPOLARITY_RISING; sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI; sConfig.IC1Prescaler = TIM_ICPSC_DIV1; - sConfig.IC1Filter = 0; + sConfig.IC1Filter = 8; sConfig.IC2Polarity = TIM_ICPOLARITY_RISING; sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI; sConfig.IC2Prescaler = TIM_ICPSC_DIV1; - sConfig.IC2Filter = 0; + sConfig.IC2Filter = 8; if (HAL_TIM_Encoder_Init(&htim2, &sConfig) != HAL_OK) { Error_Handler(); @@ -705,11 +705,11 @@ static void MX_TIM3_Init(void) sConfig.IC1Polarity = TIM_ICPOLARITY_RISING; sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI; sConfig.IC1Prescaler = TIM_ICPSC_DIV1; - sConfig.IC1Filter = 0; + sConfig.IC1Filter = 8; sConfig.IC2Polarity = TIM_ICPOLARITY_RISING; sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI; sConfig.IC2Prescaler = TIM_ICPSC_DIV1; - sConfig.IC2Filter = 0; + sConfig.IC2Filter = 8; if (HAL_TIM_Encoder_Init(&htim3, &sConfig) != HAL_OK) { Error_Handler(); From 31ed142e7ccf46e30288d597a61eb8b7394fa20a Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 2 Dec 2021 05:02:16 +0100 Subject: [PATCH 196/286] refactoring graphics --- Magus/Inc/hardware.h | 2 +- Magus/Src/Magus.cpp | 21 ++- Source/MagusParameterController.hpp | 272 +++++++++++----------------- 3 files changed, 122 insertions(+), 173 deletions(-) diff --git a/Magus/Inc/hardware.h b/Magus/Inc/hardware.h index 71002559..21e0fdf9 100644 --- a/Magus/Inc/hardware.h +++ b/Magus/Inc/hardware.h @@ -25,7 +25,7 @@ #define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) -#define MAIN_LOOP_SLEEP_MS 20 +/* #define MAIN_LOOP_SLEEP_MS 20 */ #define USE_USBD_AUDIO #define USE_USBD_AUDIO_TX // microphone diff --git a/Magus/Src/Magus.cpp b/Magus/Src/Magus.cpp index cef24f9a..f00dccc5 100644 --- a/Magus/Src/Magus.cpp +++ b/Magus/Src/Magus.cpp @@ -17,8 +17,8 @@ const uint32_t* dyn_rainbowinputs = rainbowinputs; const uint32_t* dyn_rainbowoutputs = rainbowoutputs; -MagusParameterController params; -Graphics graphics; +static MagusParameterController params; +Graphics graphics DMA_RAM; extern "C" void onResourceUpdate(void); @@ -138,6 +138,16 @@ void onSetup(){ Encoders_readAll(); } +void onScreenDraw(){ +#ifdef USE_TLC5946 + for(int i=0; i<16; ++i){ + uint16_t val = params.getValue(i)>>2; + setLed(i, dyn_rainbowinputs[val&0x3ff]); + } + TLC5946_Refresh_GS(); +#endif +} + void onLoop(){ #ifdef USE_USB_HOST @@ -168,25 +178,18 @@ void onLoop(){ } updateMAX11300 = false; } -#ifdef USE_TLC5946 - TLC5946_Refresh_GS(); -#endif Encoders_readAll(); params.updateEncoders(Encoders_get(), 7); MAX11300_bulkreadADC(); for(int i=0; i<16; ++i){ if(getPortMode(i) == PORT_UNI_INPUT){ params.updateValue(i, MAX11300_getADCValue(i+1)); - uint16_t val = params.getValue(i)>>2; - setLed(i, dyn_rainbowinputs[val&0x3ff]); }else{ // DACs // TODO: store values set from patch somewhere and multiply with user[] value for outputs // params.updateOutput(i, getOutputValue(i)); // MAX11300_setDACValue(i+1, params.parameters[i]); params.updateValue(i, 0); - uint16_t val = params.getValue(i)>>2; - setLed(i, dyn_rainbowoutputs[val&0x3ff]); MAX11300_setDAC(i+1, params.getValue(i)); } } diff --git a/Source/MagusParameterController.hpp b/Source/MagusParameterController.hpp index ecd6daa2..f9b3f8c5 100644 --- a/Source/MagusParameterController.hpp +++ b/Source/MagusParameterController.hpp @@ -18,7 +18,6 @@ #include "HAL_TLC5946.h" #define NOF_ENCODERS 6 -#define ENC_MULTIPLIER 6 // shift left by this many steps #define SHOW_CALIBRATION_INFO // This flag renders current values in calibration menu #define CALIBRATION_INFO_FLOAT // Display float values instead of raw integers @@ -53,7 +52,6 @@ press once to toggle mode: update > select turn to scroll through 4 functions press again to select parameter: select > update - todo: - update parameter / encoderChanged - select parameter @@ -63,20 +61,18 @@ press again to select parameter: select > update class MagusParameterController : public ParameterController { public: enum EncoderSensitivity { - SENS_SUPER_FINE = 0, - SENS_FINE = (ENC_MULTIPLIER / 2), - SENS_STANDARD = ENC_MULTIPLIER, - SENS_COARSE = (3 * ENC_MULTIPLIER / 2), - SENS_SUPER_COARSE = (ENC_MULTIPLIER * 2) + SENS_SUPER_FINE = 1, + SENS_FINE = 2, + SENS_STANDARD = 3, + SENS_COARSE = 4, + SENS_SUPER_COARSE = 5 }; EncoderSensitivity encoderSensitivity = SENS_STANDARD; // Sensitivity is currently not stored in settings, but it's not reset either. bool sensitivitySelected; - + static constexpr int16_t encoder_mask = 0x03; int16_t encoders[NOF_ENCODERS]; // last seen encoder values - int16_t offsets[NOF_ENCODERS]; // last seen encoder values int16_t user[NOF_PARAMETERS]; // user set values (ie by encoder or MIDI) - char names[NOF_PARAMETERS][12]; // char blocknames[4][NOF_ENCODERS] = {"OSC", "FLT", "ENV", "LFO"} ; // 4 times up to 5 letters/32px uint8_t selectedBlock; uint8_t selectedPid[NOF_ENCODERS]; @@ -84,7 +80,7 @@ class MagusParameterController : public ParameterController { STANDARD, SELECTBLOCKPARAMETER, SELECTGLOBALPARAMETER, CONTROL, ERROR }; DisplayMode displayMode; - + enum ControlMode { PLAY, STATUS, PRESET, DATA, VOLUME, LEDS, CALIBRATE, EXIT, NOF_CONTROL_MODES }; @@ -124,10 +120,6 @@ class MagusParameterController : public ParameterController { for(int i=0; i> encoderSensitivity); - } void drawLoadProgress(ScreenBuffer &screen){ extern char* progress_message; @@ -645,23 +629,15 @@ class MagusParameterController : public ParameterController { } void setName(uint8_t pid, const char* name){ - if(pid < NOF_PARAMETERS){ - strncpy(names[pid], name, 11); + ParameterController::setName(pid, name); #ifdef OWL_MAGUS - if(names[pid][strnlen(names[pid], 11)-1] == '>') + if(pid < NOF_PARAMETERS){ + if(name[strnlen(name, 11)-1] == '>') setPortMode(pid, PORT_UNI_OUTPUT); else setPortMode(pid, PORT_UNI_INPUT); -#endif } - } - - void setTitle(const char* str){ - strncpy(title, str, 10); - } - - uint8_t getSize(){ - return NOF_PARAMETERS; +#endif } void selectBlockParameter(uint8_t enc, int8_t pid){ @@ -671,12 +647,10 @@ class MagusParameterController : public ParameterController { if(pid == i*2+7) pid = i*2+1; // skip down selectedPid[enc] = max(i*2, min(i*2+9, pid)); - setEncoderValue(enc, user[selectedPid[enc]]); } void selectGlobalParameter(int8_t pid){ selectedPid[0] = max(0, min(NOF_PARAMETERS-1, pid)); - setEncoderValue(0, user[selectedPid[0]]); } void setControlMode(uint8_t value){ @@ -779,10 +753,10 @@ class MagusParameterController : public ParameterController { } else{ int16_t delta = value - encoders[1]; - if(delta > 0 && controlMode+1 < NOF_CONTROL_MODES){ + if(delta > 0 && controlMode+1 < NOF_CONTROL_MODES && (value & encoder_mask) == 0){ setControlMode(controlMode+1); } - else if(delta < 0 && controlMode > 0){ + else if(delta < 0 && controlMode > 0 && (value & encoder_mask) == 0){ setControlMode(controlMode-1); } if (controlMode == CALIBRATE) { @@ -852,32 +826,22 @@ class MagusParameterController : public ParameterController { } void setControlModeValue(uint8_t value){ - bool sensitivityChanged = false; switch(controlMode){ case PLAY: - sensitivitySelected = true; - value = max((uint8_t)SENS_SUPER_FINE, min((uint8_t)SENS_SUPER_COARSE, value)); - if (value > (uint8_t)encoderSensitivity){ - encoderSensitivity = (EncoderSensitivity)((uint8_t)encoderSensitivity + ENC_MULTIPLIER / 2); - value = (uint8_t)encoderSensitivity; - sensitivityChanged = true; - } - else { - if (selectedPid[1] < encoderSensitivity) { - encoderSensitivity = (EncoderSensitivity)((uint8_t)encoderSensitivity - ENC_MULTIPLIER / 2); - value = (uint8_t)encoderSensitivity; - sensitivityChanged = true; - } - } - selectedPid[1] = value; - if (sensitivityChanged) { - for (int eid = 0; eid < NOF_ENCODERS; eid++) { - // We update encoders with previous values recalculated with different sensitivity - if (eid != 1) - setEncoderValue(eid, user[selectedPid[eid]]); - } - } - break; + sensitivitySelected = true; + value = max((uint8_t)SENS_SUPER_FINE, min((uint8_t)SENS_SUPER_COARSE, value)); + if (value > (uint8_t)encoderSensitivity){ + encoderSensitivity = (EncoderSensitivity)((uint8_t)encoderSensitivity + 1); + value = (uint8_t)encoderSensitivity; + } + else { + if (value < encoderSensitivity) { + encoderSensitivity = (EncoderSensitivity)((uint8_t)encoderSensitivity - 1); + value = (uint8_t)encoderSensitivity; + } + } + selectedPid[1] = value; + break; case VOLUME: selectedPid[1] = max(0, min(127, value)); codec.setOutputGain(selectedPid[1]); @@ -923,7 +887,7 @@ class MagusParameterController : public ParameterController { break; } } - + void updateEncoders(int16_t* data, uint8_t size){ uint16_t pressed = data[0]; @@ -934,114 +898,96 @@ class MagusParameterController : public ParameterController { selectControlMode(value, pressed&0x3); // action if either left or right encoder pushed if(pressed&0x3c) // exit status mode if any other encoder is pressed controlMode = EXIT; - // use delta value from encoder 0 top left, store in selectedPid[1] - int16_t delta = data[1] - encoders[0]; - if(delta > 0 && selectedPid[1] < 127) { - setControlModeValue(selectedPid[1]+1); - } - else { - if(delta < 0 && selectedPid[1] > 0) { - setControlModeValue(selectedPid[1]-1); - } - } + // use delta value from encoder 0 top left + int16_t delta = getDiscreteEncoderValue(data[1], encoders[0]); + // we use selectedPid[1] to store control values because we don't need it to select a pid + setControlModeValue(selectedPid[1] + delta); encoders[0] = data[1]; return; // skip normal encoder processing - // todo: should update offsets so values aren't changed on exit } - else { - if(pressed & (1 << 1)){ - displayMode = CONTROL; - controlMode = PLAY; - selectedPid[1] = encoderSensitivity; - } - encoders[1] = value; - - // update encoder 0 top left - value = data[1]; - if(pressed & (1<<0)){ - // update selected global parameter - // TODO: add 'special' parameters: Volume, Freq, Gain, Gate - displayMode = SELECTGLOBALPARAMETER; - int16_t delta = value - encoders[0]; - selectedPid[0] = selectedPid[selectedBlock]; - selectedBlock = 0; - if(delta < 0) { - selectGlobalParameter(selectedPid[selectedBlock] - 1); + if(pressed & (1 << 1)){ + displayMode = CONTROL; + controlMode = PLAY; + selectedPid[1] = encoderSensitivity; // initialise control value + } + encoders[1] = value; + + // update encoder 0 top left + value = data[1]; + if(pressed & (1<<0)){ + // update selected global parameter + // TODO: add 'special' parameters: Volume, Freq, Gain, Gate + displayMode = SELECTGLOBALPARAMETER; + int16_t delta = getDiscreteEncoderValue(value, encoders[0]); + selectedPid[0] = selectedPid[selectedBlock]; + selectedBlock = 0; + selectGlobalParameter(selectedPid[selectedBlock] + delta); + } + else{ + if (displayMode == STANDARD) { + // Quick selection of global parameter by right encoder - without popover menu + int16_t delta = getDiscreteEncoderValue(data[2], right_enc); + encoders[1] = data[2]; + selectGlobalParameter(selectedPid[selectedBlock] + delta); + selectedBlock = 0; } - else { - if(delta > 0) { - selectGlobalParameter(selectedPid[selectedBlock] + 1); - } - } + if(encoders[0] != value){ + user[selectedPid[0]] += getContinuousEncoderValue(value, encoders[0]); + encoders[0] = value; } - else{ - if (displayMode == STANDARD) { - // Quick selection of global parameter by right encoder - without popover menu - int16_t delta = data[2] - right_enc; - encoders[1] = data[2]; - if(delta < 0) { - selectGlobalParameter(selectedPid[selectedBlock] - 1); - selectedBlock = 0; - } - else - if(delta > 0) { - selectGlobalParameter(selectedPid[selectedBlock] + 1); - selectedBlock = 0; - } - } - if(encoders[0] != value){ - encoders[0] = value; - // We must update encoder value before calculating user value, otherwise - // previous value would be displayed - user[selectedPid[0]] = getEncoderValue(0); - } - if(displayMode == SELECTGLOBALPARAMETER) - displayMode = STANDARD; + if(displayMode == SELECTGLOBALPARAMETER) + displayMode = STANDARD; + } + encoders[0] = value; + + // update encoders 2-6 bottom row + for(uint8_t i=2; i 0) - selectBlockParameter(i, selectedPid[i]+1); - } - else{ - if(encoders[i] != value){ - selectedBlock = i; - encoders[i] = value; - // We must update encoder value before calculating user value, otherwise - // previous value would be displayed - user[selectedPid[i]] = getEncoderValue(i); - selectGlobalParameter(selectedPid[i]); - } - if(displayMode == SELECTBLOCKPARAMETER && selectedBlock == i) - displayMode = STANDARD; - } - encoders[i] = value; + else{ + if(encoders[i] != value){ + selectedBlock = i; + user[selectedPid[i]] += getContinuousEncoderValue(value, encoders[i]); + encoders[i] = value; + selectGlobalParameter(selectedPid[i]); + } + if(displayMode == SELECTBLOCKPARAMETER && selectedBlock == i) + displayMode = STANDARD; } - if(displayMode == STANDARD && getErrorStatus() && getErrorMessage() != NULL) - displayMode = ERROR; + encoders[i] = value; } + if(displayMode == STANDARD && getErrorStatus() && getErrorMessage() != NULL) + displayMode = ERROR; } - // called by MIDI cc and/or from patch + int16_t getDiscreteEncoderValue(int16_t current, int16_t previous){ + int32_t delta = (current - previous) * encoderSensitivity; + if(delta > 0 && (delta & encoder_mask) == 0) + return 1; + if(delta < 0 && (delta & encoder_mask) == 0) + return -1; + return 0; + } + + int16_t getContinuousEncoderValue(int16_t current, int16_t previous){ + int32_t delta = (current - previous) * encoderSensitivity; + if(delta > 0) + delta = 20 << (delta/2); + else + delta = -20 << (-delta/2); + return delta; + } + +// called by MIDI cc and/or from patch void setValue(uint8_t pid, int16_t value){ user[pid] = value; - // reset encoder value if associated through selectedPid to avoid skipping - for(int i=0; i>12)>>1))); } - // void updateValues(uint16_t* data, uint8_t size){ - // for(int i=0; i<16; ++i) - // parameters[selectedPid[i]] = encoders[i] + data[i]; - // } + void updateValues(uint16_t* data, uint8_t size){ + for(int i=0; i Date: Thu, 2 Dec 2021 07:49:42 +0100 Subject: [PATCH 197/286] refactoring graphics --- Magus/Src/Magus.cpp | 2 +- Source/MagusParameterController.hpp | 1366 ++++++++++++--------------- 2 files changed, 613 insertions(+), 755 deletions(-) diff --git a/Magus/Src/Magus.cpp b/Magus/Src/Magus.cpp index f00dccc5..e85d67fe 100644 --- a/Magus/Src/Magus.cpp +++ b/Magus/Src/Magus.cpp @@ -17,7 +17,7 @@ const uint32_t* dyn_rainbowinputs = rainbowinputs; const uint32_t* dyn_rainbowoutputs = rainbowoutputs; -static MagusParameterController params; +MagusParameterController params; Graphics graphics DMA_RAM; extern "C" void onResourceUpdate(void); diff --git a/Source/MagusParameterController.hpp b/Source/MagusParameterController.hpp index f9b3f8c5..f53949e9 100644 --- a/Source/MagusParameterController.hpp +++ b/Source/MagusParameterController.hpp @@ -1,6 +1,9 @@ #ifndef __MagusParameterController_hpp__ #define __MagusParameterController_hpp__ +#include +#include +#include #include "device.h" #include "errorhandlers.h" #include "ProgramVector.h" @@ -18,8 +21,6 @@ #include "HAL_TLC5946.h" #define NOF_ENCODERS 6 -#define SHOW_CALIBRATION_INFO // This flag renders current values in calibration menu -#define CALIBRATION_INFO_FLOAT // Display float values instead of raw integers #ifndef min #define min(a,b) ((a)<(b)?(a):(b)) @@ -31,11 +32,8 @@ #define abs(x) ((x)>0?(x):-(x)) #endif -#include "calibration.hpp" - extern VersionToken* bootloader_token; - #define PORT_UNI_INPUT 1 #define PORT_UNI_OUTPUT 2 #define PORT_BI_INPUT 3 @@ -43,6 +41,70 @@ extern VersionToken* bootloader_token; void setPortMode(uint8_t index, uint8_t mode); uint8_t getPortMode(uint8_t index); +enum EncoderIdentifier { + ENCODER_L, + ENCODER_R, + ENCODER_1, + ENCODER_2, + ENCODER_3, + ENCODER_4, + ENCODER_1234 = 0x3c, + ENCODER_ANY = 0x3f, +}; + +enum EncoderSensitivity { + SENS_SUPER_FINE = 1, + SENS_FINE = 2, + SENS_STANDARD = 3, + SENS_COARSE = 4, + SENS_SUPER_COARSE = 5 +}; +static EncoderSensitivity encoder_sensitivity = SENS_FINE; +// Sensitivity is currently not stored in settings, but it's not reset either. + +enum DisplayMode { + STANDARD_DISPLAY_MODE, + PROGRESS_DISPLAY_MODE, + SELECT_BLOCK_DISPLAY_MODE, + SELECT_GLOBAL_DISPLAY_MODE, + STATUS_DISPLAY_MODE, + CONFIG_EXIT_DISPLAY_MODE, + CONFIG_SENSITIVITY_DISPLAY_MODE, + CONFIG_PATCH_DISPLAY_MODE, + CONFIG_VOLUME_DISPLAY_MODE, + CONFIG_LEDS_DISPLAY_MODE, + ERROR_DISPLAY_MODE +}; +// DisplayMode displayMode; +void setDisplayMode(uint8_t mode); + +class Page { +protected: + // static constexpr int16_t encoder_sensitivity = 1; + static constexpr int16_t encoder_mask = 0x01; +public: + virtual void draw(ScreenBuffer& screen){} + virtual void enter(){} + virtual void exit(){} + virtual void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){} + int16_t getDiscreteEncoderValue(int16_t current, int16_t previous){ + int32_t delta = (current - previous) * encoder_sensitivity; + if(delta > 0 && (current & encoder_mask) == encoder_mask) + return 1; + if(delta < 0 && (current & encoder_mask) == encoder_mask) + return -1; + return 0; + } + int16_t getContinuousEncoderValue(int16_t current, int16_t previous){ + int32_t delta = (current - previous) * encoder_sensitivity; + if(delta > 0) + delta = 20 << (delta/2); + else + delta = -20 << (-delta/2); + return delta; + } +}; + /* screen 128 x 64, font 5x7 4 blocks, 32px per each, 3-4 letters each @@ -60,63 +122,21 @@ press again to select parameter: select > update */ class MagusParameterController : public ParameterController { public: - enum EncoderSensitivity { - SENS_SUPER_FINE = 1, - SENS_FINE = 2, - SENS_STANDARD = 3, - SENS_COARSE = 4, - SENS_SUPER_COARSE = 5 - }; - EncoderSensitivity encoderSensitivity = SENS_STANDARD; - // Sensitivity is currently not stored in settings, but it's not reset either. - bool sensitivitySelected; - static constexpr int16_t encoder_mask = 0x03; + Page* page; + uint16_t buttons; int16_t encoders[NOF_ENCODERS]; // last seen encoder values int16_t user[NOF_PARAMETERS]; // user set values (ie by encoder or MIDI) - // char blocknames[4][NOF_ENCODERS] = {"OSC", "FLT", "ENV", "LFO"} ; // 4 times up to 5 letters/32px uint8_t selectedBlock; uint8_t selectedPid[NOF_ENCODERS]; - enum DisplayMode { - STANDARD, SELECTBLOCKPARAMETER, SELECTGLOBALPARAMETER, CONTROL, ERROR - }; - DisplayMode displayMode; - - enum ControlMode { - PLAY, STATUS, PRESET, DATA, VOLUME, LEDS, CALIBRATE, EXIT, NOF_CONTROL_MODES - }; - ControlMode controlMode = PLAY; - bool saveSettings; - - bool resourceDelete; - bool resourceDeletePressed; // This is used to ensure that we don't delete current resourse on menu enter - - InputCalibration input_cal; - OutputCalibration output_cal; - BaseCalibration *current_cal; - BaseCalibration::CalibrationMode calibrationMode; - bool isCalibrationRunning; - bool isCalibrationModeSelected; - bool calibrationConfirm = false; //A flag used to track encoder presses. - bool continueCalibration = false; // Runs output calibration for several buffer - - const char controlModeNames[NOF_CONTROL_MODES][12] = { - " Play >", - "< Status >", - "< Preset >", - "< Data >", - "< Volume >", - "< LEDs >", - "< V/Oct " }; MagusParameterController(){ reset(); + setDisplayMode(PROGRESS_DISPLAY_MODE); } void reset(){ setTitle("Magus"); ParameterController::reset(); Encoders_reset(); - saveSettings = false; - resourceDelete = false; for(int i=0; ipage != page){ + this->page->exit(); + this->page = page; + page->enter(); } } + + void drawMessage(int16_t y, ScreenBuffer& screen){ + ProgramVector* pv = getProgramVector(); + if(pv->message != NULL){ + screen.setTextSize(1); + screen.setTextWrap(true); + screen.print(0, y, pv->message); + screen.setTextWrap(false); + } + } + + void drawParameter(ScreenBuffer& screen){ + drawParameter(selectedPid[selectedBlock], 54, screen); + } void drawParameter(int pid, int y, ScreenBuffer& screen){ int x = 0; @@ -235,90 +262,176 @@ class MagusParameterController : public ParameterController { } } } - - void drawPlay(ScreenBuffer& screen) { - int offset = 16; - screen.setTextSize(1); - screen.print(1, offset + 33, "Encoder sensitivity"); - screen.drawCircle(24, offset + 15, 8, WHITE); - screen.drawCircle(44, offset + 15, 8, WHITE); - screen.drawCircle(64, offset + 15, 8, WHITE); - screen.drawCircle(84, offset + 15, 8, WHITE); - screen.drawCircle(104, offset + 15, 8, WHITE); - - screen.fillCircle(24, offset + 15, 6, WHITE); - if (encoderSensitivity >= SENS_FINE) - screen.fillCircle(44, offset + 15, 6, WHITE); - if (encoderSensitivity >= SENS_STANDARD) - screen.fillCircle(64, offset + 15, 6, WHITE); - if (encoderSensitivity >= SENS_COARSE) - screen.fillCircle(84, offset + 15, 6, WHITE); - if (encoderSensitivity >= SENS_SUPER_COARSE) - screen.fillCircle(104, offset + 15, 6, WHITE); -} + void drawTitle(ScreenBuffer& screen){ + drawTitle(title, screen); + } - void drawStatus(ScreenBuffer& screen){ - int offset = 16; - screen.setTextSize(1); - // single row - screen.print(1, offset+8, "mem "); - ProgramVector* pv = getProgramVector(); - int mem = (int)(pv->heap_bytes_used)/1024; - if(mem > 999){ - screen.print(mem/1024); - screen.print("M"); - }else{ - screen.print(mem); - screen.print("k"); - } + void drawTitle(const char* title, ScreenBuffer& screen){ + // draw title + screen.setTextSize(2); + screen.print(0, 16, title); + } - // draw flash usage - int flash_used = storage.getUsedSize() / 1024; - int flash_total = storage.getTotalCapacity() / 1024; - screen.print(64, offset + 8, "flash "); - screen.print(flash_used * 100 / flash_total); - screen.print("%"); - screen.setCursor(64, offset + 17); - if (flash_used > 999) { - screen.print(flash_used / 1024); - screen.print("."); - screen.print((int)((flash_used % 1024) * 10 / 1024)); - screen.print("M/"); - } - else { - screen.print(flash_used); - screen.print("k/"); - } - if (flash_total > 999) { - screen.print(flash_total / 1024); - screen.print("."); - screen.print((int)((flash_total % 1024) * 10 / 1024)); - screen.print("M"); + void draw(ScreenBuffer& screen){ + screen.clear(); + screen.setTextWrap(false); + page->draw(screen); + drawBlocks(screen); + } + + void setName(uint8_t pid, const char* name){ + ParameterController::setName(pid, name); +#ifdef OWL_MAGUS + if(pid < NOF_PARAMETERS){ + if(name[strnlen(name, 11)-1] == '>') + setPortMode(pid, PORT_UNI_OUTPUT); + else + setPortMode(pid, PORT_UNI_INPUT); } - else { - screen.print(flash_total); - screen.print("k"); +#endif + } + + void selectBlockParameter(uint8_t enc, int8_t pid){ + uint8_t i = enc-2; + if(pid == i*2+2) + pid = i*2+8; // skip up + if(pid == i*2+7) + pid = i*2+1; // skip down + selectedPid[enc] = max(i*2, min(i*2+9, pid)); + } + + void selectGlobalParameter(int8_t pid){ + selectedPid[0] = max(0, min(NOF_PARAMETERS-1, pid)); + } + + bool isEncoderPushed(uint16_t enc){ + return buttons & enc; + } + + void updateEncoders(int16_t* data, uint8_t size){ + buttons = data[0]; + for(size_t i=1; iencoderChanged(i, data[i], encoders[i]); + encoders[i] = data[i]; + } } + } - // draw CPU load - screen.print(1, offset + 17, "cpu "); - screen.print((int)((pv->cycles_per_block) / pv->audio_blocksize) / 35); - screen.print("%"); - - // draw firmware version - screen.print(1, offset+26, getFirmwareVersion()); - if (bootloader_token->magic == BOOTLOADER_MAGIC){ - screen.print(" (bt."); - screen.print(getBootloaderVersion()); - screen.print(")"); +// called by MIDI cc and/or from patch + void setValue(uint8_t pid, int16_t value){ + user[pid] = value; + // TODO: store values set from patch somewhere and multiply with user[] value for outputs + // graphics.params.updateOutput(i, getOutputValue(i)); + } + + // @param value is the modulation ADC value + void updateValue(uint8_t pid, int16_t value){ + // smoothing at apprx 50Hz + parameters[pid] = max(0, min(4095, (parameters[pid] + user[pid] + value)>>1)); + } + + int16_t getValue(uint8_t pid){ + return parameters[pid]; + } + + void updateOutput(uint8_t pid, int16_t value){ + parameters[pid] = max(0, min(4095, (((parameters[pid] + (user[pid]*value))>>12)>>1))); + } + + void updateValues(uint16_t* data, uint8_t size){ + for(int i=0; icycles_per_block)/pv->audio_blocksize)/35); screen.print("%"); } +}; - void drawError(ScreenBuffer& screen){ - if(getErrorMessage() != NULL){ - screen.setTextSize(1); - screen.setTextWrap(true); - screen.print(0, 26, getErrorMessage()); - screen.setTextWrap(false); +class SelectGlobalPage : public Page { +public: + void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ + if(encoder == ENCODER_L){ + // update selected global parameter + // TODO: add 'special' parameters: Volume, Freq, Gain, Gate + params.changeBlockAssign(ENCODER_L, getDiscreteEncoderValue(current, previous)); } - drawMessage(51, screen); } - - void drawTitle(ScreenBuffer& screen){ - drawTitle(title, screen); + void draw(ScreenBuffer& screen){ + if(!params.isEncoderPushed(ENCODER_L)) + setDisplayMode(STANDARD_DISPLAY_MODE); + params.drawTitle(screen); + params.drawGlobalParameterNames(screen); } +}; - void drawTitle(const char* title, ScreenBuffer& screen){ - // draw title - screen.setTextSize(2); - screen.print(0, 16, title); +class SelectBlockPage : public Page { +public: + void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ + // if(params.isEncoderPushed(ENCODER_1234)){ + // if(params.isEncoderPushed(ENCODER_1234)){ + if(encoder == params.selectedBlock){ + // update selected block parameter + params.changeBlockAssign(encoder, getDiscreteEncoderValue(current, previous)); + } } - - void drawMessage(int16_t y, ScreenBuffer& screen){ - ProgramVector* pv = getProgramVector(); - if(pv->message != NULL){ - screen.setTextSize(1); - screen.setTextWrap(true); - screen.print(0, y, pv->message); - screen.setTextWrap(false); - } + void draw(ScreenBuffer& screen){ + if(!params.isEncoderPushed(ENCODER_1234)) + setDisplayMode(STANDARD_DISPLAY_MODE); + params.drawTitle(screen); + params.drawBlockParameterNames(screen); } +}; - void drawPresetNames(uint8_t selected, ScreenBuffer& screen){ +class EncoderSensitivityPage : public Page { +public: + void enter(){ + // selectedPid[1] = encoder_sensitivity; // initialise control value + } + void exit(){} + + void draw(ScreenBuffer& screen){ + if(params.isEncoderPushed(ENCODER_ANY)) + setDisplayMode(CONFIG_EXIT_DISPLAY_MODE); + params.drawTitle("< Encode >", screen); + int offset = 16; screen.setTextSize(1); - selected = min(selected, (int)registry.getNumberOfPatches()-1); - if(selected > 1) { - screen.setCursor(1, 24); - screen.print((int)selected - 1); - screen.print("."); - screen.print(registry.getPatchName(selected - 1)); - }; - screen.setCursor(1, 24+10); - screen.print((int)selected); - screen.print("."); - screen.print(registry.getPatchName(selected)); - if(selected+1 < (int)registry.getNumberOfPatches()) { - screen.setCursor(1, 24+20); - screen.print((int)selected + 1); - screen.print("."); - screen.print(registry.getPatchName(selected+1)); - } - screen.invert(0, 25, 128, 10); + screen.print(1, offset + 33, "Encoder sensitivity"); + screen.drawCircle(24, offset + 15, 8, WHITE); + screen.drawCircle(44, offset + 15, 8, WHITE); + screen.drawCircle(64, offset + 15, 8, WHITE); + screen.drawCircle(84, offset + 15, 8, WHITE); + screen.drawCircle(104, offset + 15, 8, WHITE); + screen.fillCircle(24, offset + 15, 6, WHITE); + if (encoder_sensitivity >= SENS_FINE) + screen.fillCircle(44, offset + 15, 6, WHITE); + if (encoder_sensitivity >= SENS_STANDARD) + screen.fillCircle(64, offset + 15, 6, WHITE); + if (encoder_sensitivity >= SENS_COARSE) + screen.fillCircle(84, offset + 15, 6, WHITE); + if (encoder_sensitivity >= SENS_SUPER_COARSE) + screen.fillCircle(104, offset + 15, 6, WHITE); } - void drawResourceNames(int selected, ScreenBuffer &screen) { - screen.setTextSize(1); - if (resourceDelete) - selected = min(selected, (int)registry.getNumberOfResources()); - else - selected = min(selected, (int)registry.getNumberOfResources() - 1); - if (resourceDelete && selected == 0) - screen.print(18, 24, "Delete:"); - if (selected > 0 && registry.getNumberOfResources() > 0) { - screen.setCursor(1, 24); - screen.print((int)selected); - screen.print("."); - screen.print(registry.getResourceName(selected)); - }; - if (selected < (int)registry.getNumberOfResources()) { - screen.setCursor(1, 24 + 10); - screen.print((int)selected + 1); - screen.print("."); - screen.print(registry.getResourceName(1 + selected)); + void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ + if(encoder == ENCODER_R){ + int16_t delta = getDiscreteEncoderValue(current, previous); + setDisplayMode(std::clamp(CONFIG_SENSITIVITY_DISPLAY_MODE + delta, (int)STATUS_DISPLAY_MODE, (int)CONFIG_LEDS_DISPLAY_MODE)); + }else if(encoder == ENCODER_L){ + int16_t delta = getDiscreteEncoderValue(current, previous); + encoder_sensitivity = (EncoderSensitivity)std::clamp(encoder_sensitivity + delta, (int)SENS_SUPER_FINE, (int)SENS_SUPER_COARSE); } - else if (resourceDelete) - screen.print(18, 24 + 10, "Exit"); - if (selected + 1 < (int)registry.getNumberOfResources()) { - screen.setCursor(1, 24 + 20); - screen.print((int)selected + 2); - screen.print("."); - screen.print(registry.getResourceName(2 + selected)); + // // update encoder 1 top right + // int16_t value = data[2]; + // int16_t right_enc = encoders[1]; // Save old value for encoder scrolling in main menu + // if(displayMode == CONTROL){ + // selectControlMode(value, pressed&0x3); // action if either left or right encoder pushed + // if(params.isEncoderPushed(ENCODER_1234)){ + // // if(pressed&0x3c) // exit status mode if any other encoder is pressed + // controlMode = EXIT; + // // use delta value from encoder 0 top left + // int16_t delta = getDiscreteEncoderValue(data[1], encoders[0]); + // // we use selectedPid[1] to store control values because we don't need it to select a pid + // setControlModeValue(selectedPid[1] + delta); + // encoders[0] = data[1]; + // return; // skip normal encoder processing + // } + } +}; + +class ConfigVolumePage : public Page { +public: + void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ + if(encoder == ENCODER_R){ + int16_t delta = getDiscreteEncoderValue(current, previous); + setDisplayMode(std::clamp(CONFIG_VOLUME_DISPLAY_MODE + delta, (int)STATUS_DISPLAY_MODE, (int)CONFIG_LEDS_DISPLAY_MODE)); + }else if(encoder == ENCODER_L){ + int16_t value = std::clamp(settings.audio_output_gain + getContinuousEncoderValue(current, previous), 0, 127); + if(settings.audio_output_gain != value){ + settings.audio_output_gain = value; + codec.setOutputGain(value); + } } - if (resourceDelete) - screen.drawRectangle(0, 25, 128, 10, WHITE); - else - screen.invert(0, 25, 128, 10); + } + void draw(ScreenBuffer& screen){ + if(params.isEncoderPushed(ENCODER_ANY)) + setDisplayMode(CONFIG_EXIT_DISPLAY_MODE); + params.drawTitle("< Volume >", screen); + drawVolume(screen); } - void drawVolume(uint8_t selected, ScreenBuffer& screen){ + void drawVolume(ScreenBuffer& screen){ screen.setTextSize(1); screen.print(1, 24 + 10, "Volume "); screen.print((int)settings.audio_output_gain); @@ -434,8 +574,37 @@ class MagusParameterController : public ParameterController { screen.fillRectangle(64, 24 + 1 + 2, (int)settings.audio_output_gain >> 1, 4, WHITE); screen.invert(0, 24, 40, 10); } +}; - void drawLeds(uint8_t selected, ScreenBuffer& screen){ +class ConfigLedsPage : public Page { +public: + void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ + if(encoder == ENCODER_R){ + int16_t delta = getDiscreteEncoderValue(current, previous); + setDisplayMode(std::clamp(CONFIG_LEDS_DISPLAY_MODE + delta, (int)STATUS_DISPLAY_MODE, (int)CONFIG_LEDS_DISPLAY_MODE)); + }else if(encoder == ENCODER_L){ + int16_t value = std::clamp(settings.leds_brightness + getContinuousEncoderValue(current, previous), 0, 63); + if(settings.leds_brightness != value){ + settings.leds_brightness = value; + TLC5946_setAll_DC(value); + TLC5946_Refresh_DC(); + } + } + } + void draw(ScreenBuffer& screen){ + if(params.isEncoderPushed(ENCODER_ANY)) + setDisplayMode(CONFIG_EXIT_DISPLAY_MODE); + // " Play >", + // "< Status >", + // "< Preset >", + // "< Data >", + // "< Volume >", + // "< LEDs >", + params.drawTitle("< LEDs >", screen); + drawLeds(screen); + } + + void drawLeds(ScreenBuffer& screen){ screen.setTextSize(1); screen.print(1, 24 + 10, "Level "); screen.print((int)settings.leds_brightness); @@ -443,582 +612,271 @@ class MagusParameterController : public ParameterController { screen.fillRectangle(64, 24 + 1 + 2, (int)settings.leds_brightness, 4, WHITE); screen.invert(0, 24, 40, 10); } +}; - void drawCalibration(uint8_t selected, ScreenBuffer& screen){ - screen.setTextSize(1); - if (isCalibrationRunning) { - if (isCalibrationModeSelected) { - float input_multiplier = (float)(int32_t)settings.input_scalar / UINT16_MAX; - float input_offset = (float)(int32_t)settings.input_offset / UINT16_MAX; - float input_sample = current_cal->getInput(); - float input_voltage = (input_sample - input_offset) * input_multiplier; - - switch (current_cal->state){ - case BaseCalibration::CAL_LO: - if (calibrationMode == BaseCalibration::CAL_INPUT) { - screen.print(1, 24 + 10, "1V to IN1"); - } - else { - screen.print(1, 24 + 10, "OUT1 to IN1"); - screen.print(1, 24 + 20, "Voltage "); - screen.print(input_voltage); - } - screen.print(1, 24 + 30, "Sample "); - screen.print(input_sample); - break; - case BaseCalibration::CAL_HI: - if (calibrationMode == BaseCalibration::CAL_INPUT) { - screen.print(1, 24 + 10, "3V to IN1"); - } - else { - screen.print(1, 24 + 10, "OUT1 to IN1"); - screen.print(1, 24 + 20, "Voltage "); - screen.print(input_voltage); - } - screen.print(1, 24 + 30, "Sample "); - screen.print(input_sample); - break; - case BaseCalibration::CAL_DONE: - // Save or discard results - screen.print(1, 24, "Calibration results"); - screen.print(1, 24 + 10, "Scalar:"); - screen.print((float)current_cal->getScalar() / UINT16_MAX); - screen.print(1, 24 + 20, "Offset:"); - screen.print((float)current_cal->getOffset() / UINT16_MAX); - - screen.print(1, 24 + 30, "Save"); - screen.print(65, 24 + 30, "Discard"); - if (selected == BaseCalibration::CAL_SAVE) { - screen.invert(0, 24 + 20, 64, 10); - } - else { - screen.invert(64, 24 + 20, 64, 10); - } - break; - } - } - else { - // Select calibration mode - screen.print(1, 24, "Input"); - screen.print(49, 24, "Output"); - screen.print(97, 24, "Exit"); - switch (selected) { - case BaseCalibration::CAL_INPUT: - screen.invert(0, 14, 48, 10); - break; - case BaseCalibration::CAL_OUTPUT: - screen.invert(48, 14, 48, 10); - break; - default: - screen.invert(96, 14, 48, 10); - break; - } - } - } - else { - screen.print(1, 24, "Start calibration"); - #ifdef SHOW_CALIBRATION_INFO - // Not sure if this should be visible by default, but it helps while debugging - screen.invert(0, 14, 128, 10); - screen.print(29, 24 + 10, "Input"); - screen.print(78, 24 + 10, "Output"); - screen.print(1, 24 + 20, "Scl"); - - #ifdef CALIBRATION_INFO_FLOAT - screen.print(29, 24 + 20, msg_ftoa((float)((int32_t)settings.input_scalar) / UINT16_MAX, 10)); - screen.print(78, 24 + 20, msg_ftoa((float)((int32_t)settings.output_scalar) / UINT16_MAX, 10)); - #else - screen.print(29, 24 + 20, msg_itoa(settings.input_scalar, 10)); - screen.print(78, 24 + 20, msg_itoa(settings.output_scalar, 10)); - #endif // CALIBRATION_INFO_FLOAT - - screen.print(1, 24 + 30, "Off"); - - #ifdef CALIBRATION_INFO_FLOAT - screen.print(29, 24 + 30, msg_ftoa((float)((int32_t)settings.input_offset) / UINT16_MAX, 10)); - screen.print(78, 24 + 30, msg_ftoa((float)((int32_t)settings.output_offset) / UINT16_MAX, 10)); - #else - screen.print(29, 24 + 30, msg_itoa(settings.input_offset, 10)); - screen.print(78, 24 + 30, msg_itoa(settings.output_offset, 10)); - #endif // CALIBRATION_INFO_FLOAT - - screen.drawHorizontalLine(0, 24 + 10, 128, WHITE); - screen.drawHorizontalLine(0, 24 + 20, 128, WHITE); - screen.drawVerticalLine(27, 24, 30, WHITE); - screen.drawVerticalLine(76, 24, 30, WHITE); - #endif // SHOW_CALIBRATION_INFO +class SelectPatchPage : public Page { +private: + uint8_t patchselect; +public: + void enter(){ + patchselect = program.getProgramIndex(); + } + void exit(){ + if(registry.hasPatch(patchselect)){ + program.loadProgram(patchselect); + program.resetProgram(false); } } - - void drawControlMode(ScreenBuffer& screen){ - switch(controlMode){ - case PLAY: - // drawMessage("push to exit ->", screen); - drawTitle(controlModeNames[controlMode], screen); - drawPlay(screen); - break; - case STATUS: - drawTitle(controlModeNames[controlMode], screen); - drawStatus(screen); - drawMessage(51, screen); - break; - case PRESET: - drawTitle(controlModeNames[controlMode], screen); - drawPresetNames(selectedPid[1], screen); - break; - case DATA: - drawTitle(controlModeNames[controlMode], screen); - drawResourceNames(selectedPid[1], screen); - break; - case VOLUME: - drawTitle(controlModeNames[controlMode], screen); - drawVolume(selectedPid[1], screen); - break; - case LEDS: - drawTitle(controlModeNames[controlMode], screen); - drawLeds(selectedPid[1], screen); - break; - case CALIBRATE: - drawTitle(controlModeNames[controlMode], screen); - drawCalibration(selectedPid[1], screen); - break; - case EXIT: - drawTitle("done", screen); - break; - default: - break; + void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ + if(encoder == ENCODER_R){ + int16_t delta = getDiscreteEncoderValue(current, previous); + setDisplayMode(std::clamp(CONFIG_LEDS_DISPLAY_MODE + delta, (int)STATUS_DISPLAY_MODE, (int)CONFIG_LEDS_DISPLAY_MODE)); + }else if(encoder == ENCODER_L){ + patchselect = std::clamp(patchselect + getContinuousEncoderValue(current, previous), 0, (int)registry.getNumberOfPatches()-1); } - // todo! - // select: Scope, VU Meter, Patch Stats, Set Gain, Show MIDI, Reset Patch, Select Patch... } - void draw(ScreenBuffer& screen){ - screen.clear(); - screen.setTextWrap(false); - switch(displayMode){ - case STANDARD: - // draw most recently changed parameter - // drawParameter(selectedPid[selectedBlock], 44, screen); - if (owl.getOperationMode() == LOAD_MODE){ - drawLoadProgress(screen); - } - else { - drawParameter(selectedPid[selectedBlock], 54, screen); - } - // use callback to draw title and message - graphics.drawCallback(screen.getBuffer(), screen.getWidth(), screen.getHeight()); - break; - case SELECTBLOCKPARAMETER: - drawTitle(screen); - drawBlockParameterNames(screen); - break; - case SELECTGLOBALPARAMETER: - drawTitle(screen); - drawGlobalParameterNames(screen); - break; - case CONTROL: - drawControlMode(screen); - break; - case ERROR: - drawTitle("ERROR", screen); - drawError(screen); - drawStats(screen); - break; + if(params.isEncoderPushed(ENCODER_ANY)){ + setDisplayMode(CONFIG_EXIT_DISPLAY_MODE); } - drawBlocks(screen); - } - - void setName(uint8_t pid, const char* name){ - ParameterController::setName(pid, name); -#ifdef OWL_MAGUS - if(pid < NOF_PARAMETERS){ - if(name[strnlen(name, 11)-1] == '>') - setPortMode(pid, PORT_UNI_OUTPUT); - else - setPortMode(pid, PORT_UNI_INPUT); + params.drawTitle("< Patch >", screen); + drawPresetNames(patchselect, screen); + } + void drawPresetNames(uint8_t selected, ScreenBuffer& screen){ + screen.setTextSize(1); + selected = min(selected, (int)registry.getNumberOfPatches()-1); + if(selected > 1) { + screen.setCursor(1, 24); + screen.print((int)selected - 1); + screen.print("."); + screen.print(registry.getPatchName(selected - 1)); + }; + screen.setCursor(1, 24+10); + screen.print((int)selected); + screen.print("."); + screen.print(registry.getPatchName(selected)); + if(selected+1 < (int)registry.getNumberOfPatches()) { + screen.setCursor(1, 24+20); + screen.print((int)selected + 1); + screen.print("."); + screen.print(registry.getPatchName(selected+1)); } -#endif - } - - void selectBlockParameter(uint8_t enc, int8_t pid){ - uint8_t i = enc-2; - if(pid == i*2+2) - pid = i*2+8; // skip up - if(pid == i*2+7) - pid = i*2+1; // skip down - selectedPid[enc] = max(i*2, min(i*2+9, pid)); - } - - void selectGlobalParameter(int8_t pid){ - selectedPid[0] = max(0, min(NOF_PARAMETERS-1, pid)); + screen.invert(0, 25, 128, 10); } +}; - void setControlMode(uint8_t value){ - controlMode = (ControlMode)value; - switch(controlMode){ - case PLAY: - case STATUS: - break; - case PRESET: - selectedPid[1] = settings.program_index; - break; - case DATA: - selectedPid[1] = 0; // Go to beginning of resource list - resourceDelete = false; - break; - case VOLUME: - selectedPid[1] = settings.audio_output_gain; // todo: get current - break; - case LEDS: - selectedPid[1] = settings.leds_brightness; - break; - case CALIBRATE: - selectedPid[1] = 2; - resetCalibration(); - break; - default: - break; +class StatusPage : public Page { +public: + void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ + if(encoder == ENCODER_R){ + int16_t delta = getDiscreteEncoderValue(current, previous); + setDisplayMode(std::clamp(STATUS_DISPLAY_MODE + delta, (int)STATUS_DISPLAY_MODE, (int)CONFIG_LEDS_DISPLAY_MODE)); } } - - void selectControlMode(int16_t value, bool pressed){ - if(pressed){ - switch(controlMode){ - case PLAY: - if (sensitivitySelected) { - controlMode = EXIT; - } - break; - case STATUS: - setErrorStatus(NO_ERROR); - break; - case PRESET: - // load preset - settings.program_index = selectedPid[1]; - program.loadProgram(settings.program_index); - program.resetProgram(false); - controlMode = EXIT; - break; - case DATA: { - if (resourceDelete) { - if (selectedPid[1] == registry.getNumberOfResources()){ - // Exit on last menu item (exit link after resources list) - resourceDelete = false; - resourceDeletePressed = false; - controlMode = EXIT; - } - else if (!resourceDeletePressed) { - // Delete resource unless it's protected by "__" prefix - resourceDeletePressed = true; - Resource* res = registry.getResource(selectedPid[1]); - if (res != NULL) { - if(res->getName()[0] == '_' && res->getName()[1] == '_'){ - debugMessage("Resource protected"); - } - else { - storage.eraseResource(res); - } - } - } - } - else { - resourceDelete = true; - resourceDeletePressed = true; - } - break; - } - case VOLUME: - controlMode = EXIT; - break; - case LEDS: - controlMode = EXIT; - break; - case CALIBRATE: - if (!calibrationConfirm) { - calibrationConfirm = true; - updateCalibration(); - } - break; - default: - break; - } - } - else{ - if(controlMode == EXIT){ - displayMode = STANDARD; - //selectedBlock = 0; - sensitivitySelected = false; - if(saveSettings) - settings.saveToFlash(); - } - else{ - int16_t delta = value - encoders[1]; - if(delta > 0 && controlMode+1 < NOF_CONTROL_MODES && (value & encoder_mask) == 0){ - setControlMode(controlMode+1); - } - else if(delta < 0 && controlMode > 0 && (value & encoder_mask) == 0){ - setControlMode(controlMode-1); - } - if (controlMode == CALIBRATE) { - if (continueCalibration) - updateCalibration(); - else - calibrationConfirm = false; - } - else if (controlMode == DATA && resourceDeletePressed) { - resourceDeletePressed = false; - } - encoders[1] = value; - } + void draw(ScreenBuffer& screen){ + if(params.isEncoderPushed(ENCODER_ANY)){ + setDisplayMode(CONFIG_EXIT_DISPLAY_MODE); + }else{ + params.drawTitle(" Status >", screen); + drawStatus(screen); } } - - void resetCalibration(){ - //selectedPid[1] = 0; - isCalibrationRunning = false; - isCalibrationModeSelected = false; - input_cal.reset(); - output_cal.reset(); - } - - void updateCalibration(){ - continueCalibration = false; - // This function runs once every time when encoder is pressed. - if (isCalibrationRunning){ - if (isCalibrationModeSelected) { - if (current_cal->state == BaseCalibration::CAL_DONE) { - current_cal->results = (BaseCalibration::CalibrationResults)selectedPid[1]; - if (current_cal->results == BaseCalibration::CAL_SAVE) - current_cal->storeResults(); - resetCalibration(); - program.loadProgram(settings.program_index); - program.resetProgram(false); - } else{ - if (current_cal->readSample()) { - current_cal->nextState(); - } - else { - continueCalibration = true; - } - if (current_cal->isDone()) - current_cal->calibrate(); - } - } else { - isCalibrationModeSelected = true; - switch (selectedPid[1]){ - case 0: - program.exitProgram(false); - input_cal.reset(); - break; - case 1: - program.exitProgram(false); - output_cal.reset(); - break; - //case 2: - // controlMode = EXIT; - // break; - } - } - } - else{ - isCalibrationRunning = true; + + void drawStatus(ScreenBuffer& screen){ + int offset = 16; + screen.setTextSize(1); + // single row + screen.print(1, offset+8, "mem "); + ProgramVector* pv = getProgramVector(); + int mem = (int)(pv->heap_bytes_used)/1024; + if(mem > 999){ + screen.print(mem/1024); + screen.print("M"); + }else{ + screen.print(mem); + screen.print("k"); } - } - void setControlModeValue(uint8_t value){ - switch(controlMode){ - case PLAY: - sensitivitySelected = true; - value = max((uint8_t)SENS_SUPER_FINE, min((uint8_t)SENS_SUPER_COARSE, value)); - if (value > (uint8_t)encoderSensitivity){ - encoderSensitivity = (EncoderSensitivity)((uint8_t)encoderSensitivity + 1); - value = (uint8_t)encoderSensitivity; - } - else { - if (value < encoderSensitivity) { - encoderSensitivity = (EncoderSensitivity)((uint8_t)encoderSensitivity - 1); - value = (uint8_t)encoderSensitivity; - } - } - selectedPid[1] = value; - break; - case VOLUME: - selectedPid[1] = max(0, min(127, value)); - codec.setOutputGain(selectedPid[1]); - settings.audio_output_gain = selectedPid[1]; - saveSettings = true; - break; - case LEDS: - selectedPid[1] = max(0, min(63, value)); - TLC5946_setAll_DC(selectedPid[1]); - TLC5946_Refresh_DC(); - settings.leds_brightness = selectedPid[1]; - saveSettings = true; - break; - case PRESET: - selectedPid[1] = max(1, min(registry.getNumberOfPatches()-1, value)); - break; - case DATA: - if (resourceDelete) - selectedPid[1] = max(0, min(registry.getNumberOfResources(), value)); - else - selectedPid[1] = max(0, min(registry.getNumberOfResources() - 1, value)); - break; - case CALIBRATE: - if (isCalibrationRunning && !isCalibrationModeSelected) { - selectedPid[1] = max(0, min(value, 2)); - // calibration process is not running yet. - switch ((BaseCalibration::CalibrationMode)selectedPid[1]){ - case BaseCalibration::CAL_INPUT: - calibrationMode = BaseCalibration::CAL_INPUT; - current_cal = &input_cal; - break; - case BaseCalibration::CAL_OUTPUT: - calibrationMode = BaseCalibration::CAL_OUTPUT; - current_cal = &output_cal; - break; - } - } - else if (isCalibrationRunning && isCalibrationModeSelected && current_cal->state == BaseCalibration::CAL_DONE) { - selectedPid[1] = max(0, min(value, 1)); - } - break; - default: - break; + // draw flash usage + int flash_used = storage.getUsedSize() / 1024; + int flash_total = storage.getTotalCapacity() / 1024; + screen.print(64, offset + 8, "flash "); + screen.print(flash_used * 100 / flash_total); + screen.print("%"); + screen.setCursor(64, offset + 17); + if (flash_used > 999) { + screen.print(flash_used / 1024); + screen.print("."); + screen.print((int)((flash_used % 1024) * 10 / 1024)); + screen.print("M/"); } - } - - void updateEncoders(int16_t* data, uint8_t size){ - uint16_t pressed = data[0]; - - // update encoder 1 top right - int16_t value = data[2]; - int16_t right_enc = encoders[1]; // Save old value for encoder scrolling in main menu - if(displayMode == CONTROL){ - selectControlMode(value, pressed&0x3); // action if either left or right encoder pushed - if(pressed&0x3c) // exit status mode if any other encoder is pressed - controlMode = EXIT; - // use delta value from encoder 0 top left - int16_t delta = getDiscreteEncoderValue(data[1], encoders[0]); - // we use selectedPid[1] to store control values because we don't need it to select a pid - setControlModeValue(selectedPid[1] + delta); - encoders[0] = data[1]; - return; // skip normal encoder processing + else { + screen.print(flash_used); + screen.print("k/"); } - if(pressed & (1 << 1)){ - displayMode = CONTROL; - controlMode = PLAY; - selectedPid[1] = encoderSensitivity; // initialise control value + if (flash_total > 999) { + screen.print(flash_total / 1024); + screen.print("."); + screen.print((int)((flash_total % 1024) * 10 / 1024)); + screen.print("M"); } - encoders[1] = value; - - // update encoder 0 top left - value = data[1]; - if(pressed & (1<<0)){ - // update selected global parameter - // TODO: add 'special' parameters: Volume, Freq, Gain, Gate - displayMode = SELECTGLOBALPARAMETER; - int16_t delta = getDiscreteEncoderValue(value, encoders[0]); - selectedPid[0] = selectedPid[selectedBlock]; - selectedBlock = 0; - selectGlobalParameter(selectedPid[selectedBlock] + delta); + else { + screen.print(flash_total); + screen.print("k"); } - else{ - if (displayMode == STANDARD) { - // Quick selection of global parameter by right encoder - without popover menu - int16_t delta = getDiscreteEncoderValue(data[2], right_enc); - encoders[1] = data[2]; - selectGlobalParameter(selectedPid[selectedBlock] + delta); - selectedBlock = 0; - } - if(encoders[0] != value){ - user[selectedPid[0]] += getContinuousEncoderValue(value, encoders[0]); - encoders[0] = value; - } - if(displayMode == SELECTGLOBALPARAMETER) - displayMode = STANDARD; + // draw CPU load + screen.print(1, offset + 17, "cpu "); + screen.print((int)((pv->cycles_per_block) / pv->audio_blocksize) / 35); + screen.print("%"); + + // draw firmware version + screen.print(1, offset+26, getFirmwareVersion()); + if (bootloader_token->magic == BOOTLOADER_MAGIC){ + screen.print(" (bt."); + screen.print(getBootloaderVersion()); + screen.print(")"); } - encoders[0] = value; - - // update encoders 2-6 bottom row - for(uint8_t i=2; imessage != NULL) +// screen.print(2, 16, pv->message); +// screen.print(2, 26, "cpu/mem: "); +// float percent = (pv->cycles_per_block/pv->audio_blocksize) / (float)ARM_CYCLES_PER_SAMPLE; +// screen.print((int)(percent*100)); +// screen.print("% "); +// screen.print((int)(pv->heap_bytes_used)/1024); +// screen.print("kB"); +// // draw firmware version +// screen.print(1, 36, getFirmwareVersion()); +// if (bootloader_token->magic == BOOTLOADER_MAGIC){ +// screen.print(" bt."); +// screen.print(getBootloaderVersion()); +// } +// #ifdef USE_DIGITALBUS +// screen.print(1, 56, "Bus: "); +// screen.print(bus.getStatusString()); +// screen.print(" "); +// extern uint32_t bus_tx_packets, bus_rx_packets; +// screen.print((int)bus_tx_packets); +// screen.print("/"); +// screen.print((int)bus_rx_packets); +// if (bus.getStatus() == BUS_STATUS_CONNECTED) { +// screen.print(", "); +// screen.print(bus.getPeers()); +// screen.print(" peers"); +// } +// #endif +// } +}; + +class ExitPage : public Page { +public: + void exit(){} // todo: save settings? + void draw(ScreenBuffer& screen){ + if(!params.isEncoderPushed(ENCODER_ANY)){ + // leave configuration mode on release + setDisplayMode(STANDARD_DISPLAY_MODE); + }else{ + screen.setTextSize(2); + screen.print(40, 26, "exit"); } - if(displayMode == STANDARD && getErrorStatus() && getErrorMessage() != NULL) - displayMode = ERROR; } +}; - int16_t getDiscreteEncoderValue(int16_t current, int16_t previous){ - int32_t delta = (current - previous) * encoderSensitivity; - if(delta > 0 && (delta & encoder_mask) == 0) - return 1; - if(delta < 0 && (delta & encoder_mask) == 0) - return -1; - return 0; +class ProgressPage : public Page { + void draw(ScreenBuffer& screen){ + drawLoadProgress(screen); } - - int16_t getContinuousEncoderValue(int16_t current, int16_t previous){ - int32_t delta = (current - previous) * encoderSensitivity; - if(delta > 0) - delta = 20 << (delta/2); + void drawLoadProgress(ScreenBuffer &screen){ + extern char* progress_message; + extern uint16_t progress_counter; + screen.drawRectangle(0, 30, 128, 20, WHITE); + // if(progress_counter != 4095) + screen.fillRectangle(0, 44, progress_counter * 128 / 4095, 5, WHITE); + screen.setCursor(33, 40); + screen.setTextSize(1); + if(progress_message == NULL) + screen.print("Loading"); else - delta = -20 << (-delta/2); - return delta; - } - -// called by MIDI cc and/or from patch - void setValue(uint8_t pid, int16_t value){ - user[pid] = value; - // TODO: store values set from patch somewhere and multiply with user[] value for outputs - // graphics.params.updateOutput(i, getOutputValue(i)); - } - - // @param value is the modulation ADC value - void updateValue(uint8_t pid, int16_t value){ - // smoothing at apprx 50Hz - parameters[pid] = max(0, min(4095, (parameters[pid] + user[pid] + value)>>1)); - } - - int16_t getValue(uint8_t pid){ - return parameters[pid]; - } - - void updateOutput(uint8_t pid, int16_t value){ - parameters[pid] = max(0, min(4095, (((parameters[pid] + (user[pid]*value))>>12)>>1))); - } - - void updateValues(uint16_t* data, uint8_t size){ - for(int i=0; i", + // "< Status >", + // "< Preset >", + // "< Data >", + // "< Volume >", + // "< LEDs >", + // "< V/Oct " }; + +StandardPage standardPage; +ProgressPage progressPage; +SelectBlockPage selectBlockPage; +SelectGlobalPage selectGlobalPage; +StatusPage statusPage; +EncoderSensitivityPage sensitivityPage; +SelectPatchPage selectPatchPage; +ConfigVolumePage configVolumePage; +ConfigLedsPage configLedsPage; +ExitPage exitPage; +ErrorPage errorPage; + +void setDisplayMode(uint8_t mode){ + switch(mode){ + case STANDARD_DISPLAY_MODE: + params.changePage(&standardPage); + break; + case PROGRESS_DISPLAY_MODE: + params.changePage(&progressPage); + break; + case SELECT_BLOCK_DISPLAY_MODE: + params.changePage(&selectBlockPage); + break; + case SELECT_GLOBAL_DISPLAY_MODE: + params.changePage(&selectGlobalPage); + break; + case STATUS_DISPLAY_MODE: + params.changePage(&statusPage); + break; + case CONFIG_SENSITIVITY_DISPLAY_MODE: + params.changePage(&sensitivityPage); + break; + case CONFIG_PATCH_DISPLAY_MODE: + params.changePage(&selectPatchPage); + break; + case CONFIG_VOLUME_DISPLAY_MODE: + params.changePage(&configVolumePage); + break; + case CONFIG_LEDS_DISPLAY_MODE: + params.changePage(&configLedsPage); + break; + case CONFIG_EXIT_DISPLAY_MODE: + params.changePage(&exitPage); + break; + case ERROR_DISPLAY_MODE: + params.changePage(&errorPage); + break; + } +} + #endif // __MagusParameterController_hpp__ From f84c69e3bf4c5b63f2d78d217f5ef7b7ed9431e4 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 2 Dec 2021 10:41:45 +0100 Subject: [PATCH 198/286] virtual setName() --- Source/ParameterController.hpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Source/ParameterController.hpp b/Source/ParameterController.hpp index 4c65f8ad..e382ef6e 100644 --- a/Source/ParameterController.hpp +++ b/Source/ParameterController.hpp @@ -14,7 +14,7 @@ class ParameterController { virtual void reset(){ for(size_t i=0; i 8) + if(i >= 8) names[i][c++] = '@'+(i/8); names[i][c++] = 'A'+(i%8); names[i][c] = '\0'; @@ -26,18 +26,19 @@ class ParameterController { virtual void updateEncoders(int16_t* data, uint8_t size) = 0; /* Update parameters with ADC values */ virtual void updateValues(int16_t* values, size_t len){}; + virtual void setValue(uint8_t pid, int16_t value){ + parameters[pid] = value; + } const char* getName(uint8_t pid){ if(pid < NOF_PARAMETERS) return names[pid]; return ""; } - void setName(uint8_t pid, const char* name){ + virtual void setName(uint8_t pid, const char* name){ + // todo : set direction (input/output), type (parameter/button) if(pid < NOF_PARAMETERS) strncpy(names[pid], name, 11); } - void setValue(uint8_t pid, int16_t value){ - parameters[pid] = value; - } int16_t getValue(uint8_t pid){ return parameters[pid]; } From f7120d9c52cf2d884b9a2077f6a69dc983381003 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 2 Dec 2021 10:45:11 +0100 Subject: [PATCH 199/286] fixing ui issues --- Magus/Src/Magus.cpp | 21 +++- Source/MagusParameterController.hpp | 180 +++++++++++++++------------- 2 files changed, 116 insertions(+), 85 deletions(-) diff --git a/Magus/Src/Magus.cpp b/Magus/Src/Magus.cpp index e85d67fe..1e57dfc3 100644 --- a/Magus/Src/Magus.cpp +++ b/Magus/Src/Magus.cpp @@ -12,8 +12,6 @@ #include "Storage.h" #include "MagusParameterController.hpp" -// 63, 19, 60 // TODO: balance levels - const uint32_t* dyn_rainbowinputs = rainbowinputs; const uint32_t* dyn_rainbowoutputs = rainbowoutputs; @@ -30,6 +28,25 @@ void setProgress(uint16_t value, const char* reason){ progress_counter = value; } +void onChangeMode(OperationMode new_mode, OperationMode old_mode){ + switch(new_mode){ + case STARTUP_MODE: + case STREAM_MODE: + case LOAD_MODE: + setDisplayMode(PROGRESS_DISPLAY_MODE); + break; + case CONFIGURE_MODE: + setDisplayMode(STATUS_DISPLAY_MODE); + break; + case RUN_MODE: + setDisplayMode(STANDARD_DISPLAY_MODE); + break; + case ERROR_MODE: + setDisplayMode(ERROR_DISPLAY_MODE); + break; + } +} + static bool updateMAX11300 = false; static uint8_t portMode[20]; void setPortMode(uint8_t index, uint8_t mode){ diff --git a/Source/MagusParameterController.hpp b/Source/MagusParameterController.hpp index f53949e9..e64c6705 100644 --- a/Source/MagusParameterController.hpp +++ b/Source/MagusParameterController.hpp @@ -42,14 +42,23 @@ void setPortMode(uint8_t index, uint8_t mode); uint8_t getPortMode(uint8_t index); enum EncoderIdentifier { - ENCODER_L, - ENCODER_R, - ENCODER_1, + ENCODER_L = 0, // top left + ENCODER_R, // top right + ENCODER_1, // bottom row ENCODER_2, ENCODER_3, ENCODER_4, - ENCODER_1234 = 0x3c, - ENCODER_ANY = 0x3f, +}; + +enum EncoderButton { + ENCODER_BUTTON_L = 0b00000001, + ENCODER_BUTTON_R = 0b00000010, + ENCODER_BUTTON_1 = 0b00000100, + ENCODER_BUTTON_2 = 0b00001000, + ENCODER_BUTTON_3 = 0b00010000, + ENCODER_BUTTON_4 = 0b00100000, + ENCODER_BUTTON_1234 = 0b00111100, + ENCODER_BUTTON_ANY = 0b00111111, }; enum EncoderSensitivity { @@ -65,15 +74,15 @@ static EncoderSensitivity encoder_sensitivity = SENS_FINE; enum DisplayMode { STANDARD_DISPLAY_MODE, PROGRESS_DISPLAY_MODE, + ERROR_DISPLAY_MODE, SELECT_BLOCK_DISPLAY_MODE, SELECT_GLOBAL_DISPLAY_MODE, STATUS_DISPLAY_MODE, - CONFIG_EXIT_DISPLAY_MODE, - CONFIG_SENSITIVITY_DISPLAY_MODE, CONFIG_PATCH_DISPLAY_MODE, CONFIG_VOLUME_DISPLAY_MODE, + CONFIG_SENSITIVITY_DISPLAY_MODE, CONFIG_LEDS_DISPLAY_MODE, - ERROR_DISPLAY_MODE + CONFIG_EXIT_DISPLAY_MODE, }; // DisplayMode displayMode; void setDisplayMode(uint8_t mode); @@ -95,12 +104,12 @@ class Page { return -1; return 0; } - int16_t getContinuousEncoderValue(int16_t current, int16_t previous){ + int16_t getContinuousEncoderValue(int16_t current, int16_t previous, int16_t scale){ int32_t delta = (current - previous) * encoder_sensitivity; if(delta > 0) - delta = 20 << (delta/2); + delta = scale << (delta/3); else - delta = -20 << (-delta/2); + delta = -scale << (-delta/3); return delta; } }; @@ -122,7 +131,7 @@ press again to select parameter: select > update */ class MagusParameterController : public ParameterController { public: - Page* page; + Page* page = NULL; uint16_t buttons; int16_t encoders[NOF_ENCODERS]; // last seen encoder values int16_t user[NOF_PARAMETERS]; // user set values (ie by encoder or MIDI) @@ -156,7 +165,8 @@ class MagusParameterController : public ParameterController { void changePage(Page* page){ if(this->page != page){ - this->page->exit(); + if(this->page != NULL) + this->page->exit(); this->page = page; page->enter(); } @@ -192,6 +202,7 @@ class MagusParameterController : public ParameterController { y -= 7; x += 64; screen.drawRectangle(x, y, max(1, min(64, parameters[pid]/64)), 6, WHITE); + screen.fillRectangle(x, y+1, max(1, min(64, user[pid]/64)), 4, WHITE); } void drawBlocks(ScreenBuffer& screen){ @@ -248,17 +259,19 @@ class MagusParameterController : public ParameterController { int block = 2; for(int i=0; i<16; ++i){ // 4px high by up to 16px long rectangle, filled if selected - if(i == selectedPid[block]) + if(i == selectedPid[block]){ screen.fillRectangle(x, y, max(1, min(16, parameters[i]/255)), 4, WHITE); - else + }else{ screen.drawRectangle(x, y, max(1, min(16, parameters[i]/255)), 4, WHITE); + // screen.drawRectangle(x, y+1, max(1, min(16, user[i]/255)), 2, WHITE); + } x += 16; - if(i & 0x01) - block++; if(i == 7){ x = 0; y += 3; - block = 0; + block = 2; + }else if(i & 0x01){ + block++; } } } @@ -292,29 +305,17 @@ class MagusParameterController : public ParameterController { #endif } - void selectBlockParameter(uint8_t enc, int8_t pid){ - uint8_t i = enc-2; - if(pid == i*2+2) - pid = i*2+8; // skip up - if(pid == i*2+7) - pid = i*2+1; // skip down - selectedPid[enc] = max(i*2, min(i*2+9, pid)); - } - - void selectGlobalParameter(int8_t pid){ - selectedPid[0] = max(0, min(NOF_PARAMETERS-1, pid)); - } - - bool isEncoderPushed(uint16_t enc){ + bool isEncoderPushed(EncoderButton enc){ return buttons & enc; } void updateEncoders(int16_t* data, uint8_t size){ buttons = data[0]; - for(size_t i=1; iencoderChanged(i, data[i], encoders[i]); - encoders[i] = data[i]; + for(size_t i=0; iencoderChanged(i, value, encoders[i]); + encoders[i] = value; } } } @@ -340,51 +341,65 @@ class MagusParameterController : public ParameterController { parameters[pid] = max(0, min(4095, (((parameters[pid] + (user[pid]*value))>>12)>>1))); } - void updateValues(uint16_t* data, uint8_t size){ - for(int i=0; i", screen); int offset = 16; @@ -532,7 +547,7 @@ class EncoderSensitivityPage : public Page { // int16_t right_enc = encoders[1]; // Save old value for encoder scrolling in main menu // if(displayMode == CONTROL){ // selectControlMode(value, pressed&0x3); // action if either left or right encoder pushed - // if(params.isEncoderPushed(ENCODER_1234)){ + // if(params.isEncoderPushed(ENCODER_BUTTON_1234)){ // // if(pressed&0x3c) // exit status mode if any other encoder is pressed // controlMode = EXIT; // // use delta value from encoder 0 top left @@ -552,7 +567,7 @@ class ConfigVolumePage : public Page { int16_t delta = getDiscreteEncoderValue(current, previous); setDisplayMode(std::clamp(CONFIG_VOLUME_DISPLAY_MODE + delta, (int)STATUS_DISPLAY_MODE, (int)CONFIG_LEDS_DISPLAY_MODE)); }else if(encoder == ENCODER_L){ - int16_t value = std::clamp(settings.audio_output_gain + getContinuousEncoderValue(current, previous), 0, 127); + int16_t value = std::clamp(settings.audio_output_gain + getContinuousEncoderValue(current, previous, 1), 0, 127); if(settings.audio_output_gain != value){ settings.audio_output_gain = value; codec.setOutputGain(value); @@ -560,7 +575,7 @@ class ConfigVolumePage : public Page { } } void draw(ScreenBuffer& screen){ - if(params.isEncoderPushed(ENCODER_ANY)) + if(params.isEncoderPushed(ENCODER_BUTTON_ANY)) setDisplayMode(CONFIG_EXIT_DISPLAY_MODE); params.drawTitle("< Volume >", screen); drawVolume(screen); @@ -583,7 +598,7 @@ class ConfigLedsPage : public Page { int16_t delta = getDiscreteEncoderValue(current, previous); setDisplayMode(std::clamp(CONFIG_LEDS_DISPLAY_MODE + delta, (int)STATUS_DISPLAY_MODE, (int)CONFIG_LEDS_DISPLAY_MODE)); }else if(encoder == ENCODER_L){ - int16_t value = std::clamp(settings.leds_brightness + getContinuousEncoderValue(current, previous), 0, 63); + int16_t value = std::clamp(settings.leds_brightness + getContinuousEncoderValue(current, previous, 1), 0, 63); if(settings.leds_brightness != value){ settings.leds_brightness = value; TLC5946_setAll_DC(value); @@ -592,14 +607,14 @@ class ConfigLedsPage : public Page { } } void draw(ScreenBuffer& screen){ - if(params.isEncoderPushed(ENCODER_ANY)) + if(params.isEncoderPushed(ENCODER_BUTTON_ANY)) setDisplayMode(CONFIG_EXIT_DISPLAY_MODE); // " Play >", // "< Status >", // "< Preset >", // "< Data >", // "< Volume >", - // "< LEDs >", + // "< LEDs >", params.drawTitle("< LEDs >", screen); drawLeds(screen); } @@ -630,15 +645,14 @@ class SelectPatchPage : public Page { void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ if(encoder == ENCODER_R){ int16_t delta = getDiscreteEncoderValue(current, previous); - setDisplayMode(std::clamp(CONFIG_LEDS_DISPLAY_MODE + delta, (int)STATUS_DISPLAY_MODE, (int)CONFIG_LEDS_DISPLAY_MODE)); + setDisplayMode(std::clamp(CONFIG_PATCH_DISPLAY_MODE + delta, (int)STATUS_DISPLAY_MODE, (int)CONFIG_LEDS_DISPLAY_MODE)); }else if(encoder == ENCODER_L){ - patchselect = std::clamp(patchselect + getContinuousEncoderValue(current, previous), 0, (int)registry.getNumberOfPatches()-1); + patchselect = std::clamp(patchselect + getDiscreteEncoderValue(current, previous), 0, (int)registry.getNumberOfPatches()-1); } } void draw(ScreenBuffer& screen){ - if(params.isEncoderPushed(ENCODER_ANY)){ + if(params.isEncoderPushed(ENCODER_BUTTON_ANY)) setDisplayMode(CONFIG_EXIT_DISPLAY_MODE); - } params.drawTitle("< Patch >", screen); drawPresetNames(patchselect, screen); } @@ -674,7 +688,7 @@ class StatusPage : public Page { } } void draw(ScreenBuffer& screen){ - if(params.isEncoderPushed(ENCODER_ANY)){ + if(params.isEncoderPushed(ENCODER_BUTTON_1234)){ setDisplayMode(CONFIG_EXIT_DISPLAY_MODE); }else{ params.drawTitle(" Status >", screen); @@ -775,9 +789,9 @@ class StatusPage : public Page { class ExitPage : public Page { public: - void exit(){} // todo: save settings? + void exit(){} // todo: save settings if exited with ENCODER_BUTTON_R void draw(ScreenBuffer& screen){ - if(!params.isEncoderPushed(ENCODER_ANY)){ + if(!params.isEncoderPushed(ENCODER_BUTTON_ANY)){ // leave configuration mode on release setDisplayMode(STANDARD_DISPLAY_MODE); }else{ @@ -858,15 +872,15 @@ void setDisplayMode(uint8_t mode){ case STATUS_DISPLAY_MODE: params.changePage(&statusPage); break; - case CONFIG_SENSITIVITY_DISPLAY_MODE: - params.changePage(&sensitivityPage); - break; case CONFIG_PATCH_DISPLAY_MODE: params.changePage(&selectPatchPage); break; case CONFIG_VOLUME_DISPLAY_MODE: params.changePage(&configVolumePage); break; + case CONFIG_SENSITIVITY_DISPLAY_MODE: + params.changePage(&sensitivityPage); + break; case CONFIG_LEDS_DISPLAY_MODE: params.changePage(&configLedsPage); break; From f991134eca921a55e7c4cbd2db497e6f845f9a3a Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 3 Dec 2021 00:11:37 +0100 Subject: [PATCH 200/286] reverse owl.setup() and onSetup() order --- Source/callbacks.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/callbacks.cpp b/Source/callbacks.cpp index a621809f..37b9b95c 100644 --- a/Source/callbacks.cpp +++ b/Source/callbacks.cpp @@ -164,8 +164,8 @@ __weak void setup(){ HAL_TIM_Encoder_Start_IT(&ENCODER_TIM1, TIM_CHANNEL_ALL); HAL_TIM_Encoder_Start_IT(&ENCODER_TIM2, TIM_CHANNEL_ALL); #endif /* USE_ENCODERS */ - onSetup(); owl.setup(); + onSetup(); } __weak void onLoop(){ From 3ea860d7ae887679c7b951ee79e96c48e25422b0 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 3 Dec 2021 00:11:52 +0100 Subject: [PATCH 201/286] fix typo --- Source/ServiceCall.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ServiceCall.cpp b/Source/ServiceCall.cpp index 991f5343..341415b8 100644 --- a/Source/ServiceCall.cpp +++ b/Source/ServiceCall.cpp @@ -143,7 +143,7 @@ static int handleLoadResource(void** params, int len){ // We require offset to be aligned to 4 bytes if (res != NULL && !(offset & 0b11)) { if (*buffer == NULL) { - // Buffer pointer not given, so we will update value refenced by max_size with + // Buffer pointer not given, so we will update value referenced by max_size with // actual resource size here *max_size = res->getDataSize() - offset; if(res->isMemoryMapped()) From 7f9b3618738b7e8a713e579e77ceca1765fcc806 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 3 Dec 2021 00:12:39 +0100 Subject: [PATCH 202/286] bigger USB fifos on H7 --- Source/usbd_audio.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/usbd_audio.h b/Source/usbd_audio.h index ecddbe04..134804ef 100644 --- a/Source/usbd_audio.h +++ b/Source/usbd_audio.h @@ -50,7 +50,11 @@ #define MIDI_TX_PACKET_SIZE 0x40 #define MIDI_RX_PACKET_SIZE 0x40 -#define USBD_TOTAL_FIFO_SIZE 0x500 +#ifdef STM32H7xx +#define USBD_TOTAL_FIFO_SIZE 0x1000 /* 4k FIFO buffers on H7 */ +#else +#define USBD_TOTAL_FIFO_SIZE 0x500 /* 1.25k FIFO buffers on F4 */ +#endif #define USBD_MIN_FIFO_SIZE 0x40 /* Isochronous Synchronisation Type */ From b75f6e2ef1948466413e26e661a31ece8c0844ef Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 3 Dec 2021 00:12:50 +0100 Subject: [PATCH 203/286] added bypass mode --- Source/callbacks.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/callbacks.h b/Source/callbacks.h index ebd5b843..1265a609 100644 --- a/Source/callbacks.h +++ b/Source/callbacks.h @@ -14,6 +14,7 @@ extern "C" { RUN_MODE, CONFIGURE_MODE, STREAM_MODE, + BYPASS_MODE, ERROR_MODE } OperationMode; From 1da6798f7f09d3b60a0b6702881996cd26f5469b Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 3 Dec 2021 00:12:54 +0100 Subject: [PATCH 204/286] Magus ui changes --- Magus/Inc/hardware.h | 16 +++---- Magus/Src/Magus.cpp | 15 +++++-- Source/MagusParameterController.hpp | 65 +++++++++++++++++------------ Source/ParameterController.hpp | 2 + 4 files changed, 60 insertions(+), 38 deletions(-) diff --git a/Magus/Inc/hardware.h b/Magus/Inc/hardware.h index 21e0fdf9..fe0f9347 100644 --- a/Magus/Inc/hardware.h +++ b/Magus/Inc/hardware.h @@ -25,17 +25,17 @@ #define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) -/* #define MAIN_LOOP_SLEEP_MS 20 */ - #define USE_USBD_AUDIO -#define USE_USBD_AUDIO_TX // microphone -/* #define USE_USBD_AUDIO_RX // speaker */ +#define USE_USBD_RX_FB +#define USE_USBD_AUDIO_FEATURES +#define USE_USBD_AUDIO_RX // speaker +#define USE_USBD_AUDIO_TX // microphone #define USE_USBD_FS -#define USBD_HANDLE hUsbDeviceFS -#define USBH_HANDLE hUsbHostHS +#define USBD_HANDLE hUsbDeviceFS +#define USBH_HANDLE hUsbHostHS #define USE_USB_HOST +#define USB_HOST_RX_BUFF_SIZE 256 /* Max Received data 64 bytes */ #define USE_USBH_MIDI -#define USB_HOST_RX_BUFF_SIZE 256 // Serial MIDI TX only #define USE_UART_MIDI_TX @@ -43,7 +43,7 @@ #define UART_MIDI_RX_BUFFER_SIZE 256 #define USE_TLC5946 -#define LEDS_BRIGTHNESS 20 +#define LEDS_BRIGTHNESS 6 #define TLC5946_SPI hspi6 #define MAX11300_SPI hspi5 #define ENCODERS_SPI hspi5 diff --git a/Magus/Src/Magus.cpp b/Magus/Src/Magus.cpp index 1e57dfc3..fee2ed1c 100644 --- a/Magus/Src/Magus.cpp +++ b/Magus/Src/Magus.cpp @@ -30,9 +30,13 @@ void setProgress(uint16_t value, const char* reason){ void onChangeMode(OperationMode new_mode, OperationMode old_mode){ switch(new_mode){ - case STARTUP_MODE: case STREAM_MODE: + setProgress(0, "Streaming"); + setDisplayMode(PROGRESS_DISPLAY_MODE); + break; + case STARTUP_MODE: case LOAD_MODE: + setProgress(0, "Loading"); setDisplayMode(PROGRESS_DISPLAY_MODE); break; case CONFIGURE_MODE: @@ -103,8 +107,8 @@ void onSetup(){ // LEDs TLC5946_init(&TLC5946_SPI); - TLC5946_setAll_DC(0); // Start with 0 brightness here, update from settings later - TLC5946_setAll(0x10, 0x10, 0x10); + TLC5946_setAll_DC(0); // Start with low brightness here, update from settings later + TLC5946_setAll(0, 0, 0); HAL_GPIO_WritePin(TLC_BLANK_GPIO_Port, TLC_BLANK_Pin, GPIO_PIN_RESET); @@ -159,7 +163,10 @@ void onScreenDraw(){ #ifdef USE_TLC5946 for(int i=0; i<16; ++i){ uint16_t val = params.getValue(i)>>2; - setLed(i, dyn_rainbowinputs[val&0x3ff]); + if(getPortMode(i) == PORT_UNI_INPUT) + setLed(i, dyn_rainbowinputs[val&0x3ff]); + else + setLed(i, dyn_rainbowoutputs[val&0x3ff]); } TLC5946_Refresh_GS(); #endif diff --git a/Source/MagusParameterController.hpp b/Source/MagusParameterController.hpp index e64c6705..395ada2d 100644 --- a/Source/MagusParameterController.hpp +++ b/Source/MagusParameterController.hpp @@ -497,7 +497,7 @@ class SelectBlockPage : public Page { } } void draw(ScreenBuffer& screen){ - if(!params.isEncoderPushed(ENCODER_BUTTON_1234)) + if(!params.isEncoderPushed(EncoderButton(1<", screen); + params.drawTitle("< Patch >", screen); drawPresetNames(patchselect, screen); } void drawPresetNames(uint8_t selected, ScreenBuffer& screen){ @@ -787,20 +791,6 @@ class StatusPage : public Page { // } }; -class ExitPage : public Page { -public: - void exit(){} // todo: save settings if exited with ENCODER_BUTTON_R - void draw(ScreenBuffer& screen){ - if(!params.isEncoderPushed(ENCODER_BUTTON_ANY)){ - // leave configuration mode on release - setDisplayMode(STANDARD_DISPLAY_MODE); - }else{ - screen.setTextSize(2); - screen.print(40, 26, "exit"); - } - } -}; - class ProgressPage : public Page { void draw(ScreenBuffer& screen){ drawLoadProgress(screen); @@ -852,9 +842,32 @@ EncoderSensitivityPage sensitivityPage; SelectPatchPage selectPatchPage; ConfigVolumePage configVolumePage; ConfigLedsPage configLedsPage; -ExitPage exitPage; ErrorPage errorPage; +class ExitPage : public Page { +public: + void enter(){ + uint8_t patchselect = selectPatchPage.patchselect; + if(patchselect != program.getProgramIndex() && + registry.hasPatch(patchselect)){ + program.loadProgram(patchselect); + program.resetProgram(false); + } + } // todo: save settings if exited with ENCODER_BUTTON_R + void draw(ScreenBuffer& screen){ + if(!params.isEncoderPushed(ENCODER_BUTTON_ANY)){ + // leave configuration mode on release + setDisplayMode(STANDARD_DISPLAY_MODE); + }else{ + screen.setTextSize(2); + screen.print(40, 26, "exit"); + } + } +}; + +ExitPage exitPage; + + void setDisplayMode(uint8_t mode){ switch(mode){ case STANDARD_DISPLAY_MODE: diff --git a/Source/ParameterController.hpp b/Source/ParameterController.hpp index e382ef6e..3f12f501 100644 --- a/Source/ParameterController.hpp +++ b/Source/ParameterController.hpp @@ -34,6 +34,8 @@ class ParameterController { return names[pid]; return ""; } + // bool isInput(uint8_t pid) + // bool isBipolar(uint8_t pid) virtual void setName(uint8_t pid, const char* name){ // todo : set direction (input/output), type (parameter/button) if(pid < NOF_PARAMETERS) From 7d7cd56ec707d9d27ffb8e1611df7414d91a0451 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 3 Dec 2021 01:26:03 +0100 Subject: [PATCH 205/286] moved changePage --- Genius/Inc/GeniusParameterController.hpp | 36 ++++++++++++------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Genius/Inc/GeniusParameterController.hpp b/Genius/Inc/GeniusParameterController.hpp index c2d64a01..3183b551 100644 --- a/Genius/Inc/GeniusParameterController.hpp +++ b/Genius/Inc/GeniusParameterController.hpp @@ -90,6 +90,16 @@ class GeniusParameterController : public ParameterController { user[i] = 0; setDisplayMode(PROGRESS_DISPLAY_MODE); } + + void changePage(Page* page){ + if(this->page != page){ + if(this->page != NULL) + this->page->exit(); + this->page = page; + page->enter(); + } + } + void draw(ScreenBuffer& screen){ screen.clear(); page->draw(screen); @@ -362,41 +372,31 @@ ExitPage exitPage; StatsPage configurationPage; AssignPage assignPage; -void changePage(Page* page){ - if(params.page != page){ - if(params.page != NULL) - params.page->exit(); - params.page = page; - if(page != NULL) - page->enter(); - } -} - void setDisplayMode(DisplayMode mode){ switch(mode){ case STANDARD_DISPLAY_MODE: - changePage(&standardPage); + params.changePage(&standardPage); break; case CONFIGURATION_DISPLAY_MODE: - changePage(&configurationPage); + params.changePage(&configurationPage); break; case PROGRESS_DISPLAY_MODE: - changePage(&progressPage); + params.changePage(&progressPage); break; case SELECT_ONE_DISPLAY_MODE: - changePage(&selectOnePage); + params.changePage(&selectOnePage); break; case SELECT_TWO_DISPLAY_MODE: - changePage(&selectTwoPage); + params.changePage(&selectTwoPage); break; case EXIT_DISPLAY_MODE: - changePage(&exitPage); + params.changePage(&exitPage); break; case ASSIGN_DISPLAY_MODE: - changePage(&assignPage); + params.changePage(&assignPage); break; case ERROR_DISPLAY_MODE: - changePage(&errorPage); + params.changePage(&errorPage); break; } } From c1ed60ab8d38d09d9083b04c599b518e807b20f5 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 3 Dec 2021 01:26:51 +0100 Subject: [PATCH 206/286] screen fixes --- Source/MagusParameterController.hpp | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/Source/MagusParameterController.hpp b/Source/MagusParameterController.hpp index 395ada2d..b8ecf094 100644 --- a/Source/MagusParameterController.hpp +++ b/Source/MagusParameterController.hpp @@ -542,21 +542,6 @@ class EncoderSensitivityPage : public Page { int16_t delta = getDiscreteEncoderValue(current, previous); encoder_sensitivity = (EncoderSensitivity)std::clamp(encoder_sensitivity + delta, (int)SENS_SUPER_FINE, (int)SENS_SUPER_COARSE); } - // // update encoder 1 top right - // int16_t value = data[2]; - // int16_t right_enc = encoders[1]; // Save old value for encoder scrolling in main menu - // if(displayMode == CONTROL){ - // selectControlMode(value, pressed&0x3); // action if either left or right encoder pushed - // if(params.isEncoderPushed(ENCODER_BUTTON_1234)){ - // // if(pressed&0x3c) // exit status mode if any other encoder is pressed - // controlMode = EXIT; - // // use delta value from encoder 0 top left - // int16_t delta = getDiscreteEncoderValue(data[1], encoders[0]); - // // we use selectedPid[1] to store control values because we don't need it to select a pid - // setControlModeValue(selectedPid[1] + delta); - // encoders[0] = data[1]; - // return; // skip normal encoder processing - // } } }; @@ -614,8 +599,8 @@ class ConfigLedsPage : public Page { // "< Preset >", // "< Data >", // "< Volume >", - // "< LEDs >", - params.drawTitle("< LEDs >", screen); + // "< LEDs", + params.drawTitle("< LEDs", screen); drawLeds(screen); } @@ -692,7 +677,7 @@ class StatusPage : public Page { } } void draw(ScreenBuffer& screen){ - if(params.isEncoderPushed(ENCODER_BUTTON_1234)){ + if(params.isEncoderPushed(ENCODER_BUTTON_ANY)){ setDisplayMode(CONFIG_EXIT_DISPLAY_MODE); }else{ params.drawTitle(" Status >", screen); From 2b1a81e31199b2b66193ef06b738299d9177b8a4 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 3 Dec 2021 21:30:28 +0100 Subject: [PATCH 207/286] use different input/output LED colours --- Magus3/Src/Magus.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Magus3/Src/Magus.cpp b/Magus3/Src/Magus.cpp index f00dccc5..31419b8a 100644 --- a/Magus3/Src/Magus.cpp +++ b/Magus3/Src/Magus.cpp @@ -142,7 +142,10 @@ void onScreenDraw(){ #ifdef USE_TLC5946 for(int i=0; i<16; ++i){ uint16_t val = params.getValue(i)>>2; - setLed(i, dyn_rainbowinputs[val&0x3ff]); + if(getPortMode(i) == PORT_UNI_INPUT) + setLed(i, dyn_rainbowinputs[val&0x3ff]); + else + setLed(i, dyn_rainbowoutputs[val&0x3ff]); } TLC5946_Refresh_GS(); #endif From 855958e3e2e3a4aaa67974ad5f2ee4e0b44b7445 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 6 Dec 2021 21:49:44 +0100 Subject: [PATCH 208/286] changed OperationMode to use uint8_t instead of enum --- Source/Owl.cpp | 6 +++--- Source/Owl.h | 6 +++--- Source/callbacks.cpp | 2 +- Source/callbacks.h | 3 +-- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Source/Owl.cpp b/Source/Owl.cpp index dabdc3ee..e80a2355 100644 --- a/Source/Owl.cpp +++ b/Source/Owl.cpp @@ -163,12 +163,12 @@ void updateLed(){ } #endif /*USE_RGB_LED */ -OperationMode Owl::getOperationMode(){ +uint8_t Owl::getOperationMode(){ return operationMode; } -void Owl::setOperationMode(OperationMode mode){ - OperationMode old_mode = operationMode; +void Owl::setOperationMode(uint8_t mode){ + uint8_t old_mode = operationMode; operationMode = mode; onChangeMode(mode, old_mode); } diff --git a/Source/Owl.h b/Source/Owl.h index e934ccea..69d343bb 100644 --- a/Source/Owl.h +++ b/Source/Owl.h @@ -63,15 +63,15 @@ class BackgroundTask { class Owl { private: - volatile OperationMode operationMode = STARTUP_MODE; + volatile uint8_t operationMode = STARTUP_MODE; BackgroundTask* backgroundTask = NULL; void (*messageCallback)(const char* msg, size_t len) = NULL; public: void setup(); void loop(); - OperationMode getOperationMode(); - void setOperationMode(OperationMode mode); + uint8_t getOperationMode(); + void setOperationMode(uint8_t mode); void setBackgroundTask(BackgroundTask* bt); void setMessageCallback(void* callback); void handleMessage(const char* msg, size_t len); diff --git a/Source/callbacks.cpp b/Source/callbacks.cpp index 37b9b95c..db9853a8 100644 --- a/Source/callbacks.cpp +++ b/Source/callbacks.cpp @@ -227,7 +227,7 @@ __weak void loop(){ __weak void onScreenDraw(){} -__weak void onChangeMode(OperationMode new_mode, OperationMode old_mode){ +__weak void onChangeMode(uint8_t new_mode, uint8_t old_mode){ setLed(0, new_mode == RUN_MODE ? GREEN_COLOUR : YELLOW_COLOUR); } diff --git a/Source/callbacks.h b/Source/callbacks.h index 1265a609..d1fc40b2 100644 --- a/Source/callbacks.h +++ b/Source/callbacks.h @@ -14,7 +14,6 @@ extern "C" { RUN_MODE, CONFIGURE_MODE, STREAM_MODE, - BYPASS_MODE, ERROR_MODE } OperationMode; @@ -27,7 +26,7 @@ extern "C" { void setAnalogValue(uint8_t ch, int16_t value); void setGateValue(uint8_t bid, int16_t value); void onChangePin(uint16_t pin); - void onChangeMode(OperationMode new_mode, OperationMode old_mode); + void onChangeMode(uint8_t new_mode, uint8_t old_mode); void onStartProgram(); void onError(int8_t code, const char* msg); // sets a progress bar (if available) to a value from 0 to 4095 From 4164b5775cb41f97005d7a889109636cb0f0ba51 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 7 Dec 2021 19:31:08 +0100 Subject: [PATCH 209/286] updated patch selection --- OwlPedal2/Inc/hardware.h | 4 +- OwlPedal2/Src/OwlPedal.cpp | 256 ++++++++++++++++++++----------------- 2 files changed, 140 insertions(+), 120 deletions(-) diff --git a/OwlPedal2/Inc/hardware.h b/OwlPedal2/Inc/hardware.h index b3a326ad..6895090f 100644 --- a/OwlPedal2/Inc/hardware.h +++ b/OwlPedal2/Inc/hardware.h @@ -20,10 +20,10 @@ #define USBD_PCD_HANDLE hpcd_USB_OTG_HS #define USE_USBD_AUDIO -#define USE_USBD_RX_FB #define USE_USBD_AUDIO_FEATURES #define USE_USBD_AUDIO_TX // microphone -#define USE_USBD_AUDIO_RX // speaker +/* #define USE_USBD_AUDIO_RX // speaker */ +/* #define USE_USBD_RX_FB */ #define USE_USBD_MIDI /* USB audio settings */ diff --git a/OwlPedal2/Src/OwlPedal.cpp b/OwlPedal2/Src/OwlPedal.cpp index 5a7a4070..031456c0 100644 --- a/OwlPedal2/Src/OwlPedal.cpp +++ b/OwlPedal2/Src/OwlPedal.cpp @@ -1,3 +1,4 @@ +#include #include "Owl.h" #include "errorhandlers.h" #include "Codec.h" @@ -9,16 +10,24 @@ #include "Pin.h" #include "usb_device.h" -#define PATCH_RESET_COUNTER (1024/MAIN_LOOP_SLEEP_MS) +#define PATCH_RESET_COUNTER (768/MAIN_LOOP_SLEEP_MS) #define PATCH_CONFIG_COUNTER (3072/MAIN_LOOP_SLEEP_MS) -#define PATCH_INDICATOR_COUNTER (128/MAIN_LOOP_SLEEP_MS) +#define PATCH_INDICATOR_COUNTER (256/MAIN_LOOP_SLEEP_MS) + +#define BYPASS_MODE (ERROR_MODE+1) +#define ENTER_CONFIG_MODE (ERROR_MODE+2) static int16_t knobvalues[2]; static uint8_t patchselect; -#define PATCH_CONFIG_KNOB_THRESHOLD (4096/4) +#define PATCH_CONFIG_KNOB_THRESHOLD (4096/8) #define PATCH_CONFIG_PROGRAM_CONTROL 0 #define PATCH_CONFIG_VOLUME_CONTROL 3 +#define SW3_Pin EXP2_T_Pin +#define SW3_GPIO_Port EXP2_T_GPIO_Port +#define SW4_Pin EXP2_R_Pin +#define SW4_GPIO_Port EXP2_R_GPIO_Port + // Pin footswitch_pin(GPIOA, GPIO_PIN_0); Pin bypass_pin(GPIOA, GPIO_PIN_0); Pin bufpass_pin(GPIOF, GPIO_PIN_9); // high is bypass @@ -27,10 +36,7 @@ Pin exp1_ring_pin(GPIOA, GPIO_PIN_3); Pin led_green_pin(GPIOB, GPIO_PIN_8); Pin led_red_pin(GPIOB, GPIO_PIN_9); -#define SW3_Pin EXP2_T_Pin -#define SW3_GPIO_Port EXP2_T_GPIO_Port -#define SW4_Pin EXP2_R_Pin -#define SW4_GPIO_Port EXP2_R_GPIO_Port +static uint32_t counter = 0; void initLed(){ #ifdef OWL_PEDAL_PWM_LEDS @@ -77,10 +83,12 @@ bool getBufferedBypass(){ void setBufferedBypass(bool value){ setLed(0, value ? RED_COLOUR : GREEN_COLOUR); bufpass_pin.set(!value); + // todo; set BYPASS_MODE } bool isBypassed(){ return HAL_GPIO_ReadPin(FOOTSWITCH_GPIO_Port, FOOTSWITCH_Pin) == GPIO_PIN_RESET; + // todo: || getBufferedBypass() } bool isPushbuttonPressed(){ @@ -89,69 +97,70 @@ bool isPushbuttonPressed(){ } void onChangePin(uint16_t pin){ - switch(pin){ - case FOOTSWITCH_Pin: { // bypass / stomp switch - bool state = isBypassed(); - setButtonValue(0, state); - setLed(0, state ? NO_COLOUR : GREEN_COLOUR); - // todo: save LED state - // todo: only allow config mode in bypass? - break; - } - case SW1_Pin: - case SW1_ALT_Pin: { // pushbutton - bool state = isPushbuttonPressed(); - setButtonValue(PUSHBUTTON, state); - setButtonValue(BUTTON_A, state); - setLed(0, state ? RED_COLOUR : GREEN_COLOUR); - midi_tx.sendCc(PATCH_BUTTON, state ? 127 : 0); - if(state && owl.getOperationMode() == CONFIGURE_MODE){ - // exit configure mode - owl.setOperationMode(RUN_MODE); + if(owl.getOperationMode() == RUN_MODE){ + switch(pin){ + case FOOTSWITCH_Pin: { // bypass / stomp switch + bool state = isBypassed(); + setButtonValue(0, state); + setLed(0, state ? NO_COLOUR : GREEN_COLOUR); + // todo: save LED state + // todo: only allow config mode in bypass? + break; + } + case SW1_Pin: + case SW1_ALT_Pin: { // pushbutton + bool state = isPushbuttonPressed(); + setButtonValue(PUSHBUTTON, state); + setButtonValue(BUTTON_A, state); + setLed(0, state ? RED_COLOUR : GREEN_COLOUR); + midi_tx.sendCc(PATCH_BUTTON, state ? 127 : 0); + break; + } + case SW2_Pin: { // mode button + bool state = HAL_GPIO_ReadPin(SW2_GPIO_Port, SW2_Pin) == GPIO_PIN_RESET; + setButtonValue(BUTTON_B, state); + break; + } + case SW3_Pin: { // EXP2 Tip + bool state = HAL_GPIO_ReadPin(SW3_GPIO_Port, SW3_Pin) == GPIO_PIN_RESET; + setButtonValue(BUTTON_C, state); + break; + } + case SW4_Pin: { // EXP2 Ring + bool state = HAL_GPIO_ReadPin(SW4_GPIO_Port, SW4_Pin) == GPIO_PIN_RESET; + setButtonValue(BUTTON_D, state); + break; + } } - break; - } - case SW2_Pin: { // mode button - bool state = HAL_GPIO_ReadPin(SW2_GPIO_Port, SW2_Pin) == GPIO_PIN_RESET; - setButtonValue(BUTTON_B, state); - break; - } - case SW3_Pin: { // EXP2 Tip - bool state = HAL_GPIO_ReadPin(SW3_GPIO_Port, SW3_Pin) == GPIO_PIN_RESET; - setButtonValue(BUTTON_C, state); - break; - } - case SW4_Pin: { // EXP2 Ring - bool state = HAL_GPIO_ReadPin(SW4_GPIO_Port, SW4_Pin) == GPIO_PIN_RESET; - setButtonValue(BUTTON_D, state); - break; - } } } void setGateValue(uint8_t ch, int16_t value){ - switch(ch){ - case PUSHBUTTON: - setLed(0, value ? RED_COLOUR : GREEN_COLOUR); - break; - case GREEN_BUTTON: - setLed(0, value ? GREEN_COLOUR : NO_COLOUR); - break; - case RED_BUTTON: - setLed(0, value ? RED_COLOUR : NO_COLOUR); - break; - case BUTTON_1: - setBufferedBypass(value); - break; + if(owl.getOperationMode() == RUN_MODE){ + switch(ch){ + case PUSHBUTTON: + setLed(0, value ? RED_COLOUR : GREEN_COLOUR); + break; + case GREEN_BUTTON: + setLed(0, value ? GREEN_COLOUR : NO_COLOUR); + break; + case RED_BUTTON: + setLed(0, value ? RED_COLOUR : NO_COLOUR); + break; + } } + if(ch == BUTTON_1) + setBufferedBypass(value); } void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* adc_values, size_t adc_len){ - parameter_values[0] = (parameter_values[0]*3 + adc_values[ADC_A])>>2; - parameter_values[1] = (parameter_values[1]*3 + adc_values[ADC_B])>>2; - parameter_values[2] = (parameter_values[2]*3 + adc_values[ADC_C])>>2; - parameter_values[3] = (parameter_values[3]*3 + adc_values[ADC_D])>>2; - parameter_values[4] = (parameter_values[4]*3 + 4095-adc_values[ADC_E])>>2; + if(owl.getOperationMode() == RUN_MODE){ + parameter_values[0] = (parameter_values[0]*3 + adc_values[ADC_A])>>2; + parameter_values[1] = (parameter_values[1]*3 + adc_values[ADC_B])>>2; + parameter_values[2] = (parameter_values[2]*3 + adc_values[ADC_C])>>2; + parameter_values[3] = (parameter_values[3]*3 + adc_values[ADC_D])>>2; + parameter_values[4] = (parameter_values[4]*3 + 4095-adc_values[ADC_E])>>2; + } } void onSetup(){ @@ -172,32 +181,29 @@ void onSetup(){ setBufferedBypass(false); } -static uint32_t counter = 0; -void onChangeMode(OperationMode new_mode, OperationMode old_mode){ +void onChangeMode(uint8_t new_mode, uint8_t old_mode){ counter = 0; setLed(0, NO_COLOUR); if(new_mode == CONFIGURE_MODE){ knobvalues[0] = getAnalogValue(PATCH_CONFIG_PROGRAM_CONTROL); knobvalues[1] = getAnalogValue(PATCH_CONFIG_VOLUME_CONTROL); patchselect = program.getProgramIndex(); - counter = PATCH_RESET_COUNTER; }else if(new_mode == BYPASS_MODE){ setLed(0, NO_COLOUR); // todo: save LED state }else if(new_mode == RUN_MODE){ - if(old_mode == CONFIGURE_MODE){ - if(program.getProgramIndex() != patchselect && - registry.hasPatch(patchselect)){ - // change patch on mode button release - program.loadProgram(patchselect); // enters load mode (calls onChangeMode) - program.resetProgram(true); // true if setOperationMode() is called from button IRQ - // }else{ - // owl.setOperationMode(RUN_MODE); - } - } setLed(0, GREEN_COLOUR); // todo: restore to saved state } } +// static uint16_t progress = 0; +void setProgress(uint16_t value, const char* msg){ + // debugMessage(msg, (int)(100*value/4095)); + // progress = value; + // toggle red/green + led_red_pin.set(led_green_pin.get()); + led_green_pin.toggle(); +} + void onLoop(){ switch(owl.getOperationMode()){ case STARTUP_MODE: @@ -207,55 +213,69 @@ void onLoop(){ counter = PATCH_RESET_COUNTER; break; case LOAD_MODE: - setLed(0, counter > PATCH_INDICATOR_COUNTER/2 ? GREEN_COLOUR : NO_COLOUR); + // setLed(0, counter > PATCH_INDICATOR_COUNTER/2 ? GREEN_COLOUR : NO_COLOUR); // todo: use setProgress()? - if(counter-- == 0) - counter = PATCH_RESET_COUNTER; + // if(counter-- == 0) + // counter = PATCH_RESET_COUNTER; break; case BYPASS_MODE: if(!isBypassed()){ - owl.setOperationMode(RUN_MODE); + owl.setOperationMode(RUN_MODE); }else if(isPushbuttonPressed()){ - if(counter-- == 0){ - owl.setOperationMode(CONFIGURE_MODE); - }else if(counter % 100 == 0){ - led_green_pin.toggle(); - led_red_pin.toggle(); - } - }else{ - counter = PATCH_RESET_COUNTER; + owl.setOperationMode(ENTER_CONFIG_MODE); } break; case RUN_MODE: if(getErrorStatus() != NO_ERROR){ owl.setOperationMode(ERROR_MODE); - }else if(isBypassed()){ - owl.setOperationMode(BYPASS_MODE); }else if(isPushbuttonPressed()){ - if(counter-- == 0){ - owl.setOperationMode(CONFIGURE_MODE); - }else if(counter < PATCH_RESET_COUNTER && counter % 100 == 0){ + if(--counter == 0){ // counter == 0 when we enter RUN_MODE + owl.setOperationMode(ENTER_CONFIG_MODE); + }else if(counter < PATCH_RESET_COUNTER && counter % 128 == 0){ led_green_pin.toggle(); led_red_pin.toggle(); } + }else if(isBypassed()){ + // don't change to BYPASS_MODE while pushbutton is pressed + // (we might have just come from CONFIGURATION_MODE) + owl.setOperationMode(BYPASS_MODE); }else{ counter = PATCH_CONFIG_COUNTER; } break; + case ENTER_CONFIG_MODE: + if(isPushbuttonPressed()){ + // toggle rapidly for yellow-ish LED + led_red_pin.set(led_green_pin.get()); + led_green_pin.toggle(); + }else{ + owl.setOperationMode(CONFIGURE_MODE); + } + break; case CONFIGURE_MODE: - // if(isPushbuttonPressed()){ + if(isPushbuttonPressed()){ // exit configure mode + if(program.getProgramIndex() != patchselect && + registry.hasPatch(patchselect)){ + // change patch on mode button release + program.loadProgram(patchselect); // enters load mode (calls onChangeMode) + program.resetProgram(false); + }else{ + owl.setOperationMode(RUN_MODE); + } + }else{ + // update patch control if(abs(knobvalues[0] - getAnalogValue(PATCH_CONFIG_PROGRAM_CONTROL)) >= PATCH_CONFIG_KNOB_THRESHOLD){ knobvalues[0] = -PATCH_CONFIG_KNOB_THRESHOLD; - float idx = 1 + (getAnalogValue(PATCH_CONFIG_PROGRAM_CONTROL) * registry.getNumberOfPatches()) / 4096.0f; - if(abs(patchselect - idx) > 0.6 && registry.hasPatch(idx)){ // ensure a small dead zone + float pos = 0.5f + (getAnalogValue(PATCH_CONFIG_PROGRAM_CONTROL) * (registry.getNumberOfPatches() - 1)) / 4096.0f; + uint8_t idx = roundf(pos); + if(abs(patchselect - pos) > 0.6 && registry.hasPatch(idx)){ // ensure a small dead zone patchselect = idx; - midi_tx.sendPc(idx); - // setLed(0, idx & 0x01 ? RED_COLOUR : GREEN_COLOUR); + midi_tx.sendPc(patchselect); + // update patch indicator + counter = PATCH_RESET_COUNTER + PATCH_INDICATOR_COUNTER*(2*patchselect + 1); } - // }else{ - // led_green_pin.toggle(); - // led_red_pin.toggle(); } + // update volume control if(abs(knobvalues[1] - getAnalogValue(PATCH_CONFIG_VOLUME_CONTROL)) >= PATCH_CONFIG_KNOB_THRESHOLD){ knobvalues[1] = -PATCH_CONFIG_KNOB_THRESHOLD; uint8_t value = (getAnalogValue(PATCH_CONFIG_VOLUME_CONTROL) >> 6) + 63; @@ -265,33 +285,33 @@ void onLoop(){ midi_tx.sendCc(MIDI_CC_VOLUME, value); } } + // indicator LED if(counter-- == 0){ - counter = PATCH_RESET_COUNTER + PATCH_INDICATOR_COUNTER + PATCH_INDICATOR_COUNTER*2*patchselect; + counter = PATCH_RESET_COUNTER + PATCH_INDICATOR_COUNTER*(2*patchselect + 1); // patch indicator setLed(0, NO_COLOUR); }else if(counter <= PATCH_RESET_COUNTER){ - // toggle rapidly during 1 second for yellow-ish LED - led_red_pin.set(led_green_pin.get()); - led_green_pin.toggle(); - }else if(counter % PATCH_INDICATOR_COUNTER == 0){ - if(counter >= PATCH_RESET_COUNTER + 5*2*PATCH_INDICATOR_COUNTER){ - counter -= 4*PATCH_INDICATOR_COUNTER; - led_red_pin.toggle(); - }else{ + if(patchselect == 0){ + // toggle rapidly for yellow-ish LED + led_red_pin.set(led_green_pin.get()); led_green_pin.toggle(); + }else{ + setLed(0, NO_COLOUR); } + }else if((counter - PATCH_RESET_COUNTER) % (2*PATCH_INDICATOR_COUNTER) == 0){ + if((counter - PATCH_RESET_COUNTER) >= 10*PATCH_INDICATOR_COUNTER){ + counter -= 8*PATCH_INDICATOR_COUNTER; + setLed(0, RED_COLOUR); + }else{ + setLed(0, GREEN_COLOUR); + } + }else if((counter - PATCH_RESET_COUNTER) % PATCH_INDICATOR_COUNTER == 0){ + setLed(0, NO_COLOUR); } - // if(isPushbuttonPressed()){ // exit configure mode - // if(program.getProgramIndex() != patchselect && - // registry.hasPatch(patchselect)){ - // // change patch on mode button release - // program.loadProgram(patchselect); // enters load mode (calls onChangeMode) - // program.resetProgram(false); - // }else{ - // owl.setOperationMode(RUN_MODE); - // } - // } + } break; case ERROR_MODE: + if(isPushbuttonPressed()) + owl.setOperationMode(ENTER_CONFIG_MODE); setLed(0, counter > PATCH_RESET_COUNTER/2 ? RED_COLOUR : NO_COLOUR); if(counter-- == 0) counter = PATCH_RESET_COUNTER; From c2553fdd2480fbd3095b99882d377447dd3935e9 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 7 Dec 2021 19:32:37 +0100 Subject: [PATCH 210/286] eeprom_erase_sector changes --- Genius/Src/Genius.cpp | 4 ++-- MidiBoot/Src/MidiBoot.cpp | 12 ++++++------ MidiBoot3/Src/MidiBoot.cpp | 12 ++++++------ MidiBootOwl/Src/MidiBoot.cpp | 24 ++++++++++++------------ Source/BootloaderStorage.cpp | 8 ++++---- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Genius/Src/Genius.cpp b/Genius/Src/Genius.cpp index 3877be29..48a16d1f 100644 --- a/Genius/Src/Genius.cpp +++ b/Genius/Src/Genius.cpp @@ -18,7 +18,7 @@ extern "C"{ {return 0;} int eeprom_wait() {return 0;} - int eeprom_erase_sector(uint32_t sector) + int eeprom_erase_sector(uint32_t sector, uint32_t bank) {return 0;} int eeprom_write_unlock(uint32_t wrp_sectors) {return 0;} @@ -50,7 +50,7 @@ void setProgress(uint16_t value, const char* reason){ progress_counter = value; } -void onChangeMode(OperationMode new_mode, OperationMode old_mode){ +void onChangeMode(uint8_t new_mode, uint8_t old_mode){ switch(new_mode){ case STARTUP_MODE: case STREAM_MODE: diff --git a/MidiBoot/Src/MidiBoot.cpp b/MidiBoot/Src/MidiBoot.cpp index 2cd2803a..4c8a7bf0 100644 --- a/MidiBoot/Src/MidiBoot.cpp +++ b/MidiBoot/Src/MidiBoot.cpp @@ -21,7 +21,7 @@ ProgramManager::ProgramManager(){} void ProgramManager::exitProgram(bool isr){} void setParameterValue(uint8_t ch, int16_t value){} void SystemMidiReader::reset(){} -void Owl::setOperationMode(OperationMode mode){} +void Owl::setOperationMode(uint8_t mode){} const char* getFirmwareVersion(){ return (const char*)(HARDWARE_VERSION " " FIRMWARE_VERSION) ; @@ -95,10 +95,10 @@ void eraseFromFlash(uint8_t sector){ storage.erase(RESOURCE_PORT_MAPPED); #endif storage.erase(RESOURCE_MEMORY_MAPPED); - sendMessage(SYSEX_PROGRAM_MESSAGE, "Erased patch storage"); + sendMessage(SYSEX_PROGRAM_MESSAGE, "Erased storage"); led_green(); }else{ - eeprom_erase_sector(sector); + eeprom_erase_sector(sector, FLASH_BANK_1); sendMessage(SYSEX_PROGRAM_MESSAGE, "Erased flash sector"); led_green(); } @@ -108,11 +108,11 @@ void eraseFromFlash(uint8_t sector){ void saveToFlash(uint8_t sector, void* data, uint32_t length){ if(sector == FIRMWARE_SECTOR && length <= (64+3*128)*1024){ eeprom_unlock(); - eeprom_erase_sector(FLASH_SECTOR_4); + eeprom_erase_sector(FLASH_SECTOR_4, FLASH_BANK_1); if(length > 64*1024){ - eeprom_erase_sector(FLASH_SECTOR_5); + eeprom_erase_sector(FLASH_SECTOR_5, FLASH_BANK_1); if(length > (64+128)*1024){ - eeprom_erase_sector(FLASH_SECTOR_6); + eeprom_erase_sector(FLASH_SECTOR_6, FLASH_BANK_1); } } eeprom_write_block(ADDR_FLASH_SECTOR_4, data, length); diff --git a/MidiBoot3/Src/MidiBoot.cpp b/MidiBoot3/Src/MidiBoot.cpp index 1b6ad5d3..a5617f3b 100644 --- a/MidiBoot3/Src/MidiBoot.cpp +++ b/MidiBoot3/Src/MidiBoot.cpp @@ -20,7 +20,7 @@ ProgramManager::ProgramManager(){} void ProgramManager::exitProgram(bool isr){} void setParameterValue(uint8_t ch, int16_t value){} void SystemMidiReader::reset(){} -void Owl::setOperationMode(OperationMode mode){} +void Owl::setOperationMode(uint8_t mode){} const char* getFirmwareVersion(){ return (const char*)(HARDWARE_VERSION " " FIRMWARE_VERSION) ; @@ -81,13 +81,13 @@ void eraseFromFlash(uint8_t sector){ uint32_t address = (uint32_t)&_FLASH_STORAGE_BEGIN; uint32_t sector = FLASH_SECTOR_4; while (address < (uint32_t)&_FLASH_STORAGE_END) { - eeprom_erase_sector(sector++); + eeprom_erase_sector(sector++, FLASH_BANK_1); address += FLASH_SECTOR_SIZE; } setMessage("Erased patch storage"); led_green(); }else{ - eeprom_erase_sector(sector); + eeprom_erase_sector(sector, FLASH_BANK_1); setMessage("Erased flash sector"); led_green(); } @@ -98,11 +98,11 @@ void saveToFlash(uint8_t sector, void* data, uint32_t length){ // TODO! if(sector == FIRMWARE_SECTOR && length <= (3*128)*1024){ eeprom_unlock(); - eeprom_erase_sector(FLASH_SECTOR_1); + eeprom_erase_sector(FLASH_SECTOR_1, FLASH_BANK_1); if(length > 128*1024){ - eeprom_erase_sector(FLASH_SECTOR_2); + eeprom_erase_sector(FLASH_SECTOR_2, FLASH_BANK_1); if(length > (128+128)*1024){ - eeprom_erase_sector(FLASH_SECTOR_3); + eeprom_erase_sector(FLASH_SECTOR_3, FLASH_BANK_1); } } extern char _BOOTLOADER_END; diff --git a/MidiBootOwl/Src/MidiBoot.cpp b/MidiBootOwl/Src/MidiBoot.cpp index c570ea26..864fce1c 100644 --- a/MidiBootOwl/Src/MidiBoot.cpp +++ b/MidiBootOwl/Src/MidiBoot.cpp @@ -18,7 +18,7 @@ ProgramManager::ProgramManager(){} void ProgramManager::exitProgram(bool isr){} void setParameterValue(uint8_t ch, int16_t value){} void SystemMidiReader::reset(){} -void Owl::setOperationMode(OperationMode mode) {} +void Owl::setOperationMode(uint8_t mode) {} const char* getFirmwareVersion(){ return (const char*)(HARDWARE_VERSION " " FIRMWARE_VERSION) ; @@ -66,15 +66,15 @@ void sendMessage(){ void eraseFromFlash(uint8_t sector){ eeprom_unlock(); if(sector == 0xff){ - eeprom_erase_sector(FLASH_SECTOR_7); - eeprom_erase_sector(FLASH_SECTOR_8); - eeprom_erase_sector(FLASH_SECTOR_9); - eeprom_erase_sector(FLASH_SECTOR_10); - eeprom_erase_sector(FLASH_SECTOR_11); + eeprom_erase_sector(FLASH_SECTOR_7, FLASH_BANK_1); + eeprom_erase_sector(FLASH_SECTOR_8, FLASH_BANK_1); + eeprom_erase_sector(FLASH_SECTOR_9, FLASH_BANK_1); + eeprom_erase_sector(FLASH_SECTOR_10, FLASH_BANK_1); + eeprom_erase_sector(FLASH_SECTOR_11, FLASH_BANK_1); setMessage("Erased patch storage"); led_green(); }else{ - eeprom_erase_sector(sector); + eeprom_erase_sector(sector, FLASH_BANK_1); setMessage("Erased flash sector"); led_green(); } @@ -84,15 +84,15 @@ void eraseFromFlash(uint8_t sector){ void saveToFlash(uint8_t sector, void* data, uint32_t length){ if(sector == FIRMWARE_SECTOR && length <= (16 * 2 + 64 + 2 * 128) * 1024){ eeprom_unlock(); - eeprom_erase_sector(FLASH_SECTOR_2); + eeprom_erase_sector(FLASH_SECTOR_2, FLASH_BANK_1); if(length > 16 * 1024){ - eeprom_erase_sector(FLASH_SECTOR_3); + eeprom_erase_sector(FLASH_SECTOR_3, FLASH_BANK_1); if(length > (16 * 2) * 1024){ - eeprom_erase_sector(FLASH_SECTOR_4); + eeprom_erase_sector(FLASH_SECTOR_4, FLASH_BANK_1); if (length > (16 * 2 + 64) * 1024){ - eeprom_erase_sector(FLASH_SECTOR_5); + eeprom_erase_sector(FLASH_SECTOR_5, FLASH_BANK_1); if (length > (16 * 2 + 64 + 128) * 1024){ - eeprom_erase_sector(FLASH_SECTOR_6); + eeprom_erase_sector(FLASH_SECTOR_6, FLASH_BANK_1); } } } diff --git a/Source/BootloaderStorage.cpp b/Source/BootloaderStorage.cpp index 9f575399..8d77cf53 100644 --- a/Source/BootloaderStorage.cpp +++ b/Source/BootloaderStorage.cpp @@ -18,13 +18,13 @@ BootloaderStorage::BootloaderStorage(){ bool BootloaderStorage::erase(){ eeprom_unlock(); // We expect bootloader to occupy 1 - 4 sectors. Currently OWL1 uses 2 sectors, OWL2 uses 4. - int ret = eeprom_erase_sector(FLASH_SECTOR_0); + int ret = eeprom_erase_sector(FLASH_SECTOR_0, FLASH_BANK_1); if (bootloader_sectors & OB_WRP_SECTOR_1) - ret |= eeprom_erase_sector(FLASH_SECTOR_1); + ret |= eeprom_erase_sector(FLASH_SECTOR_1, FLASH_BANK_1); if (bootloader_sectors & OB_WRP_SECTOR_2) - ret |= eeprom_erase_sector(FLASH_SECTOR_2); + ret |= eeprom_erase_sector(FLASH_SECTOR_2, FLASH_BANK_1); if (bootloader_sectors & OB_WRP_SECTOR_3) - ret |= eeprom_erase_sector(FLASH_SECTOR_3); + ret |= eeprom_erase_sector(FLASH_SECTOR_3, FLASH_BANK_1); eeprom_lock(); return ret == 0; } From 515a617b2a13fe06a258706f85b3ffb44828d563 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 7 Dec 2021 19:33:08 +0100 Subject: [PATCH 211/286] only change mode when new != old --- Source/Owl.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/Owl.cpp b/Source/Owl.cpp index e80a2355..c0fb8fd3 100644 --- a/Source/Owl.cpp +++ b/Source/Owl.cpp @@ -168,9 +168,12 @@ uint8_t Owl::getOperationMode(){ } void Owl::setOperationMode(uint8_t mode){ - uint8_t old_mode = operationMode; - operationMode = mode; - onChangeMode(mode, old_mode); + if(mode != operationMode){ + uint8_t old_mode = operationMode; + // make sure this is set before calling onChangeMode + operationMode = mode; + onChangeMode(mode, old_mode); + } } void Owl::loop(){ From 8437739af8f044cf91419dc07933db969bb555f6 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 7 Dec 2021 19:34:16 +0100 Subject: [PATCH 212/286] eeprom_erase_sector changes to take into account bank --- Source/eepromcontrol.c | 70 ++++++++++++++++++++++-------------------- Source/eepromcontrol.h | 3 +- 2 files changed, 39 insertions(+), 34 deletions(-) diff --git a/Source/eepromcontrol.c b/Source/eepromcontrol.c index 29e546dd..cbbf72a7 100644 --- a/Source/eepromcontrol.c +++ b/Source/eepromcontrol.c @@ -23,12 +23,10 @@ int eeprom_get_error() { return HAL_FLASH_GetError(); } -int eeprom_erase_sector(uint32_t sector) { +int eeprom_erase_sector(uint32_t sector, uint32_t bank) { FLASH_EraseInitTypeDef cfg; cfg.TypeErase = FLASH_TYPEERASE_SECTORS; -#ifndef OWL_ARCH_F7 - cfg.Banks = FLASH_BANK_1; -#endif + cfg.Banks = bank; cfg.Sector = sector; cfg.NbSectors = 1; cfg.VoltageRange = FLASH_VOLTAGE_RANGE_3; @@ -90,65 +88,71 @@ void eeprom_unlock(){ int eeprom_erase_address(uint32_t address){ int ret = 0; if(address < ADDR_FLASH_SECTOR_1){ - eeprom_erase_sector(FLASH_SECTOR_0); + eeprom_erase_sector(FLASH_SECTOR_0, FLASH_BANK_1); ret = ADDR_FLASH_SECTOR_1 - ADDR_FLASH_SECTOR_0; }else if(address < ADDR_FLASH_SECTOR_2){ - eeprom_erase_sector(FLASH_SECTOR_1); + eeprom_erase_sector(FLASH_SECTOR_1, FLASH_BANK_1); ret = ADDR_FLASH_SECTOR_2 - ADDR_FLASH_SECTOR_1; }else if(address < ADDR_FLASH_SECTOR_3){ - eeprom_erase_sector(FLASH_SECTOR_2); + eeprom_erase_sector(FLASH_SECTOR_2, FLASH_BANK_1); ret = ADDR_FLASH_SECTOR_3 - ADDR_FLASH_SECTOR_2; }else if(address < ADDR_FLASH_SECTOR_4){ - eeprom_erase_sector(FLASH_SECTOR_3); + eeprom_erase_sector(FLASH_SECTOR_3, FLASH_BANK_1); ret = ADDR_FLASH_SECTOR_4 - ADDR_FLASH_SECTOR_3; }else if(address < ADDR_FLASH_SECTOR_5){ - eeprom_erase_sector(FLASH_SECTOR_4); + eeprom_erase_sector(FLASH_SECTOR_4, FLASH_BANK_1); ret = ADDR_FLASH_SECTOR_5 - ADDR_FLASH_SECTOR_4; }else if(address < ADDR_FLASH_SECTOR_6){ - eeprom_erase_sector(FLASH_SECTOR_5); + eeprom_erase_sector(FLASH_SECTOR_5, FLASH_BANK_1); ret = ADDR_FLASH_SECTOR_6 - ADDR_FLASH_SECTOR_5; }else if(address < ADDR_FLASH_SECTOR_7){ - eeprom_erase_sector(FLASH_SECTOR_6); + eeprom_erase_sector(FLASH_SECTOR_6, FLASH_BANK_1); ret = ADDR_FLASH_SECTOR_7 - ADDR_FLASH_SECTOR_6; -#ifdef FLASH_SECTOR_8 +#ifdef STM32H7xx }else if(address < ADDR_FLASH_SECTOR_8){ - eeprom_erase_sector(FLASH_SECTOR_7); + eeprom_erase_sector(FLASH_SECTOR_7, FLASH_BANK_1); ret = ADDR_FLASH_SECTOR_8 - ADDR_FLASH_SECTOR_7; }else if(address < ADDR_FLASH_SECTOR_9){ - eeprom_erase_sector(FLASH_SECTOR_8); + eeprom_erase_sector(FLASH_SECTOR_0, FLASH_BANK_2); ret = ADDR_FLASH_SECTOR_9 - ADDR_FLASH_SECTOR_8; }else if(address < ADDR_FLASH_SECTOR_10){ - eeprom_erase_sector(FLASH_SECTOR_9); + eeprom_erase_sector(FLASH_SECTOR_1, FLASH_BANK_2); ret = ADDR_FLASH_SECTOR_10 - ADDR_FLASH_SECTOR_9; }else if(address < ADDR_FLASH_SECTOR_11){ - eeprom_erase_sector(FLASH_SECTOR_10); + eeprom_erase_sector(FLASH_SECTOR_2, FLASH_BANK_2); ret = ADDR_FLASH_SECTOR_11 - ADDR_FLASH_SECTOR_10; -#ifdef ADDR_FLASH_SECTOR_12 }else if(address < ADDR_FLASH_SECTOR_12){ - eeprom_erase_sector(FLASH_SECTOR_11); + eeprom_erase_sector(FLASH_SECTOR_3, FLASH_BANK_2); ret = ADDR_FLASH_SECTOR_12 - ADDR_FLASH_SECTOR_11; }else if(address < ADDR_FLASH_SECTOR_13){ - eeprom_erase_sector(FLASH_SECTOR_12); + eeprom_erase_sector(FLASH_SECTOR_4, FLASH_BANK_2); ret = ADDR_FLASH_SECTOR_13 - ADDR_FLASH_SECTOR_12; }else if(address < ADDR_FLASH_SECTOR_14){ - eeprom_erase_sector(FLASH_SECTOR_13); + eeprom_erase_sector(FLASH_SECTOR_5, FLASH_BANK_2); ret = ADDR_FLASH_SECTOR_14 - ADDR_FLASH_SECTOR_13; }else if(address < ADDR_FLASH_SECTOR_15){ - eeprom_erase_sector(FLASH_SECTOR_14); + eeprom_erase_sector(FLASH_SECTOR_6, FLASH_BANK_2); ret = ADDR_FLASH_SECTOR_15 - ADDR_FLASH_SECTOR_14; - }else if(address < FLASH_END){ - eeprom_erase_sector(FLASH_SECTOR_15); - ret = FLASH_END - ADDR_FLASH_SECTOR_15; -#else /* define FLASH_SECTOR_12 */ - }else if(address < FLASH_END){ - eeprom_erase_sector(FLASH_SECTOR_11); - ret = FLASH_END - ADDR_FLASH_SECTOR_11; -#endif /* define FLASH_SECTOR_12 */ + }else if(address < ADDR_FLASH_SECTOR_END){ + eeprom_erase_sector(FLASH_SECTOR_7, FLASH_BANK_2); + ret = ADDR_FLASH_SECTOR_END - ADDR_FLASH_SECTOR_15; #else - }else if(address < FLASH_END){ - eeprom_erase_sector(FLASH_SECTOR_7); - ret = FLASH_END - ADDR_FLASH_SECTOR_7; -#endif /* define FLASH_SECTOR_8 */ + }else if(address < ADDR_FLASH_SECTOR_8){ + eeprom_erase_sector(FLASH_SECTOR_7, FLASH_BANK_1); + ret = ADDR_FLASH_SECTOR_8 - ADDR_FLASH_SECTOR_7; + }else if(address < ADDR_FLASH_SECTOR_9){ + eeprom_erase_sector(FLASH_SECTOR_8, FLASH_BANK_1); + ret = ADDR_FLASH_SECTOR_9 - ADDR_FLASH_SECTOR_8; + }else if(address < ADDR_FLASH_SECTOR_10){ + eeprom_erase_sector(FLASH_SECTOR_9, FLASH_BANK_1); + ret = ADDR_FLASH_SECTOR_10 - ADDR_FLASH_SECTOR_9; + }else if(address < ADDR_FLASH_SECTOR_11){ + eeprom_erase_sector(FLASH_SECTOR_10, FLASH_BANK_1); + ret = ADDR_FLASH_SECTOR_11 - ADDR_FLASH_SECTOR_10; + }else if(address < ADDR_FLASH_SECTOR_END){ + eeprom_erase_sector(FLASH_SECTOR_11, FLASH_BANK_1); + ret = ADDR_FLASH_SECTOR_END - ADDR_FLASH_SECTOR_11; +#endif } return ret; } diff --git a/Source/eepromcontrol.h b/Source/eepromcontrol.h index 151cec3c..ab7230f7 100644 --- a/Source/eepromcontrol.h +++ b/Source/eepromcontrol.h @@ -35,6 +35,7 @@ #define ADDR_FLASH_SECTOR_10 ((uint32_t)0x080C0000) /* Base @ of Sector 10, 128 Kbyte */ #define ADDR_FLASH_SECTOR_11 ((uint32_t)0x080E0000) /* Base @ of Sector 11, 128 Kbyte */ #endif +#define ADDR_FLASH_SECTOR_END ((uint32_t)(FLASH_END + 1)) #ifdef __cplusplus extern "C" { @@ -47,7 +48,7 @@ int eeprom_write_byte(uint32_t address, uint8_t data); int eeprom_erase(uint32_t address, uint32_t size); int eeprom_wait(); - int eeprom_erase_sector(uint32_t sector); + int eeprom_erase_sector(uint32_t sector, uint32_t bank); /* * Functions to lock/unlock pages will perform system reset unless flash is already in desired state */ From d2a14ec7460f1194168253b0b5adc90a586a6dad Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 8 Dec 2021 11:20:52 +0100 Subject: [PATCH 213/286] cleaned up compilation flags --- Hardware/owl2.mk | 4 ---- Hardware/owl3.mk | 6 +----- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/Hardware/owl2.mk b/Hardware/owl2.mk index 4980b071..c9c43d86 100644 --- a/Hardware/owl2.mk +++ b/Hardware/owl2.mk @@ -25,11 +25,7 @@ endif LDFLAGS += -Wl,--gc-sections LDSCRIPT ?= $(OPENWARE)/Hardware/owl2.ld LDLIBS += -lc -lm -# CPPFLAGS += -DEXTERNAL_SRAM -DARM_CORTEX -# CPPFLAGS += -fpic -fpie CPPFLAGS += -Wdouble-promotion -Werror=double-promotion -CPPFLAGS += -fdata-sections -CPPFLAGS += -ffunction-sections CPPFLAGS += -fno-builtin -ffreestanding LDFLAGS += -fno-builtin -ffreestanding CXXFLAGS = -fno-rtti -fno-exceptions -std=gnu++17 diff --git a/Hardware/owl3.mk b/Hardware/owl3.mk index 40718463..2db6d870 100644 --- a/Hardware/owl3.mk +++ b/Hardware/owl3.mk @@ -25,11 +25,7 @@ endif LDFLAGS += -Wl,--gc-sections LDSCRIPT ?= $(OPENWARE)/Hardware/owl3.ld LDLIBS += -lc -lm -# CPPFLAGS += -DEXTERNAL_SRAM -DARM_CORTEX -# CPPFLAGS += -fpic -fpie -CPPFLAGS += -Wdouble-promotion -CPPFLAGS += -fdata-sections -CPPFLAGS += -ffunction-sections +CPPFLAGS += -Wdouble-promotion -Werror=double-promotion CPPFLAGS += -fno-builtin -ffreestanding LDFLAGS += -fno-builtin -ffreestanding CXXFLAGS = -fno-rtti -fno-exceptions -std=gnu++17 From e2f7b328340c5f1deea237872bad77c74c1a4a82 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 8 Dec 2021 11:21:16 +0100 Subject: [PATCH 214/286] OperationMode changes --- Lich/Src/Lich.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lich/Src/Lich.cpp b/Lich/Src/Lich.cpp index 1764bdb6..cffc5867 100644 --- a/Lich/Src/Lich.cpp +++ b/Lich/Src/Lich.cpp @@ -156,7 +156,7 @@ void setProgress(uint16_t value, const char* msg){ progress = value; } -void onChangeMode(OperationMode new_mode, OperationMode old_mode){ +void onChangeMode(uint8_t new_mode, uint8_t old_mode){ progress = 0; patchselect = program.getProgramIndex(); setEncoderValue(patchselect); From fba7fd5a400591a9f82a818e128b37911216219e Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 8 Dec 2021 11:21:49 +0100 Subject: [PATCH 215/286] OperationMode changes --- Magus/Inc/hardware.h | 1 - Magus/Src/Magus.cpp | 2 +- Magus3/Src/Magus.cpp | 31 ++++++++++++++++++++++++++----- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/Magus/Inc/hardware.h b/Magus/Inc/hardware.h index fe0f9347..732ba89b 100644 --- a/Magus/Inc/hardware.h +++ b/Magus/Inc/hardware.h @@ -10,7 +10,6 @@ #define USE_SCREEN #define SSD1309 /* #define OLED_DMA */ -#define OLED_SOFT_CS #define OLED_SPI hspi6 /* #define OLED_IT */ /* #define OLED_BITBANG */ diff --git a/Magus/Src/Magus.cpp b/Magus/Src/Magus.cpp index fee2ed1c..1c5b75ce 100644 --- a/Magus/Src/Magus.cpp +++ b/Magus/Src/Magus.cpp @@ -28,7 +28,7 @@ void setProgress(uint16_t value, const char* reason){ progress_counter = value; } -void onChangeMode(OperationMode new_mode, OperationMode old_mode){ +void onChangeMode(uint8_t new_mode, uint8_t old_mode){ switch(new_mode){ case STREAM_MODE: setProgress(0, "Streaming"); diff --git a/Magus3/Src/Magus.cpp b/Magus3/Src/Magus.cpp index 31419b8a..1c5b75ce 100644 --- a/Magus3/Src/Magus.cpp +++ b/Magus3/Src/Magus.cpp @@ -12,12 +12,10 @@ #include "Storage.h" #include "MagusParameterController.hpp" -// 63, 19, 60 // TODO: balance levels - const uint32_t* dyn_rainbowinputs = rainbowinputs; const uint32_t* dyn_rainbowoutputs = rainbowoutputs; -static MagusParameterController params; +MagusParameterController params; Graphics graphics DMA_RAM; extern "C" void onResourceUpdate(void); @@ -30,6 +28,29 @@ void setProgress(uint16_t value, const char* reason){ progress_counter = value; } +void onChangeMode(uint8_t new_mode, uint8_t old_mode){ + switch(new_mode){ + case STREAM_MODE: + setProgress(0, "Streaming"); + setDisplayMode(PROGRESS_DISPLAY_MODE); + break; + case STARTUP_MODE: + case LOAD_MODE: + setProgress(0, "Loading"); + setDisplayMode(PROGRESS_DISPLAY_MODE); + break; + case CONFIGURE_MODE: + setDisplayMode(STATUS_DISPLAY_MODE); + break; + case RUN_MODE: + setDisplayMode(STANDARD_DISPLAY_MODE); + break; + case ERROR_MODE: + setDisplayMode(ERROR_DISPLAY_MODE); + break; + } +} + static bool updateMAX11300 = false; static uint8_t portMode[20]; void setPortMode(uint8_t index, uint8_t mode){ @@ -86,8 +107,8 @@ void onSetup(){ // LEDs TLC5946_init(&TLC5946_SPI); - TLC5946_setAll_DC(0); // Start with 0 brightness here, update from settings later - TLC5946_setAll(0x10, 0x10, 0x10); + TLC5946_setAll_DC(0); // Start with low brightness here, update from settings later + TLC5946_setAll(0, 0, 0); HAL_GPIO_WritePin(TLC_BLANK_GPIO_Port, TLC_BLANK_Pin, GPIO_PIN_RESET); From 9643d40067f529d71de83e8d5c96f7cea11489bc Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 8 Dec 2021 11:22:02 +0100 Subject: [PATCH 216/286] OperationMode changes --- Witch/Src/Witch.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Witch/Src/Witch.cpp b/Witch/Src/Witch.cpp index 9f67b4be..14c03499 100644 --- a/Witch/Src/Witch.cpp +++ b/Witch/Src/Witch.cpp @@ -81,12 +81,12 @@ bool updatePin(size_t bid, Pin pin){ setButtonValue(bid+3, state); setLed(bid+6, state ? RED_COLOUR : NO_COLOUR); }else if(owl.getOperationMode() == CONFIGURE_MODE && state){ - if(patchselect == bid){ - if(registry.hasPatch(bid+4)) - patchselect = bid+4; - }else{ - if(registry.hasPatch(bid)) - patchselect = bid; + if(patchselect == bid && registry.hasPatch(bid+4)){ + patchselect = bid+4; + }else if(registry.hasPatch(bid)){ + patchselect = bid; + }else if(registry.hasPatch(bid+4)){ + patchselect = bid+4; } } return state; @@ -400,7 +400,7 @@ void onStartProgram(){ memset(button_led_values, 0, sizeof(button_led_values)); // reset leds } -void onChangeMode(OperationMode new_mode, OperationMode old_mode){ +void onChangeMode(uint8_t new_mode, uint8_t old_mode){ if(new_mode == CONFIGURE_MODE){ // entering config mode HAL_GPIO_WritePin(TR_OUT1_GPIO_Port, TR_OUT1_Pin, GPIO_PIN_SET); From 784a28ec48fe4d504bb0501ffd9216f2e16bff38 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 8 Dec 2021 11:22:49 +0100 Subject: [PATCH 217/286] backwards patch compatibility: stereo audio format (omit channels) and CCM stack (heap) --- Source/ProgramManager.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Source/ProgramManager.cpp b/Source/ProgramManager.cpp index 90d1f928..f5dbc390 100644 --- a/Source/ProgramManager.cpp +++ b/Source/ProgramManager.cpp @@ -365,22 +365,24 @@ void updateProgramVector(ProgramVector* pv, PatchDefinition* def){ pv->encoderChangedCallback = NULL; #endif #ifdef PROGRAM_VECTOR_V13 - extern char _PATCHRAM_END; + extern uint8_t _PATCHRAM, _PATCHRAM_END, _PATCHRAM_SIZE; uint8_t* end = (uint8_t*)def->getStackBase(); // program end - uint32_t remain = (uint32_t)&_PATCHRAM_END - (uint32_t)def->getStackBase(); // space left + uint32_t remain = &_PATCHRAM_END - end; // space left + if(end < &_PATCHRAM || remain > (uint32_t)&_PATCHRAM_SIZE) // sanity check + remain = 0; // prevent errors if program stack is not linked to PATCHRAM #ifdef USE_CCM_RAM extern char _CCMRAM, _CCMRAM_SIZE; #endif #ifdef USE_PLUS_RAM - extern char _PLUSRAM, _PLUSRAM_END, _PLUSRAM_SIZE; - extern char _PATCHRAM, _PATCHRAM_SIZE; + extern uint8_t _PLUSRAM, _PLUSRAM_END, _PLUSRAM_SIZE; uint8_t* plusend = (uint8_t*)&_PLUSRAM; uint32_t plusremain = (uint32_t)&_PLUSRAM_SIZE; if(def->getLinkAddress() == (uint32_t*)&_PLUSRAM){ end = (uint8_t*)&_PATCHRAM; - remain = (uint32_t)&_PATCHRAM_SIZE; + remain = (uint32_t)&_PATCHRAM_SIZE; // use all of PATCHRAM for heap plusend = (uint8_t*)def->getStackBase(); - plusremain = (uint32_t)&_PLUSRAM_END - (uint32_t)def->getStackBase(); + plusremain = def->getStackSize(); + plusremain = &_PLUSRAM_END - plusend; } #endif #ifdef USE_EXTERNAL_RAM @@ -406,6 +408,8 @@ void updateProgramVector(ProgramVector* pv, PatchDefinition* def){ pv->heapSegments = (MemorySegment*)heapSegments; #ifdef USE_WM8731 pv->audio_format = AUDIO_FORMAT_24B16_2X; +#elif AUDIO_CHANNELS == 2 + pv->audio_format = AUDIO_FORMAT_24B32; #else pv->audio_format = AUDIO_FORMAT_24B32 | AUDIO_CHANNELS; #endif From e22cdc872918fd48c52b9bac9d6854a10b730a00 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 8 Dec 2021 23:38:09 +0100 Subject: [PATCH 218/286] reverted to use -fdata-sections and -ffunction-sections to prevent missing (unused) symbols --- Hardware/owl2.mk | 1 + Hardware/owl3.mk | 1 + 2 files changed, 2 insertions(+) diff --git a/Hardware/owl2.mk b/Hardware/owl2.mk index c9c43d86..02ff048c 100644 --- a/Hardware/owl2.mk +++ b/Hardware/owl2.mk @@ -26,6 +26,7 @@ LDFLAGS += -Wl,--gc-sections LDSCRIPT ?= $(OPENWARE)/Hardware/owl2.ld LDLIBS += -lc -lm CPPFLAGS += -Wdouble-promotion -Werror=double-promotion +CPPFLAGS += -fdata-sections -ffunction-sections CPPFLAGS += -fno-builtin -ffreestanding LDFLAGS += -fno-builtin -ffreestanding CXXFLAGS = -fno-rtti -fno-exceptions -std=gnu++17 diff --git a/Hardware/owl3.mk b/Hardware/owl3.mk index 2db6d870..9ed4cbc0 100644 --- a/Hardware/owl3.mk +++ b/Hardware/owl3.mk @@ -26,6 +26,7 @@ LDFLAGS += -Wl,--gc-sections LDSCRIPT ?= $(OPENWARE)/Hardware/owl3.ld LDLIBS += -lc -lm CPPFLAGS += -Wdouble-promotion -Werror=double-promotion +CPPFLAGS += -fdata-sections -ffunction-sections CPPFLAGS += -fno-builtin -ffreestanding LDFLAGS += -fno-builtin -ffreestanding CXXFLAGS = -fno-rtti -fno-exceptions -std=gnu++17 From bdce75d28a6e4c32c203003c57f9d9c8ebc45c19 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 8 Dec 2021 23:38:50 +0100 Subject: [PATCH 219/286] use HAL_GetUIDn() instead of UID_BASE pointer --- Source/MidiController.cpp | 7 +++---- Source/Owl.cpp | 3 +-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Source/MidiController.cpp b/Source/MidiController.cpp index 2461d115..faf4aedd 100644 --- a/Source/MidiController.cpp +++ b/Source/MidiController.cpp @@ -366,14 +366,13 @@ void MidiController::sendConfigurationSetting(const char* name, uint32_t value){ } void MidiController::sendDeviceId(){ - uint32_t* deviceId = (uint32_t*)UID_BASE; char buf[32]; buf[0] = SYSEX_DEVICE_ID; char* p = &buf[1]; - p = stpcpy(p, msg_itoa(deviceId[0], 16, 8)); + p = stpcpy(p, msg_itoa(HAL_GetUIDw0(), 16, 8)); p = stpcpy(p, ":"); - p = stpcpy(p, msg_itoa(deviceId[1], 16, 8)); + p = stpcpy(p, msg_itoa(HAL_GetUIDw1(), 16, 8)); p = stpcpy(p, ":"); - p = stpcpy(p, msg_itoa(deviceId[2], 16, 8)); + p = stpcpy(p, msg_itoa(HAL_GetUIDw2(), 16, 8)); sendSysEx((uint8_t*)buf, p-buf); } diff --git a/Source/Owl.cpp b/Source/Owl.cpp index c0fb8fd3..81c237d4 100644 --- a/Source/Owl.cpp +++ b/Source/Owl.cpp @@ -278,8 +278,7 @@ const char* getDeviceName(){ static char name[22]; static char* ptr = 0; if(ptr == 0){ - uint32_t* id = (uint32_t*)UID_BASE; // get a pointer to the 96-bit unique device id - unsigned int hash = id[0]^id[1]^id[2]; // hash into 32-bit value + uint32_t hash = HAL_GetUIDw0() ^ HAL_GetUIDw1() ^ HAL_GetUIDw2(); // hash into 32-bit value hash = (hash>>16)^(hash&0xffff); // hash into 16-bit value char* p = stpcpy(name, "OWL-" HARDWARE_VERSION "-"); stpcpy(p, msg_itoa(hash, 16)); From 08b0ba27b722b498d2902cbf4fdc0afce0ac5aa0 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Wed, 8 Dec 2021 23:51:56 +0100 Subject: [PATCH 220/286] change to uSec delay using CYCCNT --- Source/HAL_Encoders.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/Source/HAL_Encoders.c b/Source/HAL_Encoders.c index 9a26f7cf..ac64df6c 100644 --- a/Source/HAL_Encoders.c +++ b/Source/HAL_Encoders.c @@ -10,32 +10,31 @@ SPI_HandleTypeDef* Encoders_SPIConfig; static int16_t rgENC_Values[7] = {0}; -#ifdef STM32H7xx -static volatile uint16_t NOP_CNT = 600; -#else -static uint16_t NOP_CNT = 250; // 150 doesn't work in Release build -#endif +#define ENCODER_CS_DELAY_US 8 + +__STATIC_INLINE void DWT_Delay_us(volatile uint32_t microseconds) +{ + uint32_t clk_cycle_start = DWT->CYCCNT; + /* Go to number of cycles for system */ + microseconds *= (HAL_RCC_GetHCLKFreq() / 1000000); + /* Delay till end */ + while ((DWT->CYCCNT - clk_cycle_start) < microseconds); +} //_____ Functions _____________________________________________________________________________________________________ // Port and Chip Setup void Encoders_readAll(void) { - volatile uint16_t x = NOP_CNT; - pbarCS(0); - while(--x){__NOP();} // TODO: microsecond delay using CYCCNT - // *** The minimum NOP delay for proper operation seems to be 150 *** + DWT_Delay_us(ENCODER_CS_DELAY_US); HAL_SPI_Receive(Encoders_SPIConfig, (uint8_t*)rgENC_Values, 14, 100); pbarCS(1); } void Encoders_readSwitches(void) { - volatile uint16_t x = NOP_CNT; - pbarCS(0); - while(--x){__NOP();} - // *** The minimum NOP delay for proper operation seems to be 150 *** + DWT_Delay_us(ENCODER_CS_DELAY_US); HAL_SPI_Receive(Encoders_SPIConfig, (uint8_t*)rgENC_Values, 2, 100); pbarCS(1); } @@ -54,8 +53,7 @@ void Encoders_init (SPI_HandleTypeDef *spiconfig) void Encoders_reset(void){ pbarRST(0); - volatile uint16_t x = NOP_CNT; - while(--x){__NOP();} + HAL_Delay(20); pbarRST(1); } From 92d3b96442064f401e8036c794a34c47de54c884 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 9 Dec 2021 12:52:21 +0100 Subject: [PATCH 221/286] reduce default brightness --- Magus/Inc/hardware.h | 2 +- Magus/Src/Magus.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Magus/Inc/hardware.h b/Magus/Inc/hardware.h index 732ba89b..692a159e 100644 --- a/Magus/Inc/hardware.h +++ b/Magus/Inc/hardware.h @@ -42,7 +42,7 @@ #define UART_MIDI_RX_BUFFER_SIZE 256 #define USE_TLC5946 -#define LEDS_BRIGTHNESS 6 +#define LEDS_BRIGTHNESS 2 #define TLC5946_SPI hspi6 #define MAX11300_SPI hspi5 #define ENCODERS_SPI hspi5 diff --git a/Magus/Src/Magus.cpp b/Magus/Src/Magus.cpp index 1c5b75ce..24689e4c 100644 --- a/Magus/Src/Magus.cpp +++ b/Magus/Src/Magus.cpp @@ -98,6 +98,8 @@ void onResourceUpdate(void){ void onSetup(){ HAL_GPIO_WritePin(TLC_BLANK_GPIO_Port, TLC_BLANK_Pin, GPIO_PIN_SET); // LEDs off Pin enc_nrst(ENC_NRST_GPIO_Port, ENC_NRST_Pin); + + // Encoders_reset(); enc_nrst.outputMode(); enc_nrst.low(); @@ -148,7 +150,8 @@ void onSetup(){ HAL_GPIO_WritePin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin, GPIO_PIN_SET); #endif - // Update LEDs brighness from settings + // Update LEDs brightness from settings + // TLC5946_setRGB_DC(63, 19, 60); TLC5946_setAll_DC(settings.leds_brightness); TLC5946_Refresh_DC(); @@ -156,6 +159,7 @@ void onSetup(){ // allows us to program chip with SWD enc_nrst.inputMode(); enc_nrst.setPull(PIN_PULL_UP); + HAL_Delay(20); Encoders_readAll(); } From 9354a0ce1617dca163788e18a2fdbc5d63f87d78 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 9 Dec 2021 12:54:25 +0100 Subject: [PATCH 222/286] updated encoder SPI settings (very fast GPIO) --- Magus3/Inc/hardware.h | 8 +++++--- Magus3/Inc/stm32h7xx_hal_conf.h | 1 + Magus3/Magus3.ioc | 13 ++++++++----- Magus3/Src/Magus.cpp | 6 +++++- Magus3/Src/main.c | 4 +++- Magus3/Src/stm32h7xx_hal_msp.c | 8 +++++--- 6 files changed, 27 insertions(+), 13 deletions(-) diff --git a/Magus3/Inc/hardware.h b/Magus3/Inc/hardware.h index f8f72f89..904422c9 100644 --- a/Magus3/Inc/hardware.h +++ b/Magus3/Inc/hardware.h @@ -35,12 +35,14 @@ #define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) -#define MAIN_LOOP_SLEEP_MS 20 +/* #define MAIN_LOOP_SLEEP_MS 2 */ #define ARM_CYCLES_PER_SAMPLE (480000000/AUDIO_SAMPLINGRATE) /* 480MHz / 48kHz */ #define USE_USBD_AUDIO -#define USE_USBD_AUDIO_TX // microphone +#define USE_USBD_RX_FB +#define USE_USBD_AUDIO_FEATURES #define USE_USBD_AUDIO_RX // speaker +#define USE_USBD_AUDIO_TX // microphone #define USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS #define USBH_HANDLE hUsbHostHS @@ -54,7 +56,7 @@ /* #define UART_MIDI_RX_BUFFER_SIZE 256 */ #define USE_TLC5946 -#define LEDS_BRIGTHNESS 20 +#define LEDS_BRIGTHNESS 2 #define TLC5946_SPI hspi6 #define MAX11300_SPI hspi5 #define ENCODERS_SPI hspi5 diff --git a/Magus3/Inc/stm32h7xx_hal_conf.h b/Magus3/Inc/stm32h7xx_hal_conf.h index 6378c585..a16c3613 100644 --- a/Magus3/Inc/stm32h7xx_hal_conf.h +++ b/Magus3/Inc/stm32h7xx_hal_conf.h @@ -65,6 +65,7 @@ /* #define HAL_LPTIM_MODULE_ENABLED */ /* #define HAL_LTDC_MODULE_ENABLED */ /* #define HAL_QSPI_MODULE_ENABLED */ +/* #define HAL_RAMECC_MODULE_ENABLED */ /* #define HAL_RNG_MODULE_ENABLED */ /* #define HAL_RTC_MODULE_ENABLED */ #define HAL_SAI_MODULE_ENABLED diff --git a/Magus3/Magus3.ioc b/Magus3/Magus3.ioc index 77e65bc5..adfbc33c 100644 --- a/Magus3/Magus3.ioc +++ b/Magus3/Magus3.ioc @@ -453,16 +453,19 @@ PF2.Signal=FMC_A2 PF3.Signal=FMC_A3 PF4.Signal=FMC_A4 PF5.Signal=FMC_A5 -PF7.GPIOParameters=GPIO_Label +PF7.GPIOParameters=GPIO_Speed,GPIO_Label PF7.GPIO_Label=SPI_A_SCK +PF7.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH PF7.Mode=Full_Duplex_Master PF7.Signal=SPI5_SCK -PF8.GPIOParameters=GPIO_Label +PF8.GPIOParameters=GPIO_Speed,GPIO_Label PF8.GPIO_Label=SPI_A_MISO +PF8.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH PF8.Mode=Full_Duplex_Master PF8.Signal=SPI5_MISO -PF9.GPIOParameters=GPIO_Label +PF9.GPIOParameters=GPIO_Speed,GPIO_Label PF9.GPIO_Label=SPI_A_MOSI +PF9.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH PF9.Mode=Full_Duplex_Master PF9.Signal=SPI5_MOSI PG0.Signal=FMC_A10 @@ -766,8 +769,8 @@ SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,VirtualType,Direction SPI4.Mode=SPI_MODE_MASTER SPI4.NSSPMode=SPI_NSS_PULSE_DISABLE SPI4.VirtualType=VM_MASTER -SPI5.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_64 -SPI5.CalculateBaudRate=1.875 MBits/s +SPI5.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_32 +SPI5.CalculateBaudRate=3.75 MBits/s SPI5.DataSize=SPI_DATASIZE_8BIT SPI5.Direction=SPI_DIRECTION_2LINES SPI5.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,DataSize,NSSPMode diff --git a/Magus3/Src/Magus.cpp b/Magus3/Src/Magus.cpp index 1c5b75ce..24689e4c 100644 --- a/Magus3/Src/Magus.cpp +++ b/Magus3/Src/Magus.cpp @@ -98,6 +98,8 @@ void onResourceUpdate(void){ void onSetup(){ HAL_GPIO_WritePin(TLC_BLANK_GPIO_Port, TLC_BLANK_Pin, GPIO_PIN_SET); // LEDs off Pin enc_nrst(ENC_NRST_GPIO_Port, ENC_NRST_Pin); + + // Encoders_reset(); enc_nrst.outputMode(); enc_nrst.low(); @@ -148,7 +150,8 @@ void onSetup(){ HAL_GPIO_WritePin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin, GPIO_PIN_SET); #endif - // Update LEDs brighness from settings + // Update LEDs brightness from settings + // TLC5946_setRGB_DC(63, 19, 60); TLC5946_setAll_DC(settings.leds_brightness); TLC5946_Refresh_DC(); @@ -156,6 +159,7 @@ void onSetup(){ // allows us to program chip with SWD enc_nrst.inputMode(); enc_nrst.setPull(PIN_PULL_UP); + HAL_Delay(20); Encoders_readAll(); } diff --git a/Magus3/Src/main.c b/Magus3/Src/main.c index dd25cfdc..d90c7e7a 100644 --- a/Magus3/Src/main.c +++ b/Magus3/Src/main.c @@ -52,6 +52,8 @@ #include "cmsis_os.h" #include "usb_device.h" #include "usb_host.h" +#include "usb_device.h" +#include "usb_host.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ @@ -524,7 +526,7 @@ static void MX_SPI5_Init(void) hspi5.Init.CLKPolarity = SPI_POLARITY_LOW; hspi5.Init.CLKPhase = SPI_PHASE_1EDGE; hspi5.Init.NSS = SPI_NSS_SOFT; - hspi5.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64; + hspi5.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32; hspi5.Init.FirstBit = SPI_FIRSTBIT_MSB; hspi5.Init.TIMode = SPI_TIMODE_DISABLE; hspi5.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; diff --git a/Magus3/Src/stm32h7xx_hal_msp.c b/Magus3/Src/stm32h7xx_hal_msp.c index 8edfe3d7..348a4ae7 100644 --- a/Magus3/Src/stm32h7xx_hal_msp.c +++ b/Magus3/Src/stm32h7xx_hal_msp.c @@ -200,7 +200,7 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) GPIO_InitStruct.Pin = SPI_A_SCK_Pin|SPI_A_MISO_Pin|SPI_A_MOSI_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF5_SPI5; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); @@ -871,7 +871,7 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; HAL_GPIO_Init(CS_SDIN_GPIO_Port, &GPIO_InitStruct); - /* Peripheral DMA init*/ + /* Peripheral DMA init*/ hdma_sai1_a.Instance = DMA2_Stream1; hdma_sai1_a.Init.Request = DMA_REQUEST_SAI1_A; @@ -914,7 +914,7 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; HAL_GPIO_Init(CS_SDOUT_GPIO_Port, &GPIO_InitStruct); - /* Peripheral DMA init*/ + /* Peripheral DMA init*/ hdma_sai1_b.Instance = DMA2_Stream4; hdma_sai1_b.Init.Request = DMA_REQUEST_SAI1_B; @@ -959,6 +959,7 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) HAL_GPIO_DeInit(CS_SDIN_GPIO_Port, CS_SDIN_Pin); + /* SAI1 DMA Deinit */ HAL_DMA_DeInit(hsai->hdmarx); HAL_DMA_DeInit(hsai->hdmatx); } @@ -976,6 +977,7 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) */ HAL_GPIO_DeInit(CS_SDOUT_GPIO_Port, CS_SDOUT_Pin); + /* SAI1 DMA Deinit */ HAL_DMA_DeInit(hsai->hdmarx); HAL_DMA_DeInit(hsai->hdmatx); } From ff3b627fdcbe74e1b720d39c364bc23fadef4468 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 9 Dec 2021 12:54:50 +0100 Subject: [PATCH 223/286] correct usec delay for H7 / F4 --- Source/HAL_Encoders.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/HAL_Encoders.c b/Source/HAL_Encoders.c index ac64df6c..5582f52b 100644 --- a/Source/HAL_Encoders.c +++ b/Source/HAL_Encoders.c @@ -10,10 +10,18 @@ SPI_HandleTypeDef* Encoders_SPIConfig; static int16_t rgENC_Values[7] = {0}; +#ifdef STM32H7xx +#define ENCODER_CS_DELAY_US 14 +#else #define ENCODER_CS_DELAY_US 8 +#endif +/* uint8_t ENCODER_CS_DELAY_US = 14; */ __STATIC_INLINE void DWT_Delay_us(volatile uint32_t microseconds) { +#ifndef DEBUG_DWT +#error "Need DWT enabled for microsecond delay" +#endif uint32_t clk_cycle_start = DWT->CYCCNT; /* Go to number of cycles for system */ microseconds *= (HAL_RCC_GetHCLKFreq() / 1000000); From b9fbdb580210c8cc38457f89cd392767ceac9cdc Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 9 Dec 2021 12:55:59 +0100 Subject: [PATCH 224/286] cleaned up TLC driver --- Source/HAL_TLC5946.c | 40 ++++++++++++++++++++-------------------- Source/HAL_TLC5946.h | 4 ---- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/Source/HAL_TLC5946.c b/Source/HAL_TLC5946.c index 894433a2..3bb82485 100644 --- a/Source/HAL_TLC5946.c +++ b/Source/HAL_TLC5946.c @@ -8,12 +8,15 @@ #define TLC_DEVICES 3 #endif -#define TLC_CHANNELS 16 +#define TLC_CHANNELS 16 #define TLC_DC_BYTES (TLC_CHANNELS * 3 / 4) #define TLC_GS_BYTES (TLC_CHANNELS * 3 / 2) +// Modes +#define TLC_MODE_GS 0 +#define TLC_MODE_DC 1 -static uint8_t rgGSbuf[TLC_DEVICES*TLC_GS_BYTES+1]; -static uint8_t rgDCbuf[TLC_DEVICES*TLC_DC_BYTES+1] = +static uint8_t rgGSbuf[TLC_DEVICES*TLC_GS_BYTES] = {0}; +static uint8_t rgDCbuf[TLC_DEVICES*TLC_DC_BYTES] = { 12, 48, 195, 12, 48, 195, 12, 48, 195, 12, 48, 195, // DC=3 Red 12, 48, 195, 12, 48, 195, 12, 48, 195, 12, 48, 195, // DC=3 Blue @@ -62,9 +65,9 @@ void TLC5946_SetOutput_DC(uint8_t ic, uint8_t led, uint8_t value) } // Set the same value on one or more TLC clips. This is not called outside of this file. -static void TLC5946_SetOutput_DC_Many(uint8_t* data, uint8_t num_values, uint8_t value) +static void TLC5946_SetOutput_DC_Many(uint8_t* data, size_t len, uint8_t value) { - uint8_t* last_data = data + num_values * 3 / 4; + uint8_t* last_data = data + len; uint8_t byte1 = value << 2 | value >> 4; uint8_t byte2 = value << 4 | value >> 2; uint8_t byte3 = value << 6 | value; @@ -80,6 +83,7 @@ void TLC5946_TxINTCallback(void) // Latch pulse pXLAT(1); /* pBLANK(1); */ + // XLAT pulse duration min 20nS pXLAT(0); #ifdef TLC_CONTINUOUS @@ -91,7 +95,6 @@ void TLC5946_TxINTCallback(void) void TLC5946_Refresh_GS(void) { // Update Grayscale - pMODE(Mode_GS); pXLAT(0); /* pBLANK(1); */ @@ -109,44 +112,42 @@ void TLC5946_Refresh_GS(void) void TLC5946_Refresh_DC(void) { - pMODE(Mode_DC); + pMODE(TLC_MODE_DC); pXLAT(0); - // Update Dot Correction HAL_SPI_Transmit(TLC5946_SPIConfig, (uint8_t*)rgDCbuf, TLC_DC_BYTES*TLC_DEVICES, 100); - // Latch pulse pXLAT(1); + HAL_Delay(1); // TH2 MODE-XLAT^ min 100nS + pMODE(TLC_MODE_GS); + pXLAT(0); } // _____ Magus Functions _____ void TLC5946_setRGB(uint8_t LED_ID, uint16_t val_R, uint16_t val_G, uint16_t val_B) { TLC5946_SetOutput_GS(0, rgLED_R[LED_ID-1], val_R); - TLC5946_SetOutput_GS(2, rgLED_G[LED_ID-1], val_G); TLC5946_SetOutput_GS(1, rgLED_B[LED_ID-1], val_B); + TLC5946_SetOutput_GS(2, rgLED_G[LED_ID-1], val_G); } void TLC5946_setRGB_DC(uint8_t val_R, uint8_t val_G, uint8_t val_B) { - TLC5946_SetOutput_DC_Many(rgDCbuf, TLC_CHANNELS, val_R); - TLC5946_SetOutput_DC_Many(rgDCbuf + TLC_DC_BYTES, TLC_CHANNELS, val_G); - TLC5946_SetOutput_DC_Many(rgDCbuf + TLC_DC_BYTES * 2, TLC_CHANNELS, val_B); - - TLC5946_Refresh_DC(); + TLC5946_SetOutput_DC_Many(rgDCbuf, TLC_DC_BYTES, val_R); + TLC5946_SetOutput_DC_Many(rgDCbuf + TLC_DC_BYTES, TLC_DC_BYTES, val_B); + TLC5946_SetOutput_DC_Many(rgDCbuf + TLC_DC_BYTES*2, TLC_DC_BYTES, val_G); } void TLC5946_setAll_DC(uint8_t value) { - TLC5946_SetOutput_DC_Many(rgDCbuf, TLC_CHANNELS * TLC_DEVICES, value); - TLC5946_Refresh_DC(); + TLC5946_SetOutput_DC_Many(rgDCbuf, TLC_DC_BYTES * TLC_DEVICES, value); } void TLC5946_setAll(uint16_t val_R, uint16_t val_G, uint16_t val_B){ for(int i=0; i<16; i++){ TLC5946_SetOutput_GS(0, i, val_R); - TLC5946_SetOutput_GS(2, i, val_G); TLC5946_SetOutput_GS(1, i, val_B); + TLC5946_SetOutput_GS(2, i, val_G); } } @@ -155,6 +156,5 @@ void TLC5946_init (SPI_HandleTypeDef *spiconfig) { // Copy SPI handle to local variable TLC5946_SPIConfig = spiconfig; - - // + pMODE(TLC_MODE_GS); } diff --git a/Source/HAL_TLC5946.h b/Source/HAL_TLC5946.h index 4fb6ba45..9a4567d8 100644 --- a/Source/HAL_TLC5946.h +++ b/Source/HAL_TLC5946.h @@ -8,10 +8,6 @@ extern "C" { #endif -// Modes -#define Mode_GS 0 -#define Mode_DC 1 - // Pin Control #define pXLAT(state) HAL_GPIO_WritePin(TLC_XLAT_GPIO_Port, TLC_XLAT_Pin, (GPIO_PinState)state) #define pMODE(state) HAL_GPIO_WritePin(TLC_MODE_GPIO_Port, TLC_MODE_Pin, (GPIO_PinState)state) From 8532300714f834239ee21e0a1f0b44d39b1082e4 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 9 Dec 2021 12:56:42 +0100 Subject: [PATCH 225/286] call Graphics::reset in Graphics::begin() --- Source/Graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Graphics.cpp b/Source/Graphics.cpp index 5851847f..35463e0c 100644 --- a/Source/Graphics.cpp +++ b/Source/Graphics.cpp @@ -16,7 +16,7 @@ void Graphics::begin(ParameterController* pc, SPI_HandleTypeDef *spi) { oled_init(spi); screen.setBuffer(pixelbuffer); screen.clear(); - params->reset(); + reset(); display(); } From 952ed495d7df2e85391a7d7357176988ef1b38bc Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 9 Dec 2021 12:57:08 +0100 Subject: [PATCH 226/286] changed to use button event handlers --- Source/MagusParameterController.hpp | 97 +++++++++++++++++------------ 1 file changed, 56 insertions(+), 41 deletions(-) diff --git a/Source/MagusParameterController.hpp b/Source/MagusParameterController.hpp index b8ecf094..48434cbf 100644 --- a/Source/MagusParameterController.hpp +++ b/Source/MagusParameterController.hpp @@ -96,7 +96,9 @@ class Page { virtual void enter(){} virtual void exit(){} virtual void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){} - int16_t getDiscreteEncoderValue(int16_t current, int16_t previous){ + virtual void buttonsChanged(uint32_t current, uint32_t previous){} + // helper functions + static int16_t getDiscreteEncoderValue(int16_t current, int16_t previous){ int32_t delta = (current - previous) * encoder_sensitivity; if(delta > 0 && (current & encoder_mask) == encoder_mask) return 1; @@ -104,7 +106,7 @@ class Page { return -1; return 0; } - int16_t getContinuousEncoderValue(int16_t current, int16_t previous, int16_t scale){ + static int16_t getContinuousEncoderValue(int16_t current, int16_t previous, int16_t scale){ int32_t delta = (current - previous) * encoder_sensitivity; if(delta > 0) delta = scale << (delta/3); @@ -112,6 +114,12 @@ class Page { delta = -scale << (-delta/3); return delta; } + static bool pressed(uint32_t bid, uint32_t current, uint32_t previous){ + return (current & bid) && !(previous & bid); + } + static bool released(uint32_t bid, uint32_t current, uint32_t previous){ + return !(current & bid) && (previous & bid); + } }; /* @@ -123,29 +131,19 @@ press once to toggle mode: update > select turn to scroll through 4 functions press again to select parameter: select > update -todo: -- update parameter / encoderChanged -- select parameter -- select global parameter -- select preset mode */ class MagusParameterController : public ParameterController { public: Page* page = NULL; - uint16_t buttons; + uint16_t buttons; int16_t encoders[NOF_ENCODERS]; // last seen encoder values int16_t user[NOF_PARAMETERS]; // user set values (ie by encoder or MIDI) uint8_t selectedBlock; uint8_t selectedPid[NOF_ENCODERS]; - MagusParameterController(){ - reset(); - setDisplayMode(PROGRESS_DISPLAY_MODE); - } void reset(){ setTitle("Magus"); ParameterController::reset(); - Encoders_reset(); for(int i=0; ibuttonsChanged(data[0], buttons); + buttons = data[0]; + } for(size_t i=0; i", screen); int offset = 16; screen.setTextSize(1); @@ -533,7 +535,10 @@ class EncoderSensitivityPage : public Page { if (encoder_sensitivity >= SENS_SUPER_COARSE) screen.fillCircle(104, offset + 15, 6, WHITE); } - + void buttonsChanged(uint32_t current, uint32_t previous){ + if(pressed(ENCODER_BUTTON_ANY, current, previous)) + setDisplayMode(CONFIG_EXIT_DISPLAY_MODE); + } void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ if(encoder == ENCODER_R){ int16_t delta = getDiscreteEncoderValue(current, previous); @@ -547,6 +552,10 @@ class EncoderSensitivityPage : public Page { class ConfigVolumePage : public Page { public: + void buttonsChanged(uint32_t current, uint32_t previous){ + if(pressed(ENCODER_BUTTON_ANY, current, previous)) + setDisplayMode(CONFIG_EXIT_DISPLAY_MODE); + } void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ if(encoder == ENCODER_R){ int16_t delta = getDiscreteEncoderValue(current, previous); @@ -560,12 +569,9 @@ class ConfigVolumePage : public Page { } } void draw(ScreenBuffer& screen){ - if(params.isEncoderPushed(ENCODER_BUTTON_ANY)) - setDisplayMode(CONFIG_EXIT_DISPLAY_MODE); params.drawTitle("< Volume >", screen); drawVolume(screen); } - void drawVolume(ScreenBuffer& screen){ screen.setTextSize(1); screen.print(1, 24 + 10, "Volume "); @@ -578,12 +584,21 @@ class ConfigVolumePage : public Page { class ConfigLedsPage : public Page { public: + // void exit(){ + // extern uint8_t ENCODER_CS_DELAY_US; + // ENCODER_CS_DELAY_US = settings.leds_brightness; + // } + void buttonsChanged(uint32_t current, uint32_t previous){ + if(pressed(ENCODER_BUTTON_ANY, current, previous)) + setDisplayMode(CONFIG_EXIT_DISPLAY_MODE); + } void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ if(encoder == ENCODER_R){ int16_t delta = getDiscreteEncoderValue(current, previous); setDisplayMode(std::clamp(CONFIG_LEDS_DISPLAY_MODE + delta, (int)STATUS_DISPLAY_MODE, (int)CONFIG_LEDS_DISPLAY_MODE)); }else if(encoder == ENCODER_L){ - int16_t value = std::clamp(settings.leds_brightness + getContinuousEncoderValue(current, previous, 1), 0, 63); + // todo: set red/green/blue individually with different encoders + int8_t value = std::clamp(settings.leds_brightness + getContinuousEncoderValue(current, previous, 1), 0, 63); if(settings.leds_brightness != value){ settings.leds_brightness = value; TLC5946_setAll_DC(value); @@ -592,8 +607,6 @@ class ConfigLedsPage : public Page { } } void draw(ScreenBuffer& screen){ - if(params.isEncoderPushed(ENCODER_BUTTON_ANY)) - setDisplayMode(CONFIG_EXIT_DISPLAY_MODE); // " Play >", // "< Status >", // "< Preset >", @@ -630,6 +643,10 @@ class SelectPatchPage : public Page { // program.resetProgram(false); // } // } // only change patch when exiting through ExitPatch + void buttonsChanged(uint32_t current, uint32_t previous){ + if(pressed(ENCODER_BUTTON_ANY, current, previous)) + setDisplayMode(CONFIG_EXIT_DISPLAY_MODE); + } void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ if(encoder == ENCODER_R){ reset(); @@ -640,8 +657,6 @@ class SelectPatchPage : public Page { } } void draw(ScreenBuffer& screen){ - if(params.isEncoderPushed(ENCODER_BUTTON_ANY)) - setDisplayMode(CONFIG_EXIT_DISPLAY_MODE); params.drawTitle("< Patch >", screen); drawPresetNames(patchselect, screen); } @@ -670,6 +685,10 @@ class SelectPatchPage : public Page { class StatusPage : public Page { public: + void buttonsChanged(uint32_t current, uint32_t previous){ + if(pressed(ENCODER_BUTTON_ANY, current, previous)) + setDisplayMode(CONFIG_EXIT_DISPLAY_MODE); + } void encoderChanged(uint8_t encoder, int32_t current, int32_t previous){ if(encoder == ENCODER_R){ int16_t delta = getDiscreteEncoderValue(current, previous); @@ -677,12 +696,8 @@ class StatusPage : public Page { } } void draw(ScreenBuffer& screen){ - if(params.isEncoderPushed(ENCODER_BUTTON_ANY)){ - setDisplayMode(CONFIG_EXIT_DISPLAY_MODE); - }else{ - params.drawTitle(" Status >", screen); - drawStatus(screen); - } + params.drawTitle(" Status >", screen); + drawStatus(screen); } void drawStatus(ScreenBuffer& screen){ From 9ceb1f1b5652b2c6ac7b85a8e0fca682ca81b87c Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 9 Dec 2021 12:57:56 +0100 Subject: [PATCH 227/286] unlock debug unit on H7 --- Source/ProgramManager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/ProgramManager.cpp b/Source/ProgramManager.cpp index f5dbc390..5e9e8b94 100644 --- a/Source/ProgramManager.cpp +++ b/Source/ProgramManager.cpp @@ -155,7 +155,7 @@ void usbd_tx_convert(int32_t* src, size_t len){ #define MANAGER_TASK_PRIORITY (AUDIO_TASK_PRIORITY | portPRIVILEGE_BIT) // audio and manager task priority must be the same so that the program can stop itself in case of errors #define FLASH_TASK_PRIORITY 1 // allow default task to run when FLASH task yields -#define SCREEN_TASK_PRIORITY 3 // less than AUDIO_TASK_PRIORITY, more than osPriorityNormal +#define SCREEN_TASK_PRIORITY 3 // less than AUDIO_TASK_PRIORITY, more than osPriorityNormal (which is probably 1) #define PROGRAMSTACK_SIZE (PROGRAM_TASK_STACK_SIZE*sizeof(portSTACK_TYPE)) // size in bytes @@ -657,8 +657,8 @@ ProgramManager::ProgramManager(){ #ifdef DEBUG_DWT // DWT cycle count enable CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; -#ifdef OWL_ARCH_F7 - DWT->LAR = 0xC5ACCE55; // enable debug access: required on F7 +#ifdef STM32H7xx + DWT->LAR = 0xC5ACCE55; // enable debug access: required on M7 #endif DWT->CYCCNT = 0; DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk; From 03ea6d04e3d54c3ebc25f8176108e2e9b516c133 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 9 Dec 2021 13:36:53 +0100 Subject: [PATCH 228/286] enable DEBUG_DWT also for Xibeca --- Source/device.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Source/device.h b/Source/device.h index d8762503..ea42c508 100644 --- a/Source/device.h +++ b/Source/device.h @@ -3,7 +3,7 @@ #include "hardware.h" -#define FIRMWARE_VERSION "v22.1.rc2" +#define FIRMWARE_VERSION "v22.1.rc3" #ifdef USE_SPI_FLASH #define MAX_SPI_FLASH_HEADERS 32 @@ -59,9 +59,8 @@ #define STORAGE_MAX_BLOCKS 64 #endif -#ifndef OWL_XIBECA #define DEBUG_DWT -#endif + /* #define DEBUG_STACK */ #define DEBUG_STORAGE /* #define DEBUG_BOOTLOADER */ From 4ab7986c8bd6fe276063f3b07c4f2c3f59116c7d Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 9 Dec 2021 21:10:28 +0100 Subject: [PATCH 229/286] set correct bit ATMDDA for pcm3168a output gain control --- Source/pcm3168a.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/pcm3168a.c b/Source/pcm3168a.c index 0eae7633..a5f7752a 100644 --- a/Source/pcm3168a.c +++ b/Source/pcm3168a.c @@ -100,7 +100,7 @@ void codec_init(){ /* Each DAC channel (VOUTx) has a digital attenuator function. The attenuation level can be set from 0 dB to –100 dB in */ /* 0.5-dB steps, and also can be set to infinite attenuation (mute). The attenuation level change from current value to target */ /* value is performed by incrementing or decrementing with s-curve responses and a time set by ATSPDA. */ - codec_write(70, 0b1000000); // ATMDDA=1 All channels with preset (independent) data + master (common) data in decibel number + codec_write(70, 0b10000000); // ATMDDA=1 All channels with preset (independent) data + master (common) data in decibel number /* Data formats, see Table 11 p.33 */ From 05be43d31bd53a17e232e5df5f2c08aee422ed42 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 17 Dec 2021 09:26:31 +0100 Subject: [PATCH 230/286] set flash pins and 10Vpp output gain --- ACDC/Core/Inc/hardware.h | 3 ++- ACDC/Core/Inc/main.h | 8 +++++++- ACDC/Core/Src/ACDC.cpp | 12 +++++++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ACDC/Core/Inc/hardware.h b/ACDC/Core/Inc/hardware.h index 7a17d540..7a8d99b5 100644 --- a/ACDC/Core/Inc/hardware.h +++ b/ACDC/Core/Inc/hardware.h @@ -18,8 +18,9 @@ // todo: quad SPI /* #define USE_SPI_FLASH */ +/* #define SPI_FLASH_HSPI hqspi */ -/* #define AUDIO_OUTPUT_GAIN 112 in/out gain not working?*/ +#define AUDIO_OUTPUT_GAIN 114 #define USE_CODEC #define USE_PCM3168A diff --git a/ACDC/Core/Inc/main.h b/ACDC/Core/Inc/main.h index 36925edc..760d6690 100644 --- a/ACDC/Core/Inc/main.h +++ b/ACDC/Core/Inc/main.h @@ -103,10 +103,16 @@ void Error_Handler(void); #define ADC_NCS_Pin ADC_SPI_NCS_Pin #define ADC_NCS_GPIO_Port ADC_SPI_NCS_GPIO_Port - #define ADC_RESET_Pin ADC_RST_Pin #define ADC_RESET_GPIO_Port ADC_RST_GPIO_Port +#define FLASH_nCS_Pin FLASH_NCS_Pin +#define FLASH_nCS_GPIO_Port FLASH_NCS_GPIO_Port +#define FLASH_WP_Pin FLASH_DQ2_Pin +#define FLASH_WP_GPIO_Port FLASH_DQ2_GPIO_Port +#define FLASH_HOLD_Pin FLASH_DQ3_Pin +#define FLASH_HOLD_GPIO_Port FLASH_DQ3_GPIO_Port + /* USER CODE END Private defines */ #ifdef __cplusplus diff --git a/ACDC/Core/Src/ACDC.cpp b/ACDC/Core/Src/ACDC.cpp index 74f1834c..1251cd44 100644 --- a/ACDC/Core/Src/ACDC.cpp +++ b/ACDC/Core/Src/ACDC.cpp @@ -5,6 +5,7 @@ #include "ApplicationSettings.h" #include "OpenWareMidiControl.h" #include "message.h" +#include "Codec.h" #define XIBECA_PIN3 GPIOD, GPIO_PIN_2 #define XIBECA_PIN4 GPIOG, GPIO_PIN_10 @@ -133,12 +134,13 @@ void onSetup(){ initLed(); for(size_t i=1; i<=8; ++i) setLed(i, NO_COLOUR); + codec.set((1<<22)-1); } void onLoop(void){ - for(size_t i=0; i<4; ++i){ - int16_t value = getParameterValue(PARAMETER_AA+i); - setLed(i+1, value >= 4095 ? RED_COLOUR : value); - setLed(i+5, getParameterValue(PARAMETER_BA+i)); - } + // for(size_t i=0; i<4; ++i){ + // int16_t value = getParameterValue(PARAMETER_AA+i); + // setLed(i+1, value >= 4095 ? RED_COLOUR : value); + // setLed(i+5, getParameterValue(PARAMETER_BA+i)); + // } } From b64c06bf195455539c418ad33d424a7852bcd13e Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 17 Dec 2021 09:27:14 +0100 Subject: [PATCH 231/286] fixed typo --- MidiBoot3/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MidiBoot3/Makefile b/MidiBoot3/Makefile index 1ce9b420..3312f974 100644 --- a/MidiBoot3/Makefile +++ b/MidiBoot3/Makefile @@ -50,7 +50,7 @@ unlock: $(OPENOCD) -c "init" -c "reset halt" -c "flash protect 0 0 1 off" -c "flash info 0" -c "exit" erase: - $(OPENOCD) -c "init" -c "halt" -c "stm32h7 mass_erase 0" -c "flash info 0" -c "exit" + $(OPENOCD) -c "init" -c "halt" -c "stm32h7x mass_erase 0" -c "flash info 0" -c "exit" erase-boot: # flash erase_sector num first last $(OPENOCD) -c "init" -c "halt" -c "flash erase_sector 0 0 1" -c "exit" From 84cabffd11411e3d005c1167a38b777ec485595e Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 17 Dec 2021 09:28:05 +0100 Subject: [PATCH 232/286] Configurable exp/fs. PWM LED --- OwlPedal2/Inc/hardware.h | 24 +++- OwlPedal2/Src/OwlPedal.cpp | 240 +++++++++++++++++++++++++++---------- 2 files changed, 192 insertions(+), 72 deletions(-) diff --git a/OwlPedal2/Inc/hardware.h b/OwlPedal2/Inc/hardware.h index 6895090f..d10be1fc 100644 --- a/OwlPedal2/Inc/hardware.h +++ b/OwlPedal2/Inc/hardware.h @@ -1,23 +1,34 @@ #include "main.h" #include "stm32f4xx_hal.h" -#define OWL_PEDAL_MKII +#define OWL_PEDAL #define HARDWARE_ID OWL_PEDAL_HARDWARE #define HARDWARE_VERSION "OWL Pedal mkII" +#define EXPRESSION_MODE_EXP_TRS 1 +#define EXPRESSION_MODE_EXP_RTS 2 +#define EXPRESSION_MODE_FS_TS 3 // single footswitch +#define EXPRESSION_MODE_FS_TRS 4 // dual footswitch +#define EXPRESSION_MODE EXPRESSION_MODE_EXP_TRS + +#define OWL_PEDAL_PWM_LEDS + /* #define USE_SPI_FLASH */ +#define USE_USBD_HS /* #define USE_USBD_FS */ -/* #define USBD_DESC FS_Desc */ -/* #define USBD_HSFS DEVICE_FS */ -/* #define USBD_HANDLE hUsbDeviceFS */ -/* #define USBD_PCD_HANDLE hpcd_USB_OTG_FS */ -#define USE_USBD_HS +#ifdef USE_USBD_FS +#define USBD_DESC FS_Desc +#define USBD_HSFS DEVICE_FS +#define USBD_HANDLE hUsbDeviceFS +#define USBD_PCD_HANDLE hpcd_USB_OTG_FS +#else #define USBD_DESC HS_Desc #define USBD_HSFS DEVICE_HS #define USBD_HANDLE hUsbDeviceHS #define USBD_PCD_HANDLE hpcd_USB_OTG_HS +#endif #define USE_USBD_AUDIO #define USE_USBD_AUDIO_FEATURES @@ -37,6 +48,7 @@ #define USE_BKPSRAM #define AUDIO_OUTPUT_GAIN 123 + /* #define USE_MODE_BUTTON */ /* #define MODE_BUTTON_PIN SW3_Pin */ /* #define MODE_BUTTON_PORT SW3_GPIO_Port */ diff --git a/OwlPedal2/Src/OwlPedal.cpp b/OwlPedal2/Src/OwlPedal.cpp index 031456c0..32816d86 100644 --- a/OwlPedal2/Src/OwlPedal.cpp +++ b/OwlPedal2/Src/OwlPedal.cpp @@ -33,10 +33,67 @@ Pin bypass_pin(GPIOA, GPIO_PIN_0); Pin bufpass_pin(GPIOF, GPIO_PIN_9); // high is bypass Pin exp1_tip_pin(GPIOA, GPIO_PIN_2); Pin exp1_ring_pin(GPIOA, GPIO_PIN_3); + +#ifndef OWL_PEDAL_PWM_LEDS Pin led_green_pin(GPIOB, GPIO_PIN_8); Pin led_red_pin(GPIOB, GPIO_PIN_9); +#endif static uint32_t counter = 0; +static uint8_t expression_mode = 0; + +bool getBufferedBypass(){ + return !bufpass_pin.get(); +} + +void setBufferedBypass(bool value){ + // setLed(0, value ? RED_COLOUR : GREEN_COLOUR); + bufpass_pin.set(!value); + // todo; set BYPASS_MODE +} + +bool isBypassed(){ + return HAL_GPIO_ReadPin(FOOTSWITCH_GPIO_Port, FOOTSWITCH_Pin) == GPIO_PIN_RESET; + // todo: || getBufferedBypass() +} + +bool isPushbuttonPressed(){ + return HAL_GPIO_ReadPin(SW1_GPIO_Port, SW1_Pin) == GPIO_PIN_RESET || + HAL_GPIO_ReadPin(SW1_ALT_GPIO_Port, SW1_ALT_Pin) == GPIO_PIN_RESET; +} + +void configureExpression(uint8_t mode){ + if(mode != expression_mode){ + switch(mode){ + case EXPRESSION_MODE_EXP_TRS: + // Ring is available on ADC_F + exp1_ring_pin.outputMode(); + exp1_ring_pin.high(); + exp1_ring_pin.setPull(PIN_PULL_NONE); + exp1_tip_pin.analogMode(); + exp1_tip_pin.setPull(PIN_PULL_NONE); + break; + case EXPRESSION_MODE_EXP_RTS: + exp1_tip_pin.outputMode(); + exp1_tip_pin.high(); + exp1_tip_pin.setPull(PIN_PULL_NONE); + exp1_ring_pin.analogMode(); + exp1_ring_pin.setPull(PIN_PULL_NONE); + break; + case EXPRESSION_MODE_FS_TS: + case EXPRESSION_MODE_FS_TRS: + exp1_tip_pin.inputMode(); + exp1_tip_pin.setPull(PIN_PULL_UP); + exp1_ring_pin.inputMode(); + exp1_ring_pin.setPull(PIN_PULL_UP); + break; + } + expression_mode = mode; + setButtonValue(PUSHBUTTON, isPushbuttonPressed()); + setButtonValue(BUTTON_1, isPushbuttonPressed()); + setButtonValue(BUTTON_2, false); + } +} void initLed(){ #ifdef OWL_PEDAL_PWM_LEDS @@ -50,10 +107,38 @@ void initLed(){ #endif } +uint32_t getLed(uint8_t led){ +#ifdef OWL_PEDAL_PWM_LEDS + uint32_t r = 1023 - TIM4->CCR3; + uint32_t g = TIM4->CCR4; + return (r<<20) | (g<<10); +#else + if(!led_green_pin.get() && led_red_pin.get()) + return RED_COLOUR; + else if(led_green_pin.get() && !led_red_pin.get()) + return GREEN_COLOUR; + else + return NO_COLOUR; +#endif +} + +void toggleLed(uint8_t led){ +#ifdef OWL_PEDAL_PWM_LEDS + setLed(led, getLed(led) == GREEN_COLOUR ? RED_COLOUR : GREEN_COLOUR); + // uint32_t r = TIM4->CCR3; + // uint32_t g = TIM4->CCR4; + // TIM4->CCR3 = 1023 - r; + // TIM4->CCR4 = 1023 - g; +#else + led_red_pin.set(led_green_pin.get()); + led_green_pin.toggle(); +#endif +} + void setLed(uint8_t led, uint32_t rgb){ #ifdef OWL_PEDAL_PWM_LEDS uint32_t r = 1023 - ((rgb>>20) & 0x3ff); - uint32_t g = 1023 - ((rgb>>10) & 0x3ff); + uint32_t g = ((rgb>>10) & 0x3ff); // green TIM4 has reverse polarity TIM4->CCR3 = r; TIM4->CCR4 = g; #else @@ -76,61 +161,42 @@ void setLed(uint8_t led, uint32_t rgb){ #endif } -bool getBufferedBypass(){ - return !bufpass_pin.get(); -} - -void setBufferedBypass(bool value){ - setLed(0, value ? RED_COLOUR : GREEN_COLOUR); - bufpass_pin.set(!value); - // todo; set BYPASS_MODE -} - -bool isBypassed(){ - return HAL_GPIO_ReadPin(FOOTSWITCH_GPIO_Port, FOOTSWITCH_Pin) == GPIO_PIN_RESET; - // todo: || getBufferedBypass() -} - -bool isPushbuttonPressed(){ - return HAL_GPIO_ReadPin(SW1_GPIO_Port, SW1_Pin) == GPIO_PIN_RESET || - HAL_GPIO_ReadPin(SW1_ALT_GPIO_Port, SW1_ALT_Pin) == GPIO_PIN_RESET; -} - void onChangePin(uint16_t pin){ + if(pin == FOOTSWITCH_Pin){ + setButtonValue(0, isBypassed()); + } if(owl.getOperationMode() == RUN_MODE){ switch(pin){ - case FOOTSWITCH_Pin: { // bypass / stomp switch - bool state = isBypassed(); - setButtonValue(0, state); - setLed(0, state ? NO_COLOUR : GREEN_COLOUR); - // todo: save LED state - // todo: only allow config mode in bypass? - break; - } + // case FOOTSWITCH_Pin: { // bypass / stomp switch + // bool state = isBypassed(); + // setButtonValue(0, state); + // setLed(0, state ? NO_COLOUR : GREEN_COLOUR); + // break; + // } case SW1_Pin: case SW1_ALT_Pin: { // pushbutton bool state = isPushbuttonPressed(); setButtonValue(PUSHBUTTON, state); - setButtonValue(BUTTON_A, state); + setButtonValue(BUTTON_1, state); setLed(0, state ? RED_COLOUR : GREEN_COLOUR); midi_tx.sendCc(PATCH_BUTTON, state ? 127 : 0); break; } - case SW2_Pin: { // mode button - bool state = HAL_GPIO_ReadPin(SW2_GPIO_Port, SW2_Pin) == GPIO_PIN_RESET; - setButtonValue(BUTTON_B, state); - break; - } - case SW3_Pin: { // EXP2 Tip - bool state = HAL_GPIO_ReadPin(SW3_GPIO_Port, SW3_Pin) == GPIO_PIN_RESET; - setButtonValue(BUTTON_C, state); - break; - } - case SW4_Pin: { // EXP2 Ring - bool state = HAL_GPIO_ReadPin(SW4_GPIO_Port, SW4_Pin) == GPIO_PIN_RESET; - setButtonValue(BUTTON_D, state); - break; - } + // case SW2_Pin: { // mode button + // bool state = HAL_GPIO_ReadPin(SW2_GPIO_Port, SW2_Pin) == GPIO_PIN_RESET; + // setButtonValue(BUTTON_2, state); + // break; + // } + // case SW3_Pin: { // EXP2 Tip + // bool state = HAL_GPIO_ReadPin(SW3_GPIO_Port, SW3_Pin) == GPIO_PIN_RESET; + // setButtonValue(BUTTON_3, state); + // break; + // } + // case SW4_Pin: { // EXP2 Ring + // bool state = HAL_GPIO_ReadPin(SW4_GPIO_Port, SW4_Pin) == GPIO_PIN_RESET; + // setButtonValue(BUTTON_4, state); + // break; + // } } } } @@ -138,19 +204,28 @@ void onChangePin(uint16_t pin){ void setGateValue(uint8_t ch, int16_t value){ if(owl.getOperationMode() == RUN_MODE){ switch(ch){ + case BUTTON_1: case PUSHBUTTON: setLed(0, value ? RED_COLOUR : GREEN_COLOUR); break; case GREEN_BUTTON: +#ifdef OWL_PEDAL_PWM_LEDS + setLed(0, (value<<8) & (0x3ff<<10)); // use top 10 bits (out of 12) as green value +#else setLed(0, value ? GREEN_COLOUR : NO_COLOUR); +#endif break; case RED_BUTTON: +#ifdef OWL_PEDAL_PWM_LEDS + setLed(0, (value<<18) & (0x3ff<<20)); // use top 10 bits (out of 12) as red value +#else setLed(0, value ? RED_COLOUR : NO_COLOUR); +#endif break; } } - if(ch == BUTTON_1) - setBufferedBypass(value); + // if(ch == 0) + // setBufferedBypass(value); } void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* adc_values, size_t adc_len){ @@ -159,7 +234,39 @@ void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* parameter_values[1] = (parameter_values[1]*3 + adc_values[ADC_B])>>2; parameter_values[2] = (parameter_values[2]*3 + adc_values[ADC_C])>>2; parameter_values[3] = (parameter_values[3]*3 + adc_values[ADC_D])>>2; - parameter_values[4] = (parameter_values[4]*3 + 4095-adc_values[ADC_E])>>2; + + static uint8_t fs_state = 0; + uint8_t buttons = 0; + switch(expression_mode){ + case EXPRESSION_MODE_EXP_TRS: + parameter_values[4] = (parameter_values[4]*3 + 4095-adc_values[ADC_E])>>2; + break; + case EXPRESSION_MODE_EXP_RTS: + parameter_values[4] = (parameter_values[4]*3 + 4095-adc_values[ADC_F])>>2; + break; + case EXPRESSION_MODE_FS_TRS: + buttons = (!exp1_ring_pin.get()) << BUTTON_2; + buttons |= (!exp1_tip_pin.get()) << BUTTON_1; + if(buttons != fs_state){ + if((buttons & (1 << BUTTON_2)) != (fs_state & (1 << BUTTON_2))){ + setButtonValue(BUTTON_2, buttons & (1 << BUTTON_2)); + } + if((buttons & (1 << BUTTON_1)) != (fs_state & (1 << BUTTON_1))){ + setButtonValue(BUTTON_1, buttons & (1 << BUTTON_1)); + setButtonValue(PUSHBUTTON, buttons & (1 << BUTTON_1)); + } + fs_state = buttons; + } + break; + case EXPRESSION_MODE_FS_TS: + buttons = (!exp1_tip_pin.get()) << BUTTON_1; + if(buttons != fs_state){ + setButtonValue(BUTTON_1, buttons & (1 << BUTTON_1)); + setButtonValue(PUSHBUTTON, buttons & (1 << BUTTON_1)); + fs_state = buttons; + } + break; + } } } @@ -169,10 +276,7 @@ void onSetup(){ bypass_pin.low(); bufpass_pin.outputMode(); bufpass_pin.low(); - // Ring is available on ADC_F - exp1_ring_pin.outputMode(); - exp1_ring_pin.high(); - // exp1_tip_pin.analogMode(); + configureExpression(settings.expression_mode); setLed(0, RED_COLOUR); @@ -181,27 +285,33 @@ void onSetup(){ setBufferedBypass(false); } +void onStartProgram(){ + setLed(0, GREEN_COLOUR); +} + void onChangeMode(uint8_t new_mode, uint8_t old_mode){ counter = 0; + static uint32_t saved_led = NO_COLOUR; + if(old_mode == RUN_MODE){ + saved_led = getLed(0); // leaving RUN_MODE, save LED state + } setLed(0, NO_COLOUR); if(new_mode == CONFIGURE_MODE){ knobvalues[0] = getAnalogValue(PATCH_CONFIG_PROGRAM_CONTROL); knobvalues[1] = getAnalogValue(PATCH_CONFIG_VOLUME_CONTROL); patchselect = program.getProgramIndex(); - }else if(new_mode == BYPASS_MODE){ - setLed(0, NO_COLOUR); // todo: save LED state }else if(new_mode == RUN_MODE){ - setLed(0, GREEN_COLOUR); // todo: restore to saved state + setLed(0, saved_led); // restore to saved LED state } } // static uint16_t progress = 0; void setProgress(uint16_t value, const char* msg){ - // debugMessage(msg, (int)(100*value/4095)); - // progress = value; - // toggle red/green - led_red_pin.set(led_green_pin.get()); - led_green_pin.toggle(); +#ifdef OWL_PEDAL_PWM_LEDS + setLed(0, (value<<18) & (0x3ff<<20)); +#else + toggleLed(0); +#endif } void onLoop(){ @@ -232,8 +342,7 @@ void onLoop(){ if(--counter == 0){ // counter == 0 when we enter RUN_MODE owl.setOperationMode(ENTER_CONFIG_MODE); }else if(counter < PATCH_RESET_COUNTER && counter % 128 == 0){ - led_green_pin.toggle(); - led_red_pin.toggle(); + toggleLed(0); } }else if(isBypassed()){ // don't change to BYPASS_MODE while pushbutton is pressed @@ -246,8 +355,7 @@ void onLoop(){ case ENTER_CONFIG_MODE: if(isPushbuttonPressed()){ // toggle rapidly for yellow-ish LED - led_red_pin.set(led_green_pin.get()); - led_green_pin.toggle(); + toggleLed(0); }else{ owl.setOperationMode(CONFIGURE_MODE); } @@ -292,8 +400,7 @@ void onLoop(){ }else if(counter <= PATCH_RESET_COUNTER){ if(patchselect == 0){ // toggle rapidly for yellow-ish LED - led_red_pin.set(led_green_pin.get()); - led_green_pin.toggle(); + toggleLed(0); }else{ setLed(0, NO_COLOUR); } @@ -317,4 +424,5 @@ void onLoop(){ counter = PATCH_RESET_COUNTER; break; } + configureExpression(settings.expression_mode); } From 2c051de166220b82c6902be40c75d953bf057734 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 17 Dec 2021 11:35:05 +0100 Subject: [PATCH 233/286] copied witch usb config --- OwlPedal2/Inc/hardware.h | 18 +++++++++--------- OwlPedal2/Src/main.c | 2 +- OwlPedal2/Src/usbd_conf.c | 1 + 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/OwlPedal2/Inc/hardware.h b/OwlPedal2/Inc/hardware.h index d10be1fc..b327c04f 100644 --- a/OwlPedal2/Inc/hardware.h +++ b/OwlPedal2/Inc/hardware.h @@ -13,7 +13,7 @@ #define OWL_PEDAL_PWM_LEDS -/* #define USE_SPI_FLASH */ +#define USE_SPI_FLASH #define USE_USBD_HS /* #define USE_USBD_FS */ @@ -30,21 +30,21 @@ #define USBD_PCD_HANDLE hpcd_USB_OTG_HS #endif -#define USE_USBD_AUDIO -#define USE_USBD_AUDIO_FEATURES -#define USE_USBD_AUDIO_TX // microphone -/* #define USE_USBD_AUDIO_RX // speaker */ -/* #define USE_USBD_RX_FB */ -#define USE_USBD_MIDI - /* USB audio settings */ #define AUDIO_BITS_PER_SAMPLE 16 #define AUDIO_BYTES_PER_SAMPLE (AUDIO_BITS_PER_SAMPLE/8) #define AUDIO_CHANNELS 2 -#define USB_AUDIO_CHANNELS 2 +#define USBD_AUDIO_RX_CHANNELS AUDIO_CHANNELS +#define USBD_AUDIO_TX_CHANNELS AUDIO_CHANNELS #define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) +#define USE_USBD_AUDIO +#define USE_USBD_RX_FB +#define USE_USBD_AUDIO_FEATURES +#define USE_USBD_AUDIO_RX // speaker +#define USE_USBD_AUDIO_TX // microphone + #define USE_BKPSRAM #define AUDIO_OUTPUT_GAIN 123 diff --git a/OwlPedal2/Src/main.c b/OwlPedal2/Src/main.c index 9ef28244..f55a3002 100644 --- a/OwlPedal2/Src/main.c +++ b/OwlPedal2/Src/main.c @@ -693,7 +693,7 @@ static void MX_USB_OTG_HS_PCD_Init(void) hpcd_USB_OTG_HS.Init.speed = PCD_SPEED_FULL; hpcd_USB_OTG_HS.Init.dma_enable = DISABLE; hpcd_USB_OTG_HS.Init.phy_itface = USB_OTG_EMBEDDED_PHY; - hpcd_USB_OTG_HS.Init.Sof_enable = DISABLE; + hpcd_USB_OTG_HS.Init.Sof_enable = ENABLE; hpcd_USB_OTG_HS.Init.low_power_enable = DISABLE; hpcd_USB_OTG_HS.Init.lpm_enable = DISABLE; hpcd_USB_OTG_HS.Init.vbus_sensing_enable = ENABLE; diff --git a/OwlPedal2/Src/usbd_conf.c b/OwlPedal2/Src/usbd_conf.c index 22ab2ba9..a8958c77 100644 --- a/OwlPedal2/Src/usbd_conf.c +++ b/OwlPedal2/Src/usbd_conf.c @@ -325,6 +325,7 @@ USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; + USB_DISABLE_EP_BEFORE_CLOSE(ep_addr); hal_status = HAL_PCD_EP_Close(pdev->pData, ep_addr); usb_status = USBD_Get_USB_Status(hal_status); From 5f10672993cbf11666798552ea93d94b0aa1b128 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 17 Dec 2021 15:23:35 +0100 Subject: [PATCH 234/286] added header guards --- OwlPedal2/Src/stm32f4xx_it.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OwlPedal2/Src/stm32f4xx_it.c b/OwlPedal2/Src/stm32f4xx_it.c index 3a63a2e7..21838a2f 100644 --- a/OwlPedal2/Src/stm32f4xx_it.c +++ b/OwlPedal2/Src/stm32f4xx_it.c @@ -238,11 +238,11 @@ void DMA2_Stream4_IRQHandler(void) void OTG_FS_IRQHandler(void) { /* USER CODE BEGIN OTG_FS_IRQn 0 */ - +#ifdef USE_USBD_FS /* USER CODE END OTG_FS_IRQn 0 */ HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS); /* USER CODE BEGIN OTG_FS_IRQn 1 */ - +#endif /* USER CODE END OTG_FS_IRQn 1 */ } @@ -252,11 +252,11 @@ void OTG_FS_IRQHandler(void) void OTG_HS_IRQHandler(void) { /* USER CODE BEGIN OTG_HS_IRQn 0 */ - +#ifdef USE_USBD_HS /* USER CODE END OTG_HS_IRQn 0 */ HAL_PCD_IRQHandler(&hpcd_USB_OTG_HS); /* USER CODE BEGIN OTG_HS_IRQn 1 */ - +#endif /* USER CODE END OTG_HS_IRQn 1 */ } From d231787a4d7ab8629370f4c4d21288d34d014888 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 17 Dec 2021 15:37:54 +0100 Subject: [PATCH 235/286] updated to support FS or HS --- OwlPedal2/Inc/usbd_conf.h | 3 +-- OwlPedal2/Src/main.c | 14 ++++++++++---- OwlPedal2/Src/usbd_conf.c | 10 +++++++--- OwlPedal2/Src/usbd_desc.c | 28 ++++++++++++---------------- 4 files changed, 30 insertions(+), 25 deletions(-) diff --git a/OwlPedal2/Inc/usbd_conf.h b/OwlPedal2/Inc/usbd_conf.h index ddc83566..0c8b9b89 100644 --- a/OwlPedal2/Inc/usbd_conf.h +++ b/OwlPedal2/Inc/usbd_conf.h @@ -79,9 +79,8 @@ /*---------- -----------*/ #define USBD_LPM_ENABLED 0U /*---------- -----------*/ -#define USBD_SELF_POWERED 1U +#define USBD_SELF_POWERED 0U /*---------- -----------*/ -#define USBD_AUDIO_FREQ 22100U /****************************************/ /* #define for FS and HS identification */ diff --git a/OwlPedal2/Src/main.c b/OwlPedal2/Src/main.c index f55a3002..272d49ff 100644 --- a/OwlPedal2/Src/main.c +++ b/OwlPedal2/Src/main.c @@ -54,6 +54,7 @@ /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ +#include "device.h" #include "errorhandlers.h" /* USER CODE END Includes */ @@ -89,8 +90,12 @@ SPI_HandleTypeDef hspi4; TIM_HandleTypeDef htim4; +#ifdef USE_USBD_FS PCD_HandleTypeDef hpcd_USB_OTG_FS; +#endif +#ifdef USE_USBD_HS PCD_HandleTypeDef hpcd_USB_OTG_HS; +#endif SDRAM_HandleTypeDef hsdram1; @@ -651,14 +656,14 @@ static void MX_USB_OTG_FS_PCD_Init(void) /* USER CODE END USB_OTG_FS_Init 0 */ /* USER CODE BEGIN USB_OTG_FS_Init 1 */ - +#ifdef USE_USBD_FS /* USER CODE END USB_OTG_FS_Init 1 */ hpcd_USB_OTG_FS.Instance = USB_OTG_FS; hpcd_USB_OTG_FS.Init.dev_endpoints = 4; hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; - hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; + hpcd_USB_OTG_FS.Init.Sof_enable = ENABLE; hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE; @@ -668,6 +673,7 @@ static void MX_USB_OTG_FS_PCD_Init(void) Error_Handler(); } /* USER CODE BEGIN USB_OTG_FS_Init 2 */ +#endif /* USE_USBD_FS */ /* USER CODE END USB_OTG_FS_Init 2 */ @@ -686,7 +692,7 @@ static void MX_USB_OTG_HS_PCD_Init(void) /* USER CODE END USB_OTG_HS_Init 0 */ /* USER CODE BEGIN USB_OTG_HS_Init 1 */ - +#ifdef USE_USBD_HS /* USER CODE END USB_OTG_HS_Init 1 */ hpcd_USB_OTG_HS.Instance = USB_OTG_HS; hpcd_USB_OTG_HS.Init.dev_endpoints = 6; @@ -704,7 +710,7 @@ static void MX_USB_OTG_HS_PCD_Init(void) Error_Handler(); } /* USER CODE BEGIN USB_OTG_HS_Init 2 */ - +#endif /* USE_USBD_HS */ /* USER CODE END USB_OTG_HS_Init 2 */ } diff --git a/OwlPedal2/Src/usbd_conf.c b/OwlPedal2/Src/usbd_conf.c index a8958c77..9460a97a 100644 --- a/OwlPedal2/Src/usbd_conf.c +++ b/OwlPedal2/Src/usbd_conf.c @@ -230,15 +230,19 @@ void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) */ USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) { - if (pdev->id == DEVICE_FS) { +#ifdef USE_USBD_FS + /* if (pdev->id == DEVICE_FS) { */ /* Link the driver to the stack. */ hpcd_USB_OTG_FS.pData = pdev; pdev->pData = &hpcd_USB_OTG_FS; - } else if (pdev->id == DEVICE_HS) { +#endif + /* } else if (pdev->id == DEVICE_HS) { */ +#ifdef USE_USBD_HS /* Link the driver to the stack. */ hpcd_USB_OTG_HS.pData = pdev; pdev->pData = &hpcd_USB_OTG_HS; - } +#endif + /* } */ USBD_AUDIO_SetFiFos(pdev->pData); return USBD_OK; } diff --git a/OwlPedal2/Src/usbd_desc.c b/OwlPedal2/Src/usbd_desc.c index 9999c7a8..5afb6ed8 100644 --- a/OwlPedal2/Src/usbd_desc.c +++ b/OwlPedal2/Src/usbd_desc.c @@ -66,14 +66,10 @@ #define USBD_VID 0x1209 #define USBD_LANGID_STRING 1033 #define USBD_MANUFACTURER_STRING "Rebel Technology" -#define USBD_PID_FS 0xDADA -#define USBD_PRODUCT_STRING_FS "OWL-PEDAL" -#define USBD_CONFIGURATION_STRING_FS "AUDIO Config" -#define USBD_INTERFACE_STRING_FS "AUDIO Interface" -#define USBD_PID_HS 0xDADA -#define USBD_PRODUCT_STRING_HS "OWL-PEDAL" -#define USBD_CONFIGURATION_STRING_HS "AUDIO Config" -#define USBD_INTERFACE_STRING_HS "AUDIO Interface" +#define USBD_PID_FSHS 0xDADA +#define USBD_PRODUCT_STRING_FSHS "OWL-PEDAL" +#define USBD_CONFIGURATION_STRING_FSHS "AUDIO Config" +#define USBD_INTERFACE_STRING_FSHS "AUDIO Interface" #define USB_SIZ_BOS_DESC 0x0C @@ -177,8 +173,8 @@ __ALIGN_BEGIN uint8_t USBD_FSHS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = USB_MAX_EP0_SIZE, /*bMaxPacketSize*/ LOBYTE(USBD_VID), /*idVendor*/ HIBYTE(USBD_VID), /*idVendor*/ - LOBYTE(USBD_PID_HS), /*idProduct*/ - HIBYTE(USBD_PID_HS), /*idProduct*/ + LOBYTE(USBD_PID_FSHS), /*idProduct*/ + HIBYTE(USBD_PID_FSHS), /*idProduct*/ 0x00, /*bcdDevice rel. 2.00*/ 0x02, USBD_IDX_MFC_STR, /*Index of manufacturer string*/ @@ -291,11 +287,11 @@ uint8_t * USBD_FSHS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *leng { if(speed == 0) { - USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_HS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FSHS, USBD_StrDesc, length); } else { - USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_HS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FSHS, USBD_StrDesc, length); } return USBD_StrDesc; } @@ -344,11 +340,11 @@ uint8_t * USBD_FSHS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *lengt { if(speed == USBD_SPEED_HIGH) { - USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_HS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FSHS, USBD_StrDesc, length); } else { - USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_HS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FSHS, USBD_StrDesc, length); } return USBD_StrDesc; } @@ -363,11 +359,11 @@ uint8_t * USBD_FSHS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *le { if(speed == 0) { - USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_HS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FSHS, USBD_StrDesc, length); } else { - USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_HS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FSHS, USBD_StrDesc, length); } return USBD_StrDesc; } From 565ef19665239dd375e20042ca2243039d4fc722 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 17 Dec 2021 15:44:15 +0100 Subject: [PATCH 236/286] drivers configurable for HS or FS USBD interface --- Witch/Inc/usbd_conf.h | 11 +- Witch/Inc/usbd_desc.h | 8 +- Witch/Src/usbd_conf.c | 288 +++++++++++++----------------------------- Witch/Src/usbd_desc.c | 114 +++++++++-------- 4 files changed, 159 insertions(+), 262 deletions(-) diff --git a/Witch/Inc/usbd_conf.h b/Witch/Inc/usbd_conf.h index 008bfcc3..27e21fa6 100644 --- a/Witch/Inc/usbd_conf.h +++ b/Witch/Inc/usbd_conf.h @@ -95,14 +95,13 @@ * @brief Aliases. * @{ */ - -/* Memory management macros */ - +/* Memory management macros make sure to use static memory allocation */ /** Alias for memory allocation. */ -#define USBD_malloc malloc + +#define USBD_malloc (void *)USBD_static_malloc /** Alias for memory release. */ -#define USBD_free free +#define USBD_free USBD_static_free /** Alias for memory set. */ #define USBD_memset memset @@ -158,6 +157,8 @@ */ /* Exported functions -------------------------------------------------------*/ +void *USBD_static_malloc(uint32_t size); +void USBD_static_free(void *p); /** * @} diff --git a/Witch/Inc/usbd_desc.h b/Witch/Inc/usbd_desc.h index 122f582b..90f8968c 100644 --- a/Witch/Inc/usbd_desc.h +++ b/Witch/Inc/usbd_desc.h @@ -17,7 +17,7 @@ * ****************************************************************************** */ -/* USER CODE END Header */ +/* USER CODE END Header */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USBD_DESC__C__ #define __USBD_DESC__C__ @@ -30,7 +30,7 @@ #include "usbd_def.h" /* USER CODE BEGIN INCLUDE */ - +#include "device.h" /* USER CODE END INCLUDE */ /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY @@ -41,7 +41,7 @@ * @brief Usb device descriptors module. * @{ */ - + /** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants * @brief Constants. * @{ @@ -105,7 +105,7 @@ */ /** Descriptor for the Usb device. */ -extern USBD_DescriptorsTypeDef FS_Desc; +extern USBD_DescriptorsTypeDef USBD_DESC; /* USER CODE BEGIN EXPORTED_VARIABLES */ diff --git a/Witch/Src/usbd_conf.c b/Witch/Src/usbd_conf.c index 52b42927..9460a97a 100644 --- a/Witch/Src/usbd_conf.c +++ b/Witch/Src/usbd_conf.c @@ -25,6 +25,8 @@ #include "usbd_def.h" #include "usbd_core.h" +#include "usbd_audio.h" + /* USER CODE BEGIN Includes */ #include "device.h" uint8_t USBD_AUDIO_SetFiFos(PCD_HandleTypeDef *hpcd); @@ -39,7 +41,9 @@ uint8_t USBD_AUDIO_SetFiFos(PCD_HandleTypeDef *hpcd); /* USER CODE END PV */ -PCD_HandleTypeDef hpcd_USB_OTG_FS; +extern PCD_HandleTypeDef hpcd_USB_OTG_HS; +extern PCD_HandleTypeDef hpcd_USB_OTG_FS; + void Error_Handler(void); /* External functions --------------------------------------------------------*/ @@ -63,85 +67,18 @@ USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status); /******************************************************************************* LL Driver Callbacks (PCD -> USB Device Library) *******************************************************************************/ -/* MSP Init */ -void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - if(pcdHandle->Instance==USB_OTG_FS) - { - /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */ - - /* USER CODE END USB_OTG_FS_MspInit 0 */ - - __HAL_RCC_GPIOA_CLK_ENABLE(); - /**USB_OTG_FS GPIO Configuration - PA9 ------> USB_OTG_FS_VBUS - PA10 ------> USB_OTG_FS_ID - PA11 ------> USB_OTG_FS_DM - PA12 ------> USB_OTG_FS_DP - */ - GPIO_InitStruct.Pin = USBD_VBUS_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(USBD_VBUS_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = USBD_ID_Pin|USBD_DM_Pin|USBD_DP_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* Peripheral clock enable */ - __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); - - /* Peripheral interrupt init */ - HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(OTG_FS_IRQn); - /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */ - - /* USER CODE END USB_OTG_FS_MspInit 1 */ - } -} - -void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) -{ - if(pcdHandle->Instance==USB_OTG_FS) - { - /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */ - - /* USER CODE END USB_OTG_FS_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); - - /**USB_OTG_FS GPIO Configuration - PA9 ------> USB_OTG_FS_VBUS - PA10 ------> USB_OTG_FS_ID - PA11 ------> USB_OTG_FS_DM - PA12 ------> USB_OTG_FS_DP - */ - HAL_GPIO_DeInit(GPIOA, USBD_VBUS_Pin|USBD_ID_Pin|USBD_DM_Pin|USBD_DP_Pin); - - /* Peripheral interrupt Deinit*/ - HAL_NVIC_DisableIRQ(OTG_FS_IRQn); - - /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */ - - /* USER CODE END USB_OTG_FS_MspDeInit 1 */ - } -} +/* defined in stm32f4xx_hal_msp.c : + * void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd) + * void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd) + */ /** * @brief Setup stage callback * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_SetupStage((USBD_HandleTypeDef*)hpcd->pData, (uint8_t *)hpcd->Setup); } @@ -152,11 +89,7 @@ void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) * @param epnum: Endpoint number * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#else void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_DataOutStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff); } @@ -167,11 +100,7 @@ void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) * @param epnum: Endpoint number * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#else void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_DataInStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff); } @@ -181,11 +110,7 @@ void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_SOFCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_SOF((USBD_HandleTypeDef*)hpcd->pData); } @@ -195,12 +120,8 @@ void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ResetCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ -{ +{ USBD_SpeedTypeDef speed = USBD_SPEED_FULL; if ( hpcd->Init.speed == PCD_SPEED_HIGH) @@ -228,11 +149,7 @@ void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { /* Inform USB library that core enters in suspend Mode. */ USBD_LL_Suspend((USBD_HandleTypeDef*)hpcd->pData); @@ -253,11 +170,7 @@ void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { /* USER CODE BEGIN 3 */ /* USER CODE END 3 */ @@ -270,11 +183,7 @@ void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) * @param epnum: Endpoint number * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#else void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_IsoOUTIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); } @@ -285,11 +194,7 @@ void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) * @param epnum: Endpoint number * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#else void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_IsoINIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); } @@ -299,11 +204,7 @@ void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_DevConnected((USBD_HandleTypeDef*)hpcd->pData); } @@ -313,11 +214,7 @@ void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_DevDisconnected((USBD_HandleTypeDef*)hpcd->pData); } @@ -333,44 +230,20 @@ void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) */ USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) { - /* Init USB Ip. */ - if (pdev->id == DEVICE_FS) { - /* Link the driver to the stack. */ - hpcd_USB_OTG_FS.pData = pdev; - pdev->pData = &hpcd_USB_OTG_FS; - - hpcd_USB_OTG_FS.Instance = USB_OTG_FS; - hpcd_USB_OTG_FS.Init.dev_endpoints = 4; - hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; - hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; - hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; - hpcd_USB_OTG_FS.Init.Sof_enable = ENABLE; - hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; - hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; - hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE; - hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE; - if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) - { - Error_Handler( ); - } - -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) - /* Register USB PCD CallBacks */ - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SOF_CB_ID, PCD_SOFCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SETUPSTAGE_CB_ID, PCD_SetupStageCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESET_CB_ID, PCD_ResetCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SUSPEND_CB_ID, PCD_SuspendCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESUME_CB_ID, PCD_ResumeCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_CONNECT_CB_ID, PCD_ConnectCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_DISCONNECT_CB_ID, PCD_DisconnectCallback); - - HAL_PCD_RegisterDataOutStageCallback(&hpcd_USB_OTG_FS, PCD_DataOutStageCallback); - HAL_PCD_RegisterDataInStageCallback(&hpcd_USB_OTG_FS, PCD_DataInStageCallback); - HAL_PCD_RegisterIsoOutIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOOUTIncompleteCallback); - HAL_PCD_RegisterIsoInIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOINIncompleteCallback); -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ - USBD_AUDIO_SetFiFos(&hpcd_USB_OTG_FS); - } +#ifdef USE_USBD_FS + /* if (pdev->id == DEVICE_FS) { */ + /* Link the driver to the stack. */ + hpcd_USB_OTG_FS.pData = pdev; + pdev->pData = &hpcd_USB_OTG_FS; +#endif + /* } else if (pdev->id == DEVICE_HS) { */ +#ifdef USE_USBD_HS + /* Link the driver to the stack. */ + hpcd_USB_OTG_HS.pData = pdev; + pdev->pData = &hpcd_USB_OTG_HS; +#endif + /* } */ + USBD_AUDIO_SetFiFos(pdev->pData); return USBD_OK; } @@ -387,12 +260,12 @@ USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev) hal_status = HAL_PCD_DeInit(pdev->pData); usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + return usb_status; } /** - * @brief Starts the low level portion of the device driver. + * @brief Starts the low level portion of the device driver. * @param pdev: Device handle * @retval USBD status */ @@ -400,11 +273,11 @@ USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev) { HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - + hal_status = HAL_PCD_Start(pdev->pData); - - usb_status = USBD_Get_USB_Status(hal_status); - + + usb_status = USBD_Get_USB_Status(hal_status); + return usb_status; } @@ -419,9 +292,9 @@ USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev) USBD_StatusTypeDef usb_status = USBD_OK; hal_status = HAL_PCD_Stop(pdev->pData); - + usb_status = USBD_Get_USB_Status(hal_status); - + return usb_status; } @@ -441,7 +314,7 @@ USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uin hal_status = HAL_PCD_EP_Open(pdev->pData, ep_addr, ep_mps, ep_type); usb_status = USBD_Get_USB_Status(hal_status); - + return usb_status; } @@ -458,10 +331,10 @@ USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) USB_DISABLE_EP_BEFORE_CLOSE(ep_addr); hal_status = HAL_PCD_EP_Close(pdev->pData, ep_addr); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; } /** @@ -474,12 +347,12 @@ USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) { HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - + hal_status = HAL_PCD_EP_Flush(pdev->pData, ep_addr); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; } /** @@ -492,12 +365,12 @@ USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) { HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - + hal_status = HAL_PCD_EP_SetStall(pdev->pData, ep_addr); usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + return usb_status; } /** @@ -510,12 +383,12 @@ USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_add { HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - + hal_status = HAL_PCD_EP_ClrStall(pdev->pData, ep_addr); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; } /** @@ -527,14 +400,14 @@ USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_add uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) { PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef*) pdev->pData; - + if((ep_addr & 0x80) == 0x80) { - return hpcd->IN_ep[ep_addr & 0x7F].is_stall; + return hpcd->IN_ep[ep_addr & 0x7F].is_stall; } else { - return hpcd->OUT_ep[ep_addr & 0x7F].is_stall; + return hpcd->OUT_ep[ep_addr & 0x7F].is_stall; } } @@ -548,12 +421,12 @@ USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_a { HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - + hal_status = HAL_PCD_SetAddress(pdev->pData, dev_addr); - + usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + return usb_status; } /** @@ -561,7 +434,7 @@ USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_a * @param pdev: Device handle * @param ep_addr: Endpoint number * @param pbuf: Pointer to data to be sent - * @param size: Data size + * @param size: Data size * @retval USBD status */ USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size) @@ -570,10 +443,10 @@ USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, u USBD_StatusTypeDef usb_status = USBD_OK; hal_status = HAL_PCD_EP_Transmit(pdev->pData, ep_addr, pbuf, size); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; } /** @@ -590,23 +463,44 @@ USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_a USBD_StatusTypeDef usb_status = USBD_OK; hal_status = HAL_PCD_EP_Receive(pdev->pData, ep_addr, pbuf, size); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; } /** - * @brief Returns the last transfered packet size. + * @brief Returns the last transferred packet size. * @param pdev: Device handle * @param ep_addr: Endpoint number - * @retval Recived Data Size + * @retval Received Data Size */ uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr) { return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef*) pdev->pData, ep_addr); } +/** + * @brief Static single allocation. + * @param size: Size of allocated memory + * @retval None + */ +void *USBD_static_malloc(uint32_t size) +{ + static uint32_t mem[(sizeof(USBD_AUDIO_HandleTypeDef)/4)+1];/* On 32-bit boundary */ + return mem; +} + +/** + * @brief Dummy memory free + * @param p: Pointer to allocated memory address + * @retval None + */ +void USBD_static_free(void *p) +{ + +} + /** * @brief Delays routine for the USB Device Library. * @param Delay: Delay in ms @@ -618,7 +512,7 @@ void USBD_LL_Delay(uint32_t Delay) } /** - * @brief Retuns the USB status depending on the HAL status: + * @brief Returns the USB status depending on the HAL status: * @param hal_status: HAL status * @retval USB status */ diff --git a/Witch/Src/usbd_desc.c b/Witch/Src/usbd_desc.c index d6466ccc..085c5823 100644 --- a/Witch/Src/usbd_desc.c +++ b/Witch/Src/usbd_desc.c @@ -25,7 +25,7 @@ #include "usbd_conf.h" /* USER CODE BEGIN INCLUDE */ -const char* getDeviceName(); +#include "device.h" /* USER CODE END INCLUDE */ /* Private typedef -----------------------------------------------------------*/ @@ -66,10 +66,10 @@ const char* getDeviceName(); #define USBD_VID 0x1209 #define USBD_LANGID_STRING 1033 #define USBD_MANUFACTURER_STRING "Rebel Technology" -#define USBD_PID_FS 0xDADA -#define USBD_PRODUCT_STRING_FS "OWL-WITCH" -#define USBD_CONFIGURATION_STRING_FS "AUDIO Config" -#define USBD_INTERFACE_STRING_FS "AUDIO Interface" +#define USBD_PID_FSHS 0xDADA +#define USBD_PRODUCT_STRING_FSHS "OWL-WITCH" +#define USBD_CONFIGURATION_STRING_FSHS "AUDIO Config" +#define USBD_INTERFACE_STRING_FSHS "AUDIO Interface" #define USB_SIZ_BOS_DESC 0x0C @@ -111,19 +111,20 @@ static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len); */ /** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes - * @brief Private functions declaration for FS. + * @brief Private functions declaration for HS. * @{ */ -uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); + #if (USBD_LPM_ENABLED == 1) -uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); #endif /* (USBD_LPM_ENABLED == 1) */ /** @@ -135,17 +136,17 @@ uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); * @{ */ -USBD_DescriptorsTypeDef FS_Desc = +USBD_DescriptorsTypeDef USBD_DESC = { - USBD_FS_DeviceDescriptor -, USBD_FS_LangIDStrDescriptor -, USBD_FS_ManufacturerStrDescriptor -, USBD_FS_ProductStrDescriptor -, USBD_FS_SerialStrDescriptor -, USBD_FS_ConfigStrDescriptor -, USBD_FS_InterfaceStrDescriptor + USBD_FSHS_DeviceDescriptor +, USBD_FSHS_LangIDStrDescriptor +, USBD_FSHS_ManufacturerStrDescriptor +, USBD_FSHS_ProductStrDescriptor +, USBD_FSHS_SerialStrDescriptor +, USBD_FSHS_ConfigStrDescriptor +, USBD_FSHS_InterfaceStrDescriptor #if (USBD_LPM_ENABLED == 1) -, USBD_FS_USR_BOSDescriptor +, USBD_FSHS_USR_BOSDescriptor #endif /* (USBD_LPM_ENABLED == 1) */ }; @@ -153,7 +154,7 @@ USBD_DescriptorsTypeDef FS_Desc = #pragma data_alignment=4 #endif /* defined ( __ICCARM__ ) */ /** USB standard device descriptor. */ -__ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = +__ALIGN_BEGIN uint8_t USBD_FSHS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = { 0x12, /*bLength */ USB_DESC_TYPE_DEVICE, /*bDescriptorType*/ @@ -164,6 +165,7 @@ __ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = #else 0x00, /*bcdUSB */ #endif /* (USBD_LPM_ENABLED == 1) */ + 0x02, 0x00, /*bDeviceClass*/ 0x00, /*bDeviceSubClass*/ @@ -171,8 +173,8 @@ __ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = USB_MAX_EP0_SIZE, /*bMaxPacketSize*/ LOBYTE(USBD_VID), /*idVendor*/ HIBYTE(USBD_VID), /*idVendor*/ - LOBYTE(USBD_PID_FS), /*idProduct*/ - HIBYTE(USBD_PID_FS), /*idProduct*/ + LOBYTE(USBD_PID_FSHS), /*idProduct*/ + HIBYTE(USBD_PID_FSHS), /*idProduct*/ 0x00, /*bcdDevice rel. 2.00*/ 0x02, USBD_IDX_MFC_STR, /*Index of manufacturer string*/ @@ -181,24 +183,23 @@ __ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/ }; -/* USB_DeviceDescriptor */ /** BOS descriptor. */ #if (USBD_LPM_ENABLED == 1) #if defined ( __ICCARM__ ) /* IAR Compiler */ #pragma data_alignment=4 #endif /* defined ( __ICCARM__ ) */ -__ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = +__ALIGN_BEGIN uint8_t USBD_FSHS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = { 0x5, USB_DESC_TYPE_BOS, 0xC, 0x0, - 0x1, /* 1 device capability*/ - /* device capability*/ + 0x1, /* 1 device capability */ + /* device capability */ 0x7, USB_DEVICE_CAPABITY_TYPE, 0x2, - 0x2, /* LPM capability bit set*/ + 0x2, /*LPM capability bit set */ 0x0, 0x0, 0x0 @@ -218,7 +219,7 @@ __ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = #pragma data_alignment=4 #endif /* defined ( __ICCARM__ ) */ -/** USB lang indentifier descriptor. */ +/** USB lang identifier descriptor. */ __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = { USB_LEN_LANGID_STR_DESC, @@ -256,11 +257,11 @@ __ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); - *length = sizeof(USBD_FS_DeviceDesc); - return USBD_FS_DeviceDesc; + *length = sizeof(USBD_FSHS_DeviceDesc); + return USBD_FSHS_DeviceDesc; } /** @@ -269,7 +270,7 @@ uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); *length = sizeof(USBD_LangIDDesc); @@ -278,19 +279,19 @@ uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) /** * @brief Return the product string descriptor - * @param speed : Current device speed - * @param length : Pointer to data length variable - * @retval Pointer to descriptor buffer + * @param speed : current device speed + * @param length : pointer to data length variable + * @retval pointer to descriptor buffer */ -uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { if(speed == 0) { - USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FSHS, USBD_StrDesc, length); } else { - USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FSHS, USBD_StrDesc, length); } return USBD_StrDesc; } @@ -301,7 +302,7 @@ uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length); @@ -314,7 +315,7 @@ uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *l * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); *length = USB_SIZ_STRING_SERIAL; @@ -322,9 +323,10 @@ uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) /* Update the serial number string descriptor with the data from the unique * ID */ Get_SerialNum(); - /* USER CODE BEGIN USBD_FS_SerialStrDescriptor */ - - /* USER CODE END USBD_FS_SerialStrDescriptor */ + /* USER CODE BEGIN USBD_HS_SerialStrDescriptor */ + + /* USER CODE END USBD_HS_SerialStrDescriptor */ + return (uint8_t *) USBD_StringSerial; } @@ -334,15 +336,15 @@ uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { if(speed == USBD_SPEED_HIGH) { - USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FSHS, USBD_StrDesc, length); } else { - USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FSHS, USBD_StrDesc, length); } return USBD_StrDesc; } @@ -353,15 +355,15 @@ uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { if(speed == 0) { - USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FSHS, USBD_StrDesc, length); } else { - USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FSHS, USBD_StrDesc, length); } return USBD_StrDesc; } @@ -373,11 +375,11 @@ uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *leng * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); - *length = sizeof(USBD_FS_BOSDesc); - return (uint8_t*)USBD_FS_BOSDesc; + *length = sizeof(USBD_FSHS_BOSDesc); + return (uint8_t*)USBD_FSHS_BOSDesc; } #endif /* (USBD_LPM_ENABLED == 1) */ From 98b16147b2beaca6a3098cc159a9c9114f451a46 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 17 Dec 2021 15:51:24 +0100 Subject: [PATCH 237/286] updated USBD log macros, set max num interfaces to 5 (not 1) --- OwlPedal2/Inc/usbd_conf.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/OwlPedal2/Inc/usbd_conf.h b/OwlPedal2/Inc/usbd_conf.h index 0c8b9b89..27e21fa6 100644 --- a/OwlPedal2/Inc/usbd_conf.h +++ b/OwlPedal2/Inc/usbd_conf.h @@ -69,13 +69,13 @@ */ /*---------- -----------*/ -#define USBD_MAX_NUM_INTERFACES 1U +#define USBD_MAX_NUM_INTERFACES 5U /*---------- -----------*/ #define USBD_MAX_NUM_CONFIGURATION 1U /*---------- -----------*/ #define USBD_MAX_STR_DESC_SIZ 512U /*---------- -----------*/ -#define USBD_DEBUG_LEVEL 0U +#define USBD_DEBUG_LEVEL DEBUG_LEVEL /*---------- -----------*/ #define USBD_LPM_ENABLED 0U /*---------- -----------*/ @@ -115,25 +115,25 @@ /* DEBUG macros */ #if (USBD_DEBUG_LEVEL > 0) -#define USBD_UsrLog(...) printf(__VA_ARGS__);\ - printf("\n"); +#define USBD_UsrLog(...) do { printf(__VA_ARGS__); \ + printf("\n"); } while(0) #else #define USBD_UsrLog(...) #endif #if (USBD_DEBUG_LEVEL > 1) -#define USBD_ErrLog(...) printf("ERROR: ") ;\ +#define USBD_ErrLog(...) do { printf("ERROR: ") ;\ printf(__VA_ARGS__);\ - printf("\n"); + printf("\n"); } while(0) #else #define USBD_ErrLog(...) #endif #if (USBD_DEBUG_LEVEL > 2) -#define USBD_DbgLog(...) printf("DEBUG : ") ;\ +#define USBD_DbgLog(...) do { printf("DEBUG : ") ; \ printf(__VA_ARGS__);\ - printf("\n"); + printf("\n"); } while(0) #else #define USBD_DbgLog(...) #endif From 0fb0cbc7687fc5af80b738874b1593801b530633 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 17 Dec 2021 15:52:41 +0100 Subject: [PATCH 238/286] call onStartProgram callback after changing operation mode --- Source/ProgramManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ProgramManager.cpp b/Source/ProgramManager.cpp index 5e9e8b94..4c6e2cad 100644 --- a/Source/ProgramManager.cpp +++ b/Source/ProgramManager.cpp @@ -529,10 +529,10 @@ void runAudioTask(void* p){ def->copy(); ProgramVector* pv = def->getProgramVector(); updateProgramVector(pv, def); - onStartProgram(); programVector = pv; setErrorStatus(NO_ERROR); owl.setOperationMode(RUN_MODE); + onStartProgram(); #ifdef USE_CODEC codec.clear(); #endif From fb65549c387ae42c76168d4efddefff9e72518eb Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 17 Dec 2021 15:54:28 +0100 Subject: [PATCH 239/286] signed Codec::set(int32_t) --- Source/Codec.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Codec.cpp b/Source/Codec.cpp index 995e8a5e..b2d58bf7 100644 --- a/Source/Codec.cpp +++ b/Source/Codec.cpp @@ -114,7 +114,7 @@ float Codec::getAvg(){ return avg / CODEC_BUFFER_SIZE; } -void Codec::set(uint32_t value){ +void Codec::set(int32_t value){ for(int i=0; i Date: Fri, 17 Dec 2021 15:54:38 +0100 Subject: [PATCH 240/286] signed Codec::set(int32_t) --- Source/Codec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Codec.h b/Source/Codec.h index 8b2282b7..597f469a 100644 --- a/Source/Codec.h +++ b/Source/Codec.h @@ -36,7 +36,7 @@ class Codec { void mute(bool doMute); void clear(); void txrx(); - void set(uint32_t value); + void set(int32_t value); void ramp(uint32_t max); void setInputGain(int8_t value); /* int8_t getOutputGain(); */ From bdfb5a5d897616e512bb047e16a9072f4a8f65ed Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 17 Dec 2021 16:14:23 +0100 Subject: [PATCH 241/286] removed USB class drivers from cube config --- Witch/Inc/hardware.h | 1 + Witch/Inc/stm32f4xx_hal_conf.h | 34 +- Witch/Src/Witch.cpp | 8 + Witch/Src/main.c | 107 ++- Witch/Src/stm32f4xx_hal_msp.c | 165 +++- Witch/Src/stm32f4xx_it.c | 4 +- Witch/Src/usb_device.c | 12 +- Witch/Src/usbh_conf.c | 6 +- Witch/Witch.ioc | 1459 ++++++++++++++++---------------- 9 files changed, 1017 insertions(+), 779 deletions(-) diff --git a/Witch/Inc/hardware.h b/Witch/Inc/hardware.h index c1314a34..f74483ef 100644 --- a/Witch/Inc/hardware.h +++ b/Witch/Inc/hardware.h @@ -22,6 +22,7 @@ #define USE_USBD_AUDIO_RX // speaker #define USE_USBD_AUDIO_TX // microphone #define USE_USBD_FS +#define USBD_HSFS DEVICE_FS #define USBD_HANDLE hUsbDeviceFS #define USBH_HANDLE hUsbHostHS #define USE_USB_HOST diff --git a/Witch/Inc/stm32f4xx_hal_conf.h b/Witch/Inc/stm32f4xx_hal_conf.h index 504cfb66..e620013c 100644 --- a/Witch/Inc/stm32f4xx_hal_conf.h +++ b/Witch/Inc/stm32f4xx_hal_conf.h @@ -76,6 +76,7 @@ /* #define HAL_QSPI_MODULE_ENABLED */ /* #define HAL_CEC_MODULE_ENABLED */ /* #define HAL_FMPI2C_MODULE_ENABLED */ +/* #define HAL_FMPSMBUS_MODULE_ENABLED */ /* #define HAL_SPDIFRX_MODULE_ENABLED */ /* #define HAL_DFSDM_MODULE_ENABLED */ /* #define HAL_LPTIM_MODULE_ENABLED */ @@ -94,11 +95,11 @@ * (when HSE is used as system clock source, directly or through the PLL). */ #if !defined (HSE_VALUE) - #define HSE_VALUE ((uint32_t)25000000U) /*!< Value of the External oscillator in Hz */ + #define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ #endif /* HSE_VALUE */ #if !defined (HSE_STARTUP_TIMEOUT) - #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ + #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ #endif /* HSE_STARTUP_TIMEOUT */ /** @@ -114,7 +115,7 @@ * @brief Internal Low Speed oscillator (LSI) value. */ #if !defined (LSI_VALUE) - #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/ + #define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/ #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz The real value may vary depending on the variations in voltage and temperature.*/ @@ -122,11 +123,11 @@ * @brief External Low Speed oscillator (LSE) value. */ #if !defined (LSE_VALUE) - #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */ + #define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ #endif /* LSE_VALUE */ #if !defined (LSE_STARTUP_TIMEOUT) - #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ + #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ #endif /* LSE_STARTUP_TIMEOUT */ /** @@ -135,7 +136,7 @@ * frequency, this source is inserted directly through I2S_CKIN pad. */ #if !defined (EXTERNAL_CLOCK_VALUE) - #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/ + #define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External audio frequency in Hz*/ #endif /* EXTERNAL_CLOCK_VALUE */ /* Tip: To avoid modifying this file each time you need to use different HSE, @@ -145,8 +146,8 @@ /** * @brief This is the HAL system configuration section */ -#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ -#define TICK_INT_PRIORITY ((uint32_t)15U) /*!< tick interrupt priority */ +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY 15U /*!< tick interrupt priority */ #define USE_RTOS 0U #define PREFETCH_ENABLE 1U #define INSTRUCTION_CACHE_ENABLE 1U @@ -166,6 +167,7 @@ #define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ #define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ #define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */ +#define USE_HAL_FMPSMBUS_REGISTER_CALLBACKS 0U /* FMPSMBUS register callback disabled */ #define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ #define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ #define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ @@ -213,20 +215,20 @@ /* Definition of the Ethernet driver buffers size and count */ #define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ #define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ -#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ -#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ +#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ /* Section 2: PHY configuration section */ /* DP83848_PHY_ADDRESS Address*/ #define DP83848_PHY_ADDRESS 0x01U /* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ -#define PHY_RESET_DELAY ((uint32_t)0x000000FFU) +#define PHY_RESET_DELAY 0x000000FFU /* PHY Configuration delay */ -#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU) +#define PHY_CONFIG_DELAY 0x00000FFFU -#define PHY_READ_TO ((uint32_t)0x0000FFFFU) -#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU) +#define PHY_READ_TO 0x0000FFFFU +#define PHY_WRITE_TO 0x0000FFFFU /* Section 3: Common PHY Registers */ @@ -444,6 +446,10 @@ #include "stm32f4xx_hal_fmpi2c.h" #endif /* HAL_FMPI2C_MODULE_ENABLED */ +#ifdef HAL_FMPSMBUS_MODULE_ENABLED + #include "stm32f4xx_hal_fmpsmbus.h" +#endif /* HAL_FMPSMBUS_MODULE_ENABLED */ + #ifdef HAL_SPDIFRX_MODULE_ENABLED #include "stm32f4xx_hal_spdifrx.h" #endif /* HAL_SPDIFRX_MODULE_ENABLED */ diff --git a/Witch/Src/Witch.cpp b/Witch/Src/Witch.cpp index 14c03499..62fdd2fb 100644 --- a/Witch/Src/Witch.cpp +++ b/Witch/Src/Witch.cpp @@ -12,6 +12,8 @@ #include "TakeoverControls.h" #include "qint.h" #include "Pin.h" +#include "usb_device.h" +#include "usb_host.h" #ifndef min #define min(a,b) ((a)<(b)?(a):(b)) @@ -439,6 +441,12 @@ void onSetup(){ takeover.set(9, settings.audio_output_gain<<5); takeover.reset(9, false); patchselect = program.getProgramIndex(); + + /* init code for USB_DEVICE */ + MX_USB_DEVICE_Init(); + + /* init code for USB_HOST */ + MX_USB_HOST_Init(); } void onLoop(){ diff --git a/Witch/Src/main.c b/Witch/Src/main.c index dbedf604..a9734381 100644 --- a/Witch/Src/main.c +++ b/Witch/Src/main.c @@ -8,8 +8,6 @@ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "cmsis_os.h" -#include "usb_device.h" -#include "usb_host.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ @@ -54,6 +52,9 @@ TIM_HandleTypeDef htim3; TIM_HandleTypeDef htim4; TIM_HandleTypeDef htim13; +PCD_HandleTypeDef hpcd_USB_OTG_FS; +HCD_HandleTypeDef hhcd_USB_OTG_HS; + SDRAM_HandleTypeDef hsdram1; osThreadId defaultTaskHandle; @@ -64,6 +65,7 @@ osThreadId defaultTaskHandle; /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); +void PeriphCommonClock_Config(void); static void MX_GPIO_Init(void); static void MX_DMA_Init(void); static void MX_ADC3_Init(void); @@ -77,6 +79,8 @@ static void MX_TIM1_Init(void); static void MX_TIM3_Init(void); static void MX_TIM4_Init(void); static void MX_TIM13_Init(void); +static void MX_USB_OTG_FS_PCD_Init(void); +static void MX_USB_OTG_HS_HCD_Init(void); void StartDefaultTask(void const * argument); /* USER CODE BEGIN PFP */ @@ -115,6 +119,9 @@ int main(void) /* Configure the system clock */ SystemClock_Config(); +/* Configure the peripherals common clocks */ + PeriphCommonClock_Config(); + /* USER CODE BEGIN SysInit */ /*Configure GPIO pin Output Level */ @@ -136,6 +143,8 @@ int main(void) MX_TIM3_Init(); MX_TIM4_Init(); MX_TIM13_Init(); + MX_USB_OTG_FS_PCD_Init(); + MX_USB_OTG_HS_HCD_Init(); /* USER CODE BEGIN 2 */ GPIO_InitTypeDef GPIO_InitStruct = {0}; @@ -229,7 +238,6 @@ void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; - RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; /** Macro to configure SAI1BlockB clock source selection */ @@ -270,11 +278,22 @@ void SystemClock_Config(void) { Error_Handler(); } - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SAI_PLLSAI|RCC_PERIPHCLK_RTC; +} + +/** + * @brief Peripherals Common Clock Configuration + * @retval None + */ +void PeriphCommonClock_Config(void) +{ + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SAI_PLLSAI; PeriphClkInitStruct.PLLSAI.PLLSAIN = 100; PeriphClkInitStruct.PLLSAI.PLLSAIQ = 4; PeriphClkInitStruct.PLLSAIDivQ = 1; - PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) { Error_Handler(); @@ -831,6 +850,75 @@ static void MX_TIM13_Init(void) } +/** + * @brief USB_OTG_FS Initialization Function + * @param None + * @retval None + */ +static void MX_USB_OTG_FS_PCD_Init(void) +{ + + /* USER CODE BEGIN USB_OTG_FS_Init 0 */ + + /* USER CODE END USB_OTG_FS_Init 0 */ + + /* USER CODE BEGIN USB_OTG_FS_Init 1 */ + + /* USER CODE END USB_OTG_FS_Init 1 */ + hpcd_USB_OTG_FS.Instance = USB_OTG_FS; + hpcd_USB_OTG_FS.Init.dev_endpoints = 4; + hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; + hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; + hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; + hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; + hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; + hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; + hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE; + hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE; + if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN USB_OTG_FS_Init 2 */ + + /* USER CODE END USB_OTG_FS_Init 2 */ + +} + +/** + * @brief USB_OTG_HS Initialization Function + * @param None + * @retval None + */ +static void MX_USB_OTG_HS_HCD_Init(void) +{ + + /* USER CODE BEGIN USB_OTG_HS_Init 0 */ + + /* USER CODE END USB_OTG_HS_Init 0 */ + + /* USER CODE BEGIN USB_OTG_HS_Init 1 */ + + /* USER CODE END USB_OTG_HS_Init 1 */ + hhcd_USB_OTG_HS.Instance = USB_OTG_HS; + hhcd_USB_OTG_HS.Init.Host_channels = 12; + hhcd_USB_OTG_HS.Init.speed = HCD_SPEED_FULL; + hhcd_USB_OTG_HS.Init.dma_enable = DISABLE; + hhcd_USB_OTG_HS.Init.phy_itface = USB_OTG_EMBEDDED_PHY; + hhcd_USB_OTG_HS.Init.Sof_enable = DISABLE; + hhcd_USB_OTG_HS.Init.low_power_enable = DISABLE; + hhcd_USB_OTG_HS.Init.vbus_sensing_enable = DISABLE; + hhcd_USB_OTG_HS.Init.use_external_vbus = DISABLE; + if (HAL_HCD_Init(&hhcd_USB_OTG_HS) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN USB_OTG_HS_Init 2 */ + + /* USER CODE END USB_OTG_HS_Init 2 */ + +} + /** * Enable DMA controller clock */ @@ -1043,10 +1131,10 @@ static void MX_GPIO_Init(void) HAL_GPIO_Init(SW4_GPIO_Port, &GPIO_InitStruct); /* EXTI interrupt init*/ - HAL_NVIC_SetPriority(EXTI1_IRQn, 0, 0); + HAL_NVIC_SetPriority(EXTI1_IRQn, 5, 0); HAL_NVIC_EnableIRQ(EXTI1_IRQn); - HAL_NVIC_SetPriority(EXTI2_IRQn, 0, 0); + HAL_NVIC_SetPriority(EXTI2_IRQn, 5, 0); HAL_NVIC_EnableIRQ(EXTI2_IRQn); HAL_NVIC_SetPriority(EXTI9_5_IRQn, 5, 0); @@ -1067,11 +1155,6 @@ static void MX_GPIO_Init(void) /* USER CODE END Header_StartDefaultTask */ void StartDefaultTask(void const * argument) { - /* init code for USB_DEVICE */ - MX_USB_DEVICE_Init(); - - /* init code for USB_HOST */ - MX_USB_HOST_Init(); /* USER CODE BEGIN 5 */ setup(); diff --git a/Witch/Src/stm32f4xx_hal_msp.c b/Witch/Src/stm32f4xx_hal_msp.c index 4ad07d73..633a42d6 100644 --- a/Witch/Src/stm32f4xx_hal_msp.c +++ b/Witch/Src/stm32f4xx_hal_msp.c @@ -297,11 +297,21 @@ void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac) */ void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc) { + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; if(hrtc->Instance==RTC) { /* USER CODE BEGIN RTC_MspInit 0 */ /* USER CODE END RTC_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC; + PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + /* Peripheral clock enable */ __HAL_RCC_RTC_ENABLE(); /* USER CODE BEGIN RTC_MspInit 1 */ @@ -674,6 +684,153 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) } +/** +* @brief PCD MSP Initialization +* This function configures the hardware resources used in this example +* @param hpcd: PCD handle pointer +* @retval None +*/ +void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(hpcd->Instance==USB_OTG_FS) + { + /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */ + + /* USER CODE END USB_OTG_FS_MspInit 0 */ + + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**USB_OTG_FS GPIO Configuration + PA9 ------> USB_OTG_FS_VBUS + PA11 ------> USB_OTG_FS_DM + PA12 ------> USB_OTG_FS_DP + */ + GPIO_InitStruct.Pin = GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* Peripheral clock enable */ + __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); + /* USB_OTG_FS interrupt Init */ + HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(OTG_FS_IRQn); + /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */ + + /* USER CODE END USB_OTG_FS_MspInit 1 */ + } + +} + +/** +* @brief HCD MSP Initialization +* This function configures the hardware resources used in this example +* @param hhcd: HCD handle pointer +* @retval None +*/ +void HAL_HCD_MspInit(HCD_HandleTypeDef* hhcd) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(hhcd->Instance==USB_OTG_HS) + { + /* USER CODE BEGIN USB_OTG_HS_MspInit 0 */ + + /* USER CODE END USB_OTG_HS_MspInit 0 */ + + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**USB_OTG_HS GPIO Configuration + PB14 ------> USB_OTG_HS_DM + PB15 ------> USB_OTG_HS_DP + */ + GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_OTG_HS_FS; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* Peripheral clock enable */ + __HAL_RCC_USB_OTG_HS_CLK_ENABLE(); + /* USB_OTG_HS interrupt Init */ + HAL_NVIC_SetPriority(OTG_HS_IRQn, 8, 0); + HAL_NVIC_EnableIRQ(OTG_HS_IRQn); + /* USER CODE BEGIN USB_OTG_HS_MspInit 1 */ + + /* USER CODE END USB_OTG_HS_MspInit 1 */ + } + +} + +/** +* @brief PCD MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hpcd: PCD handle pointer +* @retval None +*/ +void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd) +{ + if(hpcd->Instance==USB_OTG_FS) + { + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */ + + /* USER CODE END USB_OTG_FS_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); + + /**USB_OTG_FS GPIO Configuration + PA9 ------> USB_OTG_FS_VBUS + PA11 ------> USB_OTG_FS_DM + PA12 ------> USB_OTG_FS_DP + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_12); + + /* USB_OTG_FS interrupt DeInit */ + HAL_NVIC_DisableIRQ(OTG_FS_IRQn); + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */ + + /* USER CODE END USB_OTG_FS_MspDeInit 1 */ + } + +} + +/** +* @brief HCD MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hhcd: HCD handle pointer +* @retval None +*/ +void HAL_HCD_MspDeInit(HCD_HandleTypeDef* hhcd) +{ + if(hhcd->Instance==USB_OTG_HS) + { + /* USER CODE BEGIN USB_OTG_HS_MspDeInit 0 */ + + /* USER CODE END USB_OTG_HS_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_USB_OTG_HS_CLK_DISABLE(); + + /**USB_OTG_HS GPIO Configuration + PB14 ------> USB_OTG_HS_DM + PB15 ------> USB_OTG_HS_DP + */ + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_14|GPIO_PIN_15); + + /* USB_OTG_HS interrupt DeInit */ + HAL_NVIC_DisableIRQ(OTG_HS_IRQn); + /* USER CODE BEGIN USB_OTG_HS_MspDeInit 1 */ + + /* USER CODE END USB_OTG_HS_MspDeInit 1 */ + } + +} + static uint32_t FMC_Initialized = 0; static void HAL_FMC_MspInit(void){ @@ -921,7 +1078,7 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; HAL_GPIO_Init(CS_SDIN_GPIO_Port, &GPIO_InitStruct); - /* Peripheral DMA init*/ + /* Peripheral DMA init*/ hdma_sai1_a.Instance = DMA2_Stream1; hdma_sai1_a.Init.Channel = DMA_CHANNEL_0; @@ -968,7 +1125,7 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; HAL_GPIO_Init(CS_SDOUT_GPIO_Port, &GPIO_InitStruct); - /* Peripheral DMA init*/ + /* Peripheral DMA init*/ hdma_sai1_b.Instance = DMA2_Stream4; hdma_sai1_b.Init.Channel = DMA_CHANNEL_1; @@ -1002,6 +1159,7 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) { /* Peripheral clock disable */ __HAL_RCC_SAI1_CLK_DISABLE(); + /* SAI1 interrupt DeInit */ HAL_NVIC_DisableIRQ(SAI1_IRQn); } @@ -1014,6 +1172,7 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) HAL_GPIO_DeInit(CS_SDIN_GPIO_Port, CS_SDIN_Pin); + /* SAI1 DMA Deinit */ HAL_DMA_DeInit(hsai->hdmarx); HAL_DMA_DeInit(hsai->hdmatx); } @@ -1024,6 +1183,7 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) { /* Peripheral clock disable */ __HAL_RCC_SAI1_CLK_DISABLE(); + /* SAI1 interrupt DeInit */ HAL_NVIC_DisableIRQ(SAI1_IRQn); } @@ -1032,6 +1192,7 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) */ HAL_GPIO_DeInit(CS_SDOUT_GPIO_Port, CS_SDOUT_Pin); + /* SAI1 DMA Deinit */ HAL_DMA_DeInit(hsai->hdmarx); HAL_DMA_DeInit(hsai->hdmatx); } diff --git a/Witch/Src/stm32f4xx_it.c b/Witch/Src/stm32f4xx_it.c index 2909c4cc..47283a10 100644 --- a/Witch/Src/stm32f4xx_it.c +++ b/Witch/Src/stm32f4xx_it.c @@ -73,13 +73,13 @@ /* USER CODE END 0 */ /* External variables --------------------------------------------------------*/ -extern PCD_HandleTypeDef hpcd_USB_OTG_FS; -extern HCD_HandleTypeDef hhcd_USB_OTG_HS; extern DMA_HandleTypeDef hdma_adc3; extern DMA_HandleTypeDef hdma_sai1_a; extern DMA_HandleTypeDef hdma_sai1_b; extern SAI_HandleTypeDef hsai_BlockA1; extern SAI_HandleTypeDef hsai_BlockB1; +extern PCD_HandleTypeDef hpcd_USB_OTG_FS; +extern HCD_HandleTypeDef hhcd_USB_OTG_HS; /* USER CODE BEGIN EV */ /* USER CODE END EV */ diff --git a/Witch/Src/usb_device.c b/Witch/Src/usb_device.c index 95ded99c..723305ee 100644 --- a/Witch/Src/usb_device.c +++ b/Witch/Src/usb_device.c @@ -27,6 +27,8 @@ #include "usbd_audio.h" /* USER CODE BEGIN Includes */ +#include "device.h" + /* USER CODE END Includes */ /* USER CODE BEGIN PV */ @@ -40,7 +42,7 @@ /* USER CODE END PFP */ /* USB Device Core handle declaration. */ -USBD_HandleTypeDef hUsbDeviceFS; +USBD_HandleTypeDef USBD_HANDLE; /* * -- Insert your variables declaration here -- @@ -67,19 +69,19 @@ void MX_USB_DEVICE_Init(void) /* USER CODE END USB_DEVICE_Init_PreTreatment */ /* Init Device Library, add supported class and start the library. */ - if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK) + if (USBD_Init(&USBD_HANDLE, &USBD_DESC, USBD_HSFS) != USBD_OK) { Error_Handler(); } - if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_AUDIO) != USBD_OK) + if (USBD_RegisterClass(&USBD_HANDLE, &USBD_AUDIO) != USBD_OK) { Error_Handler(); } - if (USBD_AUDIO_RegisterInterface(&hUsbDeviceFS, NULL) != USBD_OK) + if (USBD_AUDIO_RegisterInterface(&USBD_HANDLE, NULL) != USBD_OK) { Error_Handler(); } - if (USBD_Start(&hUsbDeviceFS) != USBD_OK) + if (USBD_Start(&USBD_HANDLE) != USBD_OK) { Error_Handler(); } diff --git a/Witch/Src/usbh_conf.c b/Witch/Src/usbh_conf.c index 0981749f..2c7b45d4 100644 --- a/Witch/Src/usbh_conf.c +++ b/Witch/Src/usbh_conf.c @@ -35,7 +35,7 @@ /* USER CODE END PV */ -HCD_HandleTypeDef hhcd_USB_OTG_HS; +extern HCD_HandleTypeDef hhcd_USB_OTG_HS; void Error_Handler(void); /* USER CODE BEGIN 0 */ @@ -59,7 +59,7 @@ USBH_StatusTypeDef USBH_Get_USB_Status(HAL_StatusTypeDef hal_status); *******************************************************************************/ /* MSP Init */ -void HAL_HCD_MspInit(HCD_HandleTypeDef* hcdHandle) +__weak void HAL_HCD_MspInit(HCD_HandleTypeDef* hcdHandle) { GPIO_InitTypeDef GPIO_InitStruct = {0}; if(hcdHandle->Instance==USB_OTG_HS) @@ -92,7 +92,7 @@ void HAL_HCD_MspInit(HCD_HandleTypeDef* hcdHandle) } } -void HAL_HCD_MspDeInit(HCD_HandleTypeDef* hcdHandle) +__weak void HAL_HCD_MspDeInit(HCD_HandleTypeDef* hcdHandle) { if(hcdHandle->Instance==USB_OTG_HS) { diff --git a/Witch/Witch.ioc b/Witch/Witch.ioc index aa75b622..92c6bc7f 100644 --- a/Witch/Witch.ioc +++ b/Witch/Witch.ioc @@ -1,788 +1,765 @@ #MicroXplorer Configuration settings - do not modify -PB13.GPIOParameters=GPIO_Label -SH.FMC_D0_DA0.ConfNb=1 -SH.FMC_A8.ConfNb=1 -SH.FMC_D6_DA6.ConfNb=1 -SH.FMC_A0.ConfNb=1 -FMC.SDClockPeriod2=FMC_SDRAM_CLOCK_PERIOD_2 -SH.FMC_D9_DA9.ConfNb=1 -FMC.SDClockPeriod1=FMC_SDRAM_CLOCK_PERIOD_2 -SH.FMC_A0.0=FMC_A0,12b-sda1 -PG8.Signal=FMC_SDCLK -RCC.PLLQCLKFreq_Value=48000000 -PG0.Signal=FMC_A10 -RCC.RTCFreq_Value=32000 -PD2.GPIOParameters=GPIO_Label -SH.FMC_SDNWE.ConfNb=1 -SH.S_TIM1_CH1.ConfNb=1 -SH.FMC_D5_DA5.0=FMC_D5,sd-16b-d1 -SH.FMC_D9_DA9.0=FMC_D9,sd-16b-d1 -RCC.LPTIM1Freq_Value=54000000 -USB_DEVICE.PID_AUDIO_FS=0xDADA -NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -FREERTOS.configENABLE_FPU=1 -SAI1.FSDefinition-SAI_B_SyncSlave=SAI_FS_CHANNEL_IDENTIFICATION -NVIC.EXTI1_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true -PF7.Signal=ADC3_IN5 -SH.FMC_SDNWE.0=FMC_SDNWE,12b-sda1 -SPI1.Direction=SPI_DIRECTION_2LINES -SH.FMC_D11_DA11.0=FMC_D11,sd-16b-d1 -RCC.I2C4Freq_Value=54000000 -RCC.APB2TimFreq_Value=168000000 -PB6.Signal=FMC_SDNE1 -SPI1.CalculateBaudRate=42.0 MBits/s -ADC3.ScanConvMode=ENABLE -PD0.Signal=FMC_D2_DA2 -PD8.Signal=FMC_D13_DA13 -PE1.Signal=FMC_NBL1 -RCC.USART3Freq_Value=54000000 -RCC.PLLSAIRCLKFreq_Value=50000000 -ProjectManager.ProjectBuild=false -TIM4.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3 -NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -PB3.Mode=Full_Duplex_Master -PA8.Locked=true -VP_USB_HOST_VS_USB_HOST_AUDIO_HS.Mode=AUDIO_HS -PB12.GPIO_Label=LEDPWM -FMC.SelfRefreshTime1=4 -ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.25.2 -USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology -ProjectManager.BackupPrevious=false -PC4.GPIO_Label=FLASH_HOLD -TIM1.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 -PE9.Signal=FMC_D6_DA6 -SH.FMC_A2.0=FMC_A2,12b-sda1 -PB14.Mode=Host_FS -PB1.GPIO_Label=SW2 -PE4.GPIO_Label=CS_LRCK -PF10.Locked=true -VP_USB_HOST_VS_USB_HOST_AUDIO_HS.Signal=USB_HOST_VS_USB_HOST_AUDIO_HS -PA8.Signal=S_TIM1_CH1 +ADC3.Channel-31\#ChannelRegularConversion=ADC_CHANNEL_13 +ADC3.Channel-32\#ChannelRegularConversion=ADC_CHANNEL_12 ADC3.Channel-33\#ChannelRegularConversion=ADC_CHANNEL_11 -SH.FMC_D1_DA1.0=FMC_D1,sd-16b-d1 -ADC3.SamplingTime-36\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -PC15/OSC32_OUT.Locked=true -USB_OTG_HS.IPParameters=VirtualMode-Host_FS -VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 -ProjectManager.HalAssertFull=true -Mcu.Package=LQFP144 -PB9.Signal=GPIO_Input -PB1.Signal=GPXTI1 -PA5.Locked=true -SH.FMC_SDNCAS.ConfNb=1 -VP_SYS_VS_Systick.Signal=SYS_VS_Systick -SH.FMC_A11.ConfNb=1 -PB9.GPIO_PuPd=GPIO_PULLUP -FREERTOS.FootprintOK=true -FMC.WriteRecoveryTime1=2 -PF7.Locked=true -ADC3.DMAContinuousRequests=ENABLE -RCC.APB2CLKDivider=RCC_HCLK_DIV2 -NVIC.EXTI2_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true -RCC.APB1TimFreq_Value=84000000 -FMC.RowCycleDelay2=6 -FMC.RowCycleDelay1=6 -PF10.Mode=IN8 -USB_OTG_FS.IPParameters=VirtualMode -ADC3.Rank-34\#ChannelRegularConversion=4 -PF9.GPIO_PuPd=GPIO_PULLUP -SAI1.SlotSize-SAI_A_AsyncSlave=SAI_SLOTSIZE_32B -PA4.GPIO_Label=DAC1 -PD15.Signal=FMC_D1_DA1 -RCC.PLLSAIQCLKFreq_Value=50000000 -SH.FMC_D3_DA3.ConfNb=1 -Dma.SAI1_B.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -PA6.GPIOParameters=GPIO_Label -USB_DEVICE.VID-AUDIO_FS=0x1209 +ADC3.Channel-34\#ChannelRegularConversion=ADC_CHANNEL_8 +ADC3.Channel-35\#ChannelRegularConversion=ADC_CHANNEL_0 +ADC3.Channel-36\#ChannelRegularConversion=ADC_CHANNEL_1 +ADC3.Channel-37\#ChannelRegularConversion=ADC_CHANNEL_2 +ADC3.Channel-38\#ChannelRegularConversion=ADC_CHANNEL_3 ADC3.Channel-39\#ChannelRegularConversion=ADC_CHANNEL_5 -Mcu.Pin80=PD2 -PD6.GPIOParameters=GPIO_Label -Mcu.Pin81=PD6 -SH.FMC_A4.0=FMC_A4,12b-sda1 -ProjectManager.ProjectFileName=Witch.ioc -SH.FMC_A5.ConfNb=1 -FREERTOS.Tasks01=defaultTask,0,512,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL -Mcu.Pin79=PD1 -USB_DEVICE.VirtualMode-AUDIO_FS=Audio -Mcu.PinsNb=98 -Mcu.Pin73=PA14 -PC11.Locked=true -Mcu.Pin74=PA15 -Dma.SAI1_B.1.MemInc=DMA_MINC_ENABLE -Mcu.Pin71=PA12 -Mcu.Pin72=PA13 -Mcu.Pin77=PC12 -PG5.Signal=FMC_A15_BA1 -Mcu.Pin78=PD0 -Mcu.Pin75=PC10 -SH.FMC_D10_DA10.0=FMC_D10,sd-16b-d1 -Mcu.Pin76=PC11 -FREERTOS.INCLUDE_vTaskDelayUntil=1 -Mcu.Pin70=PA11 -PC2.Signal=ADCx_IN12 -PH1/OSC_OUT.GPIOParameters=GPIO_Label -RCC.VCOSAIOutputFreq_ValueQ=25000000 -Mcu.Pin68=PA8 -Mcu.Pin69=PA9 -PD6.Mode=SAI_A_AsyncSlave -Mcu.Pin62=PG4 -Mcu.Pin63=PG5 -Mcu.Pin60=PD14 -Mcu.Pin61=PD15 -Mcu.Pin66=PC8 -Mcu.Pin67=PC9 -Mcu.Pin64=PG8 -Mcu.Pin65=PC6 -PF8.GPIO_Label=LEDPWM4 -PC3.GPIOParameters=GPIO_Label -PD10.Signal=FMC_D15_DA15 -PB8.GPIO_Label=LEDPWM3 -PA15.Locked=true -PA8.GPIO_Label=LEDPWM6 -Mcu.Pin59=PD10 -SH.GPXTI2.ConfNb=1 -Mcu.Pin57=PD8 -Mcu.Pin58=PD9 -Mcu.Pin51=PB10 -RCC.USART6Freq_Value=108000000 -Mcu.Pin52=PB11 -Mcu.Pin50=PE15 -Mcu.Pin55=PB14 -Mcu.Pin56=PB15 -Mcu.Pin53=PB12 -Mcu.Pin54=PB13 -PB9.Locked=true -PB11.GPIOParameters=GPIO_Label -Mcu.Pin48=PE13 -Mcu.Pin49=PE14 -Mcu.Pin46=PE11 -Mcu.Pin47=PE12 -TIM13.IPParameters=Channel,Prescaler,Period -PB14.Signal=USB_OTG_HS_DM -PA5.Signal=COMP_DAC2_group -Mcu.Pin40=PG0 -Mcu.Pin41=PG1 -Mcu.Pin44=PE9 -Mcu.Pin45=PE10 -Mcu.Pin42=PE7 -Mcu.Pin43=PE8 -TIM13.Period=1023 -FMC.ReadBurst1=FMC_SDRAM_RBURST_ENABLE -SH.FMC_A6.0=FMC_A6,12b-sda1 -FMC.ReadBurst2=FMC_SDRAM_RBURST_ENABLE -PE14.Signal=FMC_D11_DA11 -PE6.Mode=TX_Only_Simplex_Unidirect_Master -Mcu.Pin37=PF13 -Mcu.Pin38=PF14 -RCC.I2C1Freq_Value=54000000 -Mcu.Pin35=PF11 -Mcu.Pin36=PF12 -RCC.PLLI2SPCLKFreq_Value=96000000 -SPI1.Mode=SPI_MODE_MASTER -SH.ADCx_IN0.ConfNb=1 -SH.FMC_D14_DA14.ConfNb=1 -Mcu.Pin39=PF15 -Mcu.Pin30=PC4 -Mcu.Pin33=PB1 -SH.ADCx_IN12.ConfNb=1 -Mcu.Pin34=PB2/BOOT1 -Mcu.Pin31=PC5 -Mcu.Pin32=PB0 -NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -FREERTOS.configUSE_MUTEXES=0 -PF13.Signal=FMC_A7 -PC10.GPIOParameters=GPIO_Label -PC9.GPIOParameters=GPIO_Label -PF9.GPIOParameters=GPIO_PuPd,GPIO_Label -RCC.PLLI2SQCLKFreq_Value=96000000 -Mcu.Pin26=PA4 -NVIC.DMA2_Stream4_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -Mcu.Pin27=PA5 -Mcu.Pin24=PA2 -Mcu.Pin25=PA3 -Mcu.Pin28=PA6 -Mcu.Pin29=PA7 -Mcu.Pin22=PA0/WKUP -Mcu.Pin23=PA1 -Mcu.Pin20=PC2 -ADC3.SamplingTime-37\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -Mcu.Pin21=PC3 -PA5.GPIO_Label=DAC2 -NVIC.ForceEnableDMAVector=true -Dma.ADC3.2.PeriphInc=DMA_PINC_DISABLE -PA14.GPIOParameters=GPIO_Label -NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -PE5.GPIO_Label=CS_SCK -PC12.GPIO_Label=TR_OUT1 -SH.FMC_SDNRAS.ConfNb=1 -ProjectManager.HeapSize=0x200 -Mcu.Pin15=PF10 -NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -Mcu.Pin16=PH0/OSC_IN +ADC3.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV8 +ADC3.ContinuousConvMode=ENABLE +ADC3.DMAContinuousRequests=ENABLE +ADC3.DataAlign=ADC_DATAALIGN_RIGHT +ADC3.DiscontinuousConvMode=DISABLE ADC3.EOCSelection=ADC_EOC_SEQ_CONV -Mcu.Pin13=PF8 -Mcu.Pin14=PF9 -PF10.GPIOParameters=GPIO_Label -Mcu.Pin19=PC1 -Mcu.Pin17=PH1/OSC_OUT -Mcu.Pin18=PC0 -NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 -Mcu.Pin11=PF5 -Mcu.Pin12=PF7 -Mcu.Pin10=PF4 -PE3.Signal=SAI1_SD_B -ADC3.Rank-33\#ChannelRegularConversion=3 -PC15/OSC32_OUT.Signal=GPIO_Output -PF4.Signal=FMC_A4 -SH.GPXTI1.ConfNb=1 -PD2.Signal=GPIO_Output ADC3.EnableAnalogWatchDog=false -Mcu.Family=STM32F4 +ADC3.ExternalTrigConv=ADC_SOFTWARE_START +ADC3.ExternalTrigConvEdge=ADC_EXTERNALTRIGCONVEDGE_NONE +ADC3.IPParameters=Rank-31\#ChannelRegularConversion,Channel-31\#ChannelRegularConversion,SamplingTime-31\#ChannelRegularConversion,NbrOfConversionFlag,ScanConvMode,ContinuousConvMode,DMAContinuousRequests,EOCSelection,InjNumberOfConversion,EnableAnalogWatchDog,ExternalTrigConv,Rank-32\#ChannelRegularConversion,Channel-32\#ChannelRegularConversion,SamplingTime-32\#ChannelRegularConversion,Rank-33\#ChannelRegularConversion,Channel-33\#ChannelRegularConversion,SamplingTime-33\#ChannelRegularConversion,Rank-34\#ChannelRegularConversion,Channel-34\#ChannelRegularConversion,SamplingTime-34\#ChannelRegularConversion,NbrOfConversion,ClockPrescaler,Resolution,DataAlign,DiscontinuousConvMode,ExternalTrigConvEdge,Rank-35\#ChannelRegularConversion,Channel-35\#ChannelRegularConversion,SamplingTime-35\#ChannelRegularConversion,Rank-36\#ChannelRegularConversion,Channel-36\#ChannelRegularConversion,SamplingTime-36\#ChannelRegularConversion,Rank-37\#ChannelRegularConversion,Channel-37\#ChannelRegularConversion,SamplingTime-37\#ChannelRegularConversion,Rank-38\#ChannelRegularConversion,Channel-38\#ChannelRegularConversion,SamplingTime-38\#ChannelRegularConversion,Rank-39\#ChannelRegularConversion,Channel-39\#ChannelRegularConversion,SamplingTime-39\#ChannelRegularConversion +ADC3.InjNumberOfConversion=0 +ADC3.NbrOfConversion=9 +ADC3.NbrOfConversionFlag=1 +ADC3.Rank-31\#ChannelRegularConversion=1 +ADC3.Rank-32\#ChannelRegularConversion=2 +ADC3.Rank-33\#ChannelRegularConversion=3 +ADC3.Rank-34\#ChannelRegularConversion=4 +ADC3.Rank-35\#ChannelRegularConversion=5 +ADC3.Rank-36\#ChannelRegularConversion=6 +ADC3.Rank-37\#ChannelRegularConversion=7 ADC3.Rank-38\#ChannelRegularConversion=8 -FMC.IPParameters=ReadPipeDelay1,ReadBurst1,ReadBurst2,SDClockPeriod1,SDClockPeriod2,CASLatency1,LoadToActiveDelay1,ExitSelfRefreshDelay1,SelfRefreshTime1,RowCycleDelay1,RowCycleDelay2,WriteRecoveryTime1,RPDelay1,RPDelay2,RCDDelay1 -NVIC.OTG_HS_IRQn=true\:8\:0\:true\:false\:true\:true\:true\:true -ProjectManager.MainLocation=Src -PA6.Mode=Full_Duplex_Master -SH.FMC_A6.ConfNb=1 -USB_DEVICE.CLASS_NAME_FS=AUDIO -SH.FMC_A8.0=FMC_A8,12b-sda1 -PC15/OSC32_OUT.GPIO_Label=EXTSPI_nCS -PG9.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -ProjectManager.KeepUserCode=true -ADC3.Channel-35\#ChannelRegularConversion=ADC_CHANNEL_0 -SH.FMC_D14_DA14.0=FMC_D14,sd-16b-d1 -SAI1.FrameLength-SAI_A_AsyncSlave=64 +ADC3.Rank-39\#ChannelRegularConversion=9 +ADC3.Resolution=ADC_RESOLUTION_12B +ADC3.SamplingTime-31\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-32\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-33\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-34\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-35\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-36\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-37\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-38\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-39\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.ScanConvMode=ENABLE +Dma.ADC3.2.Direction=DMA_PERIPH_TO_MEMORY +Dma.ADC3.2.FIFOMode=DMA_FIFOMODE_DISABLE Dma.ADC3.2.Instance=DMA2_Stream0 -SAI1.FrameLength-SAI_B_SyncSlave=64 -PC5.Locked=true -PA11.Mode=Device_Only -PB2/BOOT1.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 -PD2.Locked=true -SH.FMC_A11.0=FMC_A11,12b-sda1 -PC1.Locked=true -PB13.GPIO_Label=USBH_PWR_FAULT -PB15.Signal=USB_OTG_HS_DP -SH.S_TIM13_CH1.0=TIM13_CH1,PWM Generation1 CH1 -PG11.Signal=GPIO_Output -PG15.Signal=FMC_SDNCAS -SH.COMP_DAC2_group.0=DAC_OUT2,DAC_OUT2 -SH.GPXTI2.0=GPIO_EXTI2 -SAI1.Instance-SAI_A_AsyncSlave=SAI$Index_Block_A -Mcu.IP4=FREERTOS -Mcu.IP5=NVIC -RCC.FCLKCortexFreq_Value=168000000 -Mcu.IP2=DMA -Mcu.IP3=FMC -PA15.GPIO_Label=LEDSW1 -Mcu.IP0=ADC3 -Mcu.IP1=DAC -PE4.GPIOParameters=GPIO_Label -TIM1.Prescaler=100 -PF9.Locked=true -SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE -RCC.SDMMCFreq_Value=216000000 +Dma.ADC3.2.MemDataAlignment=DMA_MDATAALIGN_HALFWORD +Dma.ADC3.2.MemInc=DMA_MINC_ENABLE +Dma.ADC3.2.Mode=DMA_CIRCULAR +Dma.ADC3.2.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD +Dma.ADC3.2.PeriphInc=DMA_PINC_DISABLE Dma.ADC3.2.Priority=DMA_PRIORITY_LOW -PB1.GPIO_PuPd=GPIO_PULLUP -SH.ADCx_IN3.0=ADC3_IN3,IN3 -ProjectManager.PreviousToolchain=TrueSTUDIO -TIM3.Period=1023 -RCC.VcooutputI2S=96000000 -SH.FMC_NBL1.0=FMC_NBL1,Sd2ByteEnable1 -PA8.GPIOParameters=GPIO_Label -SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,VirtualType,Direction -FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configENABLE_BACKWARD_COMPATIBILITY,configUSE_MUTEXES,FootprintOK,MEMORY_ALLOCATION,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,INCLUDE_vTaskDelayUntil,configTOTAL_HEAP_SIZE,configENABLE_FPU -Dma.SAI1_B.1.Instance=DMA2_Stream4 +Dma.ADC3.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +Dma.Request0=SAI1_A +Dma.Request1=SAI1_B +Dma.Request2=ADC3 +Dma.RequestsNb=3 +Dma.SAI1_A.0.Direction=DMA_MEMORY_TO_PERIPH +Dma.SAI1_A.0.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SAI1_A.0.Instance=DMA2_Stream1 +Dma.SAI1_A.0.MemDataAlignment=DMA_MDATAALIGN_WORD +Dma.SAI1_A.0.MemInc=DMA_MINC_ENABLE +Dma.SAI1_A.0.Mode=DMA_CIRCULAR +Dma.SAI1_A.0.PeriphDataAlignment=DMA_PDATAALIGN_WORD +Dma.SAI1_A.0.PeriphInc=DMA_PINC_DISABLE +Dma.SAI1_A.0.Priority=DMA_PRIORITY_VERY_HIGH +Dma.SAI1_A.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +Dma.SAI1_B.1.Direction=DMA_PERIPH_TO_MEMORY Dma.SAI1_B.1.FIFOMode=DMA_FIFOMODE_DISABLE -TIM3.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 -FREERTOS.configUSE_PREEMPTION=0 -RCC.HSE_VALUE=25000000 -NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -SH.FMC_A14_BA0.ConfNb=1 +Dma.SAI1_B.1.Instance=DMA2_Stream4 +Dma.SAI1_B.1.MemDataAlignment=DMA_MDATAALIGN_WORD +Dma.SAI1_B.1.MemInc=DMA_MINC_ENABLE +Dma.SAI1_B.1.Mode=DMA_CIRCULAR +Dma.SAI1_B.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD +Dma.SAI1_B.1.PeriphInc=DMA_PINC_DISABLE +Dma.SAI1_B.1.Priority=DMA_PRIORITY_VERY_HIGH +Dma.SAI1_B.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_3 FMC.ExitSelfRefreshDelay1=6 +FMC.IPParameters=ReadPipeDelay1,ReadBurst1,ReadBurst2,SDClockPeriod1,SDClockPeriod2,CASLatency1,LoadToActiveDelay1,ExitSelfRefreshDelay1,SelfRefreshTime1,RowCycleDelay1,RowCycleDelay2,WriteRecoveryTime1,RPDelay1,RPDelay2,RCDDelay1 +FMC.LoadToActiveDelay1=2 +FMC.RCDDelay1=2 +FMC.RPDelay1=2 +FMC.RPDelay2=2 +FMC.ReadBurst1=FMC_SDRAM_RBURST_ENABLE +FMC.ReadBurst2=FMC_SDRAM_RBURST_ENABLE +FMC.ReadPipeDelay1=FMC_SDRAM_RPIPE_DELAY_0 +FMC.RowCycleDelay1=6 +FMC.RowCycleDelay2=6 +FMC.SDClockPeriod1=FMC_SDRAM_CLOCK_PERIOD_2 +FMC.SDClockPeriod2=FMC_SDRAM_CLOCK_PERIOD_2 +FMC.SelfRefreshTime1=4 +FMC.WriteRecoveryTime1=2 +FREERTOS.FootprintOK=true +FREERTOS.INCLUDE_vTaskDelayUntil=1 +FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configENABLE_BACKWARD_COMPATIBILITY,configUSE_MUTEXES,FootprintOK,MEMORY_ALLOCATION,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,INCLUDE_vTaskDelayUntil,configTOTAL_HEAP_SIZE,configENABLE_FPU +FREERTOS.MEMORY_ALLOCATION=2 +FREERTOS.Tasks01=defaultTask,0,512,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL +FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 +FREERTOS.configENABLE_BACKWARD_COMPATIBILITY=0 +FREERTOS.configENABLE_FPU=1 +FREERTOS.configTOTAL_HEAP_SIZE=4096 +FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 +FREERTOS.configUSE_MUTEXES=0 +FREERTOS.configUSE_PREEMPTION=0 +File.Version=6 +GPIO.groupedBy=Group By Peripherals +KeepUserPlacement=true +Mcu.Family=STM32F4 +Mcu.IP0=ADC3 +Mcu.IP1=DAC Mcu.IP10=SPI4 -NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:true -Mcu.IP12=TIM1 Mcu.IP11=SYS -FREERTOS.configENABLE_BACKWARD_COMPATIBILITY=0 -PC15/OSC32_OUT.GPIOParameters=GPIO_Label -Mcu.IP18=USB_OTG_FS -PH1/OSC_OUT.GPIO_Label=OSC2 -Mcu.IP17=USB_HOST -Mcu.IP19=USB_OTG_HS -Mcu.IP14=TIM4 +Mcu.IP12=TIM1 Mcu.IP13=TIM3 -Mcu.IP16=USB_DEVICE +Mcu.IP14=TIM4 Mcu.IP15=TIM13 -RCC.VCOInputFreq_Value=1000000 -PA14.Mode=Serial_Wire -TIM3.Prescaler=100 -PB2/BOOT1.GPIO_PuPd=GPIO_PULLUP -PF11.Signal=FMC_SDNRAS -PC11.GPIO_Label=LEDSW3 -PB5.Mode=SdramChipSelect2_1 -PE3.GPIOParameters=GPIO_Label -ADC3.DataAlign=ADC_DATAALIGN_RIGHT -SH.S_TIM3_CH1.0=TIM3_CH1,PWM Generation1 CH1 -PB0.Locked=true -PA13.GPIOParameters=GPIO_Label -USB_DEVICE.PRODUCT_STRING_AUDIO_FS=OWL-WITCH -Dma.ADC3.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -PA6.Signal=SPI1_MISO -PG11.Locked=true -Dma.SAI1_A.0.MemDataAlignment=DMA_MDATAALIGN_WORD -SH.FMC_D4_DA4.ConfNb=1 -NVIC.OTG_FS_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true -ProjectManager.ToolChainLocation= -PA15.Signal=GPIO_Output -PF8.Signal=S_TIM13_CH1 -Mcu.Pin95=VP_TIM13_VS_ClockSourceINT -Mcu.Pin96=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS -Mcu.Pin93=VP_RTC_VS_RTC_Activate -Mcu.Pin94=VP_SYS_VS_Systick -SH.ADCx_IN1.0=ADC3_IN1,IN1 -Mcu.Pin97=VP_USB_HOST_VS_USB_HOST_AUDIO_HS -Dma.Request2=ADC3 -Dma.Request1=SAI1_B -ADC3.Rank-32\#ChannelRegularConversion=2 -Dma.SAI1_B.1.PeriphInc=DMA_PINC_DISABLE -Mcu.Pin91=PE1 -Mcu.Pin92=VP_FREERTOS_VS_CMSIS_V1 -PG11.GPIO_Label=LEDSW4 -PC5.Signal=GPIO_Output -Mcu.Pin90=PE0 -PE7.Signal=FMC_D4_DA4 -PD6.Signal=SAI1_SD_A -SAI1.Synchro-SAI_A_AsyncSlave=SAI_ASYNCHRONOUS -Dma.Request0=SAI1_A -Dma.SAI1_B.1.Priority=DMA_PRIORITY_VERY_HIGH -PE2.GPIO_Label=CS_SCK -Mcu.Pin84=PG15 -Mcu.Pin85=PB3 +Mcu.IP16=USB_OTG_FS +Mcu.IP17=USB_OTG_HS +Mcu.IP2=DMA +Mcu.IP3=FMC +Mcu.IP4=FREERTOS +Mcu.IP5=NVIC +Mcu.IP6=RCC +Mcu.IP7=RTC +Mcu.IP8=SAI1 +Mcu.IP9=SPI1 +Mcu.IPNb=18 +Mcu.Name=STM32F427Z(G-I)Tx +Mcu.Package=LQFP144 +Mcu.Pin0=PE2 +Mcu.Pin1=PE3 +Mcu.Pin10=PF4 +Mcu.Pin11=PF5 +Mcu.Pin12=PF7 +Mcu.Pin13=PF8 +Mcu.Pin14=PF9 +Mcu.Pin15=PF10 +Mcu.Pin16=PH0/OSC_IN +Mcu.Pin17=PH1/OSC_OUT +Mcu.Pin18=PC0 +Mcu.Pin19=PC1 +Mcu.Pin2=PE4 +Mcu.Pin20=PC2 +Mcu.Pin21=PC3 +Mcu.Pin22=PA0/WKUP +Mcu.Pin23=PA1 +Mcu.Pin24=PA2 +Mcu.Pin25=PA3 +Mcu.Pin26=PA4 +Mcu.Pin27=PA5 +Mcu.Pin28=PA6 +Mcu.Pin29=PA7 +Mcu.Pin3=PE5 +Mcu.Pin30=PC4 +Mcu.Pin31=PC5 +Mcu.Pin32=PB0 +Mcu.Pin33=PB1 +Mcu.Pin34=PB2/BOOT1 +Mcu.Pin35=PF11 +Mcu.Pin36=PF12 +Mcu.Pin37=PF13 +Mcu.Pin38=PF14 +Mcu.Pin39=PF15 +Mcu.Pin4=PE6 +Mcu.Pin40=PG0 +Mcu.Pin41=PG1 +Mcu.Pin42=PE7 +Mcu.Pin43=PE8 +Mcu.Pin44=PE9 +Mcu.Pin45=PE10 +Mcu.Pin46=PE11 +Mcu.Pin47=PE12 +Mcu.Pin48=PE13 +Mcu.Pin49=PE14 +Mcu.Pin5=PC15/OSC32_OUT +Mcu.Pin50=PE15 +Mcu.Pin51=PB10 +Mcu.Pin52=PB11 +Mcu.Pin53=PB12 +Mcu.Pin54=PB13 +Mcu.Pin55=PB14 +Mcu.Pin56=PB15 +Mcu.Pin57=PD8 +Mcu.Pin58=PD9 +Mcu.Pin59=PD10 +Mcu.Pin6=PF0 +Mcu.Pin60=PD14 +Mcu.Pin61=PD15 +Mcu.Pin62=PG4 +Mcu.Pin63=PG5 +Mcu.Pin64=PG8 +Mcu.Pin65=PC6 +Mcu.Pin66=PC8 +Mcu.Pin67=PC9 +Mcu.Pin68=PA8 +Mcu.Pin69=PA9 +Mcu.Pin7=PF1 +Mcu.Pin70=PA11 +Mcu.Pin71=PA12 +Mcu.Pin72=PA13 +Mcu.Pin73=PA14 +Mcu.Pin74=PA15 +Mcu.Pin75=PC10 +Mcu.Pin76=PC11 +Mcu.Pin77=PC12 +Mcu.Pin78=PD0 +Mcu.Pin79=PD1 +Mcu.Pin8=PF2 +Mcu.Pin80=PD2 +Mcu.Pin81=PD6 Mcu.Pin82=PG9 Mcu.Pin83=PG11 -PA3.Signal=ADCx_IN3 -Mcu.Pin88=PB8 -Mcu.Pin89=PB9 +Mcu.Pin84=PG15 +Mcu.Pin85=PB3 Mcu.Pin86=PB5 Mcu.Pin87=PB6 -SH.FMC_A3.ConfNb=1 -VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate -ADC3.SamplingTime-31\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -RCC.I2SFreq_Value=96000000 -USB_HOST.IPParameters=USBH_HandleTypeDef-AUDIO_HS,VirtualModeHS,USBH_MAX_NUM_CONFIGURATION-AUDIO_HS,USBH_MAX_NUM_ENDPOINTS-AUDIO_HS,USBH_MAX_NUM_SUPPORTED_CLASS-AUDIO_HS,USBH_MAX_SIZE_CONFIGURATION-AUDIO_HS -Dma.ADC3.2.MemDataAlignment=DMA_MDATAALIGN_HALFWORD -SH.ADCx_IN13.0=ADC3_IN13,IN13 +Mcu.Pin88=PB8 +Mcu.Pin89=PB9 +Mcu.Pin9=PF3 +Mcu.Pin90=PE0 +Mcu.Pin91=PE1 +Mcu.Pin92=VP_FREERTOS_VS_CMSIS_V1 +Mcu.Pin93=VP_RTC_VS_RTC_Activate +Mcu.Pin94=VP_SYS_VS_Systick +Mcu.Pin95=VP_TIM13_VS_ClockSourceINT +Mcu.PinsNb=96 +Mcu.ThirdPartyNb=0 +Mcu.UserConstants= +Mcu.UserName=STM32F427ZITx +MxCube.Version=6.3.0 +MxDb.Version=DB.6.0.30 +NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.DMA2_Stream0_IRQn=true\:10\:0\:true\:false\:true\:false\:true\:true +NVIC.DMA2_Stream1_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true +NVIC.DMA2_Stream4_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true +NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.EXTI1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.EXTI2_IRQn=true\:5\:0\:false\:false\:true\:false\:true\:true +NVIC.EXTI9_5_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true +NVIC.ForceEnableDMAVector=true +NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.OTG_FS_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.OTG_HS_IRQn=true\:8\:0\:true\:false\:true\:false\:true\:true +NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false +NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 +NVIC.SAI1_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true +NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.SavedPendsvIrqHandlerGenerated=true +NVIC.SavedSvcallIrqHandlerGenerated=true +NVIC.SavedSystickIrqHandlerGenerated=true +NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:true\:true +NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +PA0/WKUP.Signal=ADCx_IN0 +PA1.Signal=ADCx_IN1 +PA11.Mode=Device_Only +PA11.Signal=USB_OTG_FS_DM +PA12.Mode=Device_Only +PA12.Signal=USB_OTG_FS_DP +PA13.GPIOParameters=GPIO_Label +PA13.GPIO_Label=SWDIO +PA13.Mode=Serial_Wire +PA13.Signal=SYS_JTMS-SWDIO +PA14.GPIOParameters=GPIO_Label +PA14.GPIO_Label=SWCLK +PA14.Mode=Serial_Wire +PA14.Signal=SYS_JTCK-SWCLK +PA15.GPIOParameters=GPIO_Label +PA15.GPIO_Label=LEDSW1 +PA15.Locked=true +PA15.Signal=GPIO_Output +PA2.Signal=ADCx_IN2 +PA3.Signal=ADCx_IN3 +PA4.GPIOParameters=GPIO_Label +PA4.GPIO_Label=DAC1 +PA4.Locked=true +PA4.Signal=COMP_DAC1_group +PA5.GPIOParameters=GPIO_Label +PA5.GPIO_Label=DAC2 +PA5.Locked=true +PA5.Signal=COMP_DAC2_group +PA6.GPIOParameters=GPIO_Label +PA6.GPIO_Label=FLASH_MISO +PA6.Mode=Full_Duplex_Master +PA6.Signal=SPI1_MISO +PA7.GPIOParameters=GPIO_Label +PA7.GPIO_Label=FLASH_MOSI +PA7.Mode=Full_Duplex_Master +PA7.Signal=SPI1_MOSI +PA8.GPIOParameters=GPIO_Label +PA8.GPIO_Label=LEDPWM6 +PA8.Locked=true +PA8.Signal=S_TIM1_CH1 +PA9.Mode=Activate_VBUS +PA9.Signal=USB_OTG_FS_VBUS +PB0.GPIOParameters=GPIO_Label +PB0.GPIO_Label=FLASH_WP +PB0.Locked=true +PB0.Signal=GPIO_Output +PB1.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PB1.GPIO_Label=SW2 +PB1.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PB1.GPIO_PuPd=GPIO_PULLUP +PB1.Locked=true +PB1.Signal=GPXTI1 +PB10.GPIOParameters=GPIO_Label +PB10.GPIO_Label=CS_CS +PB10.Locked=true +PB10.Signal=GPIO_Output +PB11.GPIOParameters=GPIO_Label +PB11.GPIO_Label=CS_RST +PB11.Locked=true +PB11.Signal=GPIO_Output +PB12.GPIOParameters=GPIO_Label +PB12.GPIO_Label=LEDPWM +PB12.Locked=true +PB12.Signal=GPIO_Output +PB13.GPIOParameters=GPIO_Label +PB13.GPIO_Label=USBH_PWR_FAULT +PB13.Locked=true +PB13.Signal=GPIO_Input +PB14.Mode=Host_FS +PB14.Signal=USB_OTG_HS_DM +PB15.Mode=Host_FS +PB15.Signal=USB_OTG_HS_DP +PB2/BOOT1.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PB2/BOOT1.GPIO_Label=SW1 +PB2/BOOT1.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PB2/BOOT1.GPIO_PuPd=GPIO_PULLUP +PB2/BOOT1.Locked=true +PB2/BOOT1.Signal=GPXTI2 +PB3.GPIOParameters=GPIO_Label +PB3.GPIO_Label=FLASH_SCK +PB3.Locked=true +PB3.Mode=Full_Duplex_Master +PB3.Signal=SPI1_SCK +PB5.Mode=SdramChipSelect2_1 +PB5.Signal=FMC_SDCKE1 +PB6.Mode=SdramChipSelect2_1 +PB6.Signal=FMC_SDNE1 PB8.GPIOParameters=GPIO_Label -Dma.SAI1_B.1.Mode=DMA_CIRCULAR -RCC.UART7Freq_Value=54000000 -PC9.GPIO_Label=LEDPWM5 -NVIC.SavedSvcallIrqHandlerGenerated=true -Dma.SAI1_A.0.Direction=DMA_MEMORY_TO_PERIPH -PC11.Signal=GPIO_Output -PC8.Signal=S_TIM3_CH3 -ProjectManager.DefaultFWLocation=true -PD9.Signal=FMC_D14_DA14 -ADC3.SamplingTime-39\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -PB12.Locked=true -ProjectManager.DeletePrevious=true -USB_HOST.USBH_MAX_NUM_SUPPORTED_CLASS-AUDIO_HS=4 -PB10.Locked=true -RCC.LCDTFToutputFreq_Value=25000000 -SH.S_TIM3_CH3.0=TIM3_CH3,PWM Generation3 CH3 -USB_DEVICE.IPParameters=VirtualMode-AUDIO_FS,VirtualModeFS,CLASS_NAME_FS,VID-AUDIO_FS,PID_AUDIO_FS,MANUFACTURER_STRING-AUDIO_FS,PRODUCT_STRING_AUDIO_FS -RCC.FamilyName=M +PB8.GPIO_Label=LEDPWM3 +PB8.Locked=true +PB8.Signal=S_TIM4_CH3 PB9.GPIOParameters=GPIO_PuPd,GPIO_Label -PA13.Signal=SYS_JTMS-SWDIO -VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 -PA9.Mode=Activate_VBUS -SH.FMC_A15_BA1.ConfNb=1 -PB2/BOOT1.Signal=GPXTI2 -SH.S_TIM1_CH1.0=TIM1_CH1,PWM Generation1 CH1 -ADC3.SamplingTime-34\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -PB10.GPIO_Label=CS_CS -Dma.SAI1_A.0.Mode=DMA_CIRCULAR -SH.S_TIM13_CH1.ConfNb=1 -SH.FMC_D13_DA13.0=FMC_D13,sd-16b-d1 -SH.S_TIM4_CH3.0=TIM4_CH3,PWM Generation3 CH3 -PC5.GPIOParameters=GPIO_Label -PE2.GPIOParameters=GPIO_Label -RCC.USBFreq_Value=48000000 -PF9.GPIO_Label=SW5 -TIM4.Prescaler=100 -PA1.Signal=ADCx_IN1 -SAI1.FSDefinition-SAI_A_AsyncSlave=SAI_FS_CHANNEL_IDENTIFICATION -SH.S_TIM4_CH3.ConfNb=1 -RCC.VCOI2SOutputFreq_Value=192000000 -RCC.PLLSAIPCLKFreq_Value=50000000 -board=Witch -RCC.VCOOutputFreq_Value=336000000 -PB15.Mode=Host_FS -RCC.UART4Freq_Value=54000000 -SH.ADCx_IN11.0=ADC3_IN11,IN11 -MxCube.Version=6.0.1 -SH.ADCx_IN2.ConfNb=1 -PE5.Mode=SAI_A_AsyncSlave +PB9.GPIO_Label=SW4 +PB9.GPIO_PuPd=GPIO_PULLUP +PB9.Locked=true +PB9.Signal=GPIO_Input +PC0.Signal=FMC_SDNWE +PC1.GPIOParameters=GPIO_Label PC1.GPIO_Label=ADC3 -VP_SYS_VS_Systick.Mode=SysTick -SH.FMC_D12_DA12.0=FMC_D12,sd-16b-d1 -PF1.Signal=FMC_A1 -VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_FS -VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Mode=AUDIO_FS -SH.FMC_D11_DA11.ConfNb=1 -RCC.UART5Freq_Value=54000000 -RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CECFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SClocksFreq_Value,I2SFreq_Value,LCDTFToutputFreq_Value,LPTIM1Freq_Value,LSE_VALUE,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLI2SPCLKFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLI2SRoutputFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLQoutputFreq_Value,PLLSAIN,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIRCLKFreq_Value,PLLSAIoutputFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SAI1Freq_Value,SAI2Freq_Value,SAI_AClocksFreq_Value,SAI_BClocksFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,UART4Freq_Value,UART5Freq_Value,UART7Freq_Value,UART8Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USART6Freq_Value,USBFreq_Value,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value,VCOSAIOutputFreq_ValueQ,VcooutputI2S,VcooutputI2SQ -ProjectManager.AskForMigrate=true -PE0.Signal=FMC_NBL0 -PE12.Signal=FMC_D9_DA9 -NVIC.SavedPendsvIrqHandlerGenerated=true -Mcu.IP8=SAI1 -Mcu.IP9=SPI1 -Mcu.IP6=RCC -Mcu.IP7=RTC -ProjectManager.CoupleFile=false -RCC.48MHZClocksFreq_Value=48000000 -RCC.SYSCLKFreq_VALUE=168000000 -ADC3.Channel-38\#ChannelRegularConversion=ADC_CHANNEL_3 -KeepUserPlacement=true -USB_HOST.USBH_MAX_SIZE_CONFIGURATION-AUDIO_HS=512 -SH.GPXTI9.ConfNb=1 -NVIC.EXTI9_5_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -ADC3.Rank-35\#ChannelRegularConversion=5 -PC6.GPIOParameters=GPIO_Label -RCC.HSI_VALUE=16000000 -PH0/OSC_IN.GPIO_Label=OSC1 -SH.S_TIM3_CH4.ConfNb=1 -RCC.PLLQ=7 -RCC.PLLM=25 -RCC.PLLN=336 -PB2/BOOT1.Locked=true -PC8.Locked=true -SH.FMC_D8_DA8.ConfNb=1 -ADC3.NbrOfConversionFlag=1 -Dma.ADC3.2.FIFOMode=DMA_FIFOMODE_DISABLE -PB12.Signal=GPIO_Output -PG11.GPIOParameters=GPIO_Label -USB_OTG_HS.VirtualMode-Host_FS=Host_FS -SH.FMC_D7_DA7.0=FMC_D7,sd-16b-d1 -RCC.USART1Freq_Value=108000000 -SH.FMC_A4.ConfNb=1 -SPI4.VirtualType=VM_MASTER -SAI1.VirtualMode-SAI_A_AsyncSlave=VM_SLAVE -USB_HOST.USBH_MAX_NUM_ENDPOINTS-AUDIO_HS=10 -FMC.RCDDelay1=2 -SPI1.VirtualType=VM_MASTER +PC1.Locked=true +PC1.Signal=ADCx_IN11 +PC10.GPIOParameters=GPIO_Label +PC10.GPIO_Label=LEDSW2 +PC10.Locked=true +PC10.Signal=GPIO_Output +PC11.GPIOParameters=GPIO_Label +PC11.GPIO_Label=LEDSW3 +PC11.Locked=true +PC11.Signal=GPIO_Output +PC12.GPIOParameters=GPIO_Label +PC12.GPIO_Label=TR_OUT1 PC12.Locked=true -TIM1.IPParameters=Channel-PWM Generation1 CH1,Prescaler,Period -SH.GPXTI9.0=GPIO_EXTI9 -PG4.Signal=FMC_A14_BA0 -RCC.PLLCLKFreq_Value=168000000 PC12.Signal=GPIO_Output -PA14.GPIO_Label=SWCLK -FMC.LoadToActiveDelay1=2 -PC6.GPIO_Label=LEDPWM1 -VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled +PC15/OSC32_OUT.GPIOParameters=GPIO_Label +PC15/OSC32_OUT.GPIO_Label=EXTSPI_nCS +PC15/OSC32_OUT.Locked=true +PC15/OSC32_OUT.Signal=GPIO_Output +PC2.GPIOParameters=GPIO_Label +PC2.GPIO_Label=ADC2 +PC2.Locked=true +PC2.Signal=ADCx_IN12 +PC3.GPIOParameters=GPIO_Label +PC3.GPIO_Label=ADC1 PC3.Locked=true -PA6.GPIO_Label=FLASH_MISO -PB13.Signal=GPIO_Input -PD6.GPIO_Label=CS_SDIN -PinOutPanel.RotationAngle=0 -TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4 -PE6.GPIO_Label=CS_SDA -RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK -SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 -PE2.Mode=TX_Only_Simplex_Unidirect_Master -PB2/BOOT1.GPIO_Label=SW1 -SH.FMC_D10_DA10.ConfNb=1 -PB6.Mode=SdramChipSelect2_1 -PH1/OSC_OUT.Signal=RCC_OSC_OUT PC3.Signal=ADCx_IN13 -RCC.SAI2Freq_Value=50000000 -PE5.Signal=SAI1_SCK_A -PF10.GPIO_Label=ADC4 -PB13.Locked=true -Dma.SAI1_B.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD -PA4.Locked=true -ADC3.ExternalTrigConv=ADC_SOFTWARE_START -MxDb.Version=DB.6.0.0 -PB0.GPIOParameters=GPIO_Label -SAI1.SlotNumber-SAI_A_AsyncSlave=2 -SH.ADCx_IN1.ConfNb=1 -ADC3.Channel-37\#ChannelRegularConversion=ADC_CHANNEL_2 -SH.FMC_D15_DA15.ConfNb=1 -ADC3.ContinuousConvMode=ENABLE -Dma.ADC3.2.Direction=DMA_PERIPH_TO_MEMORY -ADC3.Rank-36\#ChannelRegularConversion=6 -ADC3.IPParameters=Rank-31\#ChannelRegularConversion,Channel-31\#ChannelRegularConversion,SamplingTime-31\#ChannelRegularConversion,NbrOfConversionFlag,ScanConvMode,ContinuousConvMode,DMAContinuousRequests,EOCSelection,InjNumberOfConversion,EnableAnalogWatchDog,ExternalTrigConv,Rank-32\#ChannelRegularConversion,Channel-32\#ChannelRegularConversion,SamplingTime-32\#ChannelRegularConversion,Rank-33\#ChannelRegularConversion,Channel-33\#ChannelRegularConversion,SamplingTime-33\#ChannelRegularConversion,Rank-34\#ChannelRegularConversion,Channel-34\#ChannelRegularConversion,SamplingTime-34\#ChannelRegularConversion,NbrOfConversion,ClockPrescaler,Resolution,DataAlign,DiscontinuousConvMode,ExternalTrigConvEdge,Rank-35\#ChannelRegularConversion,Channel-35\#ChannelRegularConversion,SamplingTime-35\#ChannelRegularConversion,Rank-36\#ChannelRegularConversion,Channel-36\#ChannelRegularConversion,SamplingTime-36\#ChannelRegularConversion,Rank-37\#ChannelRegularConversion,Channel-37\#ChannelRegularConversion,SamplingTime-37\#ChannelRegularConversion,Rank-38\#ChannelRegularConversion,Channel-38\#ChannelRegularConversion,SamplingTime-38\#ChannelRegularConversion,Rank-39\#ChannelRegularConversion,Channel-39\#ChannelRegularConversion,SamplingTime-39\#ChannelRegularConversion -SH.ADCx_IN11.ConfNb=1 -PE2.Signal=SPI4_SCK -NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false -TIM4.Period=1023 -PF3.Signal=FMC_A3 -NVIC.SAI1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -PE10.Signal=FMC_D7_DA7 -RCC.MCO2PinFreq_Value=168000000 -PC8.GPIOParameters=GPIO_Label -PF8.GPIOParameters=GPIO_Label -SH.COMP_DAC1_group.ConfNb=1 -PA5.GPIOParameters=GPIO_Label -SH.FMC_A1.0=FMC_A1,12b-sda1 -SH.FMC_SDCLK.0=FMC_SDCLK,12b-sda1 -RCC.CECFreq_Value=32786.88524590164 -ADC3.ExternalTrigConvEdge=ADC_EXTERNALTRIGCONVEDGE_NONE -PF14.Signal=FMC_A8 -NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -TIM1.Period=1023 -PB10.GPIOParameters=GPIO_Label -SH.FMC_D3_DA3.0=FMC_D3,sd-16b-d1 -ProjectManager.CustomerFirmwarePackage= PC4.GPIOParameters=GPIO_Label -RCC.SAI_AClocksFreq_Value=25000000 -SH.COMP_DAC2_group.ConfNb=1 -SH.FMC_A7.ConfNb=1 -RCC.PLLQoutputFreq_Value=48000000 -SH.FMC_A1.ConfNb=1 -PA15.GPIOParameters=GPIO_Label -PG9.GPIO_PuPd=GPIO_PULLUP -PG9.Locked=true -PG9.Signal=GPXTI9 -FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 +PC4.GPIO_Label=FLASH_HOLD +PC4.Locked=true +PC4.Signal=GPIO_Output +PC5.GPIOParameters=GPIO_Label +PC5.GPIO_Label=FLASH_nCS +PC5.Locked=true +PC5.Signal=GPIO_Output +PC6.GPIOParameters=GPIO_Label +PC6.GPIO_Label=LEDPWM1 +PC6.Locked=true PC6.Signal=S_TIM3_CH1 -PB11.GPIO_Label=CS_RST +PC8.GPIOParameters=GPIO_Label +PC8.GPIO_Label=LEDPWM2 +PC8.Locked=true +PC8.Signal=S_TIM3_CH3 +PC9.GPIOParameters=GPIO_Label +PC9.GPIO_Label=LEDPWM5 +PC9.Locked=true +PC9.Signal=S_TIM3_CH4 +PD0.Signal=FMC_D2_DA2 PD1.Signal=FMC_D3_DA3 -NVIC.DMA2_Stream1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -RCC.UART8Freq_Value=54000000 -PC0.Signal=FMC_SDNWE -RCC.APB1CLKDivider=RCC_HCLK_DIV4 -PC11.GPIOParameters=GPIO_Label -ADC3.Channel-31\#ChannelRegularConversion=ADC_CHANNEL_13 -ADC3.Resolution=ADC_RESOLUTION_12B -TIM3.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3 -SH.FMC_A3.0=FMC_A3,12b-sda1 -FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_3 -TIM13.Channel=TIM_CHANNEL_1 -TIM4.IPParameters=Channel-PWM Generation3 CH3,Prescaler,Period -SH.FMC_D15_DA15.0=FMC_D15,sd-16b-d1 -USB_HOST.VirtualModeHS=Audio -PC6.Locked=true -PA9.Signal=USB_OTG_FS_VBUS -Dma.ADC3.2.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD -ADC3.NbrOfConversion=9 -PB10.Signal=GPIO_Output -Dma.ADC3.2.Mode=DMA_CIRCULAR -FREERTOS.MEMORY_ALLOCATION=2 -ProjectManager.LastFirmware=true -Dma.SAI1_A.0.PeriphInc=DMA_PINC_DISABLE -VP_TIM13_VS_ClockSourceINT.Mode=Enable_Timer +PD10.Signal=FMC_D15_DA15 +PD14.Signal=FMC_D0_DA0 +PD15.Signal=FMC_D1_DA1 +PD2.GPIOParameters=GPIO_Label +PD2.GPIO_Label=TR_OUT2 +PD2.Locked=true +PD2.Signal=GPIO_Output +PD6.GPIOParameters=GPIO_Label +PD6.GPIO_Label=CS_SDIN +PD6.Mode=SAI_A_AsyncSlave +PD6.Signal=SAI1_SD_A +PD8.Signal=FMC_D13_DA13 +PD9.Signal=FMC_D14_DA14 +PE0.Signal=FMC_NBL0 +PE1.Signal=FMC_NBL1 +PE10.Signal=FMC_D7_DA7 +PE11.Signal=FMC_D8_DA8 +PE12.Signal=FMC_D9_DA9 +PE13.Signal=FMC_D10_DA10 +PE14.Signal=FMC_D11_DA11 PE15.Signal=FMC_D12_DA12 -TIM13.Prescaler=100 +PE2.GPIOParameters=GPIO_Label +PE2.GPIO_Label=CS_SCK +PE2.Mode=TX_Only_Simplex_Unidirect_Master +PE2.Signal=SPI4_SCK +PE3.GPIOParameters=GPIO_Label +PE3.GPIO_Label=CS_SDOUT +PE3.Mode=SAI_B_SyncSlave +PE3.Signal=SAI1_SD_B +PE4.GPIOParameters=GPIO_Label +PE4.GPIO_Label=CS_LRCK +PE4.Mode=SAI_A_AsyncSlave +PE4.Signal=SAI1_FS_A +PE5.GPIOParameters=GPIO_Label +PE5.GPIO_Label=CS_SCK +PE5.Mode=SAI_A_AsyncSlave +PE5.Signal=SAI1_SCK_A +PE6.GPIOParameters=GPIO_Label +PE6.GPIO_Label=CS_SDA +PE6.Mode=TX_Only_Simplex_Unidirect_Master +PE6.Signal=SPI4_MOSI +PE7.Signal=FMC_D4_DA4 PE8.Signal=FMC_D5_DA5 -PC2.GPIOParameters=GPIO_Label -RCC.EthernetFreq_Value=168000000 -TIM3.IPParameters=Channel-PWM Generation4 CH4,Channel-PWM Generation3 CH3,Channel-PWM Generation1 CH1,Prescaler,Period -ADC3.SamplingTime-33\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -PA13.Mode=Serial_Wire -SH.FMC_SDNCAS.0=FMC_SDNCAS,12b-sda1 -ProjectManager.FreePins=true -SH.FMC_NBL1.ConfNb=1 -RCC.RTCHSEDivFreq_Value=12500000 -ProjectManager.UnderRoot=false -SH.FMC_D7_DA7.ConfNb=1 -Dma.SAI1_B.1.MemDataAlignment=DMA_MDATAALIGN_WORD -PA4.Signal=COMP_DAC1_group -PB5.Signal=FMC_SDCKE1 -ADC3.Rank-37\#ChannelRegularConversion=7 -SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX -SH.FMC_A10.ConfNb=1 -ProjectManager.CompilerOptimize=6 -SH.FMC_A5.0=FMC_A5,12b-sda1 -PA11.Signal=USB_OTG_FS_DM -ADC3.Channel-36\#ChannelRegularConversion=ADC_CHANNEL_1 +PE9.Signal=FMC_D6_DA6 +PF0.Signal=FMC_A0 +PF1.Signal=FMC_A1 +PF10.GPIOParameters=GPIO_Label +PF10.GPIO_Label=ADC4 +PF10.Locked=true +PF10.Mode=IN8 +PF10.Signal=ADC3_IN8 +PF11.Signal=FMC_SDNRAS +PF12.Signal=FMC_A6 +PF13.Signal=FMC_A7 +PF14.Signal=FMC_A8 +PF15.Signal=FMC_A9 +PF2.Signal=FMC_A2 +PF3.Signal=FMC_A3 +PF4.Signal=FMC_A4 +PF5.Signal=FMC_A5 +PF7.Locked=true +PF7.Mode=IN5 +PF7.Signal=ADC3_IN5 +PF8.GPIOParameters=GPIO_Label +PF8.GPIO_Label=LEDPWM4 PF8.Locked=true -SH.S_TIM3_CH1.ConfNb=1 -ProjectManager.ComputerToolchain=false +PF8.Signal=S_TIM13_CH1 +PF9.GPIOParameters=GPIO_PuPd,GPIO_Label +PF9.GPIO_Label=SW5 +PF9.GPIO_PuPd=GPIO_PULLUP +PF9.Locked=true PF9.Signal=GPIO_Input -PB2/BOOT1.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -PC3.GPIO_Label=ADC1 -SH.FMC_D12_DA12.ConfNb=1 -RCC.I2C2Freq_Value=54000000 -PB0.Signal=GPIO_Output -SAI1.SlotSize-SAI_B_SyncSlave=SAI_SLOTSIZE_32B -Dma.SAI1_A.0.FIFOMode=DMA_FIFOMODE_DISABLE -PA7.GPIOParameters=GPIO_Label -PC1.Signal=ADCx_IN11 -PB12.GPIOParameters=GPIO_Label -Dma.SAI1_A.0.Instance=DMA2_Stream1 -PD2.GPIO_Label=TR_OUT2 -Dma.SAI1_A.0.PeriphDataAlignment=DMA_PDATAALIGN_WORD +PG0.Signal=FMC_A10 +PG1.Signal=FMC_A11 +PG11.GPIOParameters=GPIO_Label +PG11.GPIO_Label=LEDSW4 +PG11.Locked=true +PG11.Signal=GPIO_Output +PG15.Signal=FMC_SDNCAS +PG4.Signal=FMC_A14_BA0 +PG5.Signal=FMC_A15_BA1 +PG8.Signal=FMC_SDCLK +PG9.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PG9.GPIO_Label=SW3 +PG9.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PG9.GPIO_PuPd=GPIO_PULLUP +PG9.Locked=true +PG9.Signal=GPXTI9 PH0/OSC_IN.GPIOParameters=GPIO_Label -Dma.SAI1_A.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -SH.GPXTI1.0=GPIO_EXTI1 -RCC.SAI1Freq_Value=50000000 -RCC.CortexFreq_Value=168000000 -SH.FMC_A2.ConfNb=1 -Mcu.UserName=STM32F427ZITx -SH.ADCx_IN2.0=ADC3_IN2,IN2 -PC10.Locked=true -PC10.Signal=GPIO_Output -SPI4.Direction=SPI_DIRECTION_2LINES -SH.FMC_NBL0.0=FMC_NBL0,Sd2ByteEnable1 -ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI4_Init-SPI4-false-HAL-true,7-SystemClock_Config-RCC-false-HAL-true,8-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,9-MX_DAC_Init-DAC-false-HAL-true,10-MX_SPI1_Init-SPI1-false-HAL-true,11-MX_RTC_Init-RTC-false-HAL-true,12-MX_USB_HOST_Init-USB_HOST-false-HAL-false,13-MX_TIM1_Init-TIM1-false-HAL-true,14-MX_TIM3_Init-TIM3-false-HAL-true,15-MX_TIM4_Init-TIM4-false-HAL-true,16-MX_TIM13_Init-TIM13-false-HAL-true -ADC3.SamplingTime-38\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -SH.FMC_D6_DA6.0=FMC_D6,sd-16b-d1 -PA0/WKUP.Signal=ADCx_IN0 -PC9.Locked=true -PB0.GPIO_Label=FLASH_WP -RCC.PLLI2SRCLKFreq_Value=96000000 -ADC3.SamplingTime-35\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -RCC.USART2Freq_Value=54000000 -PB11.Signal=GPIO_Output -ADC3.Channel-32\#ChannelRegularConversion=ADC_CHANNEL_12 -PE5.GPIOParameters=GPIO_Label -ProjectManager.StackSize=0x400 -RCC.SAI_BClocksFreq_Value=25000000 -ADC3.SamplingTime-32\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -RCC.I2C3Freq_Value=54000000 -USB_HOST.USBH_HandleTypeDef-AUDIO_HS=hUsbHostHS -SH.FMC_A7.0=FMC_A7,12b-sda1 -PA12.Signal=USB_OTG_FS_DP -Mcu.UserConstants= -SPI4.Mode=SPI_MODE_MASTER -PC1.GPIOParameters=GPIO_Label -Mcu.ThirdPartyNb=0 +PH0/OSC_IN.GPIO_Label=OSC1 PH0/OSC_IN.Mode=HSE-External-Oscillator +PH0/OSC_IN.Signal=RCC_OSC_IN +PH1/OSC_OUT.GPIOParameters=GPIO_Label +PH1/OSC_OUT.GPIO_Label=OSC2 +PH1/OSC_OUT.Mode=HSE-External-Oscillator +PH1/OSC_OUT.Signal=RCC_OSC_OUT +PinOutPanel.RotationAngle=0 +ProjectManager.AskForMigrate=true +ProjectManager.BackupPrevious=false +ProjectManager.CompilerOptimize=6 +ProjectManager.ComputerToolchain=false +ProjectManager.CoupleFile=false +ProjectManager.CustomerFirmwarePackage= +ProjectManager.DefaultFWLocation=true +ProjectManager.DeletePrevious=true +ProjectManager.DeviceId=STM32F427ZITx +ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.26.2 +ProjectManager.FreePins=true +ProjectManager.HalAssertFull=true +ProjectManager.HeapSize=0x200 +ProjectManager.KeepUserCode=true +ProjectManager.LastFirmware=true +ProjectManager.LibraryCopy=1 +ProjectManager.MainLocation=Src +ProjectManager.NoMain=false +ProjectManager.PreviousToolchain=TrueSTUDIO +ProjectManager.ProjectBuild=false +ProjectManager.ProjectFileName=Witch.ioc +ProjectManager.ProjectName=Witch +ProjectManager.RegisterCallBack= +ProjectManager.StackSize=0x400 +ProjectManager.TargetToolchain=Makefile +ProjectManager.ToolChainLocation= +ProjectManager.UnderRoot=false +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI4_Init-SPI4-false-HAL-true,7-SystemClock_Config-RCC-false-HAL-true,8-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,9-MX_DAC_Init-DAC-false-HAL-true,10-MX_SPI1_Init-SPI1-false-HAL-true,11-MX_RTC_Init-RTC-false-HAL-true,12-MX_USB_HOST_Init-USB_HOST-false-HAL-false,13-MX_TIM1_Init-TIM1-false-HAL-true,14-MX_TIM3_Init-TIM3-false-HAL-true,15-MX_TIM4_Init-TIM4-false-HAL-true,16-MX_TIM13_Init-TIM13-false-HAL-true +RCC.48MHZClocksFreq_Value=48000000 +RCC.AHBFreq_Value=168000000 +RCC.APB1CLKDivider=RCC_HCLK_DIV4 +RCC.APB1Freq_Value=42000000 +RCC.APB1TimFreq_Value=84000000 +RCC.APB2CLKDivider=RCC_HCLK_DIV2 +RCC.APB2Freq_Value=84000000 +RCC.APB2TimFreq_Value=168000000 +RCC.CECFreq_Value=32786.88524590164 +RCC.CortexFreq_Value=168000000 +RCC.EthernetFreq_Value=168000000 +RCC.FCLKCortexFreq_Value=168000000 +RCC.FamilyName=M RCC.HCLKFreq_Value=168000000 -Mcu.IPNb=20 +RCC.HSE_VALUE=25000000 +RCC.HSI_VALUE=16000000 +RCC.I2C1Freq_Value=54000000 +RCC.I2C2Freq_Value=54000000 +RCC.I2C3Freq_Value=54000000 +RCC.I2C4Freq_Value=54000000 RCC.I2SClocksFreq_Value=96000000 +RCC.I2SFreq_Value=96000000 +RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CECFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SClocksFreq_Value,I2SFreq_Value,LCDTFToutputFreq_Value,LPTIM1Freq_Value,LSE_VALUE,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLI2SPCLKFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLI2SRoutputFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLQoutputFreq_Value,PLLSAIN,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIRCLKFreq_Value,PLLSAIoutputFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SAI1Freq_Value,SAI2Freq_Value,SAI_AClocksFreq_Value,SAI_BClocksFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,UART4Freq_Value,UART5Freq_Value,UART7Freq_Value,UART8Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USART6Freq_Value,USBFreq_Value,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value,VCOSAIOutputFreq_ValueQ,VcooutputI2S,VcooutputI2SQ +RCC.LCDTFToutputFreq_Value=25000000 +RCC.LPTIM1Freq_Value=54000000 +RCC.LSE_VALUE=32768 +RCC.LSI_VALUE=32000 +RCC.MCO2PinFreq_Value=168000000 +RCC.PLLCLKFreq_Value=168000000 +RCC.PLLI2SPCLKFreq_Value=96000000 +RCC.PLLI2SQCLKFreq_Value=96000000 +RCC.PLLI2SRCLKFreq_Value=96000000 RCC.PLLI2SRoutputFreq_Value=96000000 +RCC.PLLM=25 +RCC.PLLN=336 +RCC.PLLQ=7 +RCC.PLLQCLKFreq_Value=48000000 +RCC.PLLQoutputFreq_Value=48000000 +RCC.PLLSAIN=100 +RCC.PLLSAIPCLKFreq_Value=50000000 +RCC.PLLSAIQCLKFreq_Value=50000000 +RCC.PLLSAIRCLKFreq_Value=50000000 +RCC.PLLSAIoutputFreq_Value=50000000 +RCC.RTCFreq_Value=32000 +RCC.RTCHSEDivFreq_Value=12500000 +RCC.SAI1Freq_Value=50000000 +RCC.SAI2Freq_Value=50000000 +RCC.SAI_AClocksFreq_Value=25000000 +RCC.SAI_BClocksFreq_Value=25000000 +RCC.SDMMCFreq_Value=216000000 RCC.SPDIFRXFreq_Value=96000000 -PB1.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +RCC.SYSCLKFreq_VALUE=168000000 +RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK +RCC.UART4Freq_Value=54000000 +RCC.UART5Freq_Value=54000000 +RCC.UART7Freq_Value=54000000 +RCC.UART8Freq_Value=54000000 +RCC.USART1Freq_Value=108000000 +RCC.USART2Freq_Value=54000000 +RCC.USART3Freq_Value=54000000 +RCC.USART6Freq_Value=108000000 +RCC.USBFreq_Value=48000000 +RCC.VCOI2SOutputFreq_Value=192000000 +RCC.VCOInputFreq_Value=1000000 +RCC.VCOOutputFreq_Value=336000000 +RCC.VCOSAIOutputFreq_Value=100000000 +RCC.VCOSAIOutputFreq_ValueQ=25000000 +RCC.VcooutputI2S=96000000 +RCC.VcooutputI2SQ=96000000 +SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX +SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_RX +SAI1.DataSize-SAI_A_AsyncSlave=SAI_DATASIZE_24 +SAI1.FSDefinition-SAI_A_AsyncSlave=SAI_FS_CHANNEL_IDENTIFICATION +SAI1.FSDefinition-SAI_B_SyncSlave=SAI_FS_CHANNEL_IDENTIFICATION +SAI1.FrameLength-SAI_A_AsyncSlave=64 +SAI1.FrameLength-SAI_B_SyncSlave=64 +SAI1.IPParameters=Instance-SAI_A_AsyncSlave,VirtualMode-SAI_A_AsyncSlave,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,Synchro-SAI_B_SyncSlave,FrameLength-SAI_B_SyncSlave,SlotSize-SAI_B_SyncSlave,AudioMode-SAI_B_SyncSlave,AudioMode-SAI_A_AsyncSlave,DataSize-SAI_A_AsyncSlave,FrameLength-SAI_A_AsyncSlave,SlotSize-SAI_A_AsyncSlave,SlotNumber-SAI_A_AsyncSlave,FSDefinition-SAI_A_AsyncSlave,FSDefinition-SAI_B_SyncSlave,Synchro-SAI_A_AsyncSlave,Synchro_A,Synchro_B +SAI1.Instance-SAI_A_AsyncSlave=SAI$Index_Block_A +SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B +SAI1.SlotNumber-SAI_A_AsyncSlave=2 +SAI1.SlotSize-SAI_A_AsyncSlave=SAI_SLOTSIZE_32B +SAI1.SlotSize-SAI_B_SyncSlave=SAI_SLOTSIZE_32B +SAI1.Synchro-SAI_A_AsyncSlave=SAI_ASYNCHRONOUS +SAI1.Synchro-SAI_B_SyncSlave=SAI_SYNCHRONOUS +SAI1.Synchro_A=SAI_ASYNCHRONOUS +SAI1.Synchro_B=SAI_SYNCHRONOUS +SAI1.VirtualMode-SAI_A_AsyncSlave=VM_SLAVE +SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE +SH.ADCx_IN0.0=ADC3_IN0,IN0 +SH.ADCx_IN0.ConfNb=1 +SH.ADCx_IN1.0=ADC3_IN1,IN1 +SH.ADCx_IN1.ConfNb=1 +SH.ADCx_IN11.0=ADC3_IN11,IN11 +SH.ADCx_IN11.ConfNb=1 +SH.ADCx_IN12.0=ADC3_IN12,IN12 +SH.ADCx_IN12.ConfNb=1 +SH.ADCx_IN13.0=ADC3_IN13,IN13 +SH.ADCx_IN13.ConfNb=1 +SH.ADCx_IN2.0=ADC3_IN2,IN2 +SH.ADCx_IN2.ConfNb=1 +SH.ADCx_IN3.0=ADC3_IN3,IN3 SH.ADCx_IN3.ConfNb=1 -PF12.Signal=FMC_A6 -FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 -Mcu.Pin6=PF0 -Mcu.Pin7=PF1 -NVIC.DMA2_Stream0_IRQn=true\:10\:0\:true\:false\:true\:true\:true\:true -Mcu.Pin8=PF2 -Mcu.Pin9=PF3 -RCC.VCOSAIOutputFreq_Value=100000000 +SH.COMP_DAC1_group.0=DAC_OUT1,DAC_OUT1 +SH.COMP_DAC1_group.ConfNb=1 +SH.COMP_DAC2_group.0=DAC_OUT2,DAC_OUT2 +SH.COMP_DAC2_group.ConfNb=1 +SH.FMC_A0.0=FMC_A0,12b-sda1 +SH.FMC_A0.ConfNb=1 +SH.FMC_A1.0=FMC_A1,12b-sda1 +SH.FMC_A1.ConfNb=1 SH.FMC_A10.0=FMC_A10,12b-sda1 -RCC.AHBFreq_Value=168000000 -Mcu.Pin0=PE2 -Mcu.Pin1=PE3 -GPIO.groupedBy=Group By Peripherals -Mcu.Pin2=PE4 -Mcu.Pin3=PE5 -Mcu.Pin4=PE6 -Mcu.Pin5=PC15/OSC32_OUT -ADC3.InjNumberOfConversion=0 -SH.FMC_D8_DA8.0=FMC_D8,sd-16b-d1 -FMC.RPDelay2=2 -FMC.RPDelay1=2 +SH.FMC_A10.ConfNb=1 +SH.FMC_A11.0=FMC_A11,12b-sda1 +SH.FMC_A11.ConfNb=1 +SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 +SH.FMC_A14_BA0.ConfNb=1 +SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 +SH.FMC_A15_BA1.ConfNb=1 +SH.FMC_A2.0=FMC_A2,12b-sda1 +SH.FMC_A2.ConfNb=1 +SH.FMC_A3.0=FMC_A3,12b-sda1 +SH.FMC_A3.ConfNb=1 +SH.FMC_A4.0=FMC_A4,12b-sda1 +SH.FMC_A4.ConfNb=1 +SH.FMC_A5.0=FMC_A5,12b-sda1 +SH.FMC_A5.ConfNb=1 +SH.FMC_A6.0=FMC_A6,12b-sda1 +SH.FMC_A6.ConfNb=1 +SH.FMC_A7.0=FMC_A7,12b-sda1 +SH.FMC_A7.ConfNb=1 +SH.FMC_A8.0=FMC_A8,12b-sda1 +SH.FMC_A8.ConfNb=1 +SH.FMC_A9.0=FMC_A9,12b-sda1 +SH.FMC_A9.ConfNb=1 +SH.FMC_D0_DA0.0=FMC_D0,sd-16b-d1 +SH.FMC_D0_DA0.ConfNb=1 +SH.FMC_D10_DA10.0=FMC_D10,sd-16b-d1 +SH.FMC_D10_DA10.ConfNb=1 +SH.FMC_D11_DA11.0=FMC_D11,sd-16b-d1 +SH.FMC_D11_DA11.ConfNb=1 +SH.FMC_D12_DA12.0=FMC_D12,sd-16b-d1 +SH.FMC_D12_DA12.ConfNb=1 +SH.FMC_D13_DA13.0=FMC_D13,sd-16b-d1 +SH.FMC_D13_DA13.ConfNb=1 +SH.FMC_D14_DA14.0=FMC_D14,sd-16b-d1 +SH.FMC_D14_DA14.ConfNb=1 +SH.FMC_D15_DA15.0=FMC_D15,sd-16b-d1 +SH.FMC_D15_DA15.ConfNb=1 +SH.FMC_D1_DA1.0=FMC_D1,sd-16b-d1 +SH.FMC_D1_DA1.ConfNb=1 SH.FMC_D2_DA2.0=FMC_D2,sd-16b-d1 -PE13.Signal=FMC_D10_DA10 -File.Version=6 -SH.ADCx_IN13.ConfNb=1 -SH.FMC_D5_DA5.ConfNb=1 -PB3.GPIOParameters=GPIO_Label SH.FMC_D2_DA2.ConfNb=1 -PB8.Locked=true -SH.ADCx_IN0.0=ADC3_IN0,IN0 -FMC.ReadPipeDelay1=FMC_SDRAM_RPIPE_DELAY_0 -PE4.Mode=SAI_A_AsyncSlave -SH.FMC_SDNRAS.0=FMC_SDNRAS,12b-sda1 -PH1/OSC_OUT.Mode=HSE-External-Oscillator -PE4.Signal=SAI1_FS_A -PE6.GPIOParameters=GPIO_Label -Dma.RequestsNb=3 -SPI4.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128 -FREERTOS.configTOTAL_HEAP_SIZE=4096 -ProjectManager.ProjectName=Witch -SH.FMC_D0_DA0.0=FMC_D0,sd-16b-d1 -SAI1.DataSize-SAI_A_AsyncSlave=SAI_DATASIZE_24 -RCC.LSI_VALUE=32000 -USB_OTG_FS.VirtualMode=Device_Only -SH.FMC_A9.0=FMC_A9,12b-sda1 -PG9.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -VP_TIM13_VS_ClockSourceINT.Signal=TIM13_VS_ClockSourceINT +SH.FMC_D3_DA3.0=FMC_D3,sd-16b-d1 +SH.FMC_D3_DA3.ConfNb=1 SH.FMC_D4_DA4.0=FMC_D4,sd-16b-d1 -ADC3.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV8 -RCC.PLLSAIN=100 -PF5.Signal=FMC_A5 -SAI1.Synchro-SAI_B_SyncSlave=SAI_SYNCHRONOUS -PC4.Locked=true -PF0.Signal=FMC_A0 +SH.FMC_D4_DA4.ConfNb=1 +SH.FMC_D5_DA5.0=FMC_D5,sd-16b-d1 +SH.FMC_D5_DA5.ConfNb=1 +SH.FMC_D6_DA6.0=FMC_D6,sd-16b-d1 +SH.FMC_D6_DA6.ConfNb=1 +SH.FMC_D7_DA7.0=FMC_D7,sd-16b-d1 +SH.FMC_D7_DA7.ConfNb=1 +SH.FMC_D8_DA8.0=FMC_D8,sd-16b-d1 +SH.FMC_D8_DA8.ConfNb=1 +SH.FMC_D9_DA9.0=FMC_D9,sd-16b-d1 +SH.FMC_D9_DA9.ConfNb=1 +SH.FMC_NBL0.0=FMC_NBL0,Sd2ByteEnable1 SH.FMC_NBL0.ConfNb=1 -PE3.Mode=SAI_B_SyncSlave -PC2.GPIO_Label=ADC2 -PB3.Locked=true -PB3.GPIO_Label=FLASH_SCK -SH.COMP_DAC1_group.0=DAC_OUT1,DAC_OUT1 -ADC3.DiscontinuousConvMode=DISABLE -SAI1.Synchro_A=SAI_ASYNCHRONOUS -SH.FMC_A9.ConfNb=1 -SAI1.Synchro_B=SAI_SYNCHRONOUS -PA7.Mode=Full_Duplex_Master -PB9.GPIO_Label=SW4 -PC10.GPIO_Label=LEDSW2 -ProjectManager.NoMain=false -SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate -USB_DEVICE.VirtualModeFS=Audio_FS -USB_HOST.USBH_MAX_NUM_CONFIGURATION-AUDIO_HS=4 -PG1.Signal=FMC_A11 +SH.FMC_NBL1.0=FMC_NBL1,Sd2ByteEnable1 +SH.FMC_NBL1.ConfNb=1 +SH.FMC_SDCLK.0=FMC_SDCLK,12b-sda1 SH.FMC_SDCLK.ConfNb=1 -PC4.Signal=GPIO_Output -Dma.SAI1_A.0.MemInc=DMA_MINC_ENABLE -PC8.GPIO_Label=LEDPWM2 -PC12.GPIOParameters=GPIO_Label -PF7.Mode=IN5 -SH.ADCx_IN12.0=ADC3_IN12,IN12 -ProjectManager.TargetToolchain=Makefile +SH.FMC_SDNCAS.0=FMC_SDNCAS,12b-sda1 +SH.FMC_SDNCAS.ConfNb=1 +SH.FMC_SDNRAS.0=FMC_SDNRAS,12b-sda1 +SH.FMC_SDNRAS.ConfNb=1 +SH.FMC_SDNWE.0=FMC_SDNWE,12b-sda1 +SH.FMC_SDNWE.ConfNb=1 +SH.GPXTI1.0=GPIO_EXTI1 +SH.GPXTI1.ConfNb=1 +SH.GPXTI2.0=GPIO_EXTI2 +SH.GPXTI2.ConfNb=1 +SH.GPXTI9.0=GPIO_EXTI9 +SH.GPXTI9.ConfNb=1 +SH.S_TIM13_CH1.0=TIM13_CH1,PWM Generation1 CH1 +SH.S_TIM13_CH1.ConfNb=1 +SH.S_TIM1_CH1.0=TIM1_CH1,PWM Generation1 CH1 +SH.S_TIM1_CH1.ConfNb=1 +SH.S_TIM3_CH1.0=TIM3_CH1,PWM Generation1 CH1 +SH.S_TIM3_CH1.ConfNb=1 +SH.S_TIM3_CH3.0=TIM3_CH3,PWM Generation3 CH3 SH.S_TIM3_CH3.ConfNb=1 -SH.FMC_D1_DA1.ConfNb=1 -RCC.VcooutputI2SQ=96000000 -PF2.Signal=FMC_A2 -PC2.Locked=true -ProjectManager.RegisterCallBack= -RCC.PLLSAIoutputFreq_Value=50000000 -PE11.Signal=FMC_D8_DA8 -RCC.LSE_VALUE=32768 -PB1.Locked=true -SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_RX -Dma.SAI1_A.0.Priority=DMA_PRIORITY_VERY_HIGH -PG9.GPIO_Label=SW3 -SAI1.IPParameters=Instance-SAI_A_AsyncSlave,VirtualMode-SAI_A_AsyncSlave,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,Synchro-SAI_B_SyncSlave,FrameLength-SAI_B_SyncSlave,SlotSize-SAI_B_SyncSlave,AudioMode-SAI_B_SyncSlave,AudioMode-SAI_A_AsyncSlave,DataSize-SAI_A_AsyncSlave,FrameLength-SAI_A_AsyncSlave,SlotSize-SAI_A_AsyncSlave,SlotNumber-SAI_A_AsyncSlave,FSDefinition-SAI_A_AsyncSlave,FSDefinition-SAI_B_SyncSlave,Synchro-SAI_A_AsyncSlave,Synchro_A,Synchro_B -PH0/OSC_IN.Signal=RCC_OSC_IN -NVIC.SavedSystickIrqHandlerGenerated=true -RCC.APB2Freq_Value=84000000 -SH.FMC_D13_DA13.ConfNb=1 -PF10.Signal=ADC3_IN8 -Dma.ADC3.2.MemInc=DMA_MINC_ENABLE -PF15.Signal=FMC_A9 -SPI4.CalculateBaudRate=656.25 KBits/s -PA4.GPIOParameters=GPIO_Label -PE6.Signal=SPI4_MOSI -ADC3.Channel-34\#ChannelRegularConversion=ADC_CHANNEL_8 -Mcu.Name=STM32F427Z(G-I)Tx -PA2.Signal=ADCx_IN2 -PA13.GPIO_Label=SWDIO -PD14.Signal=FMC_D0_DA0 -PB3.Signal=SPI1_SCK -PA7.GPIO_Label=FLASH_MOSI -PA12.Mode=Device_Only -Dma.SAI1_B.1.Direction=DMA_PERIPH_TO_MEMORY -PC5.GPIO_Label=FLASH_nCS -ADC3.Rank-39\#ChannelRegularConversion=9 -SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B -PA14.Signal=SYS_JTCK-SWCLK -PB8.Signal=S_TIM4_CH3 -PE3.GPIO_Label=CS_SDOUT -PC9.Signal=S_TIM3_CH4 -RCC.APB1Freq_Value=42000000 -PB11.Locked=true -ProjectManager.DeviceId=STM32F427ZITx -ProjectManager.LibraryCopy=1 SH.S_TIM3_CH4.0=TIM3_CH4,PWM Generation4 CH4 -ADC3.Rank-31\#ChannelRegularConversion=1 -PB1.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -PA7.Signal=SPI1_MOSI +SH.S_TIM3_CH4.ConfNb=1 +SH.S_TIM4_CH3.0=TIM4_CH3,PWM Generation3 CH3 +SH.S_TIM4_CH3.ConfNb=1 +SPI1.CalculateBaudRate=42.0 MBits/s +SPI1.Direction=SPI_DIRECTION_2LINES +SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate +SPI1.Mode=SPI_MODE_MASTER +SPI1.VirtualType=VM_MASTER +SPI4.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128 +SPI4.CalculateBaudRate=656.25 KBits/s +SPI4.Direction=SPI_DIRECTION_2LINES +SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,VirtualType,Direction +SPI4.Mode=SPI_MODE_MASTER +SPI4.VirtualType=VM_MASTER +TIM1.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 +TIM1.IPParameters=Channel-PWM Generation1 CH1,Prescaler,Period +TIM1.Period=1023 +TIM1.Prescaler=100 +TIM13.Channel=TIM_CHANNEL_1 +TIM13.IPParameters=Channel,Prescaler,Period +TIM13.Period=1023 +TIM13.Prescaler=100 +TIM3.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 +TIM3.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3 +TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4 +TIM3.IPParameters=Channel-PWM Generation4 CH4,Channel-PWM Generation3 CH3,Channel-PWM Generation1 CH1,Prescaler,Period +TIM3.Period=1023 +TIM3.Prescaler=100 +TIM4.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3 +TIM4.IPParameters=Channel-PWM Generation3 CH3,Prescaler,Period +TIM4.Period=1023 +TIM4.Prescaler=100 +USB_OTG_FS.IPParameters=VirtualMode +USB_OTG_FS.VirtualMode=Device_Only +USB_OTG_HS.IPParameters=VirtualMode-Host_FS +USB_OTG_HS.VirtualMode-Host_FS=Host_FS +VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 +VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 +VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled +VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate +VP_SYS_VS_Systick.Mode=SysTick +VP_SYS_VS_Systick.Signal=SYS_VS_Systick +VP_TIM13_VS_ClockSourceINT.Mode=Enable_Timer +VP_TIM13_VS_ClockSourceINT.Signal=TIM13_VS_ClockSourceINT +board=Witch From 968f853416478755117b6b6a35e0f31f6bec2ccc Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 17 Dec 2021 16:31:31 +0100 Subject: [PATCH 242/286] changed to support 5 USBD interfaces instead of 1 --- ACDC/USB_DEVICE/Target/usbd_conf.h | 2 +- Alchemist/Inc/usbd_conf.h | 2 +- Mussol/Inc/usbd_conf.h | 2 +- Wizard/Inc/usbd_conf.h | 2 +- Xibeca/USB_DEVICE/Target/usbd_conf.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ACDC/USB_DEVICE/Target/usbd_conf.h b/ACDC/USB_DEVICE/Target/usbd_conf.h index b8e568d2..7fb0f34a 100644 --- a/ACDC/USB_DEVICE/Target/usbd_conf.h +++ b/ACDC/USB_DEVICE/Target/usbd_conf.h @@ -64,7 +64,7 @@ */ /*---------- -----------*/ -#define USBD_MAX_NUM_INTERFACES 1U +#define USBD_MAX_NUM_INTERFACES 5U /*---------- -----------*/ #define USBD_MAX_NUM_CONFIGURATION 1U /*---------- -----------*/ diff --git a/Alchemist/Inc/usbd_conf.h b/Alchemist/Inc/usbd_conf.h index 0d55589d..41419242 100644 --- a/Alchemist/Inc/usbd_conf.h +++ b/Alchemist/Inc/usbd_conf.h @@ -64,7 +64,7 @@ */ /*---------- -----------*/ -#define USBD_MAX_NUM_INTERFACES 1U +#define USBD_MAX_NUM_INTERFACES 5U /*---------- -----------*/ #define USBD_MAX_NUM_CONFIGURATION 1U /*---------- -----------*/ diff --git a/Mussol/Inc/usbd_conf.h b/Mussol/Inc/usbd_conf.h index 0d55589d..41419242 100644 --- a/Mussol/Inc/usbd_conf.h +++ b/Mussol/Inc/usbd_conf.h @@ -64,7 +64,7 @@ */ /*---------- -----------*/ -#define USBD_MAX_NUM_INTERFACES 1U +#define USBD_MAX_NUM_INTERFACES 5U /*---------- -----------*/ #define USBD_MAX_NUM_CONFIGURATION 1U /*---------- -----------*/ diff --git a/Wizard/Inc/usbd_conf.h b/Wizard/Inc/usbd_conf.h index 0d55589d..41419242 100644 --- a/Wizard/Inc/usbd_conf.h +++ b/Wizard/Inc/usbd_conf.h @@ -64,7 +64,7 @@ */ /*---------- -----------*/ -#define USBD_MAX_NUM_INTERFACES 1U +#define USBD_MAX_NUM_INTERFACES 5U /*---------- -----------*/ #define USBD_MAX_NUM_CONFIGURATION 1U /*---------- -----------*/ diff --git a/Xibeca/USB_DEVICE/Target/usbd_conf.h b/Xibeca/USB_DEVICE/Target/usbd_conf.h index b8e568d2..7fb0f34a 100644 --- a/Xibeca/USB_DEVICE/Target/usbd_conf.h +++ b/Xibeca/USB_DEVICE/Target/usbd_conf.h @@ -64,7 +64,7 @@ */ /*---------- -----------*/ -#define USBD_MAX_NUM_INTERFACES 1U +#define USBD_MAX_NUM_INTERFACES 5U /*---------- -----------*/ #define USBD_MAX_NUM_CONFIGURATION 1U /*---------- -----------*/ From 75e5215c478aac964f46237311e97c5497e35ecc Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 17 Dec 2021 16:35:41 +0100 Subject: [PATCH 243/286] support OWL Pedal expression mode setting --- Source/ApplicationSettings.cpp | 3 +++ Source/ApplicationSettings.h | 3 +++ Source/MidiHandler.cpp | 5 +++++ Source/OpenWareMidiControl.h | 1 + 4 files changed, 12 insertions(+) diff --git a/Source/ApplicationSettings.cpp b/Source/ApplicationSettings.cpp index ea2a695c..733c1a3b 100644 --- a/Source/ApplicationSettings.cpp +++ b/Source/ApplicationSettings.cpp @@ -39,6 +39,9 @@ void ApplicationSettings::reset(){ #ifdef USE_TLC5946 leds_brightness = LEDS_BRIGHTNESS; #endif +#ifdef OWL_PEDAL + expression_mode = EXPRESSION_MODE; +#endif } bool ApplicationSettings::settingsInFlash(){ diff --git a/Source/ApplicationSettings.h b/Source/ApplicationSettings.h index 0a7baa07..c16d8ab4 100644 --- a/Source/ApplicationSettings.h +++ b/Source/ApplicationSettings.h @@ -30,6 +30,9 @@ class ApplicationSettings { #ifdef USE_TLC5946 uint8_t leds_brightness; #endif +#ifdef OWL_PEDAL + uint8_t expression_mode; +#endif public: void init(); void reset(); diff --git a/Source/MidiHandler.cpp b/Source/MidiHandler.cpp index 2380a95e..85a9e2e1 100644 --- a/Source/MidiHandler.cpp +++ b/Source/MidiHandler.cpp @@ -260,6 +260,11 @@ void MidiHandler::handleConfigurationCommand(uint8_t* data, uint16_t size){ case HEXCODE(SYSEX_CONFIGURATION_BUS_FORWARD_MIDI): settings.bus_forward_midi = value; break; +#endif +#ifdef OWL_PEDAL + case HEXCODE(SYSEX_CONFIGURATION_EXPRESSION_PEDAL): + settings.expression_mode = value; + break; #endif } } diff --git a/Source/OpenWareMidiControl.h b/Source/OpenWareMidiControl.h index dc63a482..066f0e22 100644 --- a/Source/OpenWareMidiControl.h +++ b/Source/OpenWareMidiControl.h @@ -95,6 +95,7 @@ enum PatchButtonId { #define SYSEX_CONFIGURATION_BUS_ENABLE "BE" #define SYSEX_CONFIGURATION_BUS_FORWARD_MIDI "BM" #define SYSEX_CONFIGURATION_BOOTLOADER_LOCK "BL" +#define SYSEX_CONFIGURATION_EXPRESSION_PEDAL "EP" enum OpenWareMidiSysexCommand { SYSEX_PRESET_NAME_COMMAND = 0x01, From 42a9921966d0789b71416d8213fe9419f26cd149 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 17 Dec 2021 16:36:09 +0100 Subject: [PATCH 244/286] rc4 --- Source/device.h | 2 +- Source/usbh_midi.cpp | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Source/device.h b/Source/device.h index ea42c508..0d18526b 100644 --- a/Source/device.h +++ b/Source/device.h @@ -3,7 +3,7 @@ #include "hardware.h" -#define FIRMWARE_VERSION "v22.1.rc3" +#define FIRMWARE_VERSION "v22.1.rc4" #ifdef USE_SPI_FLASH #define MAX_SPI_FLASH_HEADERS 32 diff --git a/Source/usbh_midi.cpp b/Source/usbh_midi.cpp index 55dc0e6a..ed6e298c 100644 --- a/Source/usbh_midi.cpp +++ b/Source/usbh_midi.cpp @@ -3,6 +3,11 @@ #include "midi.h" #include "SerialBuffer.hpp" +/** + * USB Host MIDI Driver + * Based on code by Xavier Halgand @MrBlueXav + */ + extern "C" { static USBH_StatusTypeDef USBH_MIDI_InterfaceInit (USBH_HandleTypeDef *phost); @@ -127,7 +132,7 @@ USBH_StatusTypeDef USBH_MIDI_InterfaceDeInit (USBH_HandleTypeDef *phost){ if(phost->pActiveClass->pData){ /* statically allocated in init USBH_free (phost->pActiveClass->pData); */ - phost->pActiveClass->pData = 0; + phost->pActiveClass->pData = NULL; } return USBH_OK; @@ -211,6 +216,14 @@ static USBH_StatusTypeDef USBH_MIDI_Process (USBH_HandleTypeDef *phost){ * @retval USBH Status */ static USBH_StatusTypeDef USBH_MIDI_SOFProcess (USBH_HandleTypeDef *phost){ + MIDI_HandleTypeDef *MIDI_Handle = &staticMidiHandle; + + USBH_URBStateTypeDef URB_Status = USBH_LL_GetURBState(phost, MIDI_Handle->InPipe); + if(URB_Status == USBH_URB_STALL) { + USBH_DbgLog("USBH URB Stall"); + if (USBH_ClrFeature(phost, MIDI_Handle->InEp) == USBH_OK) + MIDI_Handle->state = MIDI_TRANSFER_DATA; + } return USBH_OK; } From f422a502922ce79fb081854b91dc292619e58fab Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 21 Dec 2021 17:49:55 +0100 Subject: [PATCH 245/286] dim between red and green LED using PUSHBUTTON --- OwlPedal2/Src/OwlPedal.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/OwlPedal2/Src/OwlPedal.cpp b/OwlPedal2/Src/OwlPedal.cpp index 32816d86..b40662f5 100644 --- a/OwlPedal2/Src/OwlPedal.cpp +++ b/OwlPedal2/Src/OwlPedal.cpp @@ -203,23 +203,28 @@ void onChangePin(uint16_t pin){ void setGateValue(uint8_t ch, int16_t value){ if(owl.getOperationMode() == RUN_MODE){ + value = (value >> 2) & 0x3ff; // use top 10 bits of 12 switch(ch){ case BUTTON_1: case PUSHBUTTON: - setLed(0, value ? RED_COLOUR : GREEN_COLOUR); +#ifdef OWL_PEDAL_PWM_LEDS + setLed(0, (value << 20) | ((1023 - value) << 10)); +#else + setLed(0, value < 2048 ? RED_COLOUR : GREEN_COLOUR); +#endif break; case GREEN_BUTTON: #ifdef OWL_PEDAL_PWM_LEDS - setLed(0, (value<<8) & (0x3ff<<10)); // use top 10 bits (out of 12) as green value + setLed(0, value << 10); #else - setLed(0, value ? GREEN_COLOUR : NO_COLOUR); + setLed(0, value < 2048 ? GREEN_COLOUR : NO_COLOUR); #endif break; case RED_BUTTON: #ifdef OWL_PEDAL_PWM_LEDS - setLed(0, (value<<18) & (0x3ff<<20)); // use top 10 bits (out of 12) as red value + setLed(0, value << 20); #else - setLed(0, value ? RED_COLOUR : NO_COLOUR); + setLed(0, value < 2048 ? RED_COLOUR : NO_COLOUR); #endif break; } From 0ecebbc3cff2d02bcb946ac078bddfd61c9c2b39 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 27 Dec 2021 11:41:34 +0100 Subject: [PATCH 246/286] updated ACDC --- ACDC/Core/Inc/hardware.h | 5 +++-- ACDC/Core/Src/ACDC.cpp | 12 ++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ACDC/Core/Inc/hardware.h b/ACDC/Core/Inc/hardware.h index 7a8d99b5..cc5eefcb 100644 --- a/ACDC/Core/Inc/hardware.h +++ b/ACDC/Core/Inc/hardware.h @@ -20,6 +20,7 @@ /* #define USE_SPI_FLASH */ /* #define SPI_FLASH_HSPI hqspi */ +/* #define AUDIO_INPUT_GAIN 114 */ #define AUDIO_OUTPUT_GAIN 114 #define USE_CODEC @@ -39,8 +40,8 @@ #define USE_USBD_AUDIO #define USE_USBD_AUDIO_FEATURES #define USE_USBD_AUDIO_TX // microphone -/* #define USE_USBD_AUDIO_RX // speaker */ -/* #define USE_USBD_RX_FB */ +#define USE_USBD_AUDIO_RX // speaker +#define USE_USBD_RX_FB #define USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS diff --git a/ACDC/Core/Src/ACDC.cpp b/ACDC/Core/Src/ACDC.cpp index 1251cd44..a6544a84 100644 --- a/ACDC/Core/Src/ACDC.cpp +++ b/ACDC/Core/Src/ACDC.cpp @@ -134,13 +134,13 @@ void onSetup(){ initLed(); for(size_t i=1; i<=8; ++i) setLed(i, NO_COLOUR); - codec.set((1<<22)-1); + // codec.set((1<<22)-1); } void onLoop(void){ - // for(size_t i=0; i<4; ++i){ - // int16_t value = getParameterValue(PARAMETER_AA+i); - // setLed(i+1, value >= 4095 ? RED_COLOUR : value); - // setLed(i+5, getParameterValue(PARAMETER_BA+i)); - // } + for(size_t i=0; i<4; ++i){ + int16_t value = getParameterValue(PARAMETER_AA+i); + setLed(i+1, value >= 4095 ? RED_COLOUR : value); + setLed(i+5, getParameterValue(PARAMETER_BA+i)); + } } From b812027b888a667455e202cbb2e4bd85b4dd579f Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 27 Dec 2021 12:18:03 +0100 Subject: [PATCH 247/286] prevent stack overflow by reducing FreeRTOS heap size. disable USB SOF. --- OwlPedal2/Inc/FreeRTOSConfig.h | 4 ++-- OwlPedal2/Src/OwlPedal.cpp | 1 - OwlPedal2/Src/main.c | 7 +++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/OwlPedal2/Inc/FreeRTOSConfig.h b/OwlPedal2/Inc/FreeRTOSConfig.h index c32c853a..2b70be6a 100644 --- a/OwlPedal2/Inc/FreeRTOSConfig.h +++ b/OwlPedal2/Inc/FreeRTOSConfig.h @@ -100,7 +100,7 @@ extern uint32_t SystemCoreClock; void xPortSysTickHandler(void); #endif -#define configENABLE_FPU 0 +#define configENABLE_FPU 1 #define configENABLE_MPU 0 #define configUSE_PREEMPTION 0 @@ -112,7 +112,7 @@ #define configTICK_RATE_HZ ((TickType_t)1000) #define configMAX_PRIORITIES ( 7 ) #define configMINIMAL_STACK_SIZE ((uint16_t)128) -#define configTOTAL_HEAP_SIZE ((size_t)8192) +#define configTOTAL_HEAP_SIZE ((size_t)4096) #define configMAX_TASK_NAME_LEN ( 16 ) #define configUSE_16_BIT_TICKS 0 #define configQUEUE_REGISTRY_SIZE 8 diff --git a/OwlPedal2/Src/OwlPedal.cpp b/OwlPedal2/Src/OwlPedal.cpp index b40662f5..56ea02b3 100644 --- a/OwlPedal2/Src/OwlPedal.cpp +++ b/OwlPedal2/Src/OwlPedal.cpp @@ -369,7 +369,6 @@ void onLoop(){ if(isPushbuttonPressed()){ // exit configure mode if(program.getProgramIndex() != patchselect && registry.hasPatch(patchselect)){ - // change patch on mode button release program.loadProgram(patchselect); // enters load mode (calls onChangeMode) program.resetProgram(false); }else{ diff --git a/OwlPedal2/Src/main.c b/OwlPedal2/Src/main.c index 272d49ff..ce148442 100644 --- a/OwlPedal2/Src/main.c +++ b/OwlPedal2/Src/main.c @@ -56,6 +56,9 @@ #include "device.h" #include "errorhandlers.h" +#ifdef DEBUG +#include +#endif /* USER CODE END Includes */ @@ -663,7 +666,7 @@ static void MX_USB_OTG_FS_PCD_Init(void) hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; - hpcd_USB_OTG_FS.Init.Sof_enable = ENABLE; + hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE; @@ -699,7 +702,7 @@ static void MX_USB_OTG_HS_PCD_Init(void) hpcd_USB_OTG_HS.Init.speed = PCD_SPEED_FULL; hpcd_USB_OTG_HS.Init.dma_enable = DISABLE; hpcd_USB_OTG_HS.Init.phy_itface = USB_OTG_EMBEDDED_PHY; - hpcd_USB_OTG_HS.Init.Sof_enable = ENABLE; + hpcd_USB_OTG_HS.Init.Sof_enable = DISABLE; hpcd_USB_OTG_HS.Init.low_power_enable = DISABLE; hpcd_USB_OTG_HS.Init.lpm_enable = DISABLE; hpcd_USB_OTG_HS.Init.vbus_sensing_enable = ENABLE; From 95dae5e4dd1b1dd6cd07de9ec9a757cf0e0f41d9 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 27 Dec 2021 14:22:30 +0100 Subject: [PATCH 248/286] updated programName size --- Source/PatchDefinition.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/PatchDefinition.hpp b/Source/PatchDefinition.hpp index c470ba42..b35b5e50 100644 --- a/Source/PatchDefinition.hpp +++ b/Source/PatchDefinition.hpp @@ -18,7 +18,7 @@ class PatchDefinition { uint32_t* linkAddress; uint32_t binarySize; uint32_t programSize; - char programName[24]; + char programName[20]; // ResourceHeader::name is char[20] Resource* sourceResource = NULL; void* sourceAddress = NULL; From b87147abece6a5b1fedcd0ede856d811e2281fd1 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 27 Dec 2021 14:23:05 +0100 Subject: [PATCH 249/286] use Resource::name size --- Source/MidiController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/MidiController.cpp b/Source/MidiController.cpp index faf4aedd..1e0e2f97 100644 --- a/Source/MidiController.cpp +++ b/Source/MidiController.cpp @@ -205,7 +205,7 @@ void MidiController::sendName(uint8_t cmd, uint8_t index, const char* name, size // make the numbers big-endian datasize = __REV(datasize); crc = __REV(crc); - size_t len = strnlen(name, 24); + size_t len = strnlen(name, sizeof(ResourceHeader::name)); uint8_t buf[len+3+5+5]; buf[0] = cmd; buf[1] = index; From 763f53e358bf765dc759525e8a354ec18ec98e2c Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 27 Dec 2021 14:26:49 +0100 Subject: [PATCH 250/286] check available USB IF --- Source/usbd_audio.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/usbd_audio.cpp b/Source/usbd_audio.cpp index d1b2fefa..50259ada 100644 --- a/Source/usbd_audio.cpp +++ b/Source/usbd_audio.cpp @@ -184,6 +184,10 @@ static void get_usb_full_speed_rate(unsigned int rate, uint8_t* buf){ #define MIDI_TX_EP 0x81 #endif +#if defined USE_USBD_RX and defined USE_USBD_TX and defined USE_USBD_MIDI and USBD_MAX_NUM_INTERFACES < 4 +#error "Insufficient USBD interfaces configured" +#endif + #if AUDIO_RX_FIFO_SIZE < (AUDIO_RX_MAX_PACKET_SIZE + 2*USBD_MIN_FIFO_SIZE) #pragma message "USBD RX FIFO small" #endif From 45707a318a03eaaba6ce1def3df46d6db57a8b11 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 27 Dec 2021 14:27:08 +0100 Subject: [PATCH 251/286] added configuration --- OwlPedal/Inc/hardware.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OwlPedal/Inc/hardware.h b/OwlPedal/Inc/hardware.h index bd0750bc..974324bf 100644 --- a/OwlPedal/Inc/hardware.h +++ b/OwlPedal/Inc/hardware.h @@ -50,6 +50,9 @@ #define NOF_PARAMETERS 40 #define NOF_BUTTONS (4 + 1) +#define EXPRESSION_MODE_EXP_TRS 1 +#define EXPRESSION_MODE EXPRESSION_MODE_EXP_TRS + #if 0 #define MIDI_INPUT_CHANNEL MIDI_OMNI_CHANNEL #define MIDI_OUTPUT_CHANNEL 0 From 748a85fad397bd27ee4ca8d4558ed63d8a6cd844 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 27 Dec 2021 14:27:39 +0100 Subject: [PATCH 252/286] configured for rx/tx audio and external flash --- Wizard/Inc/hardware.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Wizard/Inc/hardware.h b/Wizard/Inc/hardware.h index 3a7190a8..0e8e6682 100644 --- a/Wizard/Inc/hardware.h +++ b/Wizard/Inc/hardware.h @@ -6,6 +6,8 @@ #define HARDWARE_VERSION "Wizard" /* #define FASCINATION_MACHINE */ +#define USE_SPI_FLASH + #ifndef OWL_EUROWIZARD #define USE_USBD_HS #define USBD_HANDLE hUsbDeviceHS @@ -23,11 +25,16 @@ #define AUDIO_BITS_PER_SAMPLE 16 #define AUDIO_BYTES_PER_SAMPLE (AUDIO_BITS_PER_SAMPLE/8) #define AUDIO_CHANNELS 2 +#define USBD_AUDIO_RX_CHANNELS AUDIO_CHANNELS +#define USBD_AUDIO_TX_CHANNELS AUDIO_CHANNELS #define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) + #define USE_USBD_AUDIO +#define USE_USBD_RX_FB +#define USE_USBD_AUDIO_FEATURES +#define USE_USBD_AUDIO_RX // speaker #define USE_USBD_AUDIO_TX // microphone -/* #define USE_USBD_AUDIO_RX // speaker */ #define USE_MODE_BUTTON #define MODE_BUTTON_PIN SW5_Pin From 13c9f8b61dd1ae78d348ad4342bb81bd1c96bc9a Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 27 Dec 2021 14:28:43 +0100 Subject: [PATCH 253/286] configured for rx/tx audio and external flash --- Alchemist/Inc/hardware.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Alchemist/Inc/hardware.h b/Alchemist/Inc/hardware.h index b5a674b2..7eab9dc6 100644 --- a/Alchemist/Inc/hardware.h +++ b/Alchemist/Inc/hardware.h @@ -6,16 +6,22 @@ #define HARDWARE_ID ALCHEMIST_HARDWARE #define HARDWARE_VERSION "Alchemist" +#define USE_SPI_FLASH + /* USB audio settings */ #define AUDIO_BITS_PER_SAMPLE 16 #define AUDIO_BYTES_PER_SAMPLE (AUDIO_BITS_PER_SAMPLE/8) #define AUDIO_CHANNELS 2 +#define USBD_AUDIO_RX_CHANNELS AUDIO_CHANNELS +#define USBD_AUDIO_TX_CHANNELS AUDIO_CHANNELS #define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) + #define USE_USBD_AUDIO +#define USE_USBD_RX_FB +#define USE_USBD_AUDIO_FEATURES +#define USE_USBD_AUDIO_RX // speaker #define USE_USBD_AUDIO_TX // microphone -/* #define USE_USBD_AUDIO_RX // speaker */ -#define USBD_HANDLE hUsbDeviceHS #define USE_MODE_BUTTON #define MODE_BUTTON_PIN SW3_Pin From 1bc0bbc66b540b0702a96813a93f12ea60fdbebe Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 27 Dec 2021 14:30:36 +0100 Subject: [PATCH 254/286] configured for rx/tx audio and external flash --- Lich/Inc/hardware.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Lich/Inc/hardware.h b/Lich/Inc/hardware.h index 7edd12e7..935ca628 100644 --- a/Lich/Inc/hardware.h +++ b/Lich/Inc/hardware.h @@ -5,16 +5,23 @@ #define HARDWARE_ID LICH_HARDWARE #define HARDWARE_VERSION "Lich" +#define USE_SPI_FLASH + /* USB audio settings */ #define AUDIO_BITS_PER_SAMPLE 16 #define AUDIO_BYTES_PER_SAMPLE (AUDIO_BITS_PER_SAMPLE/8) #define AUDIO_CHANNELS 2 +#define USBD_AUDIO_RX_CHANNELS AUDIO_CHANNELS +#define USBD_AUDIO_TX_CHANNELS AUDIO_CHANNELS #define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) #define USE_USBD_AUDIO +#define USE_USBD_RX_FB +#define USE_USBD_AUDIO_FEATURES +#define USE_USBD_AUDIO_RX // speaker #define USE_USBD_AUDIO_TX // microphone -/* #define USE_USBD_AUDIO_RX // speaker */ + #define USE_USBD_FS #define USBD_HANDLE hUsbDeviceFS #define USBH_HANDLE hUsbHostHS From a5e7d4b54076e8f1e34afbd8118753cf812e3b50 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 27 Dec 2021 14:30:54 +0100 Subject: [PATCH 255/286] updated history and bump version --- HISTORY.md | 9 +++++++++ Source/device.h | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index d90293a4..c6ef1d4d 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,12 @@ +22.2.0 +------ + +* Support for OWL Pedal mk2 +* Prevent invalid characters in reported patch names +* Send resource size and checksum with name +* Improved backwards patch compatibility (CCM linked stack) + + 22.1.rc2 ------ diff --git a/Source/device.h b/Source/device.h index 0d18526b..e75b01be 100644 --- a/Source/device.h +++ b/Source/device.h @@ -3,7 +3,7 @@ #include "hardware.h" -#define FIRMWARE_VERSION "v22.1.rc4" +#define FIRMWARE_VERSION "v22.2.0" #ifdef USE_SPI_FLASH #define MAX_SPI_FLASH_HEADERS 32 From f5dc53413e8e8cca211d25d31d646a42c66fdf5e Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 27 Dec 2021 16:00:38 +0100 Subject: [PATCH 256/286] updated notes --- Source/MidiStreamReader.cpp | 1 + openware-notes.txt | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/Source/MidiStreamReader.cpp b/Source/MidiStreamReader.cpp index a4020aba..3b13deb4 100644 --- a/Source/MidiStreamReader.cpp +++ b/Source/MidiStreamReader.cpp @@ -2,6 +2,7 @@ #include "errorhandlers.h" MidiMessage MidiStreamReader::read(unsigned char data){ + // todo: realtime bytes can appear anywhere in the stream if(pos == size || status == READY_STATUS) clear(); buffer[pos++] = data; diff --git a/openware-notes.txt b/openware-notes.txt index 9dd751af..977f316b 100644 --- a/openware-notes.txt +++ b/openware-notes.txt @@ -406,3 +406,14 @@ https://systemoverlord.com/2017/03/19/got-and-plt-for-pwning.html https://reverseengineering.stackexchange.com/questions/1992/what-is-plt-got ----------------------------------------------------------------- + +CPPFLAGS += -fdata-sections -ffunction-sections +Required to compile without missing (unused) symbols + +----------------------------------------------------------------- + +use HAL_GetUIDw[012]() +Returns first word of the unique device identifier (UID based on 96 +bits) + +----------------------------------------------------------------- From 4f7efcf3a5e503c713d339b6719f7781a269c1cb Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Mon, 27 Dec 2021 17:01:17 +0100 Subject: [PATCH 257/286] updated HISTORY --- HISTORY.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/HISTORY.md b/HISTORY.md index c6ef1d4d..a7b62b99 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,6 +1,11 @@ 22.2.0 ------ +* Improved USB Audio FIFO allocation +* Refactored Graphics code +* Move screen handling to separate task +* Added patch text/message handlers +* Changed loop/setup callbacks to onLoop and onSetup * Support for OWL Pedal mk2 * Prevent invalid characters in reported patch names * Send resource size and checksum with name From 78dae666e5640a9ad4093593bd0a1e2090ff6676 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 28 Dec 2021 13:17:50 +0100 Subject: [PATCH 258/286] prevent stack overflow in patch name/crc --- Source/MidiController.cpp | 6 ++++-- Source/Storage.cpp | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Source/MidiController.cpp b/Source/MidiController.cpp index 1e0e2f97..a0c6a379 100644 --- a/Source/MidiController.cpp +++ b/Source/MidiController.cpp @@ -112,7 +112,8 @@ class SendResourceNamesTask : public BackgroundTask { Resource* resource = registry.getResource(state); if(resource) midi_tx.sendName(SYSEX_RESOURCE_NAME_COMMAND, state+MAX_NUMBER_OF_PATCHES, - resource->getName(), resource->getDataSize(), storage.getChecksum(resource)); + resource->getName(), resource->getDataSize(), + storage.getChecksum(resource)); state++; }else{ owl.setBackgroundTask(NULL); // end this task @@ -128,7 +129,8 @@ void MidiController::sendPatchName(uint8_t slot){ }else{ Resource* resource = registry.getPatch(slot-1); if(resource) - sendName(SYSEX_PRESET_NAME_COMMAND, slot, resource->getName(), resource->getDataSize(), storage.getChecksum(resource)); + sendName(SYSEX_PRESET_NAME_COMMAND, slot, resource->getName(), resource->getDataSize(), + storage.getChecksum(resource)); } } diff --git a/Source/Storage.cpp b/Source/Storage.cpp index 94d6d362..3a0f0f6b 100644 --- a/Source/Storage.cpp +++ b/Source/Storage.cpp @@ -126,9 +126,9 @@ uint32_t Storage::getChecksum(Resource* resource){ uint32_t crc = 0; if(resource->isMemoryMapped()){ crc = crc32(resource->getData(), resource->getDataSize(), 0); - }else{ #ifdef USE_SPI_FLASH - uint8_t data[64]; // read chunk of bytes at a time + }else{ + uint8_t data[32]; // read chunk of bytes at a time uint32_t address = resource->getAddress() + sizeof(ResourceHeader); uint32_t end = address + resource->getDataSize(); // uint32_t start = address; From e527a33221d9a1231da83b0ea0d5029c6e225d70 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Tue, 28 Dec 2021 17:59:34 +0100 Subject: [PATCH 259/286] added FLASH_HOLD pin config, updated cube configuration --- Alchemist/Alchemist.ioc | 1210 ++++++++++++++-------------- Alchemist/Inc/FreeRTOSConfig.h | 18 +- Alchemist/Inc/hardware.h | 1 + Alchemist/Inc/main.h | 2 + Alchemist/Inc/stm32f4xx_hal_conf.h | 163 ++-- Alchemist/Inc/stm32f4xx_it.h | 2 +- Alchemist/Inc/usbd_conf.h | 11 +- Alchemist/Inc/usbd_desc.h | 4 +- Alchemist/Src/freertos.c | 2 +- Alchemist/Src/main.c | 94 ++- Alchemist/Src/stm32f4xx_hal_msp.c | 152 ++-- Alchemist/Src/stm32f4xx_it.c | 2 +- Alchemist/Src/usbd_desc.c | 21 +- Alchemist/cube-update.sh | 1 + 14 files changed, 888 insertions(+), 795 deletions(-) diff --git a/Alchemist/Alchemist.ioc b/Alchemist/Alchemist.ioc index 249821e6..a9431db5 100644 --- a/Alchemist/Alchemist.ioc +++ b/Alchemist/Alchemist.ioc @@ -1,641 +1,653 @@ #MicroXplorer Configuration settings - do not modify -PF7.GPIOParameters=GPIO_Label -SH.FMC_D7_DA7.0=FMC_D7,sd-16b-d1 -USB_DEVICE.PID_AUDIO_HS=0xDADA -Dma.ADC3.0.FIFOMode=DMA_FIFOMODE_DISABLE -SH.FMC_D0_DA0.ConfNb=1 -RCC.USART1Freq_Value=108000000 -Dma.ADC3.0.Priority=DMA_PRIORITY_LOW -USART2.IPParameters=VirtualMode -SH.FMC_A8.ConfNb=1 -SH.FMC_A4.ConfNb=1 -SPI4.VirtualType=VM_MASTER -SH.FMC_A0.ConfNb=1 -SH.FMC_D6_DA6.ConfNb=1 -SAI1.VirtualMode-SAI_A_AsyncSlave=VM_SLAVE -FMC.SDClockPeriod2=FMC_SDRAM_CLOCK_PERIOD_2 -SH.FMC_D9_DA9.ConfNb=1 -FMC.RCDDelay1=2 -FMC.SDClockPeriod1=FMC_SDRAM_CLOCK_PERIOD_2 -SH.FMC_A0.0=FMC_A0,12b-sda1 -SPI1.VirtualType=VM_MASTER -Dma.SAI1_B.2.MemDataAlignment=DMA_MDATAALIGN_WORD -SH.GPXTI9.0=GPIO_EXTI9 -PG4.Signal=FMC_A14_BA0 -PG8.Signal=FMC_SDCLK -RCC.PLLCLKFreq_Value=168000000 -RCC.PLLQCLKFreq_Value=48000000 -PG0.Signal=FMC_A10 -FMC.LoadToActiveDelay1=2 -VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled -PC3.Locked=true -RCC.RTCFreq_Value=32000 -PA6.GPIO_Label=FLASH_MISO -Dma.SAI1_A.1.Mode=DMA_CIRCULAR -SH.FMC_SDNWE.ConfNb=1 -SH.FMC_D5_DA5.0=FMC_D5,sd-16b-d1 -PB13.Signal=USB_OTG_HS_VBUS -Dma.SAI1_A.1.MemDataAlignment=DMA_MDATAALIGN_WORD -PD6.GPIO_Label=CS_SDIN -Dma.SAI1_B.2.Mode=DMA_CIRCULAR -PinOutPanel.RotationAngle=0 -TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4 -PE6.GPIO_Label=CS_SDA -RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK -SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 -SH.FMC_D9_DA9.0=FMC_D9,sd-16b-d1 -RCC.LPTIM1Freq_Value=54000000 -NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -SAI1.FSDefinition-SAI_B_SyncSlave=SAI_FS_CHANNEL_IDENTIFICATION -PF7.Signal=SPI5_SCK -SH.FMC_SDNWE.0=FMC_SDNWE,12b-sda1 -SPI1.Direction=SPI_DIRECTION_2LINES -SH.FMC_D11_DA11.0=FMC_D11,sd-16b-d1 -Dma.SAI1_A.1.Instance=DMA2_Stream1 -RCC.I2C4Freq_Value=54000000 -PE2.Mode=TX_Only_Simplex_Unidirect_Master -TIM2.IPParameters=Period,Prescaler,Pulse-PWM Generation1 CH1,Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2,Pulse-PWM Generation2 CH2 -RCC.APB2TimFreq_Value=168000000 -PB2/BOOT1.GPIO_Label=SW2 -PB6.Signal=FMC_SDNE1 -Dma.ADC3.0.Direction=DMA_PERIPH_TO_MEMORY -SH.FMC_D10_DA10.ConfNb=1 -PH1/OSC_OUT.Signal=RCC_OSC_OUT -PB6.Mode=SdramChipSelect2_1 -SPI1.CalculateBaudRate=42.0 MBits/s -PC3.Signal=ADCx_IN13 -PD0.Signal=FMC_D2_DA2 -ADC3.ScanConvMode=ENABLE -RCC.SAI2Freq_Value=50000000 -PD8.Signal=FMC_D13_DA13 -PE5.Signal=SAI1_SCK_A -Dma.SAI1_A.1.FIFOMode=DMA_FIFOMODE_DISABLE -PE1.Signal=FMC_NBL1 -PF10.GPIO_Label=ADC4 -Dma.SAI1_A.1.MemInc=DMA_MINC_ENABLE -RCC.USART3Freq_Value=54000000 -RCC.PLLSAIRCLKFreq_Value=50000000 -ProjectManager.ProjectBuild=false -NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -PB3.Mode=Full_Duplex_Master -Dma.ADC3.0.PeriphInc=DMA_PINC_DISABLE -ADC3.ExternalTrigConv=ADC_SOFTWARE_START -FMC.SelfRefreshTime1=4 -ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.25.0 -MxDb.Version=DB.5.0.60 -PA1.GPIOParameters=GPIO_Label -ProjectManager.BackupPrevious=false -SAI1.SlotNumber-SAI_A_AsyncSlave=2 -PC4.GPIO_Label=FLASH_HOLD -PE9.Signal=FMC_D6_DA6 -SH.FMC_A2.0=FMC_A2,12b-sda1 -PB14.Mode=Device_Only_FS -PB1.GPIO_Label=PWM3 -SH.FMC_D15_DA15.ConfNb=1 -ADC3.ContinuousConvMode=ENABLE -PE4.GPIO_Label=CS_LRCK -PF10.Locked=true -ADC3.IPParameters=Rank-31\#ChannelRegularConversion,Channel-31\#ChannelRegularConversion,SamplingTime-31\#ChannelRegularConversion,NbrOfConversionFlag,ScanConvMode,ContinuousConvMode,DMAContinuousRequests,EOCSelection,InjNumberOfConversion,EnableAnalogWatchDog,ExternalTrigConv,Rank-32\#ChannelRegularConversion,Channel-32\#ChannelRegularConversion,SamplingTime-32\#ChannelRegularConversion,Rank-33\#ChannelRegularConversion,Channel-33\#ChannelRegularConversion,SamplingTime-33\#ChannelRegularConversion,Rank-34\#ChannelRegularConversion,Channel-34\#ChannelRegularConversion,SamplingTime-34\#ChannelRegularConversion,NbrOfConversion,ClockPrescaler,Resolution,DataAlign,DiscontinuousConvMode,ExternalTrigConvEdge -SH.ADCx_IN11.ConfNb=1 -PE2.Signal=SPI4_SCK -PF8.Mode=Full_Duplex_Master +ADC3.Channel-31\#ChannelRegularConversion=ADC_CHANNEL_13 +ADC3.Channel-32\#ChannelRegularConversion=ADC_CHANNEL_12 ADC3.Channel-33\#ChannelRegularConversion=ADC_CHANNEL_11 -SH.FMC_D1_DA1.0=FMC_D1,sd-16b-d1 -NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false -PC15/OSC32_OUT.Locked=true -PF3.Signal=FMC_A3 -USB_OTG_HS.IPParameters=VirtualMode-Device_Only_FS -VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 -NVIC.SAI1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -PE10.Signal=FMC_D7_DA7 -ProjectManager.HalAssertFull=true -USB_DEVICE.MANUFACTURER_STRING-AUDIO_HS=Rebel Technology -RCC.MCO2PinFreq_Value=168000000 -Mcu.Package=LQFP144 -PB9.Signal=GPXTI9 -TIM2.Prescaler=16 -PF8.GPIOParameters=GPIO_Label -PB1.Signal=S_TIM3_CH4 -SH.GPXTI8.0=GPIO_EXTI8 -Dma.SAI1_A.1.Direction=DMA_MEMORY_TO_PERIPH -SH.FMC_SDNCAS.ConfNb=1 -VP_SYS_VS_Systick.Signal=SYS_VS_Systick -SH.FMC_A11.ConfNb=1 -SH.GPXTI8.ConfNb=1 -PB9.GPIO_PuPd=GPIO_PULLUP -FREERTOS.FootprintOK=true -FMC.WriteRecoveryTime1=2 -TIM2.Pulse-PWM\ Generation2\ CH2=1023 -SH.FMC_A1.0=FMC_A1,12b-sda1 -SPI5.CalculateBaudRate=42.0 MBits/s +ADC3.Channel-34\#ChannelRegularConversion=ADC_CHANNEL_8 +ADC3.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV8 +ADC3.ContinuousConvMode=ENABLE ADC3.DMAContinuousRequests=ENABLE -RCC.APB2CLKDivider=RCC_HCLK_DIV2 -NVIC.EXTI2_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true -SH.FMC_SDCLK.0=FMC_SDCLK,12b-sda1 -RCC.CECFreq_Value=32786.88524590164 -PF14.Signal=FMC_A8 +ADC3.DataAlign=ADC_DATAALIGN_RIGHT +ADC3.DiscontinuousConvMode=DISABLE +ADC3.EOCSelection=ADC_EOC_SEQ_CONV +ADC3.EnableAnalogWatchDog=false +ADC3.ExternalTrigConv=ADC_SOFTWARE_START ADC3.ExternalTrigConvEdge=ADC_EXTERNALTRIGCONVEDGE_NONE -RCC.APB1TimFreq_Value=84000000 -Dma.ADC3.0.Instance=DMA2_Stream0 -NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -FMC.RowCycleDelay2=6 -PF10.Mode=IN8 -FMC.RowCycleDelay1=6 -PB10.GPIOParameters=GPIO_Label -PB13.Mode=Activate_VBUS_FS +ADC3.IPParameters=Rank-31\#ChannelRegularConversion,Channel-31\#ChannelRegularConversion,SamplingTime-31\#ChannelRegularConversion,NbrOfConversionFlag,ScanConvMode,ContinuousConvMode,DMAContinuousRequests,EOCSelection,InjNumberOfConversion,EnableAnalogWatchDog,ExternalTrigConv,Rank-32\#ChannelRegularConversion,Channel-32\#ChannelRegularConversion,SamplingTime-32\#ChannelRegularConversion,Rank-33\#ChannelRegularConversion,Channel-33\#ChannelRegularConversion,SamplingTime-33\#ChannelRegularConversion,Rank-34\#ChannelRegularConversion,Channel-34\#ChannelRegularConversion,SamplingTime-34\#ChannelRegularConversion,NbrOfConversion,ClockPrescaler,Resolution,DataAlign,DiscontinuousConvMode,ExternalTrigConvEdge +ADC3.InjNumberOfConversion=0 +ADC3.NbrOfConversion=4 +ADC3.NbrOfConversionFlag=1 +ADC3.Rank-31\#ChannelRegularConversion=1 +ADC3.Rank-32\#ChannelRegularConversion=2 +ADC3.Rank-33\#ChannelRegularConversion=3 ADC3.Rank-34\#ChannelRegularConversion=4 -SAI1.SlotSize-SAI_A_AsyncSlave=SAI_SLOTSIZE_32B -PD15.Signal=FMC_D1_DA1 -SH.FMC_D3_DA3.0=FMC_D3,sd-16b-d1 -SPI5.VirtualType=VM_MASTER -ProjectManager.CustomerFirmwarePackage= -PC4.GPIOParameters=GPIO_Label -RCC.SAI_AClocksFreq_Value=25000000 -RCC.PLLSAIQCLKFreq_Value=50000000 -SH.FMC_D3_DA3.ConfNb=1 -PA6.GPIOParameters=GPIO_Label -PD6.GPIOParameters=GPIO_Label -SH.FMC_A4.0=FMC_A4,12b-sda1 -PA0/WKUP.GPIOParameters=GPIO_Label -SH.FMC_A7.ConfNb=1 -RCC.PLLQoutputFreq_Value=48000000 -ProjectManager.ProjectFileName=Alchemist.ioc -SH.FMC_A5.ConfNb=1 -SH.FMC_A1.ConfNb=1 -FREERTOS.Tasks01=defaultTask,0,128,StartDefaultTask,Default,NULL -Mcu.PinsNb=78 -Dma.SAI1_B.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -Mcu.Pin73=PE1 -Mcu.Pin74=VP_FREERTOS_VS_CMSIS_V1 -Mcu.Pin71=PB9 -Mcu.Pin72=PE0 -Mcu.Pin77=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_HS -PG5.Signal=FMC_A15_BA1 -Mcu.Pin75=VP_RTC_VS_RTC_Activate -SH.FMC_D10_DA10.0=FMC_D10,sd-16b-d1 -Mcu.Pin76=VP_SYS_VS_Systick -FREERTOS.INCLUDE_vTaskDelayUntil=1 -FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 -Mcu.Pin70=PB8 -PB8.GPIO_PuPd=GPIO_PULLUP -PC2.Signal=ADCx_IN12 -PB11.GPIO_Label=CS_nRST -PD1.Signal=FMC_D3_DA3 -RCC.VCOSAIOutputFreq_ValueQ=25000000 -NVIC.DMA2_Stream1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -Mcu.Pin68=PB5 -Mcu.Pin69=PB6 -RCC.UART8Freq_Value=54000000 -PC0.Signal=FMC_SDNWE -RCC.APB1CLKDivider=RCC_HCLK_DIV4 -ADC3.Channel-31\#ChannelRegularConversion=ADC_CHANNEL_13 -PD6.Mode=SAI_A_AsyncSlave -Mcu.Pin62=PA14 -VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_HS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_HS -USB_OTG_HS.VirtualMode-Device_Only_FS=Device_Only_FS -Mcu.Pin63=PD0 -Mcu.Pin60=PG8 -SH.S_TIM2_CH1_ETR.ConfNb=1 -Mcu.Pin61=PA13 -Mcu.Pin66=PG15 -Mcu.Pin67=PB3 -Mcu.Pin64=PD1 ADC3.Resolution=ADC_RESOLUTION_12B -Mcu.Pin65=PD6 +ADC3.SamplingTime-31\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-32\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-33\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-34\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.ScanConvMode=ENABLE +Dma.ADC3.0.Direction=DMA_PERIPH_TO_MEMORY +Dma.ADC3.0.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.ADC3.0.Instance=DMA2_Stream0 +Dma.ADC3.0.MemDataAlignment=DMA_MDATAALIGN_HALFWORD +Dma.ADC3.0.MemInc=DMA_MINC_ENABLE +Dma.ADC3.0.Mode=DMA_CIRCULAR +Dma.ADC3.0.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD +Dma.ADC3.0.PeriphInc=DMA_PINC_DISABLE +Dma.ADC3.0.Priority=DMA_PRIORITY_LOW +Dma.ADC3.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +Dma.Request0=ADC3 +Dma.Request1=SAI1_A +Dma.Request2=SAI1_B +Dma.RequestsNb=3 +Dma.SAI1_A.1.Direction=DMA_MEMORY_TO_PERIPH +Dma.SAI1_A.1.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SAI1_A.1.Instance=DMA2_Stream1 +Dma.SAI1_A.1.MemDataAlignment=DMA_MDATAALIGN_WORD +Dma.SAI1_A.1.MemInc=DMA_MINC_ENABLE +Dma.SAI1_A.1.Mode=DMA_CIRCULAR +Dma.SAI1_A.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD +Dma.SAI1_A.1.PeriphInc=DMA_PINC_DISABLE +Dma.SAI1_A.1.Priority=DMA_PRIORITY_VERY_HIGH +Dma.SAI1_A.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +Dma.SAI1_B.2.Direction=DMA_PERIPH_TO_MEMORY +Dma.SAI1_B.2.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SAI1_B.2.Instance=DMA2_Stream4 +Dma.SAI1_B.2.MemDataAlignment=DMA_MDATAALIGN_WORD +Dma.SAI1_B.2.MemInc=DMA_MINC_ENABLE +Dma.SAI1_B.2.Mode=DMA_CIRCULAR +Dma.SAI1_B.2.PeriphDataAlignment=DMA_PDATAALIGN_WORD Dma.SAI1_B.2.PeriphInc=DMA_PINC_DISABLE -USB_DEVICE.VID-AUDIO_HS=0x1209 -PF8.GPIO_Label=EXTSPI_MISO -PC3.GPIOParameters=GPIO_Label -PD10.Signal=FMC_D15_DA15 -PA3.Mode=Asynchronous -SH.FMC_A3.0=FMC_A3,12b-sda1 -PB8.GPIO_Label=SW3 -Mcu.Pin59=PG5 +Dma.SAI1_B.2.Priority=DMA_PRIORITY_VERY_HIGH +Dma.SAI1_B.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode FMC.CASLatency1=FMC_SDRAM_CAS_LATENCY_3 -SH.GPXTI2.ConfNb=1 -Mcu.Pin57=PD15 -Mcu.Pin58=PG4 -Mcu.Pin51=PB14 -RCC.USART6Freq_Value=108000000 -Mcu.Pin52=PB15 -SH.FMC_D15_DA15.0=FMC_D15,sd-16b-d1 -Dma.SAI1_B.2.PeriphDataAlignment=DMA_PDATAALIGN_WORD -Mcu.Pin50=PB13 -Mcu.Pin55=PD10 -Mcu.Pin56=PD14 -Mcu.Pin53=PD8 -Mcu.Pin54=PD9 -SH.S_TIM2_CH2.ConfNb=1 -PB9.Locked=true -PB11.GPIOParameters=GPIO_Label -ADC3.NbrOfConversion=4 -Mcu.Pin48=PB10 -Mcu.Pin49=PB11 -Mcu.Pin46=PE14 -Mcu.Pin47=PE15 -PB10.Signal=GPIO_Output -PB14.Signal=USB_OTG_HS_DM -Mcu.Pin40=PE8 -Mcu.Pin41=PE9 -FREERTOS.MEMORY_ALLOCATION=2 -Mcu.Pin44=PE12 -Mcu.Pin45=PE13 -Mcu.Pin42=PE10 -Mcu.Pin43=PE11 -ProjectManager.LastFirmware=true +FMC.ExitSelfRefreshDelay1=6 +FMC.IPParameters=ReadPipeDelay1,ReadBurst1,ReadBurst2,SDClockPeriod1,SDClockPeriod2,CASLatency1,LoadToActiveDelay1,ExitSelfRefreshDelay1,SelfRefreshTime1,RowCycleDelay1,RowCycleDelay2,WriteRecoveryTime1,RPDelay1,RPDelay2,RCDDelay1 +FMC.LoadToActiveDelay1=2 +FMC.RCDDelay1=2 +FMC.RPDelay1=2 +FMC.RPDelay2=2 FMC.ReadBurst1=FMC_SDRAM_RBURST_ENABLE -SH.FMC_A6.0=FMC_A6,12b-sda1 FMC.ReadBurst2=FMC_SDRAM_RBURST_ENABLE -PE14.Signal=FMC_D11_DA11 -PE6.Mode=TX_Only_Simplex_Unidirect_Master -PE15.Signal=FMC_D12_DA12 -Mcu.Pin37=PG0 -Mcu.Pin38=PG1 -Mcu.Pin35=PF14 -RCC.I2C1Freq_Value=54000000 -Mcu.Pin36=PF15 -PE8.Signal=FMC_D5_DA5 -RCC.PLLI2SPCLKFreq_Value=96000000 -SPI1.Mode=SPI_MODE_MASTER -SH.FMC_D14_DA14.ConfNb=1 -Mcu.Pin39=PE7 -PC2.GPIOParameters=GPIO_Label -Mcu.Pin30=PB1 -PA1.GPIO_Label=PWM2 -RCC.EthernetFreq_Value=168000000 -SH.ADCx_IN12.ConfNb=1 -Mcu.Pin33=PF12 -TIM3.IPParameters=Channel-PWM Generation4 CH4,Prescaler,Period,Pulse-PWM Generation4 CH4 -Mcu.Pin34=PF13 -PA0/WKUP.GPIO_Label=PWM1 -ADC3.SamplingTime-33\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -Mcu.Pin31=PB2/BOOT1 -Mcu.Pin32=PF11 -NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +FMC.ReadPipeDelay1=FMC_SDRAM_RPIPE_DELAY_0 +FMC.RowCycleDelay1=6 +FMC.RowCycleDelay2=6 +FMC.SDClockPeriod1=FMC_SDRAM_CLOCK_PERIOD_2 +FMC.SDClockPeriod2=FMC_SDRAM_CLOCK_PERIOD_2 +FMC.SelfRefreshTime1=4 +FMC.WriteRecoveryTime1=2 +FREERTOS.FootprintOK=true +FREERTOS.INCLUDE_vTaskDelayUntil=1 +FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configENABLE_BACKWARD_COMPATIBILITY,configUSE_MUTEXES,FootprintOK,MEMORY_ALLOCATION,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,INCLUDE_vTaskDelayUntil +FREERTOS.MEMORY_ALLOCATION=2 +FREERTOS.Tasks01=defaultTask,0,128,StartDefaultTask,Default,NULL +FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 +FREERTOS.configENABLE_BACKWARD_COMPATIBILITY=0 +FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 FREERTOS.configUSE_MUTEXES=0 -PF13.Signal=FMC_A7 -TIM2.Period=1023 -PA13.Mode=Serial_Wire -SH.FMC_SDNCAS.0=FMC_SDNCAS,12b-sda1 -ProjectManager.FreePins=true -Dma.ADC3.0.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD -PF9.GPIOParameters=GPIO_Label -SH.FMC_NBL1.ConfNb=1 -RCC.PLLI2SQCLKFreq_Value=96000000 -Mcu.Pin26=PA6 -Mcu.Pin27=PA7 -NVIC.DMA2_Stream4_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -RCC.RTCHSEDivFreq_Value=12500000 +FREERTOS.configUSE_PREEMPTION=0 +File.Version=6 +GPIO.groupedBy=Group By Peripherals +KeepUserPlacement=false +Mcu.Family=STM32F4 +Mcu.IP0=ADC3 +Mcu.IP1=DMA +Mcu.IP10=SPI5 +Mcu.IP11=SYS +Mcu.IP12=TIM2 +Mcu.IP13=TIM3 +Mcu.IP14=USART2 +Mcu.IP15=USB_DEVICE +Mcu.IP16=USB_OTG_HS +Mcu.IP2=FMC +Mcu.IP3=FREERTOS +Mcu.IP4=NVIC +Mcu.IP5=RCC +Mcu.IP6=RTC +Mcu.IP7=SAI1 +Mcu.IP8=SPI1 +Mcu.IP9=SPI4 +Mcu.IPNb=17 +Mcu.Name=STM32F427Z(G-I)Tx +Mcu.Package=LQFP144 +Mcu.Pin0=PE2 +Mcu.Pin1=PE3 +Mcu.Pin10=PF4 +Mcu.Pin11=PF5 +Mcu.Pin12=PF7 +Mcu.Pin13=PF8 +Mcu.Pin14=PF9 +Mcu.Pin15=PF10 +Mcu.Pin16=PH0/OSC_IN +Mcu.Pin17=PH1/OSC_OUT +Mcu.Pin18=PC0 +Mcu.Pin19=PC1 +Mcu.Pin2=PE4 +Mcu.Pin20=PC2 +Mcu.Pin21=PC3 +Mcu.Pin22=PA0/WKUP +Mcu.Pin23=PA1 Mcu.Pin24=PA2 -ProjectManager.UnderRoot=false Mcu.Pin25=PA3 +Mcu.Pin26=PA6 +Mcu.Pin27=PA7 Mcu.Pin28=PC4 Mcu.Pin29=PC5 -SH.FMC_D7_DA7.ConfNb=1 -Mcu.Pin22=PA0/WKUP -PB5.Signal=FMC_SDCKE1 -Mcu.Pin23=PA1 -Mcu.Pin20=PC2 -Mcu.Pin21=PC3 +Mcu.Pin3=PE5 +Mcu.Pin30=PB0 +Mcu.Pin31=PB1 +Mcu.Pin32=PB2/BOOT1 +Mcu.Pin33=PF11 +Mcu.Pin34=PF12 +Mcu.Pin35=PF13 +Mcu.Pin36=PF14 +Mcu.Pin37=PF15 +Mcu.Pin38=PG0 +Mcu.Pin39=PG1 +Mcu.Pin4=PE6 +Mcu.Pin40=PE7 +Mcu.Pin41=PE8 +Mcu.Pin42=PE9 +Mcu.Pin43=PE10 +Mcu.Pin44=PE11 +Mcu.Pin45=PE12 +Mcu.Pin46=PE13 +Mcu.Pin47=PE14 +Mcu.Pin48=PE15 +Mcu.Pin49=PB10 +Mcu.Pin5=PC15/OSC32_OUT +Mcu.Pin50=PB11 +Mcu.Pin51=PB13 +Mcu.Pin52=PB14 +Mcu.Pin53=PB15 +Mcu.Pin54=PD8 +Mcu.Pin55=PD9 +Mcu.Pin56=PD10 +Mcu.Pin57=PD14 +Mcu.Pin58=PD15 +Mcu.Pin59=PG4 +Mcu.Pin6=PF0 +Mcu.Pin60=PG5 +Mcu.Pin61=PG8 +Mcu.Pin62=PA13 +Mcu.Pin63=PA14 +Mcu.Pin64=PD0 +Mcu.Pin65=PD1 +Mcu.Pin66=PD6 +Mcu.Pin67=PG15 +Mcu.Pin68=PB3 +Mcu.Pin69=PB5 +Mcu.Pin7=PF1 +Mcu.Pin70=PB6 +Mcu.Pin71=PB8 +Mcu.Pin72=PB9 +Mcu.Pin73=PE0 +Mcu.Pin74=PE1 +Mcu.Pin75=VP_FREERTOS_VS_CMSIS_V1 +Mcu.Pin76=VP_RTC_VS_RTC_Activate +Mcu.Pin77=VP_SYS_VS_Systick +Mcu.Pin78=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_HS +Mcu.Pin8=PF2 +Mcu.Pin9=PF3 +Mcu.PinsNb=79 +Mcu.ThirdPartyNb=0 +Mcu.UserConstants= +Mcu.UserName=STM32F427ZITx +MxCube.Version=6.3.0 +MxDb.Version=DB.6.0.30 +NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.DMA2_Stream0_IRQn=true\:10\:0\:true\:false\:true\:true\:true\:true +NVIC.DMA2_Stream1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true +NVIC.DMA2_Stream4_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true +NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.EXTI2_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true +NVIC.EXTI9_5_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true NVIC.ForceEnableDMAVector=true -SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX -NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -PE5.GPIO_Label=CS_SCK -SH.FMC_A10.ConfNb=1 -ProjectManager.CompilerOptimize=6 -SH.FMC_A5.0=FMC_A5,12b-sda1 -SH.S_TIM2_CH1_ETR.0=TIM2_CH1,PWM Generation1 CH1 -SH.FMC_SDNRAS.ConfNb=1 -ProjectManager.HeapSize=0x200 -Mcu.Pin15=PF10 NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -Mcu.Pin16=PH0/OSC_IN -ADC3.EOCSelection=ADC_EOC_SEQ_CONV -Mcu.Pin13=PF8 -Dma.ADC3.0.Mode=DMA_CIRCULAR -Mcu.Pin14=PF9 -PF10.GPIOParameters=GPIO_Label -Mcu.Pin19=PC1 -ProjectManager.ComputerToolchain=false -PF9.Signal=SPI5_MOSI -Mcu.Pin17=PH1/OSC_OUT -Mcu.Pin18=PC0 -Dma.SAI1_B.2.Instance=DMA2_Stream4 +NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.OTG_HS_IRQn=true\:8\:0\:true\:false\:true\:true\:true\:true +NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 -Mcu.Pin11=PF5 -Mcu.Pin12=PF7 -Mcu.Pin10=PF4 -Dma.SAI1_A.1.Priority=DMA_PRIORITY_VERY_HIGH -PB2/BOOT1.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -PE3.Signal=SAI1_SD_B -PC3.GPIO_Label=ADC1 -ADC3.Rank-33\#ChannelRegularConversion=3 -Dma.SAI1_A.1.PeriphInc=DMA_PINC_DISABLE -PC15/OSC32_OUT.Signal=GPIO_Output -PF4.Signal=FMC_A4 -Dma.SAI1_B.2.FIFOMode=DMA_FIFOMODE_DISABLE -SH.FMC_D12_DA12.ConfNb=1 -RCC.I2C2Freq_Value=54000000 -SPI5.IPParameters=Mode,CalculateBaudRate,VirtualType,Direction -SAI1.SlotSize-SAI_B_SyncSlave=SAI_SLOTSIZE_32B +NVIC.SAI1_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true +NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.SavedPendsvIrqHandlerGenerated=true +NVIC.SavedSvcallIrqHandlerGenerated=true +NVIC.SavedSystickIrqHandlerGenerated=true +NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:true\:true +NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +PA0/WKUP.GPIOParameters=GPIO_Label +PA0/WKUP.GPIO_Label=PWM1 +PA0/WKUP.Signal=S_TIM2_CH1_ETR +PA1.GPIOParameters=GPIO_Label +PA1.GPIO_Label=PWM2 +PA1.Signal=S_TIM2_CH2 +PA13.Mode=Serial_Wire +PA13.Signal=SYS_JTMS-SWDIO +PA14.Mode=Serial_Wire +PA14.Signal=SYS_JTCK-SWCLK +PA2.Locked=true +PA2.Mode=Asynchronous +PA2.Signal=USART2_TX +PA3.Mode=Asynchronous +PA3.Signal=USART2_RX +PA6.GPIOParameters=GPIO_Label +PA6.GPIO_Label=FLASH_MISO +PA6.Mode=Full_Duplex_Master +PA6.Signal=SPI1_MISO PA7.GPIOParameters=GPIO_Label +PA7.GPIO_Label=FLASH_MOSI +PA7.Mode=Full_Duplex_Master +PA7.Signal=SPI1_MOSI +PB0.GPIOParameters=GPIO_Label +PB0.GPIO_Label=FLASH_WP +PB0.Locked=true +PB0.Signal=GPIO_Output +PB1.GPIOParameters=GPIO_Label +PB1.GPIO_Label=PWM3 +PB1.Signal=S_TIM3_CH4 +PB10.GPIOParameters=GPIO_Label +PB10.GPIO_Label=CS_nCS +PB10.Locked=true +PB10.Signal=GPIO_Output +PB11.GPIOParameters=GPIO_Label +PB11.GPIO_Label=CS_nRST +PB11.Locked=true +PB11.Signal=GPIO_Output +PB13.Mode=Activate_VBUS_FS +PB13.Signal=USB_OTG_HS_VBUS +PB14.Mode=Device_Only_FS +PB14.Signal=USB_OTG_HS_DM +PB15.Mode=Device_Only_FS +PB15.Signal=USB_OTG_HS_DP +PB2/BOOT1.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PB2/BOOT1.GPIO_Label=SW2 +PB2/BOOT1.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PB2/BOOT1.GPIO_PuPd=GPIO_PULLUP +PB2/BOOT1.Locked=true +PB2/BOOT1.Signal=GPXTI2 +PB3.GPIOParameters=GPIO_Label +PB3.GPIO_Label=FLASH_SCK +PB3.Locked=true +PB3.Mode=Full_Duplex_Master +PB3.Signal=SPI1_SCK +PB5.Mode=SdramChipSelect2_1 +PB5.Signal=FMC_SDCKE1 +PB6.Mode=SdramChipSelect2_1 +PB6.Signal=FMC_SDNE1 +PB8.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PB8.GPIO_Label=SW3 +PB8.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PB8.GPIO_PuPd=GPIO_PULLUP +PB8.Locked=true +PB8.Signal=GPXTI8 +PB9.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PB9.GPIO_Label=SW1 +PB9.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PB9.GPIO_PuPd=GPIO_PULLUP +PB9.Locked=true +PB9.Signal=GPXTI9 +PC0.Signal=FMC_SDNWE +PC1.GPIOParameters=GPIO_Label +PC1.GPIO_Label=ADC3 +PC1.Locked=true PC1.Signal=ADCx_IN11 -ADC3.EnableAnalogWatchDog=false -Mcu.Family=STM32F4 -FMC.IPParameters=ReadPipeDelay1,ReadBurst1,ReadBurst2,SDClockPeriod1,SDClockPeriod2,CASLatency1,LoadToActiveDelay1,ExitSelfRefreshDelay1,SelfRefreshTime1,RowCycleDelay1,RowCycleDelay2,WriteRecoveryTime1,RPDelay1,RPDelay2,RCDDelay1 -NVIC.OTG_HS_IRQn=true\:8\:0\:true\:false\:true\:true\:true\:true -ProjectManager.MainLocation=Src -SH.FMC_A6.ConfNb=1 -PA6.Mode=Full_Duplex_Master -SH.FMC_A8.0=FMC_A8,12b-sda1 -RCC.SAI1Freq_Value=50000000 -RCC.CortexFreq_Value=168000000 -SH.FMC_A2.ConfNb=1 +PC15/OSC32_OUT.GPIOParameters=GPIO_Label PC15/OSC32_OUT.GPIO_Label=EXTSPI_nCS -ProjectManager.KeepUserCode=true -Mcu.UserName=STM32F427ZITx -SH.FMC_D14_DA14.0=FMC_D14,sd-16b-d1 -Dma.SAI1_A.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -Dma.SAI1_B.2.MemInc=DMA_MINC_ENABLE -SAI1.FrameLength-SAI_A_AsyncSlave=64 -SAI1.FrameLength-SAI_B_SyncSlave=64 +PC15/OSC32_OUT.Locked=true +PC15/OSC32_OUT.Signal=GPIO_Output +PC2.GPIOParameters=GPIO_Label +PC2.GPIO_Label=ADC2 +PC2.Locked=true +PC2.Signal=ADCx_IN12 +PC3.GPIOParameters=GPIO_Label +PC3.GPIO_Label=ADC1 +PC3.Locked=true +PC3.Signal=ADCx_IN13 +PC4.GPIOParameters=GPIO_Label +PC4.GPIO_Label=FLASH_HOLD +PC4.Locked=true +PC4.Signal=GPIO_Output +PC5.GPIOParameters=GPIO_Label +PC5.GPIO_Label=FLASH_nCS PC5.Locked=true -SPI4.Direction=SPI_DIRECTION_2LINES -SH.FMC_NBL0.0=FMC_NBL0,Sd2ByteEnable1 -ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-MX_SPI5_Init-SPI5-false-HAL-true,9-MX_TIM2_Init-TIM2-false-HAL-true,10-MX_USART2_UART_Init-USART2-false-HAL-true,11-SystemClock_Config-RCC-false-HAL-true,12-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-true,13-MX_TIM3_Init-TIM3-false-HAL-true,14-MX_RTC_Init-RTC-false-HAL-true -SH.FMC_D6_DA6.0=FMC_D6,sd-16b-d1 -PA0/WKUP.Signal=S_TIM2_CH1_ETR -PB2/BOOT1.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -RCC.PLLI2SRCLKFreq_Value=96000000 -RCC.USART2Freq_Value=54000000 -SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 -SH.FMC_A11.0=FMC_A11,12b-sda1 -TIM2.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2 -PC1.Locked=true -PB11.Signal=GPIO_Output -PB15.Signal=USB_OTG_HS_DP -ADC3.Channel-32\#ChannelRegularConversion=ADC_CHANNEL_12 +PC5.Signal=GPIO_Output +PD0.Signal=FMC_D2_DA2 +PD1.Signal=FMC_D3_DA3 +PD10.Signal=FMC_D15_DA15 +PD14.Signal=FMC_D0_DA0 +PD15.Signal=FMC_D1_DA1 +PD6.GPIOParameters=GPIO_Label +PD6.GPIO_Label=CS_SDIN +PD6.Mode=SAI_A_AsyncSlave +PD6.Signal=SAI1_SD_A +PD8.Signal=FMC_D13_DA13 +PD9.Signal=FMC_D14_DA14 +PE0.Signal=FMC_NBL0 +PE1.Signal=FMC_NBL1 +PE10.Signal=FMC_D7_DA7 +PE11.Signal=FMC_D8_DA8 +PE12.Signal=FMC_D9_DA9 +PE13.Signal=FMC_D10_DA10 +PE14.Signal=FMC_D11_DA11 +PE15.Signal=FMC_D12_DA12 +PE2.GPIOParameters=GPIO_Label +PE2.GPIO_Label=CS_SCK +PE2.Mode=TX_Only_Simplex_Unidirect_Master +PE2.Signal=SPI4_SCK +PE3.GPIOParameters=GPIO_Label +PE3.GPIO_Label=CS_SDOUT +PE3.Mode=SAI_B_SyncSlave +PE3.Signal=SAI1_SD_B +PE4.GPIOParameters=GPIO_Label +PE4.GPIO_Label=CS_LRCK +PE4.Mode=SAI_A_AsyncSlave +PE4.Signal=SAI1_FS_A +PE5.GPIOParameters=GPIO_Label +PE5.GPIO_Label=CS_SCK +PE5.Mode=SAI_A_AsyncSlave +PE5.Signal=SAI1_SCK_A +PE6.GPIOParameters=GPIO_Label +PE6.GPIO_Label=CS_SDA +PE6.Mode=TX_Only_Simplex_Unidirect_Master +PE6.Signal=SPI4_MOSI +PE7.Signal=FMC_D4_DA4 +PE8.Signal=FMC_D5_DA5 +PE9.Signal=FMC_D6_DA6 +PF0.Signal=FMC_A0 +PF1.Signal=FMC_A1 +PF10.GPIOParameters=GPIO_Label +PF10.GPIO_Label=ADC4 +PF10.Locked=true +PF10.Mode=IN8 +PF10.Signal=ADC3_IN8 +PF11.Signal=FMC_SDNRAS +PF12.Signal=FMC_A6 +PF13.Signal=FMC_A7 +PF14.Signal=FMC_A8 +PF15.Signal=FMC_A9 +PF2.Signal=FMC_A2 +PF3.Signal=FMC_A3 +PF4.Signal=FMC_A4 +PF5.Signal=FMC_A5 +PF7.GPIOParameters=GPIO_Label +PF7.GPIO_Label=EXTSPI_SCK +PF7.Mode=Full_Duplex_Master +PF7.Signal=SPI5_SCK +PF8.GPIOParameters=GPIO_Label +PF8.GPIO_Label=EXTSPI_MISO +PF8.Mode=Full_Duplex_Master +PF8.Signal=SPI5_MISO +PF9.GPIOParameters=GPIO_Label +PF9.GPIO_Label=EXTSPI_MOSI +PF9.Mode=Full_Duplex_Master +PF9.Signal=SPI5_MOSI +PG0.Signal=FMC_A10 +PG1.Signal=FMC_A11 PG15.Signal=FMC_SDNCAS -PE5.GPIOParameters=GPIO_Label +PG4.Signal=FMC_A14_BA0 +PG5.Signal=FMC_A15_BA1 +PG8.Signal=FMC_SDCLK +PH0/OSC_IN.Mode=HSE-External-Oscillator +PH0/OSC_IN.Signal=RCC_OSC_IN +PH1/OSC_OUT.Mode=HSE-External-Oscillator +PH1/OSC_OUT.Signal=RCC_OSC_OUT +PinOutPanel.RotationAngle=0 +ProjectManager.AskForMigrate=true +ProjectManager.BackupPrevious=false +ProjectManager.CompilerOptimize=6 +ProjectManager.ComputerToolchain=false +ProjectManager.CoupleFile=false +ProjectManager.CustomerFirmwarePackage= +ProjectManager.DefaultFWLocation=true +ProjectManager.DeletePrevious=true +ProjectManager.DeviceId=STM32F427ZITx +ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.26.2 +ProjectManager.FreePins=true +ProjectManager.HalAssertFull=true +ProjectManager.HeapSize=0x200 +ProjectManager.KeepUserCode=true +ProjectManager.LastFirmware=true +ProjectManager.LibraryCopy=0 +ProjectManager.MainLocation=Src +ProjectManager.NoMain=false +ProjectManager.PreviousToolchain= +ProjectManager.ProjectBuild=false +ProjectManager.ProjectFileName=Alchemist.ioc +ProjectManager.ProjectName=Alchemist +ProjectManager.RegisterCallBack= ProjectManager.StackSize=0x400 -SH.GPXTI2.0=GPIO_EXTI2 -RCC.SAI_BClocksFreq_Value=25000000 -ADC3.SamplingTime-32\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -SAI1.Instance-SAI_A_AsyncSlave=SAI$Index_Block_A -RCC.I2C3Freq_Value=54000000 -Mcu.IP4=NVIC -Mcu.IP5=RCC +ProjectManager.TargetToolchain=Makefile +ProjectManager.ToolChainLocation= +ProjectManager.UnderRoot=false +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC3_Init-ADC3-false-HAL-true,4-MX_FMC_Init-FMC-false-HAL-true,5-MX_SAI1_Init-SAI1-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_SPI4_Init-SPI4-false-HAL-true,8-MX_SPI5_Init-SPI5-false-HAL-true,9-MX_TIM2_Init-TIM2-false-HAL-true,10-MX_USART2_UART_Init-USART2-false-HAL-true,11-SystemClock_Config-RCC-false-HAL-true,12-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,13-MX_TIM3_Init-TIM3-false-HAL-true,14-MX_RTC_Init-RTC-false-HAL-true +RCC.48MHZClocksFreq_Value=48000000 +RCC.AHBFreq_Value=168000000 +RCC.APB1CLKDivider=RCC_HCLK_DIV4 +RCC.APB1Freq_Value=42000000 +RCC.APB1TimFreq_Value=84000000 +RCC.APB2CLKDivider=RCC_HCLK_DIV2 +RCC.APB2Freq_Value=84000000 +RCC.APB2TimFreq_Value=168000000 +RCC.CECFreq_Value=32786.88524590164 +RCC.CortexFreq_Value=168000000 +RCC.EthernetFreq_Value=168000000 RCC.FCLKCortexFreq_Value=168000000 -Mcu.IP2=FMC -Mcu.IP3=FREERTOS -Mcu.IP0=ADC3 -SH.FMC_A7.0=FMC_A7,12b-sda1 -Mcu.IP1=DMA -PE4.GPIOParameters=GPIO_Label -PB8.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -Mcu.UserConstants= -SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE -SPI4.Mode=SPI_MODE_MASTER -PC1.GPIOParameters=GPIO_Label -RCC.SDMMCFreq_Value=216000000 -Mcu.ThirdPartyNb=0 -PH0/OSC_IN.Mode=HSE-External-Oscillator +RCC.FamilyName=M RCC.HCLKFreq_Value=168000000 -Mcu.IPNb=17 +RCC.HSE_VALUE=25000000 +RCC.HSI_VALUE=16000000 +RCC.I2C1Freq_Value=54000000 +RCC.I2C2Freq_Value=54000000 +RCC.I2C3Freq_Value=54000000 +RCC.I2C4Freq_Value=54000000 RCC.I2SClocksFreq_Value=96000000 +RCC.I2SFreq_Value=96000000 +RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CECFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SClocksFreq_Value,I2SFreq_Value,LCDTFToutputFreq_Value,LPTIM1Freq_Value,LSE_VALUE,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLI2SPCLKFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLI2SRoutputFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLQoutputFreq_Value,PLLSAIN,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIRCLKFreq_Value,PLLSAIoutputFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SAI1Freq_Value,SAI2Freq_Value,SAI_AClocksFreq_Value,SAI_BClocksFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,UART4Freq_Value,UART5Freq_Value,UART7Freq_Value,UART8Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USART6Freq_Value,USBFreq_Value,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value,VCOSAIOutputFreq_ValueQ,VcooutputI2S,VcooutputI2SQ +RCC.LCDTFToutputFreq_Value=25000000 +RCC.LPTIM1Freq_Value=54000000 +RCC.LSE_VALUE=32768 +RCC.LSI_VALUE=32000 +RCC.MCO2PinFreq_Value=168000000 +RCC.PLLCLKFreq_Value=168000000 +RCC.PLLI2SPCLKFreq_Value=96000000 +RCC.PLLI2SQCLKFreq_Value=96000000 +RCC.PLLI2SRCLKFreq_Value=96000000 RCC.PLLI2SRoutputFreq_Value=96000000 -ProjectManager.PreviousToolchain= -TIM3.Period=1023 +RCC.PLLM=25 +RCC.PLLN=336 +RCC.PLLQ=7 +RCC.PLLQCLKFreq_Value=48000000 +RCC.PLLQoutputFreq_Value=48000000 +RCC.PLLSAIN=100 +RCC.PLLSAIPCLKFreq_Value=50000000 +RCC.PLLSAIQCLKFreq_Value=50000000 +RCC.PLLSAIRCLKFreq_Value=50000000 +RCC.PLLSAIoutputFreq_Value=50000000 +RCC.RTCFreq_Value=32000 +RCC.RTCHSEDivFreq_Value=12500000 +RCC.SAI1Freq_Value=50000000 +RCC.SAI2Freq_Value=50000000 +RCC.SAI_AClocksFreq_Value=25000000 +RCC.SAI_BClocksFreq_Value=25000000 +RCC.SDMMCFreq_Value=216000000 RCC.SPDIFRXFreq_Value=96000000 -RCC.VcooutputI2S=96000000 -SH.FMC_NBL1.0=FMC_NBL1,Sd2ByteEnable1 -PF12.Signal=FMC_A6 -FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 -PB9.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -Mcu.Pin6=PF0 -Mcu.Pin7=PF1 -NVIC.DMA2_Stream0_IRQn=true\:10\:0\:true\:false\:true\:true\:true\:true -Mcu.Pin8=PF2 -Mcu.Pin9=PF3 +RCC.SYSCLKFreq_VALUE=168000000 +RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK +RCC.UART4Freq_Value=54000000 +RCC.UART5Freq_Value=54000000 +RCC.UART7Freq_Value=54000000 +RCC.UART8Freq_Value=54000000 +RCC.USART1Freq_Value=108000000 +RCC.USART2Freq_Value=54000000 +RCC.USART3Freq_Value=54000000 +RCC.USART6Freq_Value=108000000 +RCC.USBFreq_Value=48000000 +RCC.VCOI2SOutputFreq_Value=192000000 +RCC.VCOInputFreq_Value=1000000 +RCC.VCOOutputFreq_Value=336000000 RCC.VCOSAIOutputFreq_Value=100000000 -SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,VirtualType,Direction -Dma.ADC3.0.MemDataAlignment=DMA_MDATAALIGN_HALFWORD -FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configENABLE_BACKWARD_COMPATIBILITY,configUSE_MUTEXES,FootprintOK,MEMORY_ALLOCATION,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,INCLUDE_vTaskDelayUntil +RCC.VCOSAIOutputFreq_ValueQ=25000000 +RCC.VcooutputI2S=96000000 +RCC.VcooutputI2SQ=96000000 +SAI1.AudioMode-SAI_A_AsyncSlave=SAI_MODESLAVE_TX +SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_RX +SAI1.DataSize-SAI_A_AsyncSlave=SAI_DATASIZE_24 +SAI1.FSDefinition-SAI_A_AsyncSlave=SAI_FS_CHANNEL_IDENTIFICATION +SAI1.FSDefinition-SAI_B_SyncSlave=SAI_FS_CHANNEL_IDENTIFICATION +SAI1.FrameLength-SAI_A_AsyncSlave=64 +SAI1.FrameLength-SAI_B_SyncSlave=64 +SAI1.IPParameters=Instance-SAI_A_AsyncSlave,VirtualMode-SAI_A_AsyncSlave,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,Synchro-SAI_B_SyncSlave,FrameLength-SAI_B_SyncSlave,SlotSize-SAI_B_SyncSlave,AudioMode-SAI_B_SyncSlave,AudioMode-SAI_A_AsyncSlave,DataSize-SAI_A_AsyncSlave,FrameLength-SAI_A_AsyncSlave,SlotSize-SAI_A_AsyncSlave,SlotNumber-SAI_A_AsyncSlave,FSDefinition-SAI_A_AsyncSlave,FSDefinition-SAI_B_SyncSlave,Synchro-SAI_A_AsyncSlave,Synchro_A,Synchro_B +SAI1.Instance-SAI_A_AsyncSlave=SAI$Index_Block_A +SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B +SAI1.SlotNumber-SAI_A_AsyncSlave=2 +SAI1.SlotSize-SAI_A_AsyncSlave=SAI_SLOTSIZE_32B +SAI1.SlotSize-SAI_B_SyncSlave=SAI_SLOTSIZE_32B +SAI1.Synchro-SAI_A_AsyncSlave=SAI_ASYNCHRONOUS +SAI1.Synchro-SAI_B_SyncSlave=SAI_SYNCHRONOUS +SAI1.Synchro_A=SAI_ASYNCHRONOUS +SAI1.Synchro_B=SAI_SYNCHRONOUS +SAI1.VirtualMode-SAI_A_AsyncSlave=VM_SLAVE +SAI1.VirtualMode-SAI_B_SyncSlave=VM_SLAVE +SH.ADCx_IN11.0=ADC3_IN11,IN11 +SH.ADCx_IN11.ConfNb=1 +SH.ADCx_IN12.0=ADC3_IN12,IN12 +SH.ADCx_IN12.ConfNb=1 +SH.ADCx_IN13.0=ADC3_IN13,IN13 +SH.ADCx_IN13.ConfNb=1 +SH.FMC_A0.0=FMC_A0,12b-sda1 +SH.FMC_A0.ConfNb=1 +SH.FMC_A1.0=FMC_A1,12b-sda1 +SH.FMC_A1.ConfNb=1 SH.FMC_A10.0=FMC_A10,12b-sda1 -RCC.AHBFreq_Value=168000000 -Mcu.Pin0=PE2 -Mcu.Pin1=PE3 -Mcu.Pin2=PE4 -FREERTOS.configUSE_PREEMPTION=0 -Mcu.Pin3=PE5 -Mcu.Pin4=PE6 -Mcu.Pin5=PC15/OSC32_OUT -RCC.HSE_VALUE=25000000 -NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +SH.FMC_A10.ConfNb=1 +SH.FMC_A11.0=FMC_A11,12b-sda1 +SH.FMC_A11.ConfNb=1 +SH.FMC_A14_BA0.0=FMC_BA0,FourSdramBanks1 SH.FMC_A14_BA0.ConfNb=1 -ADC3.InjNumberOfConversion=0 -SH.FMC_D8_DA8.0=FMC_D8,sd-16b-d1 -FMC.ExitSelfRefreshDelay1=6 -FMC.RPDelay2=2 -Mcu.IP10=SPI5 -FMC.RPDelay1=2 -NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:true\:true -Mcu.IP12=TIM2 -Mcu.IP11=SYS -FREERTOS.configENABLE_BACKWARD_COMPATIBILITY=0 -PC15/OSC32_OUT.GPIOParameters=GPIO_Label -SH.FMC_D2_DA2.0=FMC_D2,sd-16b-d1 -Mcu.IP14=USART2 -PF9.Mode=Full_Duplex_Master -Mcu.IP13=TIM3 -PE13.Signal=FMC_D10_DA10 -Mcu.IP16=USB_OTG_HS -Mcu.IP15=USB_DEVICE -PF7.GPIO_Label=EXTSPI_SCK -RCC.VCOInputFreq_Value=1000000 -PA14.Mode=Serial_Wire -TIM3.Prescaler=16 -PB2/BOOT1.GPIO_PuPd=GPIO_PULLUP -PF11.Signal=FMC_SDNRAS -PB5.Mode=SdramChipSelect2_1 -File.Version=6 -PE3.GPIOParameters=GPIO_Label -ADC3.DataAlign=ADC_DATAALIGN_RIGHT -SH.ADCx_IN13.ConfNb=1 -SH.FMC_D5_DA5.ConfNb=1 -PB3.GPIOParameters=GPIO_Label -Dma.ADC3.0.MemInc=DMA_MINC_ENABLE +SH.FMC_A15_BA1.0=FMC_BA1,FourSdramBanks1 +SH.FMC_A15_BA1.ConfNb=1 +SH.FMC_A2.0=FMC_A2,12b-sda1 +SH.FMC_A2.ConfNb=1 +SH.FMC_A3.0=FMC_A3,12b-sda1 +SH.FMC_A3.ConfNb=1 +SH.FMC_A4.0=FMC_A4,12b-sda1 +SH.FMC_A4.ConfNb=1 +SH.FMC_A5.0=FMC_A5,12b-sda1 +SH.FMC_A5.ConfNb=1 +SH.FMC_A6.0=FMC_A6,12b-sda1 +SH.FMC_A6.ConfNb=1 +SH.FMC_A7.0=FMC_A7,12b-sda1 +SH.FMC_A7.ConfNb=1 +SH.FMC_A8.0=FMC_A8,12b-sda1 +SH.FMC_A8.ConfNb=1 +SH.FMC_A9.0=FMC_A9,12b-sda1 +SH.FMC_A9.ConfNb=1 +SH.FMC_D0_DA0.0=FMC_D0,sd-16b-d1 +SH.FMC_D0_DA0.ConfNb=1 +SH.FMC_D10_DA10.0=FMC_D10,sd-16b-d1 +SH.FMC_D10_DA10.ConfNb=1 +SH.FMC_D11_DA11.0=FMC_D11,sd-16b-d1 +SH.FMC_D11_DA11.ConfNb=1 +SH.FMC_D12_DA12.0=FMC_D12,sd-16b-d1 +SH.FMC_D12_DA12.ConfNb=1 +SH.FMC_D13_DA13.0=FMC_D13,sd-16b-d1 +SH.FMC_D13_DA13.ConfNb=1 +SH.FMC_D14_DA14.0=FMC_D14,sd-16b-d1 +SH.FMC_D14_DA14.ConfNb=1 +SH.FMC_D15_DA15.0=FMC_D15,sd-16b-d1 +SH.FMC_D15_DA15.ConfNb=1 +SH.FMC_D1_DA1.0=FMC_D1,sd-16b-d1 +SH.FMC_D1_DA1.ConfNb=1 +SH.FMC_D2_DA2.0=FMC_D2,sd-16b-d1 SH.FMC_D2_DA2.ConfNb=1 -PB8.Locked=true -TIM2.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 -FMC.ReadPipeDelay1=FMC_SDRAM_RPIPE_DELAY_0 -PE4.Mode=SAI_A_AsyncSlave +SH.FMC_D3_DA3.0=FMC_D3,sd-16b-d1 +SH.FMC_D3_DA3.ConfNb=1 +SH.FMC_D4_DA4.0=FMC_D4,sd-16b-d1 +SH.FMC_D4_DA4.ConfNb=1 +SH.FMC_D5_DA5.0=FMC_D5,sd-16b-d1 +SH.FMC_D5_DA5.ConfNb=1 +SH.FMC_D6_DA6.0=FMC_D6,sd-16b-d1 +SH.FMC_D6_DA6.ConfNb=1 +SH.FMC_D7_DA7.0=FMC_D7,sd-16b-d1 +SH.FMC_D7_DA7.ConfNb=1 +SH.FMC_D8_DA8.0=FMC_D8,sd-16b-d1 +SH.FMC_D8_DA8.ConfNb=1 +SH.FMC_D9_DA9.0=FMC_D9,sd-16b-d1 +SH.FMC_D9_DA9.ConfNb=1 +SH.FMC_NBL0.0=FMC_NBL0,Sd2ByteEnable1 +SH.FMC_NBL0.ConfNb=1 +SH.FMC_NBL1.0=FMC_NBL1,Sd2ByteEnable1 +SH.FMC_NBL1.ConfNb=1 +SH.FMC_SDCLK.0=FMC_SDCLK,12b-sda1 +SH.FMC_SDCLK.ConfNb=1 +SH.FMC_SDNCAS.0=FMC_SDNCAS,12b-sda1 +SH.FMC_SDNCAS.ConfNb=1 SH.FMC_SDNRAS.0=FMC_SDNRAS,12b-sda1 -PH1/OSC_OUT.Mode=HSE-External-Oscillator -PE4.Signal=SAI1_FS_A -PE6.GPIOParameters=GPIO_Label -Dma.RequestsNb=3 +SH.FMC_SDNRAS.ConfNb=1 +SH.FMC_SDNWE.0=FMC_SDNWE,12b-sda1 +SH.FMC_SDNWE.ConfNb=1 +SH.GPXTI2.0=GPIO_EXTI2 +SH.GPXTI2.ConfNb=1 +SH.GPXTI8.0=GPIO_EXTI8 +SH.GPXTI8.ConfNb=1 +SH.GPXTI9.0=GPIO_EXTI9 +SH.GPXTI9.ConfNb=1 +SH.S_TIM2_CH1_ETR.0=TIM2_CH1,PWM Generation1 CH1 +SH.S_TIM2_CH1_ETR.ConfNb=1 +SH.S_TIM2_CH2.0=TIM2_CH2,PWM Generation2 CH2 +SH.S_TIM2_CH2.ConfNb=1 +SH.S_TIM3_CH4.0=TIM3_CH4,PWM Generation4 CH4 +SH.S_TIM3_CH4.ConfNb=1 +SPI1.CalculateBaudRate=42.0 MBits/s +SPI1.Direction=SPI_DIRECTION_2LINES +SPI1.IPParameters=Mode,CalculateBaudRate,VirtualType,Direction +SPI1.Mode=SPI_MODE_MASTER +SPI1.VirtualType=VM_MASTER SPI4.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_128 -ProjectManager.ProjectName=Alchemist -PA6.Signal=SPI1_MISO -SH.FMC_D0_DA0.0=FMC_D0,sd-16b-d1 -SAI1.DataSize-SAI_A_AsyncSlave=SAI_DATASIZE_24 +SPI4.CalculateBaudRate=656.25 KBits/s +SPI4.Direction=SPI_DIRECTION_2LINES +SPI4.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,VirtualType,Direction +SPI4.Mode=SPI_MODE_MASTER +SPI4.VirtualType=VM_MASTER +SPI5.CalculateBaudRate=42.0 MBits/s +SPI5.Direction=SPI_DIRECTION_2LINES +SPI5.IPParameters=Mode,CalculateBaudRate,VirtualType,Direction +SPI5.Mode=SPI_MODE_MASTER +SPI5.VirtualType=VM_MASTER +TIM2.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 +TIM2.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2 +TIM2.IPParameters=Period,Prescaler,Pulse-PWM Generation1 CH1,Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2,Pulse-PWM Generation2 CH2 +TIM2.Period=1023 +TIM2.Prescaler=16 +TIM2.Pulse-PWM\ Generation1\ CH1=1023 +TIM2.Pulse-PWM\ Generation2\ CH2=1023 +TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4 +TIM3.IPParameters=Channel-PWM Generation4 CH4,Prescaler,Period,Pulse-PWM Generation4 CH4 +TIM3.Period=1023 +TIM3.Prescaler=16 +TIM3.Pulse-PWM\ Generation4\ CH4=1023 +USART2.IPParameters=VirtualMode USART2.VirtualMode=VM_ASYNC -SH.FMC_D4_DA4.ConfNb=1 -ProjectManager.ToolChainLocation= -RCC.LSI_VALUE=32000 -SH.FMC_A9.0=FMC_A9,12b-sda1 USB_DEVICE.CLASS_NAME_HS=AUDIO -PF8.Signal=SPI5_MISO -SH.FMC_D4_DA4.0=FMC_D4,sd-16b-d1 +USB_DEVICE.IPParameters=CLASS_NAME_HS,VirtualModeHS,SERIALNUMBER_STRING_AUDIO_HS,PRODUCT_STRING_AUDIO_HS,PID_AUDIO_HS,MANUFACTURER_STRING-AUDIO_HS,VID-AUDIO_HS,VirtualMode-AUDIO_HS,USBD_MAX_NUM_INTERFACES-AUDIO_HS,USBD_AUDIO_FREQ-AUDIO_HS +USB_DEVICE.MANUFACTURER_STRING-AUDIO_HS=Rebel Technology +USB_DEVICE.PID_AUDIO_HS=0xDADA +USB_DEVICE.PRODUCT_STRING_AUDIO_HS=OWL-ALCHEMIST +USB_DEVICE.SERIALNUMBER_STRING_AUDIO_HS=00000000010D +USB_DEVICE.USBD_AUDIO_FREQ-AUDIO_HS=48000 +USB_DEVICE.USBD_MAX_NUM_INTERFACES-AUDIO_HS=5 +USB_DEVICE.VID-AUDIO_HS=0x1209 USB_DEVICE.VirtualMode-AUDIO_HS=Audio -ADC3.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV8 -RCC.PLLSAIN=100 -PF5.Signal=FMC_A5 USB_DEVICE.VirtualModeHS=Audio_HS -Dma.Request2=SAI1_B -SAI1.Synchro-SAI_B_SyncSlave=SAI_SYNCHRONOUS -Dma.Request1=SAI1_A -ADC3.Rank-32\#ChannelRegularConversion=2 -PC4.Locked=true -PF0.Signal=FMC_A0 -PC5.Signal=GPIO_Output -PE7.Signal=FMC_D4_DA4 -SH.FMC_NBL0.ConfNb=1 -PD6.Signal=SAI1_SD_A -SAI1.Synchro-SAI_A_AsyncSlave=SAI_ASYNCHRONOUS -Dma.Request0=ADC3 -PE3.Mode=SAI_B_SyncSlave -PE2.GPIO_Label=CS_SCK -PC2.GPIO_Label=ADC2 -USB_DEVICE.PRODUCT_STRING_AUDIO_HS=OWL-MIDI -PB3.Locked=true -PA3.Signal=USART2_RX -PA2.Locked=true -PB3.GPIO_Label=FLASH_SCK -SH.FMC_A3.ConfNb=1 -VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate -ADC3.SamplingTime-31\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -RCC.I2SFreq_Value=96000000 -ADC3.DiscontinuousConvMode=DISABLE -SH.ADCx_IN13.0=ADC3_IN13,IN13 -SAI1.Synchro_A=SAI_ASYNCHRONOUS -SH.FMC_A9.ConfNb=1 -SAI1.Synchro_B=SAI_SYNCHRONOUS -PB8.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -PA7.Mode=Full_Duplex_Master -RCC.UART7Freq_Value=54000000 -PB9.GPIO_Label=SW1 -ProjectManager.NoMain=false -SPI1.IPParameters=Mode,CalculateBaudRate,VirtualType,Direction -PG1.Signal=FMC_A11 -SH.FMC_SDCLK.ConfNb=1 -PC4.Signal=GPIO_Output -ProjectManager.DefaultFWLocation=true -PD9.Signal=FMC_D14_DA14 -USB_DEVICE.SERIALNUMBER_STRING_AUDIO_HS=00000000010D -ProjectManager.DeletePrevious=true -PB10.Locked=true -RCC.LCDTFToutputFreq_Value=25000000 -USB_DEVICE.IPParameters=CLASS_NAME_HS,VirtualModeHS,SERIALNUMBER_STRING_AUDIO_HS,PRODUCT_STRING_AUDIO_HS,PID_AUDIO_HS,MANUFACTURER_STRING-AUDIO_HS,VID-AUDIO_HS,VirtualMode-AUDIO_HS -SPI5.Mode=SPI_MODE_MASTER -RCC.FamilyName=M -TIM2.Pulse-PWM\ Generation1\ CH1=1023 -PB9.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -PA13.Signal=SYS_JTMS-SWDIO -PF7.Mode=Full_Duplex_Master +USB_OTG_HS.IPParameters=VirtualMode-Device_Only_FS +USB_OTG_HS.VirtualMode-Device_Only_FS=Device_Only_FS +VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 -SH.S_TIM2_CH2.0=TIM2_CH2,PWM Generation2 CH2 -SH.ADCx_IN12.0=ADC3_IN12,IN12 -SH.FMC_A15_BA1.ConfNb=1 -PB2/BOOT1.Signal=GPXTI2 -ADC3.SamplingTime-34\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -ProjectManager.TargetToolchain=Makefile -PB10.GPIO_Label=CS_nCS -SH.FMC_D13_DA13.0=FMC_D13,sd-16b-d1 -SH.FMC_D1_DA1.ConfNb=1 -PC5.GPIOParameters=GPIO_Label -RCC.VcooutputI2SQ=96000000 +VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled +VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate +VP_SYS_VS_Systick.Mode=SysTick +VP_SYS_VS_Systick.Signal=SYS_VS_Systick VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_HS.Mode=AUDIO_HS -PF2.Signal=FMC_A2 -PE2.GPIOParameters=GPIO_Label -PC2.Locked=true -RCC.USBFreq_Value=48000000 -PF9.GPIO_Label=EXTSPI_MOSI -RCC.PLLSAIoutputFreq_Value=50000000 -PE11.Signal=FMC_D8_DA8 -RCC.LSE_VALUE=32768 -PA1.Signal=S_TIM2_CH2 -SAI1.AudioMode-SAI_B_SyncSlave=SAI_MODESLAVE_RX -SAI1.FSDefinition-SAI_A_AsyncSlave=SAI_FS_CHANNEL_IDENTIFICATION -RCC.VCOI2SOutputFreq_Value=192000000 -RCC.PLLSAIPCLKFreq_Value=50000000 +VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_HS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_HS board=Alchemist -SAI1.IPParameters=Instance-SAI_A_AsyncSlave,VirtualMode-SAI_A_AsyncSlave,Instance-SAI_B_SyncSlave,VirtualMode-SAI_B_SyncSlave,Synchro-SAI_B_SyncSlave,FrameLength-SAI_B_SyncSlave,SlotSize-SAI_B_SyncSlave,AudioMode-SAI_B_SyncSlave,AudioMode-SAI_A_AsyncSlave,DataSize-SAI_A_AsyncSlave,FrameLength-SAI_A_AsyncSlave,SlotSize-SAI_A_AsyncSlave,SlotNumber-SAI_A_AsyncSlave,FSDefinition-SAI_A_AsyncSlave,FSDefinition-SAI_B_SyncSlave,Synchro-SAI_A_AsyncSlave,Synchro_A,Synchro_B -RCC.VCOOutputFreq_Value=336000000 -PB15.Mode=Device_Only_FS -PH0/OSC_IN.Signal=RCC_OSC_IN -RCC.APB2Freq_Value=84000000 -RCC.UART4Freq_Value=54000000 -SH.ADCx_IN11.0=ADC3_IN11,IN11 -MxCube.Version=5.6.0 -SH.FMC_D13_DA13.ConfNb=1 -PF10.Signal=ADC3_IN8 -PE5.Mode=SAI_A_AsyncSlave -PC1.GPIO_Label=ADC3 -VP_SYS_VS_Systick.Mode=SysTick -SH.FMC_D12_DA12.0=FMC_D12,sd-16b-d1 -PF15.Signal=FMC_A9 -SPI4.CalculateBaudRate=656.25 KBits/s -Dma.SAI1_B.2.Priority=DMA_PRIORITY_VERY_HIGH -PF1.Signal=FMC_A1 -PE6.Signal=SPI4_MOSI -SH.FMC_D11_DA11.ConfNb=1 -RCC.UART5Freq_Value=54000000 -ADC3.Channel-34\#ChannelRegularConversion=ADC_CHANNEL_8 -RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CECFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SClocksFreq_Value,I2SFreq_Value,LCDTFToutputFreq_Value,LPTIM1Freq_Value,LSE_VALUE,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLI2SPCLKFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLI2SRoutputFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLQoutputFreq_Value,PLLSAIN,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIRCLKFreq_Value,PLLSAIoutputFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SAI1Freq_Value,SAI2Freq_Value,SAI_AClocksFreq_Value,SAI_BClocksFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,UART4Freq_Value,UART5Freq_Value,UART7Freq_Value,UART8Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USART6Freq_Value,USBFreq_Value,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value,VCOSAIOutputFreq_ValueQ,VcooutputI2S,VcooutputI2SQ -ProjectManager.AskForMigrate=true -Mcu.Name=STM32F427Z(G-I)Tx -PE0.Signal=FMC_NBL0 -Dma.SAI1_B.2.Direction=DMA_PERIPH_TO_MEMORY -PE12.Signal=FMC_D9_DA9 -PA2.Signal=USART2_TX -Mcu.IP8=SPI1 -Mcu.IP9=SPI4 -PD14.Signal=FMC_D0_DA0 -Mcu.IP6=RTC -Mcu.IP7=SAI1 -ProjectManager.CoupleFile=false -RCC.48MHZClocksFreq_Value=48000000 -PB3.Signal=SPI1_SCK -RCC.SYSCLKFreq_VALUE=168000000 -PA7.GPIO_Label=FLASH_MOSI -KeepUserPlacement=false -PC5.GPIO_Label=FLASH_nCS -SAI1.Instance-SAI_B_SyncSlave=SAI$Index_Block_B -SH.GPXTI9.ConfNb=1 -NVIC.EXTI9_5_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true -PA14.Signal=SYS_JTCK-SWCLK -RCC.HSI_VALUE=16000000 -Dma.ADC3.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -SH.S_TIM3_CH4.ConfNb=1 -RCC.PLLQ=7 -RCC.PLLM=25 -RCC.PLLN=336 -PB2/BOOT1.Locked=true -Dma.SAI1_A.1.PeriphDataAlignment=DMA_PDATAALIGN_WORD -PA2.Mode=Asynchronous -PB8.Signal=GPXTI8 -PE3.GPIO_Label=CS_SDOUT -SH.FMC_D8_DA8.ConfNb=1 -RCC.APB1Freq_Value=42000000 -ADC3.NbrOfConversionFlag=1 -TIM3.Pulse-PWM\ Generation4\ CH4=1023 -PB11.Locked=true -ProjectManager.DeviceId=STM32F427ZITx -ProjectManager.LibraryCopy=0 -SPI5.Direction=SPI_DIRECTION_2LINES -SH.S_TIM3_CH4.0=TIM3_CH4,PWM Generation4 CH4 -ADC3.Rank-31\#ChannelRegularConversion=1 -PB1.GPIOParameters=GPIO_Label -PA7.Signal=SPI1_MOSI diff --git a/Alchemist/Inc/FreeRTOSConfig.h b/Alchemist/Inc/FreeRTOSConfig.h index 90c0b895..ab2425cc 100644 --- a/Alchemist/Inc/FreeRTOSConfig.h +++ b/Alchemist/Inc/FreeRTOSConfig.h @@ -78,13 +78,13 @@ * These definitions should be adjusted for your particular hardware and * application requirements. * - * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE - * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. + * These parameters and more are described within the 'configuration' section of the + * FreeRTOS API documentation available on the FreeRTOS.org web site. * - * See http://www.freertos.org/a00110.html. + * See http://www.freertos.org/a00110.html *----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ +/* USER CODE BEGIN Includes */ #include "device.h" #ifdef DEBUG_STACK @@ -92,7 +92,7 @@ #define INCLUDE_uxTaskGetStackHighWaterMark 1 #endif /* DEBUG_STACK */ -/* USER CODE END Includes */ +/* USER CODE END Includes */ /* Ensure definitions are only used by the compiler, and not by the assembler. */ #if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) @@ -124,7 +124,7 @@ /* Defaults to size_t for backward compatibility, but can be changed if lengths will always be less than the number of bytes in a size_t. */ #define configMESSAGE_BUFFER_LENGTH_TYPE size_t -/* USER CODE END MESSAGE_BUFFER_LENGTH_TYPE */ +/* USER CODE END MESSAGE_BUFFER_LENGTH_TYPE */ /* Co-routine definitions. */ #define configUSE_CO_ROUTINES 0 @@ -179,11 +179,11 @@ standard names. */ /* IMPORTANT: This define is commented when used with STM32Cube firmware, when the timebase source is SysTick, to prevent overwriting SysTick_Handler defined within STM32Cube HAL */ - + /* #define xPortSysTickHandler SysTick_Handler */ -/* USER CODE BEGIN Defines */ +/* USER CODE BEGIN Defines */ /* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */ -/* USER CODE END Defines */ +/* USER CODE END Defines */ #endif /* FREERTOS_CONFIG_H */ diff --git a/Alchemist/Inc/hardware.h b/Alchemist/Inc/hardware.h index 7eab9dc6..4ce74a7e 100644 --- a/Alchemist/Inc/hardware.h +++ b/Alchemist/Inc/hardware.h @@ -22,6 +22,7 @@ #define USE_USBD_AUDIO_FEATURES #define USE_USBD_AUDIO_RX // speaker #define USE_USBD_AUDIO_TX // microphone +#define USBD_HANDLE hUsbDeviceHS #define USE_MODE_BUTTON #define MODE_BUTTON_PIN SW3_Pin diff --git a/Alchemist/Inc/main.h b/Alchemist/Inc/main.h index cf07674e..8b221138 100644 --- a/Alchemist/Inc/main.h +++ b/Alchemist/Inc/main.h @@ -128,6 +128,8 @@ void Error_Handler(void); #define FLASH_HOLD_GPIO_Port GPIOC #define FLASH_nCS_Pin GPIO_PIN_5 #define FLASH_nCS_GPIO_Port GPIOC +#define FLASH_WP_Pin GPIO_PIN_0 +#define FLASH_WP_GPIO_Port GPIOB #define PWM3_Pin GPIO_PIN_1 #define PWM3_GPIO_Port GPIOB #define SW2_Pin GPIO_PIN_2 diff --git a/Alchemist/Inc/stm32f4xx_hal_conf.h b/Alchemist/Inc/stm32f4xx_hal_conf.h index dceb54c5..535ae668 100644 --- a/Alchemist/Inc/stm32f4xx_hal_conf.h +++ b/Alchemist/Inc/stm32f4xx_hal_conf.h @@ -2,7 +2,7 @@ ****************************************************************************** * @file stm32f4xx_hal_conf_template.h * @author MCD Application Team - * @brief HAL configuration template file. + * @brief HAL configuration template file. * This file should be copied to the application folder and renamed * to stm32f4xx_hal_conf.h. ****************************************************************************** @@ -17,7 +17,7 @@ * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** - */ + */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F4xx_HAL_CONF_H @@ -32,14 +32,15 @@ /* ########################## Module Selection ############################## */ /** - * @brief This is the list of modules to be used in the HAL driver + * @brief This is the list of modules to be used in the HAL driver */ -#define HAL_MODULE_ENABLED +#define HAL_MODULE_ENABLED #define HAL_ADC_MODULE_ENABLED /* #define HAL_CRYP_MODULE_ENABLED */ /* #define HAL_CAN_MODULE_ENABLED */ /* #define HAL_CRC_MODULE_ENABLED */ +/* #define HAL_CAN_LEGACY_MODULE_ENABLED */ /* #define HAL_CRYP_MODULE_ENABLED */ /* #define HAL_DAC_MODULE_ENABLED */ /* #define HAL_DCMI_MODULE_ENABLED */ @@ -75,6 +76,7 @@ /* #define HAL_QSPI_MODULE_ENABLED */ /* #define HAL_CEC_MODULE_ENABLED */ /* #define HAL_FMPI2C_MODULE_ENABLED */ +/* #define HAL_FMPSMBUS_MODULE_ENABLED */ /* #define HAL_SPDIFRX_MODULE_ENABLED */ /* #define HAL_DFSDM_MODULE_ENABLED */ /* #define HAL_LPTIM_MODULE_ENABLED */ @@ -90,20 +92,20 @@ /** * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. * This value is used by the RCC HAL module to compute the system frequency - * (when HSE is used as system clock source, directly or through the PLL). + * (when HSE is used as system clock source, directly or through the PLL). */ -#if !defined (HSE_VALUE) - #define HSE_VALUE ((uint32_t)25000000U) /*!< Value of the External oscillator in Hz */ +#if !defined (HSE_VALUE) + #define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ #endif /* HSE_VALUE */ #if !defined (HSE_STARTUP_TIMEOUT) - #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ + #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ #endif /* HSE_STARTUP_TIMEOUT */ /** * @brief Internal High Speed oscillator (HSI) value. * This value is used by the RCC HAL module to compute the system frequency - * (when HSI is used as system clock source, directly or through the PLL). + * (when HSI is used as system clock source, directly or through the PLL). */ #if !defined (HSI_VALUE) #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ @@ -112,8 +114,8 @@ /** * @brief Internal Low Speed oscillator (LSI) value. */ -#if !defined (LSI_VALUE) - #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/ +#if !defined (LSI_VALUE) + #define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/ #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz The real value may vary depending on the variations in voltage and temperature.*/ @@ -121,20 +123,20 @@ * @brief External Low Speed oscillator (LSE) value. */ #if !defined (LSE_VALUE) - #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */ + #define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ #endif /* LSE_VALUE */ #if !defined (LSE_STARTUP_TIMEOUT) - #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ + #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ #endif /* LSE_STARTUP_TIMEOUT */ /** * @brief External clock source for I2S peripheral - * This value is used by the I2S HAL module to compute the I2S clock source - * frequency, this source is inserted directly through I2S_CKIN pad. + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. */ #if !defined (EXTERNAL_CLOCK_VALUE) - #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/ + #define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External audio frequency in Hz*/ #endif /* EXTERNAL_CLOCK_VALUE */ /* Tip: To avoid modifying this file each time you need to use different HSE, @@ -144,19 +146,59 @@ /** * @brief This is the HAL system configuration section */ -#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ -#define TICK_INT_PRIORITY ((uint32_t)15U) /*!< tick interrupt priority */ -#define USE_RTOS 0U +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY 15U /*!< tick interrupt priority */ +#define USE_RTOS 0U #define PREFETCH_ENABLE 1U #define INSTRUCTION_CACHE_ENABLE 1U #define DATA_CACHE_ENABLE 1U +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */ +#define USE_HAL_FMPSMBUS_REGISTER_CALLBACKS 0U /* FMPSMBUS register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + /* ########################## Assert Selection ############################## */ /** - * @brief Uncomment the line below to expanse the "assert_param" macro in the + * @brief Uncomment the line below to expanse the "assert_param" macro in the * HAL drivers code */ - #define USE_FULL_ASSERT 1U + #define USE_FULL_ASSERT 1U /* ################## Ethernet peripheral configuration ##################### */ @@ -170,29 +212,29 @@ #define MAC_ADDR4 0U #define MAC_ADDR5 0U -/* Definition of the Ethernet driver buffers size and count */ +/* Definition of the Ethernet driver buffers size and count */ #define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ #define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ -#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ -#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ +#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ /* Section 2: PHY configuration section */ -/* DP83848_PHY_ADDRESS Address*/ +/* DP83848_PHY_ADDRESS Address*/ #define DP83848_PHY_ADDRESS 0x01U -/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ -#define PHY_RESET_DELAY ((uint32_t)0x000000FFU) +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY 0x000000FFU /* PHY Configuration delay */ -#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU) +#define PHY_CONFIG_DELAY 0x00000FFFU -#define PHY_READ_TO ((uint32_t)0x0000FFFFU) -#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU) +#define PHY_READ_TO 0x0000FFFFU +#define PHY_WRITE_TO 0x0000FFFFU /* Section 3: Common PHY Registers */ #define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */ #define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */ - + #define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ #define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ #define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ @@ -207,7 +249,7 @@ #define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ #define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ #define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */ - + /* Section 4: Extended PHY Registers */ #define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ @@ -225,25 +267,25 @@ /* Includes ------------------------------------------------------------------*/ /** - * @brief Include module's header file + * @brief Include module's header file */ #ifdef HAL_RCC_MODULE_ENABLED #include "stm32f4xx_hal_rcc.h" #endif /* HAL_RCC_MODULE_ENABLED */ -#ifdef HAL_EXTI_MODULE_ENABLED - #include "stm32f4xx_hal_exti.h" -#endif /* HAL_EXTI_MODULE_ENABLED */ - #ifdef HAL_GPIO_MODULE_ENABLED #include "stm32f4xx_hal_gpio.h" #endif /* HAL_GPIO_MODULE_ENABLED */ +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32f4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + #ifdef HAL_DMA_MODULE_ENABLED #include "stm32f4xx_hal_dma.h" #endif /* HAL_DMA_MODULE_ENABLED */ - + #ifdef HAL_CORTEX_MODULE_ENABLED #include "stm32f4xx_hal_cortex.h" #endif /* HAL_CORTEX_MODULE_ENABLED */ @@ -256,18 +298,18 @@ #include "stm32f4xx_hal_can.h" #endif /* HAL_CAN_MODULE_ENABLED */ +#ifdef HAL_CAN_LEGACY_MODULE_ENABLED + #include "stm32f4xx_hal_can_legacy.h" +#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ + #ifdef HAL_CRC_MODULE_ENABLED #include "stm32f4xx_hal_crc.h" #endif /* HAL_CRC_MODULE_ENABLED */ #ifdef HAL_CRYP_MODULE_ENABLED - #include "stm32f4xx_hal_cryp.h" + #include "stm32f4xx_hal_cryp.h" #endif /* HAL_CRYP_MODULE_ENABLED */ -#ifdef HAL_SMBUS_MODULE_ENABLED -#include "stm32f4xx_hal_smbus.h" -#endif /* HAL_SMBUS_MODULE_ENABLED */ - #ifdef HAL_DMA2D_MODULE_ENABLED #include "stm32f4xx_hal_dma2d.h" #endif /* HAL_DMA2D_MODULE_ENABLED */ @@ -287,7 +329,7 @@ #ifdef HAL_FLASH_MODULE_ENABLED #include "stm32f4xx_hal_flash.h" #endif /* HAL_FLASH_MODULE_ENABLED */ - + #ifdef HAL_SRAM_MODULE_ENABLED #include "stm32f4xx_hal_sram.h" #endif /* HAL_SRAM_MODULE_ENABLED */ @@ -302,11 +344,11 @@ #ifdef HAL_PCCARD_MODULE_ENABLED #include "stm32f4xx_hal_pccard.h" -#endif /* HAL_PCCARD_MODULE_ENABLED */ - +#endif /* HAL_PCCARD_MODULE_ENABLED */ + #ifdef HAL_SDRAM_MODULE_ENABLED #include "stm32f4xx_hal_sdram.h" -#endif /* HAL_SDRAM_MODULE_ENABLED */ +#endif /* HAL_SDRAM_MODULE_ENABLED */ #ifdef HAL_HASH_MODULE_ENABLED #include "stm32f4xx_hal_hash.h" @@ -316,6 +358,10 @@ #include "stm32f4xx_hal_i2c.h" #endif /* HAL_I2C_MODULE_ENABLED */ +#ifdef HAL_SMBUS_MODULE_ENABLED + #include "stm32f4xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + #ifdef HAL_I2S_MODULE_ENABLED #include "stm32f4xx_hal_i2s.h" #endif /* HAL_I2S_MODULE_ENABLED */ @@ -348,10 +394,6 @@ #include "stm32f4xx_hal_sd.h" #endif /* HAL_SD_MODULE_ENABLED */ -#ifdef HAL_MMC_MODULE_ENABLED - #include "stm32f4xx_hal_mmc.h" -#endif /* HAL_MMC_MODULE_ENABLED */ - #ifdef HAL_SPI_MODULE_ENABLED #include "stm32f4xx_hal_spi.h" #endif /* HAL_SPI_MODULE_ENABLED */ @@ -387,7 +429,7 @@ #ifdef HAL_HCD_MODULE_ENABLED #include "stm32f4xx_hal_hcd.h" #endif /* HAL_HCD_MODULE_ENABLED */ - + #ifdef HAL_DSI_MODULE_ENABLED #include "stm32f4xx_hal_dsi.h" #endif /* HAL_DSI_MODULE_ENABLED */ @@ -404,6 +446,10 @@ #include "stm32f4xx_hal_fmpi2c.h" #endif /* HAL_FMPI2C_MODULE_ENABLED */ +#ifdef HAL_FMPSMBUS_MODULE_ENABLED + #include "stm32f4xx_hal_fmpsmbus.h" +#endif /* HAL_FMPSMBUS_MODULE_ENABLED */ + #ifdef HAL_SPDIFRX_MODULE_ENABLED #include "stm32f4xx_hal_spdifrx.h" #endif /* HAL_SPDIFRX_MODULE_ENABLED */ @@ -415,14 +461,18 @@ #ifdef HAL_LPTIM_MODULE_ENABLED #include "stm32f4xx_hal_lptim.h" #endif /* HAL_LPTIM_MODULE_ENABLED */ - + +#ifdef HAL_MMC_MODULE_ENABLED + #include "stm32f4xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + /* Exported macro ------------------------------------------------------------*/ #ifdef USE_FULL_ASSERT /** * @brief The assert_param macro is used for function's parameters check. - * @param expr: If expr is false, it calls assert_failed function + * @param expr If expr is false, it calls assert_failed function * which reports the name of the source file and the source - * line number of the call that failed. + * line number of the call that failed. * If expr is true, it returns no value. * @retval None */ @@ -431,13 +481,12 @@ void assert_failed(uint8_t* file, uint32_t line); #else #define assert_param(expr) ((void)0U) -#endif /* USE_FULL_ASSERT */ +#endif /* USE_FULL_ASSERT */ #ifdef __cplusplus } #endif #endif /* __STM32F4xx_HAL_CONF_H */ - /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/Alchemist/Inc/stm32f4xx_it.h b/Alchemist/Inc/stm32f4xx_it.h index 82404a30..7699b0ab 100644 --- a/Alchemist/Inc/stm32f4xx_it.h +++ b/Alchemist/Inc/stm32f4xx_it.h @@ -39,7 +39,7 @@ #ifdef __cplusplus extern "C" { -#endif +#endif /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ diff --git a/Alchemist/Inc/usbd_conf.h b/Alchemist/Inc/usbd_conf.h index 41419242..622a1a23 100644 --- a/Alchemist/Inc/usbd_conf.h +++ b/Alchemist/Inc/usbd_conf.h @@ -91,14 +91,13 @@ * @brief Aliases. * @{ */ - -/* Memory management macros */ - +/* Memory management macros make sure to use static memory allocation */ /** Alias for memory allocation. */ -#define USBD_malloc malloc + +#define USBD_malloc (void *)USBD_static_malloc /** Alias for memory release. */ -#define USBD_free free +#define USBD_free USBD_static_free /** Alias for memory set. */ #define USBD_memset memset @@ -154,6 +153,8 @@ */ /* Exported functions -------------------------------------------------------*/ +void *USBD_static_malloc(uint32_t size); +void USBD_static_free(void *p); /** * @} diff --git a/Alchemist/Inc/usbd_desc.h b/Alchemist/Inc/usbd_desc.h index 5528b019..a1b866aa 100644 --- a/Alchemist/Inc/usbd_desc.h +++ b/Alchemist/Inc/usbd_desc.h @@ -17,7 +17,7 @@ * ****************************************************************************** */ -/* USER CODE END Header */ +/* USER CODE END Header */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USBD_DESC__C__ #define __USBD_DESC__C__ @@ -41,7 +41,7 @@ * @brief Usb device descriptors module. * @{ */ - + /** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants * @brief Constants. * @{ diff --git a/Alchemist/Src/freertos.c b/Alchemist/Src/freertos.c index ad5906e2..ace53e48 100644 --- a/Alchemist/Src/freertos.c +++ b/Alchemist/Src/freertos.c @@ -54,7 +54,7 @@ #include "main.h" /* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ +/* USER CODE BEGIN Includes */ /* USER CODE END Includes */ diff --git a/Alchemist/Src/main.c b/Alchemist/Src/main.c index f0ced17a..5f290973 100644 --- a/Alchemist/Src/main.c +++ b/Alchemist/Src/main.c @@ -47,7 +47,6 @@ ****************************************************************************** */ /* USER CODE END Header */ - /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "cmsis_os.h" @@ -103,6 +102,7 @@ osThreadId defaultTaskHandle; /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); +void PeriphCommonClock_Config(void); static void MX_GPIO_Init(void); static void MX_DMA_Init(void); static void MX_ADC3_Init(void); @@ -153,6 +153,9 @@ int main(void) /* Configure the system clock */ SystemClock_Config(); +/* Configure the peripherals common clocks */ + PeriphCommonClock_Config(); + /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ @@ -228,7 +231,7 @@ int main(void) /* Start scheduler */ osKernelStart(); - + /* We should never get here as control is now taken by the scheduler */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ @@ -250,19 +253,19 @@ void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; - RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; - /** Macro to configure SAI1BlockB clock source selection + /** Macro to configure SAI1BlockB clock source selection */ __HAL_RCC_SAI_BLOCKBCLKSOURCE_CONFIG(SAI_CLKSOURCE_PLLSAI); - /** Macro to configure SAI1BlockA clock source selection + /** Macro to configure SAI1BlockA clock source selection */ __HAL_RCC_SAI_BLOCKACLKSOURCE_CONFIG(SAI_CLKSOURCE_PLLSAI); - /** Configure the main internal regulator output voltage + /** Configure the main internal regulator output voltage */ __HAL_RCC_PWR_CLK_ENABLE(); __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); - /** Initializes the CPU, AHB and APB busses clocks + /** Initializes the RCC Oscillators according to the specified parameters + * in the RCC_OscInitTypeDef structure. */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSEState = RCC_HSE_ON; @@ -277,7 +280,7 @@ void SystemClock_Config(void) { Error_Handler(); } - /** Initializes the CPU, AHB and APB busses clocks + /** Initializes the CPU, AHB and APB buses clocks */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; @@ -290,11 +293,22 @@ void SystemClock_Config(void) { Error_Handler(); } - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SAI_PLLSAI|RCC_PERIPHCLK_RTC; +} + +/** + * @brief Peripherals Common Clock Configuration + * @retval None + */ +void PeriphCommonClock_Config(void) +{ + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SAI_PLLSAI; PeriphClkInitStruct.PLLSAI.PLLSAIN = 100; PeriphClkInitStruct.PLLSAI.PLLSAIQ = 4; PeriphClkInitStruct.PLLSAIDivQ = 1; - PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) { Error_Handler(); @@ -318,7 +332,7 @@ static void MX_ADC3_Init(void) /* USER CODE BEGIN ADC3_Init 1 */ /* USER CODE END ADC3_Init 1 */ - /** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion) + /** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion) */ hadc3.Instance = ADC3; hadc3.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV8; @@ -336,7 +350,7 @@ static void MX_ADC3_Init(void) { Error_Handler(); } - /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. */ sConfig.Channel = ADC_CHANNEL_13; sConfig.Rank = 1; @@ -345,7 +359,7 @@ static void MX_ADC3_Init(void) { Error_Handler(); } - /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. */ sConfig.Channel = ADC_CHANNEL_12; sConfig.Rank = 2; @@ -353,7 +367,7 @@ static void MX_ADC3_Init(void) { Error_Handler(); } - /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. */ sConfig.Channel = ADC_CHANNEL_11; sConfig.Rank = 3; @@ -361,7 +375,7 @@ static void MX_ADC3_Init(void) { Error_Handler(); } - /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. */ sConfig.Channel = ADC_CHANNEL_8; sConfig.Rank = 4; @@ -390,7 +404,7 @@ static void MX_RTC_Init(void) /* USER CODE BEGIN RTC_Init 1 */ /* USER CODE END RTC_Init 1 */ - /** Initialize RTC Only + /** Initialize RTC Only */ hrtc.Instance = RTC; hrtc.Init.HourFormat = RTC_HOURFORMAT_24; @@ -723,10 +737,10 @@ static void MX_USART2_UART_Init(void) } -/** +/** * Enable DMA controller clock */ -static void MX_DMA_Init(void) +static void MX_DMA_Init(void) { /* DMA controller clock enable */ @@ -815,13 +829,13 @@ static void MX_GPIO_Init(void) HAL_GPIO_WritePin(GPIOC, EXTSPI_nCS_Pin|FLASH_HOLD_Pin|FLASH_nCS_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOB, CS_nCS_Pin|CS_nRST_Pin, GPIO_PIN_RESET); + HAL_GPIO_WritePin(GPIOB, FLASH_WP_Pin|CS_nCS_Pin|CS_nRST_Pin, GPIO_PIN_RESET); - /*Configure GPIO pins : PC13 PC14 PC6 PC7 - PC8 PC9 PC10 PC11 + /*Configure GPIO pins : PC13 PC14 PC6 PC7 + PC8 PC9 PC10 PC11 PC12 */ - GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_6|GPIO_PIN_7 - |GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11 + GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_6|GPIO_PIN_7 + |GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11 |GPIO_PIN_12; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; @@ -840,18 +854,19 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); - /*Configure GPIO pins : PA4 PA5 PA8 PA9 + /*Configure GPIO pins : PA4 PA5 PA8 PA9 PA10 PA11 PA12 PA15 */ - GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_8|GPIO_PIN_9 + GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_8|GPIO_PIN_9 |GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - /*Configure GPIO pins : PB0 PB12 PB4 PB7 */ - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_12|GPIO_PIN_4|GPIO_PIN_7; - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + /*Configure GPIO pins : FLASH_WP_Pin CS_nCS_Pin CS_nRST_Pin */ + GPIO_InitStruct.Pin = FLASH_WP_Pin|CS_nCS_Pin|CS_nRST_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /*Configure GPIO pins : SW2_Pin SW3_Pin SW1_Pin */ @@ -860,26 +875,25 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - /*Configure GPIO pins : CS_nCS_Pin CS_nRST_Pin */ - GPIO_InitStruct.Pin = CS_nCS_Pin|CS_nRST_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + /*Configure GPIO pins : PB12 PB4 PB7 */ + GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_4|GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - /*Configure GPIO pins : PD11 PD12 PD13 PD2 + /*Configure GPIO pins : PD11 PD12 PD13 PD2 PD3 PD4 PD5 PD7 */ - GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_2 + GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_2 |GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_7; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); - /*Configure GPIO pins : PG2 PG3 PG6 PG7 - PG9 PG10 PG11 PG12 + /*Configure GPIO pins : PG2 PG3 PG6 PG7 + PG9 PG10 PG11 PG12 PG13 PG14 */ - GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_6|GPIO_PIN_7 - |GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12 + GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_6|GPIO_PIN_7 + |GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12 |GPIO_PIN_13|GPIO_PIN_14; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; @@ -918,7 +932,7 @@ void StartDefaultTask(void const * argument) loop(); /* osDelay(1); */ } - /* USER CODE END 5 */ + /* USER CODE END 5 */ } /** @@ -946,7 +960,7 @@ void Error_Handler(void) * @retval None */ void assert_failed(uint8_t *file, uint32_t line) -{ +{ /* USER CODE BEGIN 6 */ /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ diff --git a/Alchemist/Src/stm32f4xx_hal_msp.c b/Alchemist/Src/stm32f4xx_hal_msp.c index e716d151..643bc552 100644 --- a/Alchemist/Src/stm32f4xx_hal_msp.c +++ b/Alchemist/Src/stm32f4xx_hal_msp.c @@ -89,7 +89,7 @@ extern DMA_HandleTypeDef hdma_adc3; /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ - + void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); /** * Initializes the Global MSP. @@ -128,14 +128,14 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) /* USER CODE END ADC3_MspInit 0 */ /* Peripheral clock enable */ __HAL_RCC_ADC3_CLK_ENABLE(); - + __HAL_RCC_GPIOF_CLK_ENABLE(); __HAL_RCC_GPIOC_CLK_ENABLE(); - /**ADC3 GPIO Configuration + /**ADC3 GPIO Configuration PF10 ------> ADC3_IN8 PC1 ------> ADC3_IN11 PC2 ------> ADC3_IN12 - PC3 ------> ADC3_IN13 + PC3 ------> ADC3_IN13 */ GPIO_InitStruct.Pin = ADC4_Pin; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; @@ -188,12 +188,12 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) /* USER CODE END ADC3_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_ADC3_CLK_DISABLE(); - - /**ADC3 GPIO Configuration + + /**ADC3 GPIO Configuration PF10 ------> ADC3_IN8 PC1 ------> ADC3_IN11 PC2 ------> ADC3_IN12 - PC3 ------> ADC3_IN13 + PC3 ------> ADC3_IN13 */ HAL_GPIO_DeInit(ADC4_GPIO_Port, ADC4_Pin); @@ -216,11 +216,21 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) */ void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc) { + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; if(hrtc->Instance==RTC) { /* USER CODE BEGIN RTC_MspInit 0 */ /* USER CODE END RTC_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC; + PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + /* Peripheral clock enable */ __HAL_RCC_RTC_ENABLE(); /* USER CODE BEGIN RTC_MspInit 1 */ @@ -268,13 +278,13 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) /* USER CODE END SPI1_MspInit 0 */ /* Peripheral clock enable */ __HAL_RCC_SPI1_CLK_ENABLE(); - + __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); - /**SPI1 GPIO Configuration + /**SPI1 GPIO Configuration PA6 ------> SPI1_MISO PA7 ------> SPI1_MOSI - PB3 ------> SPI1_SCK + PB3 ------> SPI1_SCK */ GPIO_InitStruct.Pin = FLASH_MISO_Pin|FLASH_MOSI_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; @@ -301,11 +311,11 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) /* USER CODE END SPI4_MspInit 0 */ /* Peripheral clock enable */ __HAL_RCC_SPI4_CLK_ENABLE(); - + __HAL_RCC_GPIOE_CLK_ENABLE(); - /**SPI4 GPIO Configuration + /**SPI4 GPIO Configuration PE2 ------> SPI4_SCK - PE6 ------> SPI4_MOSI + PE6 ------> SPI4_MOSI */ GPIO_InitStruct.Pin = CS_SCK_Pin|CS_SDA_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; @@ -325,12 +335,12 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) /* USER CODE END SPI5_MspInit 0 */ /* Peripheral clock enable */ __HAL_RCC_SPI5_CLK_ENABLE(); - + __HAL_RCC_GPIOF_CLK_ENABLE(); - /**SPI5 GPIO Configuration + /**SPI5 GPIO Configuration PF7 ------> SPI5_SCK PF8 ------> SPI5_MISO - PF9 ------> SPI5_MOSI + PF9 ------> SPI5_MOSI */ GPIO_InitStruct.Pin = EXTSPI_SCK_Pin|EXTSPI_MISO_Pin|EXTSPI_MOSI_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; @@ -361,11 +371,11 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) /* USER CODE END SPI1_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_SPI1_CLK_DISABLE(); - - /**SPI1 GPIO Configuration + + /**SPI1 GPIO Configuration PA6 ------> SPI1_MISO PA7 ------> SPI1_MOSI - PB3 ------> SPI1_SCK + PB3 ------> SPI1_SCK */ HAL_GPIO_DeInit(GPIOA, FLASH_MISO_Pin|FLASH_MOSI_Pin); @@ -382,10 +392,10 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) /* USER CODE END SPI4_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_SPI4_CLK_DISABLE(); - - /**SPI4 GPIO Configuration + + /**SPI4 GPIO Configuration PE2 ------> SPI4_SCK - PE6 ------> SPI4_MOSI + PE6 ------> SPI4_MOSI */ HAL_GPIO_DeInit(GPIOE, CS_SCK_Pin|CS_SDA_Pin); @@ -400,11 +410,11 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) /* USER CODE END SPI5_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_SPI5_CLK_DISABLE(); - - /**SPI5 GPIO Configuration + + /**SPI5 GPIO Configuration PF7 ------> SPI5_SCK PF8 ------> SPI5_MISO - PF9 ------> SPI5_MOSI + PF9 ------> SPI5_MOSI */ HAL_GPIO_DeInit(GPIOF, EXTSPI_SCK_Pin|EXTSPI_MISO_Pin|EXTSPI_MOSI_Pin); @@ -457,9 +467,9 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) /* USER CODE END TIM2_MspPostInit 0 */ __HAL_RCC_GPIOA_CLK_ENABLE(); - /**TIM2 GPIO Configuration + /**TIM2 GPIO Configuration PA0/WKUP ------> TIM2_CH1 - PA1 ------> TIM2_CH2 + PA1 ------> TIM2_CH2 */ GPIO_InitStruct.Pin = PWM1_Pin|PWM2_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; @@ -477,10 +487,10 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) /* USER CODE BEGIN TIM3_MspPostInit 0 */ /* USER CODE END TIM3_MspPostInit 0 */ - + __HAL_RCC_GPIOB_CLK_ENABLE(); - /**TIM3 GPIO Configuration - PB1 ------> TIM3_CH4 + /**TIM3 GPIO Configuration + PB1 ------> TIM3_CH4 */ GPIO_InitStruct.Pin = PWM3_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; @@ -544,11 +554,11 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart) /* USER CODE END USART2_MspInit 0 */ /* Peripheral clock enable */ __HAL_RCC_USART2_CLK_ENABLE(); - + __HAL_RCC_GPIOA_CLK_ENABLE(); - /**USART2 GPIO Configuration + /**USART2 GPIO Configuration PA2 ------> USART2_TX - PA3 ------> USART2_RX + PA3 ------> USART2_RX */ GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; @@ -579,10 +589,10 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) /* USER CODE END USART2_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_USART2_CLK_DISABLE(); - - /**USART2 GPIO Configuration + + /**USART2 GPIO Configuration PA2 ------> USART2_TX - PA3 ------> USART2_RX + PA3 ------> USART2_RX */ HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3); @@ -607,8 +617,8 @@ static void HAL_FMC_MspInit(void){ /* Peripheral clock enable */ __HAL_RCC_FMC_CLK_ENABLE(); - - /** FMC GPIO Configuration + + /** FMC GPIO Configuration PF0 ------> FMC_A0 PF1 ------> FMC_A1 PF2 ------> FMC_A2 @@ -648,8 +658,8 @@ static void HAL_FMC_MspInit(void){ PE0 ------> FMC_NBL0 PE1 ------> FMC_NBL1 */ - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 - |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_11|GPIO_PIN_12 + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 + |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_11|GPIO_PIN_12 |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; @@ -664,7 +674,7 @@ static void HAL_FMC_MspInit(void){ GPIO_InitStruct.Alternate = GPIO_AF12_FMC; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5 + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5 |GPIO_PIN_8|GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; @@ -672,8 +682,8 @@ static void HAL_FMC_MspInit(void){ GPIO_InitStruct.Alternate = GPIO_AF12_FMC; HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); - GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 - |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 + GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 + |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; @@ -681,7 +691,7 @@ static void HAL_FMC_MspInit(void){ GPIO_InitStruct.Alternate = GPIO_AF12_FMC; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); - GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14 + GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14 |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; @@ -723,8 +733,8 @@ static void HAL_FMC_MspDeInit(void){ FMC_DeInitialized = 1; /* Peripheral clock enable */ __HAL_RCC_FMC_CLK_DISABLE(); - - /** FMC GPIO Configuration + + /** FMC GPIO Configuration PF0 ------> FMC_A0 PF1 ------> FMC_A1 PF2 ------> FMC_A2 @@ -764,20 +774,20 @@ static void HAL_FMC_MspDeInit(void){ PE0 ------> FMC_NBL0 PE1 ------> FMC_NBL1 */ - HAL_GPIO_DeInit(GPIOF, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 - |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_11|GPIO_PIN_12 + HAL_GPIO_DeInit(GPIOF, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 + |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_11|GPIO_PIN_12 |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15); HAL_GPIO_DeInit(GPIOC, GPIO_PIN_0); - HAL_GPIO_DeInit(GPIOG, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5 + HAL_GPIO_DeInit(GPIOG, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5 |GPIO_PIN_8|GPIO_PIN_15); - HAL_GPIO_DeInit(GPIOE, GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 - |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 + HAL_GPIO_DeInit(GPIOE, GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 + |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1); - HAL_GPIO_DeInit(GPIOD, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14 + HAL_GPIO_DeInit(GPIOD, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14 |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1); HAL_GPIO_DeInit(GPIOB, GPIO_PIN_5|GPIO_PIN_6); @@ -820,11 +830,11 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) HAL_NVIC_EnableIRQ(SAI1_IRQn); } SAI1_client ++; - - /**SAI1_A_Block_A GPIO Configuration + + /**SAI1_A_Block_A GPIO Configuration PE4 ------> SAI1_FS_A PE5 ------> SAI1_SCK_A - PD6 ------> SAI1_SD_A + PD6 ------> SAI1_SD_A */ GPIO_InitStruct.Pin = CS_LRCK_Pin|CS_SCKE5_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; @@ -840,8 +850,8 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; HAL_GPIO_Init(CS_SDIN_GPIO_Port, &GPIO_InitStruct); - /* Peripheral DMA init*/ - + /* Peripheral DMA init*/ + hdma_sai1_a.Instance = DMA2_Stream1; hdma_sai1_a.Init.Channel = DMA_CHANNEL_0; hdma_sai1_a.Init.Direction = DMA_MEMORY_TO_PERIPH; @@ -876,9 +886,9 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) HAL_NVIC_EnableIRQ(SAI1_IRQn); } SAI1_client ++; - - /**SAI1_B_Block_B GPIO Configuration - PE3 ------> SAI1_SD_B + + /**SAI1_B_Block_B GPIO Configuration + PE3 ------> SAI1_SD_B */ GPIO_InitStruct.Pin = CS_SDOUT_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; @@ -887,8 +897,8 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai) GPIO_InitStruct.Alternate = GPIO_AF6_SAI1; HAL_GPIO_Init(CS_SDOUT_GPIO_Port, &GPIO_InitStruct); - /* Peripheral DMA init*/ - + /* Peripheral DMA init*/ + hdma_sai1_b.Instance = DMA2_Stream4; hdma_sai1_b.Init.Channel = DMA_CHANNEL_1; hdma_sai1_b.Init.Direction = DMA_PERIPH_TO_MEMORY; @@ -919,20 +929,22 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) SAI1_client --; if (SAI1_client == 0) { - /* Peripheral clock disable */ + /* Peripheral clock disable */ __HAL_RCC_SAI1_CLK_DISABLE(); + /* SAI1 interrupt DeInit */ HAL_NVIC_DisableIRQ(SAI1_IRQn); } - - /**SAI1_A_Block_A GPIO Configuration + + /**SAI1_A_Block_A GPIO Configuration PE4 ------> SAI1_FS_A PE5 ------> SAI1_SCK_A - PD6 ------> SAI1_SD_A + PD6 ------> SAI1_SD_A */ HAL_GPIO_DeInit(GPIOE, CS_LRCK_Pin|CS_SCKE5_Pin); HAL_GPIO_DeInit(CS_SDIN_GPIO_Port, CS_SDIN_Pin); + /* SAI1 DMA Deinit */ HAL_DMA_DeInit(hsai->hdmarx); HAL_DMA_DeInit(hsai->hdmatx); } @@ -943,14 +955,16 @@ void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai) { /* Peripheral clock disable */ __HAL_RCC_SAI1_CLK_DISABLE(); + /* SAI1 interrupt DeInit */ HAL_NVIC_DisableIRQ(SAI1_IRQn); } - - /**SAI1_B_Block_B GPIO Configuration - PE3 ------> SAI1_SD_B + + /**SAI1_B_Block_B GPIO Configuration + PE3 ------> SAI1_SD_B */ HAL_GPIO_DeInit(CS_SDOUT_GPIO_Port, CS_SDOUT_Pin); + /* SAI1 DMA Deinit */ HAL_DMA_DeInit(hsai->hdmarx); HAL_DMA_DeInit(hsai->hdmatx); } diff --git a/Alchemist/Src/stm32f4xx_it.c b/Alchemist/Src/stm32f4xx_it.c index 7bdc4bbc..ef986573 100644 --- a/Alchemist/Src/stm32f4xx_it.c +++ b/Alchemist/Src/stm32f4xx_it.c @@ -84,7 +84,7 @@ extern SAI_HandleTypeDef hsai_BlockB1; /* USER CODE END EV */ /******************************************************************************/ -/* Cortex-M4 Processor Interruption and Exception Handlers */ +/* Cortex-M4 Processor Interruption and Exception Handlers */ /******************************************************************************/ /** * @brief This function handles System tick timer. diff --git a/Alchemist/Src/usbd_desc.c b/Alchemist/Src/usbd_desc.c index 3c5e84c0..8229e52e 100644 --- a/Alchemist/Src/usbd_desc.c +++ b/Alchemist/Src/usbd_desc.c @@ -97,19 +97,18 @@ /** * @} */ - + /** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes * @brief Private functions declaration. * @{ */ - + static void Get_SerialNum(void); static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len); - + /** * @} - */ - + */ /** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes * @brief Private functions declaration for HS. @@ -220,7 +219,7 @@ __ALIGN_BEGIN uint8_t USBD_HS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = #pragma data_alignment=4 #endif /* defined ( __ICCARM__ ) */ -/** USB lang indentifier descriptor. */ +/** USB lang identifier descriptor. */ __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = { USB_LEN_LANGID_STR_DESC, @@ -236,7 +235,7 @@ __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = __ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END; #if defined ( __ICCARM__ ) /*!< IAR Compiler */ - #pragma data_alignment=4 + #pragma data_alignment=4 #endif __ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { USB_SIZ_STRING_SERIAL, @@ -385,8 +384,8 @@ uint8_t * USBD_HS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) #endif /* (USBD_LPM_ENABLED == 1) */ /** - * @brief Create the serial number string descriptor - * @param None + * @brief Create the serial number string descriptor + * @param None * @retval None */ static void Get_SerialNum(void) @@ -407,9 +406,9 @@ static void Get_SerialNum(void) } /** - * @brief Convert Hex 32Bits value into char + * @brief Convert Hex 32Bits value into char * @param value: value to convert - * @param pbuf: pointer to the buffer + * @param pbuf: pointer to the buffer * @param len: buffer length * @retval None */ diff --git a/Alchemist/cube-update.sh b/Alchemist/cube-update.sh index 5ea8ad2c..e024f220 100755 --- a/Alchemist/cube-update.sh +++ b/Alchemist/cube-update.sh @@ -2,6 +2,7 @@ # git checkout Src/usbd_desc.c git checkout Makefile git checkout Src/usb_device.c +git checkout Src/usbd_conf.c # git checkout Inc/FreeRTOSConfig.h Middlewares/Third_Party/FreeRTOS # git checkout Src/usb_host.c Inc/usb_host.h rm Src/usbd_audio_if.c From feab6520943cc9200bb1c445133d8ac67016e555 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 6 Jan 2022 19:13:10 +0100 Subject: [PATCH 260/286] updated legacy OWL Pedal firmware and configuration to match mkII --- OwlPedal/Inc/FreeRTOSConfig.h | 18 +- OwlPedal/Inc/hardware.h | 58 +- OwlPedal/Inc/main.h | 20 +- OwlPedal/Inc/stm32f4xx_hal_conf.h | 165 +++-- OwlPedal/Inc/stm32f4xx_it.h | 2 - OwlPedal/Inc/usb_device.h | 2 +- OwlPedal/Inc/usbd_conf.h | 39 +- OwlPedal/Inc/usbd_desc.h | 10 +- OwlPedal/Makefile | 82 +-- OwlPedal/OwlPedal.ioc | 999 ++++++++++++++---------------- OwlPedal/Src/OwlPedal.cpp | 565 ++++++++++++----- OwlPedal/Src/freertos.c | 2 +- OwlPedal/Src/main.c | 97 ++- OwlPedal/Src/stm32f4xx_hal_msp.c | 198 +++--- OwlPedal/Src/stm32f4xx_it.c | 45 +- OwlPedal/Src/usb_device.c | 11 +- OwlPedal/Src/usbd_conf.c | 291 +++------ OwlPedal/Src/usbd_desc.c | 135 ++-- 18 files changed, 1403 insertions(+), 1336 deletions(-) diff --git a/OwlPedal/Inc/FreeRTOSConfig.h b/OwlPedal/Inc/FreeRTOSConfig.h index 9a1589c9..1b299d46 100644 --- a/OwlPedal/Inc/FreeRTOSConfig.h +++ b/OwlPedal/Inc/FreeRTOSConfig.h @@ -78,13 +78,13 @@ * These definitions should be adjusted for your particular hardware and * application requirements. * - * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE - * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. + * These parameters and more are described within the 'configuration' section of the + * FreeRTOS API documentation available on the FreeRTOS.org web site. * - * See http://www.freertos.org/a00110.html. + * See http://www.freertos.org/a00110.html *----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ +/* USER CODE BEGIN Includes */ #include "device.h" #ifdef DEBUG_STACK @@ -92,7 +92,7 @@ #define INCLUDE_uxTaskGetStackHighWaterMark 1 #endif /* DEBUG_STACK */ -/* USER CODE END Includes */ +/* USER CODE END Includes */ /* Ensure definitions are only used by the compiler, and not by the assembler. */ #if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) @@ -124,7 +124,7 @@ /* Defaults to size_t for backward compatibility, but can be changed if lengths will always be less than the number of bytes in a size_t. */ #define configMESSAGE_BUFFER_LENGTH_TYPE size_t -/* USER CODE END MESSAGE_BUFFER_LENGTH_TYPE */ +/* USER CODE END MESSAGE_BUFFER_LENGTH_TYPE */ /* Co-routine definitions. */ #define configUSE_CO_ROUTINES 0 @@ -179,11 +179,11 @@ standard names. */ /* IMPORTANT: This define is commented when used with STM32Cube firmware, when the timebase source is SysTick, to prevent overwriting SysTick_Handler defined within STM32Cube HAL */ - + /* #define xPortSysTickHandler SysTick_Handler */ -/* USER CODE BEGIN Defines */ +/* USER CODE BEGIN Defines */ /* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */ -/* USER CODE END Defines */ +/* USER CODE END Defines */ #endif /* FREERTOS_CONFIG_H */ diff --git a/OwlPedal/Inc/hardware.h b/OwlPedal/Inc/hardware.h index 974324bf..4c95e93a 100644 --- a/OwlPedal/Inc/hardware.h +++ b/OwlPedal/Inc/hardware.h @@ -19,63 +19,53 @@ #endif #define MAX_SYSEX_BOOTLOADER_SIZE (32 * 1024) +#define EXPRESSION_MODE_EXP_TRS 1 +#define EXPRESSION_MODE_EXP_RTS 2 +#define EXPRESSION_MODE_FS_TS 3 // single footswitch +#define EXPRESSION_MODE_FS_TRS 4 // dual footswitch +#define EXPRESSION_MODE EXPRESSION_MODE_EXP_TRS + #define OWLBOOT_MAGIC_NUMBER 0xF00B4400 #define USE_CODEC #define USE_WM8731 + #define USE_USBD_FS -#define USE_USBD_AUDIO -#define USE_USBD_AUDIO_TX // microphone -#define USE_USBD_AUDIO_RX // speaker +#define USBD_DESC FS_Desc +#define USBD_HSFS DEVICE_FS #define USBD_HANDLE hUsbDeviceFS +#define USBD_PCD_HANDLE hpcd_USB_OTG_FS + +/* USB audio settings */ #define AUDIO_BITS_PER_SAMPLE 16 #define AUDIO_BYTES_PER_SAMPLE (AUDIO_BITS_PER_SAMPLE/8) #define AUDIO_CHANNELS 2 +#define USBD_AUDIO_RX_CHANNELS AUDIO_CHANNELS +#define USBD_AUDIO_TX_CHANNELS AUDIO_CHANNELS #define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) +#define USE_USBD_AUDIO +#define USE_USBD_RX_FB +#define USE_USBD_AUDIO_FEATURES +#define USE_USBD_AUDIO_RX // speaker +#define USE_USBD_AUDIO_TX // microphone + +/* #define USE_BKPSRAM */ + #ifdef OWL_RACK #define NOF_ADC_VALUES 0 #else #define USE_ADC -#define NOF_ADC_VALUES 5 +#define NOF_ADC_VALUES 6 #define ADC_PERIPH hadc3 #define ADC_A 0 #define ADC_B 1 #define ADC_C 2 #define ADC_D 3 #define ADC_E 4 +#define ADC_F 5 #endif #define NOF_PARAMETERS 40 #define NOF_BUTTONS (4 + 1) - -#define EXPRESSION_MODE_EXP_TRS 1 -#define EXPRESSION_MODE EXPRESSION_MODE_EXP_TRS - -#if 0 -#define MIDI_INPUT_CHANNEL MIDI_OMNI_CHANNEL -#define MIDI_OUTPUT_CHANNEL 0 - -#define DIGITAL_BUS_ENABLED 0 -#define DIGITAL_BUS_FORWARD_MIDI 1 - -/* +0db in and out */ -#define AUDIO_INPUT_GAIN 0x017 -#define AUDIO_OUTPUT_GAIN 0x079 -#define AUDIO_INPUT_OFFSET 0xffffefaa /* -0.06382 * 65535 */ -#define AUDIO_INPUT_SCALAR 0xfffbb5c7 /* -4.290 * 65535 */ -#define AUDIO_OUTPUT_OFFSET 0x00001eec /* 0.1208 * 65535 */ -#define AUDIO_OUTPUT_SCALAR 0xfffb5bab /* -4.642 * 65535 */ -#define DEFAULT_PROGRAM 1 -#define BUTTON_PROGRAM_CHANGE -#define AUDIO_BIGEND -/* #define AUDIO_SATURATE_SAMPLES // SATURATE adds almost 500 cycles to 24-bit mode */ -#define AUDIO_PROTOCOL I2S_PROTOCOL_PHILIPS -#define AUDIO_BITDEPTH 24 /* bits per sample */ -#define AUDIO_DATAFORMAT 24 -#define AUDIO_CODEC_MASTER true -#define AUDIO_CHANNELS 2 -#define AUDIO_SAMPLINGRATE 48000 - -#endif diff --git a/OwlPedal/Inc/main.h b/OwlPedal/Inc/main.h index e8223bd8..3209af4e 100644 --- a/OwlPedal/Inc/main.h +++ b/OwlPedal/Inc/main.h @@ -91,14 +91,14 @@ void Error_Handler(void); /* USER CODE END EFP */ /* Private defines -----------------------------------------------------------*/ -#define PUSHBUTTON_Pin GPIO_PIN_2 -#define PUSHBUTTON_GPIO_Port GPIOE -#define PUSHBUTTON_EXTI_IRQn EXTI2_IRQn +#define SW1_Pin GPIO_PIN_2 +#define SW1_GPIO_Port GPIOE +#define SW1_EXTI_IRQn EXTI2_IRQn #define LED_RED_Pin GPIO_PIN_3 #define LED_RED_GPIO_Port GPIOE -#define BYPASS_Pin GPIO_PIN_4 -#define BYPASS_GPIO_Port GPIOE -#define BYPASS_EXTI_IRQn EXTI4_IRQn +#define FOOTSWITCH_Pin GPIO_PIN_4 +#define FOOTSWITCH_GPIO_Port GPIOE +#define FOOTSWITCH_EXTI_IRQn EXTI4_IRQn #define LED_GREEN_Pin GPIO_PIN_5 #define LED_GREEN_GPIO_Port GPIOE #define ADC1_Pin GPIO_PIN_0 @@ -109,10 +109,10 @@ void Error_Handler(void); #define ADC3_GPIO_Port GPIOC #define ADC4_Pin GPIO_PIN_3 #define ADC4_GPIO_Port GPIOC -#define ADC5_Pin GPIO_PIN_2 -#define ADC5_GPIO_Port GPIOA -#define EXPRESSION_PEDAL_TIP_Pin GPIO_PIN_3 -#define EXPRESSION_PEDAL_TIP_GPIO_Port GPIOA +#define EXP1_RING_Pin GPIO_PIN_2 +#define EXP1_RING_GPIO_Port GPIOA +#define EXP1_TIP_Pin GPIO_PIN_3 +#define EXP1_TIP_GPIO_Port GPIOA #define FLASH_nCS_Pin GPIO_PIN_5 #define FLASH_nCS_GPIO_Port GPIOC #define I2C_SCK_Pin GPIO_PIN_10 diff --git a/OwlPedal/Inc/stm32f4xx_hal_conf.h b/OwlPedal/Inc/stm32f4xx_hal_conf.h index 17031be0..347d0526 100644 --- a/OwlPedal/Inc/stm32f4xx_hal_conf.h +++ b/OwlPedal/Inc/stm32f4xx_hal_conf.h @@ -2,7 +2,7 @@ ****************************************************************************** * @file stm32f4xx_hal_conf_template.h * @author MCD Application Team - * @brief HAL configuration template file. + * @brief HAL configuration template file. * This file should be copied to the application folder and renamed * to stm32f4xx_hal_conf.h. ****************************************************************************** @@ -17,7 +17,7 @@ * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** - */ + */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F4xx_HAL_CONF_H @@ -32,14 +32,15 @@ /* ########################## Module Selection ############################## */ /** - * @brief This is the list of modules to be used in the HAL driver + * @brief This is the list of modules to be used in the HAL driver */ -#define HAL_MODULE_ENABLED +#define HAL_MODULE_ENABLED #define HAL_ADC_MODULE_ENABLED /* #define HAL_CRYP_MODULE_ENABLED */ /* #define HAL_CAN_MODULE_ENABLED */ /* #define HAL_CRC_MODULE_ENABLED */ +/* #define HAL_CAN_LEGACY_MODULE_ENABLED */ /* #define HAL_CRYP_MODULE_ENABLED */ /* #define HAL_DAC_MODULE_ENABLED */ /* #define HAL_DCMI_MODULE_ENABLED */ @@ -62,7 +63,7 @@ /* #define HAL_MMC_MODULE_ENABLED */ /* #define HAL_SPI_MODULE_ENABLED */ /* #define HAL_TIM_MODULE_ENABLED */ -#define HAL_UART_MODULE_ENABLED +/* #define HAL_UART_MODULE_ENABLED */ /* #define HAL_USART_MODULE_ENABLED */ /* #define HAL_IRDA_MODULE_ENABLED */ /* #define HAL_SMARTCARD_MODULE_ENABLED */ @@ -75,6 +76,7 @@ /* #define HAL_QSPI_MODULE_ENABLED */ /* #define HAL_CEC_MODULE_ENABLED */ /* #define HAL_FMPI2C_MODULE_ENABLED */ +/* #define HAL_FMPSMBUS_MODULE_ENABLED */ /* #define HAL_SPDIFRX_MODULE_ENABLED */ /* #define HAL_DFSDM_MODULE_ENABLED */ /* #define HAL_LPTIM_MODULE_ENABLED */ @@ -90,20 +92,20 @@ /** * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. * This value is used by the RCC HAL module to compute the system frequency - * (when HSE is used as system clock source, directly or through the PLL). + * (when HSE is used as system clock source, directly or through the PLL). */ -#if !defined (HSE_VALUE) - #define HSE_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */ +#if !defined (HSE_VALUE) + #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ #endif /* HSE_VALUE */ #if !defined (HSE_STARTUP_TIMEOUT) - #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ + #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ #endif /* HSE_STARTUP_TIMEOUT */ /** * @brief Internal High Speed oscillator (HSI) value. * This value is used by the RCC HAL module to compute the system frequency - * (when HSI is used as system clock source, directly or through the PLL). + * (when HSI is used as system clock source, directly or through the PLL). */ #if !defined (HSI_VALUE) #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ @@ -112,8 +114,8 @@ /** * @brief Internal Low Speed oscillator (LSI) value. */ -#if !defined (LSI_VALUE) - #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/ +#if !defined (LSI_VALUE) + #define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/ #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz The real value may vary depending on the variations in voltage and temperature.*/ @@ -121,20 +123,20 @@ * @brief External Low Speed oscillator (LSE) value. */ #if !defined (LSE_VALUE) - #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */ + #define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ #endif /* LSE_VALUE */ #if !defined (LSE_STARTUP_TIMEOUT) - #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */ + #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ #endif /* LSE_STARTUP_TIMEOUT */ /** * @brief External clock source for I2S peripheral - * This value is used by the I2S HAL module to compute the I2S clock source - * frequency, this source is inserted directly through I2S_CKIN pad. + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. */ #if !defined (EXTERNAL_CLOCK_VALUE) - #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/ + #define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External audio frequency in Hz*/ #endif /* EXTERNAL_CLOCK_VALUE */ /* Tip: To avoid modifying this file each time you need to use different HSE, @@ -144,19 +146,59 @@ /** * @brief This is the HAL system configuration section */ -#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */ -#define TICK_INT_PRIORITY ((uint32_t)15U) /*!< tick interrupt priority */ -#define USE_RTOS 0U +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY 15U /*!< tick interrupt priority */ +#define USE_RTOS 0U #define PREFETCH_ENABLE 1U #define INSTRUCTION_CACHE_ENABLE 1U #define DATA_CACHE_ENABLE 1U +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */ +#define USE_HAL_FMPSMBUS_REGISTER_CALLBACKS 0U /* FMPSMBUS register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + /* ########################## Assert Selection ############################## */ /** - * @brief Uncomment the line below to expanse the "assert_param" macro in the + * @brief Uncomment the line below to expanse the "assert_param" macro in the * HAL drivers code */ - #define USE_FULL_ASSERT 1U + #define USE_FULL_ASSERT 1U /* ################## Ethernet peripheral configuration ##################### */ @@ -170,29 +212,29 @@ #define MAC_ADDR4 0U #define MAC_ADDR5 0U -/* Definition of the Ethernet driver buffers size and count */ +/* Definition of the Ethernet driver buffers size and count */ #define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ #define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ -#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ -#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ +#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ /* Section 2: PHY configuration section */ -/* DP83848_PHY_ADDRESS Address*/ +/* DP83848_PHY_ADDRESS Address*/ #define DP83848_PHY_ADDRESS 0x01U -/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ -#define PHY_RESET_DELAY ((uint32_t)0x000000FFU) +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY 0x000000FFU /* PHY Configuration delay */ -#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU) +#define PHY_CONFIG_DELAY 0x00000FFFU -#define PHY_READ_TO ((uint32_t)0x0000FFFFU) -#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU) +#define PHY_READ_TO 0x0000FFFFU +#define PHY_WRITE_TO 0x0000FFFFU /* Section 3: Common PHY Registers */ #define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */ #define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */ - + #define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ #define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ #define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ @@ -207,7 +249,7 @@ #define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ #define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ #define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */ - + /* Section 4: Extended PHY Registers */ #define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ @@ -225,25 +267,25 @@ /* Includes ------------------------------------------------------------------*/ /** - * @brief Include module's header file + * @brief Include module's header file */ #ifdef HAL_RCC_MODULE_ENABLED #include "stm32f4xx_hal_rcc.h" #endif /* HAL_RCC_MODULE_ENABLED */ -#ifdef HAL_EXTI_MODULE_ENABLED - #include "stm32f4xx_hal_exti.h" -#endif /* HAL_EXTI_MODULE_ENABLED */ - #ifdef HAL_GPIO_MODULE_ENABLED #include "stm32f4xx_hal_gpio.h" #endif /* HAL_GPIO_MODULE_ENABLED */ +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32f4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + #ifdef HAL_DMA_MODULE_ENABLED #include "stm32f4xx_hal_dma.h" #endif /* HAL_DMA_MODULE_ENABLED */ - + #ifdef HAL_CORTEX_MODULE_ENABLED #include "stm32f4xx_hal_cortex.h" #endif /* HAL_CORTEX_MODULE_ENABLED */ @@ -256,18 +298,18 @@ #include "stm32f4xx_hal_can.h" #endif /* HAL_CAN_MODULE_ENABLED */ +#ifdef HAL_CAN_LEGACY_MODULE_ENABLED + #include "stm32f4xx_hal_can_legacy.h" +#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ + #ifdef HAL_CRC_MODULE_ENABLED #include "stm32f4xx_hal_crc.h" #endif /* HAL_CRC_MODULE_ENABLED */ #ifdef HAL_CRYP_MODULE_ENABLED - #include "stm32f4xx_hal_cryp.h" + #include "stm32f4xx_hal_cryp.h" #endif /* HAL_CRYP_MODULE_ENABLED */ -#ifdef HAL_SMBUS_MODULE_ENABLED -#include "stm32f4xx_hal_smbus.h" -#endif /* HAL_SMBUS_MODULE_ENABLED */ - #ifdef HAL_DMA2D_MODULE_ENABLED #include "stm32f4xx_hal_dma2d.h" #endif /* HAL_DMA2D_MODULE_ENABLED */ @@ -287,7 +329,7 @@ #ifdef HAL_FLASH_MODULE_ENABLED #include "stm32f4xx_hal_flash.h" #endif /* HAL_FLASH_MODULE_ENABLED */ - + #ifdef HAL_SRAM_MODULE_ENABLED #include "stm32f4xx_hal_sram.h" #endif /* HAL_SRAM_MODULE_ENABLED */ @@ -302,11 +344,11 @@ #ifdef HAL_PCCARD_MODULE_ENABLED #include "stm32f4xx_hal_pccard.h" -#endif /* HAL_PCCARD_MODULE_ENABLED */ - +#endif /* HAL_PCCARD_MODULE_ENABLED */ + #ifdef HAL_SDRAM_MODULE_ENABLED #include "stm32f4xx_hal_sdram.h" -#endif /* HAL_SDRAM_MODULE_ENABLED */ +#endif /* HAL_SDRAM_MODULE_ENABLED */ #ifdef HAL_HASH_MODULE_ENABLED #include "stm32f4xx_hal_hash.h" @@ -316,6 +358,10 @@ #include "stm32f4xx_hal_i2c.h" #endif /* HAL_I2C_MODULE_ENABLED */ +#ifdef HAL_SMBUS_MODULE_ENABLED + #include "stm32f4xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + #ifdef HAL_I2S_MODULE_ENABLED #include "stm32f4xx_hal_i2s.h" #endif /* HAL_I2S_MODULE_ENABLED */ @@ -348,10 +394,6 @@ #include "stm32f4xx_hal_sd.h" #endif /* HAL_SD_MODULE_ENABLED */ -#ifdef HAL_MMC_MODULE_ENABLED - #include "stm32f4xx_hal_mmc.h" -#endif /* HAL_MMC_MODULE_ENABLED */ - #ifdef HAL_SPI_MODULE_ENABLED #include "stm32f4xx_hal_spi.h" #endif /* HAL_SPI_MODULE_ENABLED */ @@ -387,7 +429,7 @@ #ifdef HAL_HCD_MODULE_ENABLED #include "stm32f4xx_hal_hcd.h" #endif /* HAL_HCD_MODULE_ENABLED */ - + #ifdef HAL_DSI_MODULE_ENABLED #include "stm32f4xx_hal_dsi.h" #endif /* HAL_DSI_MODULE_ENABLED */ @@ -404,6 +446,10 @@ #include "stm32f4xx_hal_fmpi2c.h" #endif /* HAL_FMPI2C_MODULE_ENABLED */ +#ifdef HAL_FMPSMBUS_MODULE_ENABLED + #include "stm32f4xx_hal_fmpsmbus.h" +#endif /* HAL_FMPSMBUS_MODULE_ENABLED */ + #ifdef HAL_SPDIFRX_MODULE_ENABLED #include "stm32f4xx_hal_spdifrx.h" #endif /* HAL_SPDIFRX_MODULE_ENABLED */ @@ -415,14 +461,18 @@ #ifdef HAL_LPTIM_MODULE_ENABLED #include "stm32f4xx_hal_lptim.h" #endif /* HAL_LPTIM_MODULE_ENABLED */ - + +#ifdef HAL_MMC_MODULE_ENABLED + #include "stm32f4xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + /* Exported macro ------------------------------------------------------------*/ #ifdef USE_FULL_ASSERT /** * @brief The assert_param macro is used for function's parameters check. - * @param expr: If expr is false, it calls assert_failed function + * @param expr If expr is false, it calls assert_failed function * which reports the name of the source file and the source - * line number of the call that failed. + * line number of the call that failed. * If expr is true, it returns no value. * @retval None */ @@ -431,13 +481,12 @@ void assert_failed(uint8_t* file, uint32_t line); #else #define assert_param(expr) ((void)0U) -#endif /* USE_FULL_ASSERT */ +#endif /* USE_FULL_ASSERT */ #ifdef __cplusplus } #endif #endif /* __STM32F4xx_HAL_CONF_H */ - /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/OwlPedal/Inc/stm32f4xx_it.h b/OwlPedal/Inc/stm32f4xx_it.h index 0822b56a..83a1a485 100644 --- a/OwlPedal/Inc/stm32f4xx_it.h +++ b/OwlPedal/Inc/stm32f4xx_it.h @@ -65,12 +65,10 @@ void SysTick_Handler(void); void EXTI2_IRQHandler(void); void EXTI4_IRQHandler(void); -void DMA1_Stream2_IRQHandler(void); void DMA1_Stream3_IRQHandler(void); void DMA1_Stream4_IRQHandler(void); void EXTI9_5_IRQHandler(void); void SPI2_IRQHandler(void); -void UART4_IRQHandler(void); void DMA2_Stream0_IRQHandler(void); void OTG_FS_IRQHandler(void); /* USER CODE BEGIN EFP */ diff --git a/OwlPedal/Inc/usb_device.h b/OwlPedal/Inc/usb_device.h index b4529d17..98cf5857 100644 --- a/OwlPedal/Inc/usb_device.h +++ b/OwlPedal/Inc/usb_device.h @@ -7,7 +7,7 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2020 STMicroelectronics. + *

© Copyright (c) 2019 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under Ultimate Liberty license diff --git a/OwlPedal/Inc/usbd_conf.h b/OwlPedal/Inc/usbd_conf.h index dc6c481c..27e21fa6 100644 --- a/OwlPedal/Inc/usbd_conf.h +++ b/OwlPedal/Inc/usbd_conf.h @@ -7,7 +7,7 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2020 STMicroelectronics. + *

© Copyright (c) 2019 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under Ultimate Liberty license @@ -36,7 +36,12 @@ #include "stm32f4xx_hal.h" /* USER CODE BEGIN INCLUDE */ - +#include "device.h" +#ifdef DEBUG +#define DEBUG_LEVEL 3 +#else +#define DEBUG_LEVEL 0 +#endif /* USER CODE END INCLUDE */ /** @addtogroup USBD_OTG_DRIVER @@ -64,19 +69,18 @@ */ /*---------- -----------*/ -#define USBD_MAX_NUM_INTERFACES 1U +#define USBD_MAX_NUM_INTERFACES 5U /*---------- -----------*/ #define USBD_MAX_NUM_CONFIGURATION 1U /*---------- -----------*/ #define USBD_MAX_STR_DESC_SIZ 512U /*---------- -----------*/ -#define USBD_DEBUG_LEVEL 0U +#define USBD_DEBUG_LEVEL DEBUG_LEVEL /*---------- -----------*/ #define USBD_LPM_ENABLED 0U /*---------- -----------*/ -#define USBD_SELF_POWERED 1U +#define USBD_SELF_POWERED 0U /*---------- -----------*/ -#define USBD_AUDIO_FREQ 22100U /****************************************/ /* #define for FS and HS identification */ @@ -91,14 +95,13 @@ * @brief Aliases. * @{ */ - -/* Memory management macros */ - +/* Memory management macros make sure to use static memory allocation */ /** Alias for memory allocation. */ -#define USBD_malloc malloc + +#define USBD_malloc (void *)USBD_static_malloc /** Alias for memory release. */ -#define USBD_free free +#define USBD_free USBD_static_free /** Alias for memory set. */ #define USBD_memset memset @@ -112,25 +115,25 @@ /* DEBUG macros */ #if (USBD_DEBUG_LEVEL > 0) -#define USBD_UsrLog(...) printf(__VA_ARGS__);\ - printf("\n"); +#define USBD_UsrLog(...) do { printf(__VA_ARGS__); \ + printf("\n"); } while(0) #else #define USBD_UsrLog(...) #endif #if (USBD_DEBUG_LEVEL > 1) -#define USBD_ErrLog(...) printf("ERROR: ") ;\ +#define USBD_ErrLog(...) do { printf("ERROR: ") ;\ printf(__VA_ARGS__);\ - printf("\n"); + printf("\n"); } while(0) #else #define USBD_ErrLog(...) #endif #if (USBD_DEBUG_LEVEL > 2) -#define USBD_DbgLog(...) printf("DEBUG : ") ;\ +#define USBD_DbgLog(...) do { printf("DEBUG : ") ; \ printf(__VA_ARGS__);\ - printf("\n"); + printf("\n"); } while(0) #else #define USBD_DbgLog(...) #endif @@ -154,6 +157,8 @@ */ /* Exported functions -------------------------------------------------------*/ +void *USBD_static_malloc(uint32_t size); +void USBD_static_free(void *p); /** * @} diff --git a/OwlPedal/Inc/usbd_desc.h b/OwlPedal/Inc/usbd_desc.h index 0c6619fd..90f8968c 100644 --- a/OwlPedal/Inc/usbd_desc.h +++ b/OwlPedal/Inc/usbd_desc.h @@ -7,7 +7,7 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2020 STMicroelectronics. + *

© Copyright (c) 2019 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under Ultimate Liberty license @@ -17,7 +17,7 @@ * ****************************************************************************** */ -/* USER CODE END Header */ +/* USER CODE END Header */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USBD_DESC__C__ #define __USBD_DESC__C__ @@ -30,7 +30,7 @@ #include "usbd_def.h" /* USER CODE BEGIN INCLUDE */ - +#include "device.h" /* USER CODE END INCLUDE */ /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY @@ -41,7 +41,7 @@ * @brief Usb device descriptors module. * @{ */ - + /** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants * @brief Constants. * @{ @@ -105,7 +105,7 @@ */ /** Descriptor for the Usb device. */ -extern USBD_DescriptorsTypeDef FS_Desc; +extern USBD_DescriptorsTypeDef USBD_DESC; /* USER CODE BEGIN EXPORTED_VARIABLES */ diff --git a/OwlPedal/Makefile b/OwlPedal/Makefile index a2add535..e61deac7 100644 --- a/OwlPedal/Makefile +++ b/OwlPedal/Makefile @@ -1,41 +1,41 @@ -BUILDROOT = . -OPENWARE ?= $(BUILDROOT)/.. - -include $(OPENWARE)/Hardware/owl1.mk - -C_SRC = $(wildcard Src/*.c) -CPP_SRC = $(wildcard Src/*.cpp) -C_SRC += $(OPENWARE)/Source/wm8731.c -CPP_SRC += $(OPENWARE)/Source/usbd_audio.cpp - -ifndef PLATFORM -PLATFORM = Pedal -endif - -ifeq ($(PLATFORM),Pedal) - PROJECT = OwlPedal - CPPFLAGS += -DOWL_PEDAL -else ifeq ($(PLATFORM),Modular) - PROJECT = OwlModular - CPPFLAGS += -DOWL_MODULAR -else ifeq ($(PLATFORM),Rack) - PROJECT = OwlRack - CPPFLAGS += -IOWL_PEDAL -DOWL_RACK - CPP_SRC += DigitalBusHandler.cpp DigitalBusReader.cpp DigitalBusStreamReader.cpp bus.cpp -endif - -include $(OPENWARE)/Hardware/sources.mk - -C_SRC += $(C_SRC_I2S) -C_SRC += $(C_SRC_SRAM) -C_SRC += $(C_SRC_USBD) -C_SRC += $(C_SRC_DSP) -C_SRC += $(C_SRC_OS) -C_SRC += $(C_SRC_UART) - -include $(OPENWARE)/Hardware/f4.mk - -DFUCMD = dfu-util -d 0483:df11 -c 1 -i 0 -a 0 -R -dfu: bin - @echo Flashing OWL $(PLATFORM) $(CONFIG) firmware - $(DFUCMD) -s 0x8008000:leave -D $(BIN) +BUILDROOT = . +OPENWARE ?= $(BUILDROOT)/.. + +include $(OPENWARE)/Hardware/owl1.mk + +C_SRC = $(wildcard Src/*.c) +CPP_SRC = $(wildcard Src/*.cpp) +C_SRC += $(OPENWARE)/Source/wm8731.c +CPP_SRC += $(OPENWARE)/Source/usbd_audio.cpp + +ifndef PLATFORM +PLATFORM = Pedal +endif + +ifeq ($(PLATFORM),Pedal) + PROJECT = OwlPedal + CPPFLAGS += -DOWL_PEDAL +else ifeq ($(PLATFORM),Modular) + PROJECT = OwlModular + CPPFLAGS += -DOWL_MODULAR +else ifeq ($(PLATFORM),Rack) + PROJECT = OwlRack + CPPFLAGS += -IOWL_PEDAL -DOWL_RACK + CPP_SRC += DigitalBusHandler.cpp DigitalBusReader.cpp DigitalBusStreamReader.cpp bus.cpp +endif + +include $(OPENWARE)/Hardware/sources.mk + +C_SRC += $(C_SRC_I2S) +C_SRC += $(C_SRC_SRAM) +C_SRC += $(C_SRC_USBD) +C_SRC += $(C_SRC_DSP) +C_SRC += $(C_SRC_OS) +C_SRC += $(C_SRC_UART) + +include $(OPENWARE)/Hardware/f4.mk + +DFUCMD = dfu-util -d 0483:df11 -c 1 -i 0 -a 0 -R +dfu: bin + @echo Flashing OWL $(PLATFORM) $(CONFIG) firmware + $(DFUCMD) -s 0x8008000:leave -D $(BIN) diff --git a/OwlPedal/OwlPedal.ioc b/OwlPedal/OwlPedal.ioc index 7379def5..d3928e7f 100644 --- a/OwlPedal/OwlPedal.ioc +++ b/OwlPedal/OwlPedal.ioc @@ -1,558 +1,521 @@ #MicroXplorer Configuration settings - do not modify +ADC3.Channel-92\#ChannelRegularConversion=ADC_CHANNEL_10 ADC3.Channel-93\#ChannelRegularConversion=ADC_CHANNEL_11 -PB13.GPIOParameters=GPIO_Label -PH0-OSC_IN.Signal=RCC_OSC_IN -ADC3.SamplingTime-96\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -SH.FSMC_D1_DA1.0=FSMC_D1,16b-d1 -PB10.Mode=I2C -PG4.Signal=FSMC_A14 -NVIC.DMA1_Stream2_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true -RCC.PLLCLKFreq_Value=168000000 -Dma.ADC3.3.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD -PB14.GPIO_Label=I2S_SDI -SH.FSMC_NWE.0=FSMC_NWE,Sram1 -RCC.PLLQCLKFreq_Value=48000000 -PG0.Signal=FSMC_A10 -PC6.GPIO_Label=I2S_MCLK -PC3.Locked=true -ADC3.SamplingTime-93\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -RCC.RTCFreq_Value=32000 -PA3.GPIOParameters=GPIO_Label -PB6.GPIO_Label=PUSH_GATE_IN -ADC3.Rank-96\#ChannelRegularConversion=5 -PB13.Signal=I2S2_CK -PA2.GPIOParameters=GPIO_Label -PinOutPanel.RotationAngle=0 -RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK -USB_DEVICE.PID_AUDIO_FS=0xDADA -NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -Dma.I2S2_EXT_RX.2.MemDataAlignment=DMA_MDATAALIGN_HALFWORD -SH.FSMC_A15.ConfNb=1 -SH.FSMC_A11.ConfNb=1 -ADC3.Rank-93\#ChannelRegularConversion=2 -PD4.Signal=FSMC_NOE -RCC.APB2TimFreq_Value=168000000 -PB6.Signal=GPXTI6 -PC3.Signal=ADCx_IN13 -PD0.Signal=FSMC_D2_DA2 -ADC3.ScanConvMode=ENABLE -PD8.Signal=FSMC_D13_DA13 -PE5.Signal=GPIO_Output -PE1.Signal=FSMC_NBL1 +ADC3.Channel-94\#ChannelRegularConversion=ADC_CHANNEL_12 +ADC3.Channel-95\#ChannelRegularConversion=ADC_CHANNEL_13 ADC3.Channel-96\#ChannelRegularConversion=ADC_CHANNEL_2 -PB13.Locked=true -SH.FSMC_D4_DA4.ConfNb=1 -ProjectManager.ProjectBuild=false -NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -PB3.Mode=Trace_Asynchronous_SW -PB12.GPIO_Label=I2S_LRCK -ADC3.ExternalTrigConv=ADC_SOFTWARE_START -ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.25.0 -MxDb.Version=DB.5.0.60 -USB_DEVICE.MANUFACTURER_STRING-AUDIO_FS=Rebel Technology -SH.FSMC_NOE.ConfNb=1 -ProjectManager.BackupPrevious=false -SH.FSMC_D10_DA10.0=FSMC_D10,16b-d1 -PE9.Signal=FSMC_D6_DA6 -SH.FSMC_A0.0=FSMC_A0,19b-a1 -PB14.Mode=Full_Duplex_Slave +ADC3.Channel-97\#ChannelRegularConversion=ADC_CHANNEL_3 +ADC3.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV8 ADC3.ContinuousConvMode=ENABLE -PE4.GPIO_Label=BYPASS -ADC3.IPParameters=Rank-92\#ChannelRegularConversion,Channel-92\#ChannelRegularConversion,SamplingTime-92\#ChannelRegularConversion,NbrOfConversionFlag,Rank-93\#ChannelRegularConversion,Channel-93\#ChannelRegularConversion,SamplingTime-93\#ChannelRegularConversion,Rank-94\#ChannelRegularConversion,Channel-94\#ChannelRegularConversion,SamplingTime-94\#ChannelRegularConversion,Rank-95\#ChannelRegularConversion,Channel-95\#ChannelRegularConversion,SamplingTime-95\#ChannelRegularConversion,Rank-96\#ChannelRegularConversion,Channel-96\#ChannelRegularConversion,SamplingTime-96\#ChannelRegularConversion,NbrOfConversion,ScanConvMode,ContinuousConvMode,EOCSelection,DMAContinuousRequests,ClockPrescaler,Resolution,DataAlign,DiscontinuousConvMode,ExternalTrigConv,ExternalTrigConvEdge,InjNumberOfConversion,EnableAnalogWatchDog -SH.ADCx_IN11.ConfNb=1 -PE2.Signal=GPXTI2 -I2S2.IPParameters=Instance,VirtualMode,FullDuplexMode,AudioFreq,RealAudioFreq,ErrorAudioFreq,DataFormat -FSMC.BusTurnAroundDuration1=1 -Dma.UART4_RX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -PE1.Locked=true -PB6.Locked=true -NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false -PF3.Signal=FSMC_A3 -VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 -PE10.Signal=FSMC_D7_DA7 -SH.FSMC_D5_DA5.0=FSMC_D5,16b-d1 -ProjectManager.HalAssertFull=true -PB7.PinState=GPIO_PIN_SET -Dma.SPI2_TX.1.FIFOMode=DMA_FIFOMODE_DISABLE -SH.FSMC_A0.ConfNb=1 -RCC.MCO2PinFreq_Value=168000000 -SH.FSMC_A8.ConfNb=1 -Mcu.Package=LQFP144 -SH.FSMC_D15_DA15.ConfNb=1 -FSMC.IPParameters=AddressSetupTime1,DataSetupTime1,BusTurnAroundDuration1,WriteOperation1,ExtendedMode1 -PD12.Signal=FSMC_A17_ALE -SH.FSMC_D14_DA14.ConfNb=1 -VP_SYS_VS_Systick.Signal=SYS_VS_Systick -FREERTOS.FootprintOK=true -Dma.SPI2_TX.1.Instance=DMA1_Stream4 -PB14.GPIOParameters=GPIO_Label -SH.FSMC_A1.0=FSMC_A1,19b-a1 ADC3.DMAContinuousRequests=ENABLE -RCC.APB2CLKDivider=RCC_HCLK_DIV2 -NVIC.EXTI2_IRQn=true\:10\:0\:true\:false\:true\:true\:true\:true -SH.FSMC_D3_DA3.0=FSMC_D3,16b-d1 +ADC3.DataAlign=ADC_DATAALIGN_RIGHT +ADC3.DiscontinuousConvMode=DISABLE +ADC3.EOCSelection=ADC_EOC_SEQ_CONV +ADC3.EnableAnalogWatchDog=false +ADC3.ExternalTrigConv=ADC_SOFTWARE_START ADC3.ExternalTrigConvEdge=ADC_EXTERNALTRIGCONVEDGE_NONE -PF14.Signal=FSMC_A8 -RCC.APB1TimFreq_Value=84000000 -NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -USB_OTG_FS.IPParameters=VirtualMode -PB10.GPIOParameters=GPIO_Label -PB13.Mode=Full_Duplex_Slave -SH.FSMC_D7_DA7.ConfNb=1 -PD15.Signal=FSMC_D1_DA1 -ProjectManager.CustomerFirmwarePackage= -NVIC.UART4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -SH.FSMC_A5.ConfNb=1 -Dma.UART4_RX.0.MemInc=DMA_MINC_ENABLE -USB_DEVICE.VID-AUDIO_FS=0x1209 -Dma.SPI2_TX.1.MemInc=DMA_MINC_ENABLE +ADC3.IPParameters=Rank-92\#ChannelRegularConversion,Channel-92\#ChannelRegularConversion,SamplingTime-92\#ChannelRegularConversion,NbrOfConversionFlag,Rank-93\#ChannelRegularConversion,Channel-93\#ChannelRegularConversion,SamplingTime-93\#ChannelRegularConversion,Rank-94\#ChannelRegularConversion,Channel-94\#ChannelRegularConversion,SamplingTime-94\#ChannelRegularConversion,Rank-95\#ChannelRegularConversion,Channel-95\#ChannelRegularConversion,SamplingTime-95\#ChannelRegularConversion,Rank-96\#ChannelRegularConversion,Channel-96\#ChannelRegularConversion,SamplingTime-96\#ChannelRegularConversion,NbrOfConversion,ScanConvMode,ContinuousConvMode,EOCSelection,DMAContinuousRequests,ClockPrescaler,Resolution,DataAlign,DiscontinuousConvMode,ExternalTrigConv,ExternalTrigConvEdge,InjNumberOfConversion,EnableAnalogWatchDog,Rank-97\#ChannelRegularConversion,Channel-97\#ChannelRegularConversion,SamplingTime-97\#ChannelRegularConversion +ADC3.InjNumberOfConversion=0 +ADC3.NbrOfConversion=6 +ADC3.NbrOfConversionFlag=1 ADC3.Rank-92\#ChannelRegularConversion=1 -NVIC.EXTI4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -I2S2.AudioFreq=I2S_AUDIOFREQ_48K -ProjectManager.ProjectFileName=OwlPedal.ioc -FREERTOS.Tasks01=defaultTask,0,512,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL -USB_DEVICE.VirtualMode-AUDIO_FS=Audio -SH.FSMC_A2.0=FSMC_A2,19b-a1 -Mcu.PinsNb=74 -Mcu.Pin73=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS -Mcu.Pin71=VP_FREERTOS_VS_CMSIS_V1 -Mcu.Pin72=VP_SYS_VS_Systick -PG5.Signal=FSMC_A15 -FREERTOS.INCLUDE_vTaskDelayUntil=1 -PB6.GPIO_PuPd=GPIO_PULLUP -Dma.UART4_RX.0.Mode=DMA_NORMAL -FREERTOS.configCHECK_FOR_STACK_OVERFLOW=1 -SH.FSMC_NBL1.ConfNb=1 -Dma.ADC3.3.Instance=DMA2_Stream0 -Mcu.Pin70=PE1 -PC6.Signal=GPIO_Input -PC2.Signal=ADCx_IN12 -PB11.GPIO_Label=I2C_SDA -SH.FSMC_A16_CLE.0=FSMC_A16,19b-a1 -SH.FSMC_D8_DA8.ConfNb=1 -PD1.Signal=FSMC_D3_DA3 -SH.FSMC_D9_DA9.0=FSMC_D9,16b-d1 -ADC3.SamplingTime-92\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -Mcu.Pin68=PB7 -Mcu.Pin69=PE0 -PC0.Signal=ADCx_IN10 -PB14.Locked=true -RCC.APB1CLKDivider=RCC_HCLK_DIV4 -UART4.VirtualMode=Asynchronous -Mcu.Pin62=PD1 -Mcu.Pin63=PD4 -Mcu.Pin60=PA14 -Mcu.Pin61=PD0 -Mcu.Pin66=PB3 -Mcu.Pin67=PB6 -Mcu.Pin64=PD5 +ADC3.Rank-93\#ChannelRegularConversion=2 +ADC3.Rank-94\#ChannelRegularConversion=3 +ADC3.Rank-95\#ChannelRegularConversion=4 +ADC3.Rank-96\#ChannelRegularConversion=5 +ADC3.Rank-97\#ChannelRegularConversion=6 ADC3.Resolution=ADC_RESOLUTION_12B -Mcu.Pin65=PG10 -PA0-WKUP.Signal=UART4_TX -PG10.Signal=FSMC_NE3 -SH.FSMC_D8_DA8.0=FSMC_D8,16b-d1 -PC3.GPIOParameters=GPIO_Label -PA0-WKUP.Mode=Asynchronous -PD10.Signal=FSMC_D15_DA15 -SH.GPXTI6.ConfNb=1 -ADC3.Channel-92\#ChannelRegularConversion=ADC_CHANNEL_10 -Mcu.Pin59=PA13 -SH.FSMC_A14.ConfNb=1 -Mcu.Pin57=PA11 -SH.GPXTI2.ConfNb=1 -Mcu.Pin58=PA12 -PB11.Mode=I2C -SH.FSMC_A3.0=FSMC_A3,19b-a1 -SH.FSMC_A15.0=FSMC_A15,19b-a1 -FSMC.DataSetupTime1=2 -SH.FSMC_D5_DA5.ConfNb=1 -Mcu.Pin51=PG2 -Mcu.Pin52=PG3 -SH.FSMC_A10.ConfNb=1 -Mcu.Pin50=PD15 -Mcu.Pin55=PC6 -Mcu.Pin56=PA9 -Mcu.Pin53=PG4 -Mcu.Pin54=PG5 -PC6.Locked=true -SH.FSMC_A3.ConfNb=1 -PA9.Signal=USB_OTG_FS_VBUS -I2S2.VirtualMode=I2S_MODE_SLAVE -PB11.GPIOParameters=GPIO_Label -ADC3.NbrOfConversion=5 -Dma.UART4_RX.0.PeriphInc=DMA_PINC_DISABLE -Mcu.Pin48=PD13 -Mcu.Pin49=PD14 -Mcu.Pin46=PD11 -Mcu.Pin47=PD12 -Dma.ADC3.3.Direction=DMA_PERIPH_TO_MEMORY -PB10.Signal=I2C2_SCL -PB14.Signal=I2S2_ext_SD -PE2.GPIO_PuPd=GPIO_PULLUP -Mcu.Pin40=PB13 -Mcu.Pin41=PB14 +ADC3.SamplingTime-92\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-93\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-94\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-95\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-96\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.SamplingTime-97\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES +ADC3.ScanConvMode=ENABLE +Dma.ADC3.2.Direction=DMA_PERIPH_TO_MEMORY +Dma.ADC3.2.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.ADC3.2.Instance=DMA2_Stream0 +Dma.ADC3.2.MemDataAlignment=DMA_MDATAALIGN_HALFWORD +Dma.ADC3.2.MemInc=DMA_MINC_ENABLE +Dma.ADC3.2.Mode=DMA_CIRCULAR +Dma.ADC3.2.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD +Dma.ADC3.2.PeriphInc=DMA_PINC_DISABLE +Dma.ADC3.2.Priority=DMA_PRIORITY_LOW +Dma.ADC3.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +Dma.I2S2_EXT_RX.1.Direction=DMA_PERIPH_TO_MEMORY +Dma.I2S2_EXT_RX.1.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.I2S2_EXT_RX.1.Instance=DMA1_Stream3 +Dma.I2S2_EXT_RX.1.MemDataAlignment=DMA_MDATAALIGN_HALFWORD +Dma.I2S2_EXT_RX.1.MemInc=DMA_MINC_ENABLE +Dma.I2S2_EXT_RX.1.Mode=DMA_CIRCULAR +Dma.I2S2_EXT_RX.1.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD +Dma.I2S2_EXT_RX.1.PeriphInc=DMA_PINC_DISABLE +Dma.I2S2_EXT_RX.1.Priority=DMA_PRIORITY_HIGH +Dma.I2S2_EXT_RX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +Dma.Request0=SPI2_TX +Dma.Request1=I2S2_EXT_RX +Dma.Request2=ADC3 +Dma.RequestsNb=3 +Dma.SPI2_TX.0.Direction=DMA_MEMORY_TO_PERIPH +Dma.SPI2_TX.0.FIFOMode=DMA_FIFOMODE_DISABLE +Dma.SPI2_TX.0.Instance=DMA1_Stream4 +Dma.SPI2_TX.0.MemDataAlignment=DMA_MDATAALIGN_HALFWORD +Dma.SPI2_TX.0.MemInc=DMA_MINC_ENABLE +Dma.SPI2_TX.0.Mode=DMA_CIRCULAR +Dma.SPI2_TX.0.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD +Dma.SPI2_TX.0.PeriphInc=DMA_PINC_DISABLE +Dma.SPI2_TX.0.Priority=DMA_PRIORITY_HIGH +Dma.SPI2_TX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +FREERTOS.FootprintOK=true +FREERTOS.INCLUDE_vTaskDelayUntil=1 +FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configENABLE_BACKWARD_COMPATIBILITY,configUSE_MUTEXES,FootprintOK,MEMORY_ALLOCATION,configCHECK_FOR_STACK_OVERFLOW,configUSE_MALLOC_FAILED_HOOK,INCLUDE_vTaskDelayUntil,configTOTAL_HEAP_SIZE FREERTOS.MEMORY_ALLOCATION=2 -Mcu.Pin44=PD9 -SH.FSMC_D7_DA7.0=FSMC_D7,16b-d1 -Mcu.Pin45=PD10 -Mcu.Pin42=PB15 -Mcu.Pin43=PD8 -ProjectManager.LastFirmware=true -Dma.UART4_RX.0.FIFOMode=DMA_FIFOMODE_DISABLE -SH.FSMC_D3_DA3.ConfNb=1 -PA1.Mode=Asynchronous -PE14.Signal=FSMC_D11_DA11 -PE15.Signal=FSMC_D12_DA12 -Dma.SPI2_TX.1.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD -Mcu.Pin37=PB10 -Mcu.Pin38=PB11 -Mcu.Pin35=PE14 -PB15.GPIO_Label=I2S_SDO -PE8.Signal=FSMC_D5_DA5 -Mcu.Pin36=PE15 -ADC3.Channel-95\#ChannelRegularConversion=ADC_CHANNEL_13 -Dma.SPI2_TX.1.Priority=DMA_PRIORITY_HIGH -Dma.ADC3.3.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -SH.FSMC_A18.0=FSMC_A18,19b-a1 -Mcu.Pin39=PB12 -PC2.GPIOParameters=GPIO_Label -Mcu.Pin30=PE9 -SH.FSMC_A4.0=FSMC_A4,19b-a1 -Dma.I2S2_EXT_RX.2.Instance=DMA1_Stream3 -RCC.EthernetFreq_Value=168000000 -SH.ADCx_IN12.ConfNb=1 -Mcu.Pin33=PE12 -Mcu.Pin34=PE13 -Mcu.Pin31=PE10 -Mcu.Pin32=PE11 -SH.FSMC_A4.ConfNb=1 -NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +FREERTOS.Tasks01=defaultTask,0,512,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL +FREERTOS.configCHECK_FOR_STACK_OVERFLOW=1 +FREERTOS.configENABLE_BACKWARD_COMPATIBILITY=0 +FREERTOS.configTOTAL_HEAP_SIZE=4096 +FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 FREERTOS.configUSE_MUTEXES=0 -PF13.Signal=FSMC_A7 -PA13.Mode=Trace_Asynchronous_SW -ProjectManager.FreePins=true -Mcu.Pin26=PG0 -Mcu.Pin27=PG1 -RCC.RTCHSEDivFreq_Value=4000000 -Mcu.Pin24=PF14 -ProjectManager.UnderRoot=false -PE4.GPIO_PuPd=GPIO_PULLUP -Mcu.Pin25=PF15 -SH.FSMC_A17_ALE.0=FSMC_A17,19b-a1 +FREERTOS.configUSE_PREEMPTION=0 +FSMC.AddressSetupTime1=2 +FSMC.BusTurnAroundDuration1=1 +FSMC.DataSetupTime1=2 +FSMC.ExtendedMode1=FSMC_EXTENDED_MODE_DISABLE +FSMC.IPParameters=AddressSetupTime1,DataSetupTime1,BusTurnAroundDuration1,WriteOperation1,ExtendedMode1 +FSMC.WriteOperation1=FSMC_WRITE_OPERATION_ENABLE +File.Version=6 +I2S2.AudioFreq=I2S_AUDIOFREQ_48K +I2S2.DataFormat=I2S_DATAFORMAT_24B +I2S2.ErrorAudioFreq=-0.01 % I2S2.FullDuplexMode=I2S_FULLDUPLEXMODE_ENABLE -Mcu.Pin28=PE7 -Mcu.Pin29=PE8 -Mcu.Pin22=PF12 -Mcu.Pin23=PF13 -Mcu.Pin20=PC4 -PA3.Locked=true -Mcu.Pin21=PC5 -NVIC.ForceEnableDMAVector=true -PD11.Signal=FSMC_A16_CLE -NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -PE5.GPIO_Label=LED_GREEN -ProjectManager.CompilerOptimize=6 -PA11.Signal=USB_OTG_FS_DM -Dma.I2S2_EXT_RX.2.FIFOMode=DMA_FIFOMODE_DISABLE -SH.FSMC_D15_DA15.0=FSMC_D15,16b-d1 -ProjectManager.HeapSize=0x200 -Mcu.Pin15=PC3 -NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -Mcu.Pin16=PA0-WKUP -ADC3.EOCSelection=ADC_EOC_SEQ_CONV -Mcu.Pin13=PC1 -Mcu.Pin14=PC2 -Mcu.Pin19=PA3 -ProjectManager.ComputerToolchain=false -Mcu.Pin17=PA1 -Mcu.Pin18=PA2 -SH.FSMC_D1_DA1.ConfNb=1 -NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 -SH.FSMC_A5.0=FSMC_A5,19b-a1 -Mcu.Pin11=PH1-OSC_OUT -Mcu.Pin12=PC0 -Mcu.Pin10=PH0-OSC_IN -Dma.UART4_RX.0.Instance=DMA1_Stream2 -PE2.Locked=true -PE3.Signal=GPIO_Output -PC3.GPIO_Label=ADC4 -SH.FSMC_NBL0.ConfNb=1 -PE2.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -Dma.I2S2_EXT_RX.2.Mode=DMA_CIRCULAR -PF4.Signal=FSMC_A4 -Dma.SPI2_TX.1.MemDataAlignment=DMA_MDATAALIGN_HALFWORD -PC0.Locked=true -PC1.Signal=ADCx_IN11 -PB12.GPIOParameters=GPIO_Label -SH.FSMC_A9.ConfNb=1 -SH.FSMC_D10_DA10.ConfNb=1 -ADC3.EnableAnalogWatchDog=false -Dma.I2S2_EXT_RX.2.MemInc=DMA_MINC_ENABLE +I2S2.IPParameters=Instance,VirtualMode,FullDuplexMode,AudioFreq,RealAudioFreq,ErrorAudioFreq,DataFormat +I2S2.Instance=SPI$Index +I2S2.RealAudioFreq=47.991 KHz +I2S2.VirtualMode=I2S_MODE_SLAVE +KeepUserPlacement=false Mcu.Family=STM32F4 -ProjectManager.MainLocation=Src -FSMC.AddressSetupTime1=2 -USB_DEVICE.CLASS_NAME_FS=AUDIO -RCC.CortexFreq_Value=168000000 -SH.FSMC_A12.0=FSMC_A12,19b-a1 -ProjectManager.KeepUserCode=true -Mcu.UserName=STM32F405ZGTx -SH.FSMC_A6.0=FSMC_A6,19b-a1 -PG2.Signal=FSMC_A12 -Dma.ADC3.3.PeriphInc=DMA_PINC_DISABLE -SH.ADCx_IN2.0=ADC3_IN2,IN2 -PC5.Locked=true -PB6.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING -ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-true,4-MX_I2S2_Init-I2S2-false-HAL-true,5-MX_ADC3_Init-ADC3-false-HAL-true,6-MX_I2C2_Init-I2C2-false-HAL-true,7-MX_UART4_Init-UART4-false-HAL-true,8-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,9-MX_FSMC_Init-FSMC-false-HAL-true -PC0.GPIOParameters=GPIO_Label -SH.FSMC_D0_DA0.0=FSMC_D0,16b-d1 -Dma.SPI2_TX.1.PeriphInc=DMA_PINC_DISABLE -PC0.GPIO_Label=ADC1 -PA11.Mode=Device_Only -Dma.I2S2_EXT_RX.2.PeriphInc=DMA_PINC_DISABLE -PB13.GPIO_Label=I2S_SCLK -PC1.Locked=true -PB11.Signal=I2C2_SDA -NVIC.DMA1_Stream4_IRQn=true\:8\:0\:true\:false\:true\:true\:true\:true -PB15.Signal=I2S2_SD -PE5.GPIOParameters=GPIO_Label -ProjectManager.StackSize=0x400 -SH.GPXTI2.0=GPIO_EXTI2 -Dma.SPI2_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -PD13.Signal=FSMC_A18 -Mcu.IP4=I2C2 -Mcu.IP5=I2S2 -RCC.FCLKCortexFreq_Value=168000000 -Mcu.IP2=FREERTOS -Mcu.IP3=FSMC Mcu.IP0=ADC3 Mcu.IP1=DMA -PA12.Signal=USB_OTG_FS_DP -PE4.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -SH.FSMC_A11.0=FSMC_A11,19b-a1 -Mcu.UserConstants= -PC1.GPIOParameters=GPIO_Label -Dma.I2S2_EXT_RX.2.Priority=DMA_PRIORITY_HIGH -SH.FSMC_A7.0=FSMC_A7,19b-a1 -Mcu.ThirdPartyNb=0 -RCC.HCLKFreq_Value=168000000 -Mcu.IPNb=12 -RCC.I2SClocksFreq_Value=86000000 -ProjectManager.PreviousToolchain= -RCC.VcooutputI2S=86000000 -PF12.Signal=FSMC_A6 -FREERTOS.configUSE_MALLOC_FAILED_HOOK=1 -Mcu.Pin6=PF2 -Mcu.Pin7=PF3 -NVIC.DMA2_Stream0_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -Mcu.Pin8=PF4 -Mcu.Pin9=PF5 -SH.FSMC_A10.0=FSMC_A10,19b-a1 -FREERTOS.IPParameters=Tasks01,configUSE_PREEMPTION,configENABLE_BACKWARD_COMPATIBILITY,configUSE_MUTEXES,FootprintOK,MEMORY_ALLOCATION,configCHECK_FOR_STACK_OVERFLOW,configUSE_MALLOC_FAILED_HOOK,INCLUDE_vTaskDelayUntil,configTOTAL_HEAP_SIZE -RCC.AHBFreq_Value=168000000 -PH0-OSC_IN.Mode=HSE-External-Oscillator +Mcu.IP2=FREERTOS +Mcu.IP3=FSMC +Mcu.IP4=I2C2 +Mcu.IP5=I2S2 +Mcu.IP6=NVIC +Mcu.IP7=RCC +Mcu.IP8=SYS +Mcu.IP9=USB_OTG_FS +Mcu.IPNb=10 +Mcu.Name=STM32F405ZGTx +Mcu.Package=LQFP144 Mcu.Pin0=PE2 Mcu.Pin1=PE3 +Mcu.Pin10=PH0-OSC_IN +Mcu.Pin11=PH1-OSC_OUT +Mcu.Pin12=PC0 +Mcu.Pin13=PC1 +Mcu.Pin14=PC2 +Mcu.Pin15=PC3 +Mcu.Pin16=PA2 +Mcu.Pin17=PA3 +Mcu.Pin18=PF12 +Mcu.Pin19=PF13 Mcu.Pin2=PE4 -FREERTOS.configUSE_PREEMPTION=0 +Mcu.Pin20=PF14 +Mcu.Pin21=PF15 +Mcu.Pin22=PG0 +Mcu.Pin23=PG1 +Mcu.Pin24=PE7 +Mcu.Pin25=PE8 +Mcu.Pin26=PE9 +Mcu.Pin27=PE10 +Mcu.Pin28=PE11 +Mcu.Pin29=PE12 Mcu.Pin3=PE5 -SH.FSMC_D12_DA12.ConfNb=1 +Mcu.Pin30=PE13 +Mcu.Pin31=PE14 +Mcu.Pin32=PE15 +Mcu.Pin33=PB10 +Mcu.Pin34=PB11 +Mcu.Pin35=PB12 +Mcu.Pin36=PB13 +Mcu.Pin37=PB14 +Mcu.Pin38=PB15 +Mcu.Pin39=PD8 Mcu.Pin4=PF0 +Mcu.Pin40=PD9 +Mcu.Pin41=PD10 +Mcu.Pin42=PD11 +Mcu.Pin43=PD12 +Mcu.Pin44=PD13 +Mcu.Pin45=PD14 +Mcu.Pin46=PD15 +Mcu.Pin47=PG2 +Mcu.Pin48=PG3 +Mcu.Pin49=PG4 Mcu.Pin5=PF1 -RCC.HSE_VALUE=8000000 +Mcu.Pin50=PG5 +Mcu.Pin51=PC6 +Mcu.Pin52=PA9 +Mcu.Pin53=PA11 +Mcu.Pin54=PA12 +Mcu.Pin55=PA13 +Mcu.Pin56=PA14 +Mcu.Pin57=PD0 +Mcu.Pin58=PD1 +Mcu.Pin59=PD4 +Mcu.Pin6=PF2 +Mcu.Pin60=PD5 +Mcu.Pin61=PG10 +Mcu.Pin62=PB3 +Mcu.Pin63=PB6 +Mcu.Pin64=PB7 +Mcu.Pin65=PE0 +Mcu.Pin66=PE1 +Mcu.Pin67=VP_FREERTOS_VS_CMSIS_V1 +Mcu.Pin68=VP_SYS_VS_Systick +Mcu.Pin7=PF3 +Mcu.Pin8=PF4 +Mcu.Pin9=PF5 +Mcu.PinsNb=69 +Mcu.ThirdPartyNb=0 +Mcu.UserConstants= +Mcu.UserName=STM32F405ZGTx +MxCube.Version=6.3.0 +MxDb.Version=DB.6.0.30 +NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.DMA1_Stream3_IRQn=true\:8\:0\:true\:false\:true\:true\:true\:true +NVIC.DMA1_Stream4_IRQn=true\:8\:0\:true\:false\:true\:true\:true\:true +NVIC.DMA2_Stream0_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false -ADC3.InjNumberOfConversion=0 -Mcu.IP10=USB_DEVICE +NVIC.EXTI2_IRQn=true\:10\:0\:true\:false\:true\:true\:true\:true +NVIC.EXTI4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.EXTI9_5_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.ForceEnableDMAVector=true +NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.OTG_FS_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true +NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:true\:false +NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 +NVIC.SPI2_IRQn=true\:8\:0\:true\:false\:true\:true\:true\:true +NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +NVIC.SavedPendsvIrqHandlerGenerated=true +NVIC.SavedSvcallIrqHandlerGenerated=true +NVIC.SavedSystickIrqHandlerGenerated=true NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:true\:true -SH.FSMC_D6_DA6.ConfNb=1 -Dma.UART4_RX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE -Mcu.IP11=USB_OTG_FS -SH.FSMC_A16_CLE.ConfNb=1 -SH.FSMC_NBL0.0=FSMC_NBL0,2ByteEnable1 -FREERTOS.configENABLE_BACKWARD_COMPATIBILITY=0 -SH.FSMC_A17_ALE.ConfNb=1 -PE13.Signal=FSMC_D10_DA10 -SH.FSMC_D14_DA14.0=FSMC_D14,16b-d1 -Dma.ADC3.3.Mode=DMA_CIRCULAR -RCC.VCOInputFreq_Value=1000000 -SH.FSMC_A14.0=FSMC_A14,19b-a1 +NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:false\:false\:true\:false +PA11.Mode=Device_Only +PA11.Signal=USB_OTG_FS_DM +PA12.Mode=Device_Only +PA12.Signal=USB_OTG_FS_DP +PA13.Mode=Trace_Asynchronous_SW +PA13.Signal=SYS_JTMS-SWDIO PA14.Mode=Trace_Asynchronous_SW -ADC3.Rank-94\#ChannelRegularConversion=3 -SH.FSMC_D6_DA6.0=FSMC_D6,16b-d1 -File.Version=6 +PA14.Signal=SYS_JTCK-SWCLK +PA2.GPIOParameters=GPIO_Label +PA2.GPIO_Label=EXP1_RING +PA2.Locked=true +PA2.Signal=ADCx_IN2 +PA3.GPIOParameters=GPIO_Label +PA3.GPIO_Label=EXP1_TIP +PA3.Locked=true +PA3.Signal=ADCx_IN3 +PA9.Mode=Activate_VBUS +PA9.Signal=USB_OTG_FS_VBUS +PB10.GPIOParameters=GPIO_Label,GPIO_Pu +PB10.GPIO_Label=I2C_SCK +PB10.GPIO_Pu=GPIO_PULLUP +PB10.Locked=true +PB10.Mode=I2C +PB10.Signal=I2C2_SCL +PB11.GPIOParameters=GPIO_Label,GPIO_Pu +PB11.GPIO_Label=I2C_SDA +PB11.GPIO_Pu=GPIO_PULLUP +PB11.Mode=I2C +PB11.Signal=I2C2_SDA +PB12.GPIOParameters=GPIO_Label +PB12.GPIO_Label=I2S_LRCK +PB12.Mode=Full_Duplex_Slave +PB12.Signal=I2S2_WS +PB13.GPIOParameters=GPIO_Label +PB13.GPIO_Label=I2S_SCLK +PB13.Locked=true +PB13.Mode=Full_Duplex_Slave +PB13.Signal=I2S2_CK +PB14.GPIOParameters=GPIO_Label +PB14.GPIO_Label=I2S_SDI +PB14.Locked=true +PB14.Mode=Full_Duplex_Slave +PB14.Signal=I2S2_ext_SD +PB15.GPIOParameters=GPIO_Label +PB15.GPIO_Label=I2S_SDO +PB15.Locked=true +PB15.Mode=Full_Duplex_Slave +PB15.Signal=I2S2_SD +PB3.Mode=Trace_Asynchronous_SW +PB3.Signal=SYS_JTDO-SWO +PB6.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PB6.GPIO_Label=PUSH_GATE_IN +PB6.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PB6.GPIO_PuPd=GPIO_PULLUP +PB6.Locked=true +PB6.Signal=GPXTI6 +PB7.GPIOParameters=PinState,GPIO_Label +PB7.GPIO_Label=PUSH_GATE_OUT +PB7.Locked=true +PB7.PinState=GPIO_PIN_SET +PB7.Signal=GPIO_Output +PC0.GPIOParameters=GPIO_Label +PC0.GPIO_Label=ADC1 +PC0.Locked=true +PC0.Signal=ADCx_IN10 +PC1.GPIOParameters=GPIO_Label +PC1.GPIO_Label=ADC2 +PC1.Locked=true +PC1.Signal=ADCx_IN11 +PC2.GPIOParameters=GPIO_Label +PC2.GPIO_Label=ADC3 +PC2.Locked=true +PC2.Signal=ADCx_IN12 +PC3.GPIOParameters=GPIO_Label +PC3.GPIO_Label=ADC4 +PC3.Locked=true +PC3.Signal=ADCx_IN13 +PC6.GPIOParameters=GPIO_Label +PC6.GPIO_Label=I2S_MCLK +PC6.Locked=true +PC6.Signal=GPIO_Input +PD0.Signal=FSMC_D2_DA2 +PD1.Signal=FSMC_D3_DA3 +PD10.Signal=FSMC_D15_DA15 +PD11.Signal=FSMC_A16_CLE +PD12.Signal=FSMC_A17_ALE +PD13.Signal=FSMC_A18 +PD14.Signal=FSMC_D0_DA0 +PD15.Signal=FSMC_D1_DA1 +PD4.Signal=FSMC_NOE +PD5.Signal=FSMC_NWE +PD8.Signal=FSMC_D13_DA13 +PD9.Signal=FSMC_D14_DA14 +PE0.Locked=true +PE0.Signal=FSMC_NBL0 +PE1.Locked=true +PE1.Signal=FSMC_NBL1 +PE10.Signal=FSMC_D7_DA7 +PE11.Signal=FSMC_D8_DA8 +PE12.Signal=FSMC_D9_DA9 +PE13.Signal=FSMC_D10_DA10 +PE14.Signal=FSMC_D11_DA11 +PE15.Signal=FSMC_D12_DA12 +PE2.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PE2.GPIO_Label=SW1 +PE2.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PE2.GPIO_PuPd=GPIO_PULLUP +PE2.Locked=true +PE2.Signal=GPXTI2 PE3.GPIOParameters=GPIO_Label -ADC3.DataAlign=ADC_DATAALIGN_RIGHT -SH.FSMC_D9_DA9.ConfNb=1 -SH.ADCx_IN13.ConfNb=1 -SH.FSMC_A8.0=FSMC_A8,19b-a1 -Dma.ADC3.3.MemInc=DMA_MINC_ENABLE -Dma.ADC3.3.FIFOMode=DMA_FIFOMODE_DISABLE +PE3.GPIO_Label=LED_RED PE3.Locked=true -PB7.Signal=GPIO_Output -NVIC.SPI2_IRQn=true\:8\:0\:true\:false\:true\:true\:true\:true -I2S2.DataFormat=I2S_DATAFORMAT_24B +PE3.Signal=GPIO_Output +PE4.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI +PE4.GPIO_Label=FOOTSWITCH +PE4.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PE4.GPIO_PuPd=GPIO_PULLUP +PE4.Locked=true PE4.Signal=GPXTI4 -Dma.RequestsNb=4 -PB6.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -FREERTOS.configTOTAL_HEAP_SIZE=4096 -ProjectManager.ProjectName=OwlPedal -SH.FSMC_D4_DA4.0=FSMC_D4,16b-d1 -PH1-OSC_OUT.Mode=HSE-External-Oscillator -PB7.GPIO_Label=PUSH_GATE_OUT -ADC3.SamplingTime-95\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -USB_DEVICE.PRODUCT_STRING_AUDIO_FS=OWL-MIDI -SH.FSMC_A2.ConfNb=1 -PB12.Mode=Full_Duplex_Slave -Dma.SPI2_TX.1.Mode=DMA_CIRCULAR -SH.FSMC_NBL1.0=FSMC_NBL1,2ByteEnable1 -Dma.I2S2_EXT_RX.2.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD -NVIC.OTG_FS_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -ProjectManager.ToolChainLocation= -PA2.GPIO_Label=ADC5 -RCC.LSI_VALUE=32000 -SH.FSMC_D13_DA13.0=FSMC_D13,16b-d1 -USB_OTG_FS.VirtualMode=Device_Only -SH.FSMC_A13.0=FSMC_A13,19b-a1 -SH.FSMC_A13.ConfNb=1 -ADC3.ClockPrescaler=ADC_CLOCK_SYNC_PCLK_DIV8 -PF5.Signal=FSMC_A5 -SH.FSMC_A9.0=FSMC_A9,19b-a1 -Dma.Request2=I2S2_EXT_RX -Dma.Request1=SPI2_TX -Dma.Request3=ADC3 -PC4.Locked=true -SH.FSMC_D2_DA2.0=FSMC_D2,16b-d1 -SH.FSMC_NWE.ConfNb=1 -PF0.Signal=FSMC_A0 -PC5.Signal=GPIO_Output +PE5.GPIOParameters=GPIO_Label +PE5.GPIO_Label=LED_GREEN +PE5.Locked=true +PE5.Signal=GPIO_Output PE7.Signal=FSMC_D4_DA4 -Dma.Request0=UART4_RX -PE2.GPIO_Label=PUSHBUTTON -PC2.GPIO_Label=ADC3 -PB15.Locked=true -PA3.Signal=GPIO_Output -PA2.Locked=true -ADC3.DiscontinuousConvMode=DISABLE -SH.ADCx_IN13.0=ADC3_IN13,IN13 -SH.FSMC_D12_DA12.0=FSMC_D12,16b-d1 -I2S2.Instance=SPI$Index -UART4.IPParameters=VirtualMode -FSMC.WriteOperation1=FSMC_WRITE_OPERATION_ENABLE -ProjectManager.NoMain=false -USB_DEVICE.VirtualModeFS=Audio_FS -PG3.Signal=FSMC_A13 +PE8.Signal=FSMC_D5_DA5 +PE9.Signal=FSMC_D6_DA6 +PF0.Signal=FSMC_A0 +PF1.Signal=FSMC_A1 +PF12.Signal=FSMC_A6 +PF13.Signal=FSMC_A7 +PF14.Signal=FSMC_A8 +PF15.Signal=FSMC_A9 +PF2.Signal=FSMC_A2 +PF3.Signal=FSMC_A3 +PF4.Signal=FSMC_A4 +PF5.Signal=FSMC_A5 +PG0.Signal=FSMC_A10 PG1.Signal=FSMC_A11 -FSMC.ExtendedMode1=FSMC_EXTENDED_MODE_DISABLE -NVIC.SavedSvcallIrqHandlerGenerated=true -PC4.Signal=GPIO_Output PG10.Mode=NorPsramChipSelect3_1 -PE4.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING +PG10.Signal=FSMC_NE3 +PG2.Signal=FSMC_A12 +PG3.Signal=FSMC_A13 +PG4.Signal=FSMC_A14 +PG5.Signal=FSMC_A15 +PH0-OSC_IN.Mode=HSE-External-Oscillator +PH0-OSC_IN.Signal=RCC_OSC_IN +PH1-OSC_OUT.Mode=HSE-External-Oscillator +PH1-OSC_OUT.Signal=RCC_OSC_OUT +PinOutPanel.RotationAngle=0 +ProjectManager.AskForMigrate=true +ProjectManager.BackupPrevious=false +ProjectManager.CompilerOptimize=6 +ProjectManager.ComputerToolchain=false +ProjectManager.CoupleFile=false +ProjectManager.CustomerFirmwarePackage= ProjectManager.DefaultFWLocation=true -Dma.I2S2_EXT_RX.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -PD5.Signal=FSMC_NWE -PD9.Signal=FSMC_D14_DA14 -SH.FSMC_D11_DA11.ConfNb=1 ProjectManager.DeletePrevious=true -PB10.Locked=true -USB_DEVICE.IPParameters=VirtualModeFS,CLASS_NAME_FS,VID-AUDIO_FS,MANUFACTURER_STRING-AUDIO_FS,PID_AUDIO_FS,SERIALNUMBER_STRING_AUDIO_FS,PRODUCT_STRING_AUDIO_FS,VirtualMode-AUDIO_FS -Dma.I2S2_EXT_RX.2.Direction=DMA_PERIPH_TO_MEMORY -RCC.FamilyName=M -PA0-WKUP.Locked=true -SH.GPXTI6.0=GPIO_EXTI6 -PA13.Signal=SYS_JTMS-SWDIO -SH.FSMC_D13_DA13.ConfNb=1 -VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 -PA9.Mode=Activate_VBUS -SH.ADCx_IN12.0=ADC3_IN12,IN12 -ADC3.Rank-95\#ChannelRegularConversion=4 -Dma.UART4_RX.0.Direction=DMA_PERIPH_TO_MEMORY -ProjectManager.TargetToolchain=Makefile -PB10.GPIO_Label=I2C_SCK -SH.FSMC_A18.ConfNb=1 -ADC3.Channel-94\#ChannelRegularConversion=ADC_CHANNEL_12 -PB7.GPIOParameters=PinState,GPIO_Label -PC5.GPIOParameters=GPIO_Label -PE4.Locked=true -PF2.Signal=FSMC_A2 -PE2.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI -PC2.Locked=true +ProjectManager.DeviceId=STM32F405ZGTx +ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.26.2 +ProjectManager.FreePins=true +ProjectManager.HalAssertFull=true +ProjectManager.HeapSize=0x200 +ProjectManager.KeepUserCode=true +ProjectManager.LastFirmware=true +ProjectManager.LibraryCopy=0 +ProjectManager.MainLocation=Src +ProjectManager.NoMain=false +ProjectManager.PreviousToolchain= +ProjectManager.ProjectBuild=false +ProjectManager.ProjectFileName=OwlPedal.ioc +ProjectManager.ProjectName=OwlPedal ProjectManager.RegisterCallBack= -PE0.Locked=true -USB_DEVICE.SERIALNUMBER_STRING_AUDIO_FS=00000000010A -PE11.Signal=FSMC_D8_DA8 +ProjectManager.StackSize=0x400 +ProjectManager.TargetToolchain=Makefile +ProjectManager.ToolChainLocation= +ProjectManager.UnderRoot=false +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-true,4-MX_I2S2_Init-I2S2-false-HAL-true,5-MX_ADC3_Init-ADC3-false-HAL-true,6-MX_I2C2_Init-I2C2-false-HAL-true,7-MX_FSMC_Init-FSMC-false-HAL-true,8-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-false-HAL-true +RCC.48MHZClocksFreq_Value=48000000 +RCC.AHBFreq_Value=168000000 +RCC.APB1CLKDivider=RCC_HCLK_DIV4 +RCC.APB1Freq_Value=42000000 +RCC.APB1TimFreq_Value=84000000 +RCC.APB2CLKDivider=RCC_HCLK_DIV2 +RCC.APB2Freq_Value=84000000 +RCC.APB2TimFreq_Value=168000000 +RCC.CortexFreq_Value=168000000 +RCC.EthernetFreq_Value=168000000 +RCC.FCLKCortexFreq_Value=168000000 +RCC.FamilyName=M +RCC.HCLKFreq_Value=168000000 +RCC.HSE_VALUE=8000000 +RCC.HSI_VALUE=16000000 +RCC.I2SClocksFreq_Value=86000000 +RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2SClocksFreq_Value,LSE_VALUE,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLI2SN,PLLI2SR,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VcooutputI2S RCC.LSE_VALUE=32768 -PA1.Signal=UART4_RX +RCC.LSI_VALUE=32000 +RCC.MCO2PinFreq_Value=168000000 +RCC.PLLCLKFreq_Value=168000000 +RCC.PLLI2SN=258 +RCC.PLLI2SR=3 +RCC.PLLM=8 +RCC.PLLN=336 +RCC.PLLQ=7 +RCC.PLLQCLKFreq_Value=48000000 +RCC.RTCFreq_Value=32000 +RCC.RTCHSEDivFreq_Value=4000000 +RCC.SYSCLKFreq_VALUE=168000000 +RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK RCC.VCOI2SOutputFreq_Value=258000000 -SH.FSMC_A7.ConfNb=1 -board=OwlPedal -SH.FSMC_D0_DA0.ConfNb=1 -Dma.SPI2_TX.1.Direction=DMA_MEMORY_TO_PERIPH +RCC.VCOInputFreq_Value=1000000 RCC.VCOOutputFreq_Value=336000000 -PB15.Mode=Full_Duplex_Slave -Dma.ADC3.3.MemDataAlignment=DMA_MDATAALIGN_HALFWORD -Dma.UART4_RX.0.Priority=DMA_PRIORITY_LOW -NVIC.SavedSystickIrqHandlerGenerated=true -RCC.APB2Freq_Value=84000000 -Dma.ADC3.3.Priority=DMA_PRIORITY_LOW -SH.ADCx_IN11.0=ADC3_IN11,IN11 -MxCube.Version=5.6.1 +RCC.VcooutputI2S=86000000 +SH.ADCx_IN10.0=ADC3_IN10,IN10 SH.ADCx_IN10.ConfNb=1 +SH.ADCx_IN11.0=ADC3_IN11,IN11 +SH.ADCx_IN11.ConfNb=1 +SH.ADCx_IN12.0=ADC3_IN12,IN12 +SH.ADCx_IN12.ConfNb=1 +SH.ADCx_IN13.0=ADC3_IN13,IN13 +SH.ADCx_IN13.ConfNb=1 +SH.ADCx_IN2.0=ADC3_IN2,IN2 SH.ADCx_IN2.ConfNb=1 -PC1.GPIO_Label=ADC2 -VP_SYS_VS_Systick.Mode=SysTick -PH1-OSC_OUT.Signal=RCC_OSC_OUT -Dma.UART4_RX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -PF15.Signal=FSMC_A9 -PE5.Locked=true -PF1.Signal=FSMC_A1 -VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_FS -VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Mode=AUDIO_FS -PB15.GPIOParameters=GPIO_Label -RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2SClocksFreq_Value,LSE_VALUE,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLI2SN,PLLI2SR,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VcooutputI2S -ProjectManager.AskForMigrate=true -Mcu.Name=STM32F405ZGTx -PE0.Signal=FSMC_NBL0 -PE12.Signal=FSMC_D9_DA9 -ADC3.SamplingTime-94\#ChannelRegularConversion=ADC_SAMPLETIME_144CYCLES -NVIC.SavedPendsvIrqHandlerGenerated=true -PA2.Signal=ADCx_IN2 -Mcu.IP8=SYS -Mcu.IP9=UART4 -PD14.Signal=FSMC_D0_DA0 -Mcu.IP6=NVIC -Mcu.IP7=RCC -ProjectManager.CoupleFile=false -RCC.48MHZClocksFreq_Value=48000000 -PB3.Signal=SYS_JTDO-SWO -RCC.SYSCLKFreq_VALUE=168000000 +SH.ADCx_IN3.0=ADC3_IN3,IN3 +SH.ADCx_IN3.ConfNb=1 +SH.FSMC_A0.0=FSMC_A0,19b-a1 +SH.FSMC_A0.ConfNb=1 +SH.FSMC_A1.0=FSMC_A1,19b-a1 +SH.FSMC_A1.ConfNb=1 +SH.FSMC_A10.0=FSMC_A10,19b-a1 +SH.FSMC_A10.ConfNb=1 +SH.FSMC_A11.0=FSMC_A11,19b-a1 +SH.FSMC_A11.ConfNb=1 +SH.FSMC_A12.0=FSMC_A12,19b-a1 +SH.FSMC_A12.ConfNb=1 +SH.FSMC_A13.0=FSMC_A13,19b-a1 +SH.FSMC_A13.ConfNb=1 +SH.FSMC_A14.0=FSMC_A14,19b-a1 +SH.FSMC_A14.ConfNb=1 +SH.FSMC_A15.0=FSMC_A15,19b-a1 +SH.FSMC_A15.ConfNb=1 +SH.FSMC_A16_CLE.0=FSMC_A16,19b-a1 +SH.FSMC_A16_CLE.ConfNb=1 +SH.FSMC_A17_ALE.0=FSMC_A17,19b-a1 +SH.FSMC_A17_ALE.ConfNb=1 +SH.FSMC_A18.0=FSMC_A18,19b-a1 +SH.FSMC_A18.ConfNb=1 +SH.FSMC_A2.0=FSMC_A2,19b-a1 +SH.FSMC_A2.ConfNb=1 +SH.FSMC_A3.0=FSMC_A3,19b-a1 +SH.FSMC_A3.ConfNb=1 +SH.FSMC_A4.0=FSMC_A4,19b-a1 +SH.FSMC_A4.ConfNb=1 +SH.FSMC_A5.0=FSMC_A5,19b-a1 +SH.FSMC_A5.ConfNb=1 +SH.FSMC_A6.0=FSMC_A6,19b-a1 SH.FSMC_A6.ConfNb=1 -SH.GPXTI4.0=GPIO_EXTI4 -PA12.Mode=Device_Only -I2S2.ErrorAudioFreq=-0.01 % -KeepUserPlacement=false -PC5.GPIO_Label=FLASH_nCS -NVIC.EXTI9_5_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -PA14.Signal=SYS_JTCK-SWCLK -SH.ADCx_IN10.0=ADC3_IN10,IN10 -SH.GPXTI4.ConfNb=1 +SH.FSMC_A7.0=FSMC_A7,19b-a1 +SH.FSMC_A7.ConfNb=1 +SH.FSMC_A8.0=FSMC_A8,19b-a1 +SH.FSMC_A8.ConfNb=1 +SH.FSMC_A9.0=FSMC_A9,19b-a1 +SH.FSMC_A9.ConfNb=1 +SH.FSMC_D0_DA0.0=FSMC_D0,16b-d1 +SH.FSMC_D0_DA0.ConfNb=1 +SH.FSMC_D10_DA10.0=FSMC_D10,16b-d1 +SH.FSMC_D10_DA10.ConfNb=1 SH.FSMC_D11_DA11.0=FSMC_D11,16b-d1 -PC6.GPIOParameters=GPIO_Label -SH.FSMC_NOE.0=FSMC_NOE,Sram1 -SH.FSMC_A12.ConfNb=1 +SH.FSMC_D11_DA11.ConfNb=1 +SH.FSMC_D12_DA12.0=FSMC_D12,16b-d1 +SH.FSMC_D12_DA12.ConfNb=1 +SH.FSMC_D13_DA13.0=FSMC_D13,16b-d1 +SH.FSMC_D13_DA13.ConfNb=1 +SH.FSMC_D14_DA14.0=FSMC_D14,16b-d1 +SH.FSMC_D14_DA14.ConfNb=1 +SH.FSMC_D15_DA15.0=FSMC_D15,16b-d1 +SH.FSMC_D15_DA15.ConfNb=1 +SH.FSMC_D1_DA1.0=FSMC_D1,16b-d1 +SH.FSMC_D1_DA1.ConfNb=1 +SH.FSMC_D2_DA2.0=FSMC_D2,16b-d1 SH.FSMC_D2_DA2.ConfNb=1 -RCC.HSI_VALUE=16000000 -RCC.PLLQ=7 -RCC.PLLM=8 -RCC.PLLN=336 -PB7.Locked=true -PE3.GPIO_Label=LED_RED -NVIC.DMA1_Stream3_IRQn=true\:8\:0\:true\:false\:true\:true\:true\:true -RCC.APB1Freq_Value=42000000 -ADC3.NbrOfConversionFlag=1 -RCC.PLLI2SR=3 -I2S2.RealAudioFreq=47.991 KHz -RCC.PLLI2SN=258 -ProjectManager.DeviceId=STM32F405ZGTx -PB12.Signal=I2S2_WS -ProjectManager.LibraryCopy=0 -PA3.GPIO_Label=EXPRESSION_PEDAL_TIP -SH.FSMC_A1.ConfNb=1 +SH.FSMC_D3_DA3.0=FSMC_D3,16b-d1 +SH.FSMC_D3_DA3.ConfNb=1 +SH.FSMC_D4_DA4.0=FSMC_D4,16b-d1 +SH.FSMC_D4_DA4.ConfNb=1 +SH.FSMC_D5_DA5.0=FSMC_D5,16b-d1 +SH.FSMC_D5_DA5.ConfNb=1 +SH.FSMC_D6_DA6.0=FSMC_D6,16b-d1 +SH.FSMC_D6_DA6.ConfNb=1 +SH.FSMC_D7_DA7.0=FSMC_D7,16b-d1 +SH.FSMC_D7_DA7.ConfNb=1 +SH.FSMC_D8_DA8.0=FSMC_D8,16b-d1 +SH.FSMC_D8_DA8.ConfNb=1 +SH.FSMC_D9_DA9.0=FSMC_D9,16b-d1 +SH.FSMC_D9_DA9.ConfNb=1 +SH.FSMC_NBL0.0=FSMC_NBL0,2ByteEnable1 +SH.FSMC_NBL0.ConfNb=1 +SH.FSMC_NBL1.0=FSMC_NBL1,2ByteEnable1 +SH.FSMC_NBL1.ConfNb=1 +SH.FSMC_NOE.0=FSMC_NOE,Sram1 +SH.FSMC_NOE.ConfNb=1 +SH.FSMC_NWE.0=FSMC_NWE,Sram1 +SH.FSMC_NWE.ConfNb=1 +SH.GPXTI2.0=GPIO_EXTI2 +SH.GPXTI2.ConfNb=1 +SH.GPXTI4.0=GPIO_EXTI4 +SH.GPXTI4.ConfNb=1 +SH.GPXTI6.0=GPIO_EXTI6 +SH.GPXTI6.ConfNb=1 +USB_OTG_FS.IPParameters=VirtualMode +USB_OTG_FS.VirtualMode=Device_Only +VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1 +VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1 +VP_SYS_VS_Systick.Mode=SysTick +VP_SYS_VS_Systick.Signal=SYS_VS_Systick +board=OwlPedal diff --git a/OwlPedal/Src/OwlPedal.cpp b/OwlPedal/Src/OwlPedal.cpp index f8242c98..bcf7712b 100644 --- a/OwlPedal/Src/OwlPedal.cpp +++ b/OwlPedal/Src/OwlPedal.cpp @@ -1,83 +1,247 @@ +#include #include "Owl.h" -#include "device.h" #include "errorhandlers.h" +#include "Codec.h" #include "MidiController.h" -#include "OpenWareMidiControl.h" +#include "ProgramManager.h" #include "ApplicationSettings.h" +#include "OpenWareMidiControl.h" #include "PatchRegistry.h" -#include "ProgramManager.h" +#include "Pin.h" +#include "usb_device.h" + +#define PATCH_RESET_COUNTER (768/MAIN_LOOP_SLEEP_MS) +#define PATCH_CONFIG_COUNTER (3072/MAIN_LOOP_SLEEP_MS) +#define PATCH_INDICATOR_COUNTER (256/MAIN_LOOP_SLEEP_MS) + +#define BYPASS_MODE (ERROR_MODE+1) +#define ENTER_CONFIG_MODE (ERROR_MODE+2) -#define PROGRAM_CHANGE_PUSHBUTTON_TICKS 2000 -// Number of buffers before patch switching kicks in, with 2 ms loop delay this should take 5.23 seconds +static int16_t knobvalues[2]; +static uint8_t patchselect; +#define PATCH_CONFIG_KNOB_THRESHOLD (4096/8) +#define PATCH_CONFIG_PROGRAM_CONTROL 0 +#define PATCH_CONFIG_VOLUME_CONTROL 3 -#ifndef abs -#define abs(x) ((x)>0?(x):-(x)) +#if 0 +#define SW3_Pin EXP2_T_Pin +#define SW3_GPIO_Port EXP2_T_GPIO_Port +#define SW4_Pin EXP2_R_Pin +#define SW4_GPIO_Port EXP2_R_GPIO_Port + +Pin bypass_pin(GPIOA, GPIO_PIN_0); +Pin bufpass_pin(GPIOF, GPIO_PIN_9); // high is bypass #endif -#ifndef max -#define max(a,b) ((a)>(b)?(a):(b)) + +Pin exp1_tip_pin(EXP1_TIP_GPIO_Port, EXP1_TIP_Pin); +Pin exp1_ring_pin(EXP1_RING_GPIO_Port, EXP1_RING_Pin); + +#ifndef OWL_PEDAL_PWM_LEDS +Pin led_green_pin(LED_GREEN_GPIO_Port, LED_GREEN_Pin); +Pin led_red_pin(LED_RED_GPIO_Port, LED_RED_Pin); #endif -extern uint32_t ledstatus; +// Pin footswitch_pin(GPIOA, GPIO_PIN_0); + +static uint32_t counter = 0; +static uint8_t expression_mode = 0; + +#if 0 +bool getBufferedBypass(){ + return !bufpass_pin.get(); +} + +void setBufferedBypass(bool value){ + // setLed(0, value ? RED_COLOUR : GREEN_COLOUR); + bufpass_pin.set(!value); + // todo; set BYPASS_MODE +} +#endif + +bool isBypassed(){ + return HAL_GPIO_ReadPin(FOOTSWITCH_GPIO_Port, FOOTSWITCH_Pin) == GPIO_PIN_RESET; + // todo: || getBufferedBypass() +} + +bool isPushbuttonPressed(){ + return HAL_GPIO_ReadPin(SW1_GPIO_Port, SW1_Pin) == GPIO_PIN_RESET +#ifdef SW1_ALT_GPIO_Port + || HAL_GPIO_ReadPin(SW1_ALT_GPIO_Port, SW1_ALT_Pin) == GPIO_PIN_RESET +#endif + ; +} + +void configureExpression(uint8_t mode){ + if(mode != expression_mode){ + switch(mode){ + case EXPRESSION_MODE_EXP_TRS: + // Ring is available on ADC_F + exp1_ring_pin.outputMode(); + exp1_ring_pin.high(); + exp1_ring_pin.setPull(PIN_PULL_NONE); + exp1_tip_pin.analogMode(); + exp1_tip_pin.setPull(PIN_PULL_NONE); + break; + case EXPRESSION_MODE_EXP_RTS: + exp1_tip_pin.outputMode(); + exp1_tip_pin.high(); + exp1_tip_pin.setPull(PIN_PULL_NONE); + exp1_ring_pin.analogMode(); + exp1_ring_pin.setPull(PIN_PULL_NONE); + break; + case EXPRESSION_MODE_FS_TS: + case EXPRESSION_MODE_FS_TRS: + exp1_tip_pin.inputMode(); + exp1_tip_pin.setPull(PIN_PULL_UP); + exp1_ring_pin.inputMode(); + exp1_ring_pin.setPull(PIN_PULL_UP); + break; + } + expression_mode = mode; + setButtonValue(PUSHBUTTON, isPushbuttonPressed()); + setButtonValue(BUTTON_1, isPushbuttonPressed()); + setButtonValue(BUTTON_2, false); + } +} void initLed(){ +#ifdef OWL_PEDAL_PWM_LEDS + extern TIM_HandleTypeDef htim4; + HAL_TIM_Base_Start(&htim4); + HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_3); + HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_4); +#else + led_green_pin.outputMode(); + led_red_pin.outputMode(); +#endif } -static bool pushButtonPressed = 0; -static uint16_t pushButtonPressDuration = 0; -static uint16_t pushButtonAnimation = 0; -static uint8_t owlSelectedProgramId = 0; -static uint16_t bank = 0; -static uint16_t prog = 0; +uint32_t getLed(uint8_t led){ +#ifdef OWL_PEDAL_PWM_LEDS + uint32_t r = 1023 - TIM4->CCR3; + uint32_t g = TIM4->CCR4; + return (r<<20) | (g<<10); +#else + if(!led_green_pin.get() && led_red_pin.get()) + return RED_COLOUR; + else if(led_green_pin.get() && !led_red_pin.get()) + return GREEN_COLOUR; + else + return NO_COLOUR; +#endif +} +void toggleLed(uint8_t led){ +#ifdef OWL_PEDAL_PWM_LEDS + setLed(led, getLed(led) == GREEN_COLOUR ? RED_COLOUR : GREEN_COLOUR); + // uint32_t r = TIM4->CCR3; + // uint32_t g = TIM4->CCR4; + // TIM4->CCR3 = 1023 - r; + // TIM4->CCR4 = 1023 - g; +#else + led_red_pin.set(led_green_pin.get()); + led_green_pin.toggle(); +#endif +} + void setLed(uint8_t led, uint32_t rgb){ - // rgb should be a 3x 10 bit value +#ifdef OWL_PEDAL_PWM_LEDS + uint32_t r = 1023 - ((rgb>>20) & 0x3ff); + uint32_t g = ((rgb>>10) & 0x3ff); // green TIM4 has reverse polarity + TIM4->CCR3 = r; + TIM4->CCR4 = g; +#else switch(rgb){ case RED_COLOUR: - HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_SET); - HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_RESET); + led_green_pin.low(); + led_red_pin.high(); break; case GREEN_COLOUR: - HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_RESET); - HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_SET); + led_green_pin.high(); + led_red_pin.low(); break; case NO_COLOUR: - HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_RESET); - HAL_GPIO_WritePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin, GPIO_PIN_RESET); + led_green_pin.low(); + led_red_pin.low(); break; + default: + break; } +#endif } void onChangePin(uint16_t pin){ - switch(pin){ - case PUSHBUTTON_Pin: { - pushButtonPressed = !(PUSHBUTTON_GPIO_Port->IDR & PUSHBUTTON_Pin); - if (pushButtonPressed) { - // Rising edge - pushButtonAnimation = 0x96; - } - else { - // Falling edge - if (pushButtonPressDuration > PROGRAM_CHANGE_PUSHBUTTON_TICKS && owlSelectedProgramId > 0) { - // This runs unless button was depressed too early or the same - // patch as before was selected. - program.loadProgram(owlSelectedProgramId); - program.resetProgram(true); - pushButtonPressDuration = 0; + if(pin == FOOTSWITCH_Pin){ + setButtonValue(0, isBypassed()); + } + if(owl.getOperationMode() == RUN_MODE){ + switch(pin){ + // case FOOTSWITCH_Pin: { // bypass / stomp switch + // bool state = isBypassed(); + // setButtonValue(0, state); + // setLed(0, state ? NO_COLOUR : GREEN_COLOUR); + // break; + // } +#ifdef SW1_ALT_Pin + case SW1_ALT_Pin: +#endif + case SW1_Pin: + { // pushbutton + bool state = isPushbuttonPressed(); + setButtonValue(PUSHBUTTON, state); + setButtonValue(BUTTON_1, state); + setLed(0, state ? RED_COLOUR : GREEN_COLOUR); + midi_tx.sendCc(PATCH_BUTTON, state ? 127 : 0); + break; } + // case SW2_Pin: { // mode button + // bool state = HAL_GPIO_ReadPin(SW2_GPIO_Port, SW2_Pin) == GPIO_PIN_RESET; + // setButtonValue(BUTTON_2, state); + // break; + // } + // case SW3_Pin: { // EXP2 Tip + // bool state = HAL_GPIO_ReadPin(SW3_GPIO_Port, SW3_Pin) == GPIO_PIN_RESET; + // setButtonValue(BUTTON_3, state); + // break; + // } + // case SW4_Pin: { // EXP2 Ring + // bool state = HAL_GPIO_ReadPin(SW4_GPIO_Port, SW4_Pin) == GPIO_PIN_RESET; + // setButtonValue(BUTTON_4, state); + // break; + // } } - setButtonValue(BUTTON_A, pushButtonPressed); - setButtonValue(PUSHBUTTON, pushButtonPressed); - midi_tx.sendCc(PUSHBUTTON, pushButtonPressed ? 127 : 0); - setLed(0, pushButtonPressed ? RED_COLOUR : GREEN_COLOUR); - break; - } -#ifdef OWL_PEDAL - case BYPASS_Pin: { - bool isSet = BYPASS_GPIO_Port->IDR & BYPASS_Pin; - setLed(0, isSet ? NO_COLOUR : GREEN_COLOUR); - break; } +} + +void setGateValue(uint8_t ch, int16_t value){ + if(owl.getOperationMode() == RUN_MODE){ + value = (value >> 2) & 0x3ff; // use top 10 bits of 12 + switch(ch){ + case BUTTON_1: + case PUSHBUTTON: +#ifdef OWL_PEDAL_PWM_LEDS + setLed(0, (value << 20) | ((1023 - value) << 10)); +#else + setLed(0, value < 512 ? GREEN_COLOUR : RED_COLOUR); +#endif +#ifdef OWL_MODULAR + HAL_GPIO_WritePin(PUSH_GATE_OUT_GPIO_Port, PUSH_GATE_OUT_Pin, value ? GPIO_PIN_RESET : GPIO_PIN_SET); +#endif + break; + case GREEN_BUTTON: +#ifdef OWL_PEDAL_PWM_LEDS + setLed(0, value << 10); +#else + setLed(0, value < 512 ? NO_COLOUR : GREEN_COLOUR); #endif + break; + case RED_BUTTON: +#ifdef OWL_PEDAL_PWM_LEDS + setLed(0, value << 20); +#else + setLed(0, value < 512 ? NO_COLOUR : RED_COLOUR); +#endif + break; #ifdef OWL_MODULAR case PUSH_GATE_IN_Pin: { bool isSet = !(PUSH_GATE_IN_GPIO_Port->IDR & PUSH_GATE_IN_Pin); @@ -86,151 +250,208 @@ void onChangePin(uint16_t pin){ break; } #endif + } } + // if(ch == 0) + // setBufferedBypass(value); } -inline uint16_t getProgramSelection(){ - // This code is copied from original firmware. The only difference is that - // it won't be running in a separate OS task. So we won't be waiting for - // usable patch being selected. Instead of that, we return -1 for invalid - // selection - it should be ignored by the caller. - #ifdef OWL_MODULAR - float a = (4095 - getAnalogValue(PARAMETER_A)) * 5 / 4096.0;// - 0.5 / 5; - float b = (4095 - getAnalogValue(PARAMETER_B)) * 8 / 4096.0;// - 0.5 / 8; - #else - float a = getAnalogValue(PARAMETER_A) * 5 / 4096.0;// - 0.5 / 5; - float b = getAnalogValue(PARAMETER_B) * 8 / 4096.0;// - 0.5 / 8; - #endif - // deadband each segment: [0.9-1.1] - if(a > 0.f && abs(a - (uint16_t)(a + 0.1f)) > 0.1f) - bank = (uint16_t)a; - else if (a <= 0.1f) - bank = 0; // Ignore bottom dead zone - else if (a >= 5.0f - 0.1f) - bank = 4; // Ignore top dead zone - - // deadband each segment: [0.85-1.15] - // larger deadband because we have the same amount of noise spread over more zones - if(b > 0.f && abs(b - (uint16_t)(b + 0.15f)) > 0.15f) - prog = (uint16_t)b + 1; - else if (b <= 0.15f) - prog = 1; // Ignore bottom dead zone - else if (b >= 8.0f - 0.15f) - prog = 8; // Ignore top dead zone - - uint16_t pc = max(bank * 8 + prog, 1); - // We must check that patch exists to avoid loading from a gap in the patches list - if (registry.hasPatch(pc)) - return pc; - else - return 0; +void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* adc_values, size_t adc_len){ + if(owl.getOperationMode() == RUN_MODE){ + parameter_values[0] = (parameter_values[0]*3 + adc_values[ADC_A])>>2; + parameter_values[1] = (parameter_values[1]*3 + adc_values[ADC_B])>>2; + parameter_values[2] = (parameter_values[2]*3 + adc_values[ADC_C])>>2; + parameter_values[3] = (parameter_values[3]*3 + adc_values[ADC_D])>>2; + + static uint8_t fs_state = 0; + uint8_t buttons = 0; + switch(expression_mode){ + case EXPRESSION_MODE_EXP_TRS: + parameter_values[4] = (parameter_values[4]*3 + 4095-adc_values[ADC_E])>>2; + break; + case EXPRESSION_MODE_EXP_RTS: + parameter_values[4] = (parameter_values[4]*3 + 4095-adc_values[ADC_F])>>2; + break; + case EXPRESSION_MODE_FS_TRS: + buttons = (!exp1_ring_pin.get()) << BUTTON_2; + buttons |= (!exp1_tip_pin.get()) << BUTTON_1; + if(buttons != fs_state){ + if((buttons & (1 << BUTTON_2)) != (fs_state & (1 << BUTTON_2))){ + setButtonValue(BUTTON_2, buttons & (1 << BUTTON_2)); + } + if((buttons & (1 << BUTTON_1)) != (fs_state & (1 << BUTTON_1))){ + setButtonValue(BUTTON_1, buttons & (1 << BUTTON_1)); + setButtonValue(PUSHBUTTON, buttons & (1 << BUTTON_1)); + } + fs_state = buttons; + } + break; + case EXPRESSION_MODE_FS_TS: + buttons = (!exp1_tip_pin.get()) << BUTTON_1; + if(buttons != fs_state){ + setButtonValue(BUTTON_1, buttons & (1 << BUTTON_1)); + setButtonValue(PUSHBUTTON, buttons & (1 << BUTTON_1)); + fs_state = buttons; + } + break; + } + } } -void setGateValue(uint8_t ch, int16_t value){ - switch (ch) { - case BUTTON_A: - setLed(0, value ? RED_COLOUR : GREEN_COLOUR); - break; - case PUSHBUTTON: - setLed(0, value ? RED_COLOUR : GREEN_COLOUR); - // deliberate fall-through - this synchronizes LED to pushbutton value - case BUTTON_B: -#ifdef OWL_MODULAR - HAL_GPIO_WritePin(PUSH_GATE_OUT_GPIO_Port, PUSH_GATE_OUT_Pin, value ? GPIO_PIN_RESET : GPIO_PIN_SET); +void onSetup(){ + initLed(); +#if 0 + bypass_pin.outputMode(); + bypass_pin.low(); + bufpass_pin.outputMode(); + bufpass_pin.low(); + setBufferedBypass(false); #endif - break; - case GREEN_BUTTON: - setLed(0, value ? GREEN_COLOUR : NO_COLOUR); - break; - case RED_BUTTON: - setLed(0, value ? RED_COLOUR : NO_COLOUR); + configureExpression(settings.expression_mode); + + setLed(0, RED_COLOUR); + + MX_USB_DEVICE_Init(); + +} + +void onStartProgram(){ + setLed(0, GREEN_COLOUR); +} + +void onChangeMode(uint8_t new_mode, uint8_t old_mode){ + counter = 0; + static uint32_t saved_led = NO_COLOUR; + if(old_mode == RUN_MODE){ + saved_led = getLed(0); // leaving RUN_MODE, save LED state + } + setLed(0, NO_COLOUR); + if(new_mode == CONFIGURE_MODE){ + knobvalues[0] = getAnalogValue(PATCH_CONFIG_PROGRAM_CONTROL); + knobvalues[1] = getAnalogValue(PATCH_CONFIG_VOLUME_CONTROL); + patchselect = program.getProgramIndex(); + }else if(new_mode == RUN_MODE){ + setLed(0, saved_led); // restore to saved LED state } } -void setup(){ -#ifdef OWL_PEDAL - /* STM32F405x/407x/415x/417x Revision Z devices: prefetch is supported */ - // if (HAL_GetREVID() == 0x1001) - // { - // /* Enable the Flash prefetch */ - // __HAL_FLASH_PREFETCH_BUFFER_ENABLE(); - // } - // enable expression pedal reference voltage - HAL_GPIO_WritePin(EXPRESSION_PEDAL_TIP_GPIO_Port, EXPRESSION_PEDAL_TIP_Pin, GPIO_PIN_SET); - // todo: on OWL Modular the ADC should read Exp pin PA2 instead of PA3 -#endif - owl.setup(); - } - -#define PATCH_RESET_COUNTER (1000/MAIN_LOOP_SLEEP_MS) - -void loop(){ - static uint32_t counter = PATCH_RESET_COUNTER; +// static uint16_t progress = 0; +void setProgress(uint16_t value, const char* msg){ +#ifdef OWL_PEDAL_PWM_LEDS + setLed(0, (value<<18) & (0x3ff<<20)); +#else + toggleLed(0); +#endif +} + +void onLoop(){ switch(owl.getOperationMode()){ case STARTUP_MODE: - case LOAD_MODE: + case STREAM_MODE: setLed(0, counter > PATCH_RESET_COUNTER/2 ? GREEN_COLOUR : NO_COLOUR); + if(counter-- == 0) + counter = PATCH_RESET_COUNTER; + break; + case LOAD_MODE: + // setLed(0, counter > PATCH_INDICATOR_COUNTER/2 ? GREEN_COLOUR : NO_COLOUR); + // todo: use setProgress()? + // if(counter-- == 0) + // counter = PATCH_RESET_COUNTER; + break; + case BYPASS_MODE: + if(!isBypassed()){ + owl.setOperationMode(RUN_MODE); + }else if(isPushbuttonPressed()){ + owl.setOperationMode(ENTER_CONFIG_MODE); + } break; case RUN_MODE: - if(getErrorStatus() != NO_ERROR) + if(getErrorStatus() != NO_ERROR){ owl.setOperationMode(ERROR_MODE); - else if (pushButtonPressed) { - if (pushButtonPressDuration++> PROGRAM_CHANGE_PUSHBUTTON_TICKS){ - // Pushbutton kept pressed above threshold, overflow is prevented - pushButtonPressDuration = PROGRAM_CHANGE_PUSHBUTTON_TICKS + 1; - if (pushButtonAnimation){ - // Pulse as we unlock patch selection - if ((pushButtonAnimation-- & 0xf) == 0){ - HAL_GPIO_TogglePin(LED_RED_GPIO_Port, LED_RED_Pin); - HAL_GPIO_TogglePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin); - } - if (!pushButtonAnimation){ - // Animation just finished and we're ready to select patches on next cycle - owlSelectedProgramId = 0; -#ifdef OWL_MODULAR - bank = (4095 - getAnalogValue(PARAMETER_A)) * 5 / 4096; - prog = (4095 - getAnalogValue(PARAMETER_B)) * 8 / 4096 + 1; -#else - bank = getAnalogValue(PARAMETER_A) * 5 / 4096; - prog = getAnalogValue(PARAMETER_B) * 8 / 4096 + 1; -#endif - } - } - else { - // Ready to check for patch selection - uint16_t newOwlProgramId = getProgramSelection(); - if (!owlSelectedProgramId) { - // No program selected yet - if (!newOwlProgramId) { - // No color if nothing is selected - setLed(0, NO_COLOUR); - } - else { - // First selection, color chosen based on patch number - owlSelectedProgramId = newOwlProgramId; - setLed(0, (owlSelectedProgramId & 1) ? GREEN_COLOUR : RED_COLOUR); - } - } - else if (newOwlProgramId != owlSelectedProgramId && newOwlProgramId > 0){ - // Toggle pushbutton LEDs if patch number was changed - owlSelectedProgramId = newOwlProgramId; - HAL_GPIO_TogglePin(LED_RED_GPIO_Port, LED_RED_Pin); - HAL_GPIO_TogglePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin); - } - } + }else if(isPushbuttonPressed()){ + if(--counter == 0){ // counter == 0 when we enter RUN_MODE + owl.setOperationMode(ENTER_CONFIG_MODE); + }else if(counter < PATCH_RESET_COUNTER && counter % 128 == 0){ + toggleLed(0); } + }else if(isBypassed()){ + // don't change to BYPASS_MODE while pushbutton is pressed + // (we might have just come from CONFIGURATION_MODE) + owl.setOperationMode(BYPASS_MODE); + }else{ + counter = PATCH_CONFIG_COUNTER; + } + break; + case ENTER_CONFIG_MODE: + if(isPushbuttonPressed()){ + // toggle rapidly for yellow-ish LED + toggleLed(0); + }else{ + owl.setOperationMode(CONFIGURE_MODE); } break; case CONFIGURE_MODE: - owl.setOperationMode(RUN_MODE); + if(isPushbuttonPressed()){ // exit configure mode + if(program.getProgramIndex() != patchselect && + registry.hasPatch(patchselect)){ + program.loadProgram(patchselect); // enters load mode (calls onChangeMode) + program.resetProgram(false); + }else{ + owl.setOperationMode(RUN_MODE); + } + }else{ + // update patch control + if(abs(knobvalues[0] - getAnalogValue(PATCH_CONFIG_PROGRAM_CONTROL)) >= PATCH_CONFIG_KNOB_THRESHOLD){ + knobvalues[0] = -PATCH_CONFIG_KNOB_THRESHOLD; + float pos = 0.5f + (getAnalogValue(PATCH_CONFIG_PROGRAM_CONTROL) * (registry.getNumberOfPatches() - 1)) / 4096.0f; + uint8_t idx = roundf(pos); + if(abs(patchselect - pos) > 0.6 && registry.hasPatch(idx)){ // ensure a small dead zone + patchselect = idx; + midi_tx.sendPc(patchselect); + // update patch indicator + counter = PATCH_RESET_COUNTER + PATCH_INDICATOR_COUNTER*(2*patchselect + 1); + } + } + // update volume control + if(abs(knobvalues[1] - getAnalogValue(PATCH_CONFIG_VOLUME_CONTROL)) >= PATCH_CONFIG_KNOB_THRESHOLD){ + knobvalues[1] = -PATCH_CONFIG_KNOB_THRESHOLD; + uint8_t value = (getAnalogValue(PATCH_CONFIG_VOLUME_CONTROL) >> 6) + 63; + if(settings.audio_output_gain != value){ + settings.audio_output_gain = value; + codec.setOutputGain(value); + midi_tx.sendCc(MIDI_CC_VOLUME, value); + } + } + // indicator LED + if(counter-- == 0){ + counter = PATCH_RESET_COUNTER + PATCH_INDICATOR_COUNTER*(2*patchselect + 1); // patch indicator + setLed(0, NO_COLOUR); + }else if(counter <= PATCH_RESET_COUNTER){ + if(patchselect == 0){ + // toggle rapidly for yellow-ish LED + toggleLed(0); + }else{ + setLed(0, NO_COLOUR); + } + }else if((counter - PATCH_RESET_COUNTER) % (2*PATCH_INDICATOR_COUNTER) == 0){ + if((counter - PATCH_RESET_COUNTER) >= 10*PATCH_INDICATOR_COUNTER){ + counter -= 8*PATCH_INDICATOR_COUNTER; + setLed(0, RED_COLOUR); + }else{ + setLed(0, GREEN_COLOUR); + } + }else if((counter - PATCH_RESET_COUNTER) % PATCH_INDICATOR_COUNTER == 0){ + setLed(0, NO_COLOUR); + } + } break; - case STREAM_MODE: case ERROR_MODE: + if(isPushbuttonPressed()) + owl.setOperationMode(ENTER_CONFIG_MODE); setLed(0, counter > PATCH_RESET_COUNTER/2 ? RED_COLOUR : NO_COLOUR); + if(counter-- == 0) + counter = PATCH_RESET_COUNTER; break; } - if(--counter == 0) - counter = PATCH_RESET_COUNTER; - - owl.loop(); + configureExpression(settings.expression_mode); } diff --git a/OwlPedal/Src/freertos.c b/OwlPedal/Src/freertos.c index 7a85e1ef..f5688229 100644 --- a/OwlPedal/Src/freertos.c +++ b/OwlPedal/Src/freertos.c @@ -54,7 +54,7 @@ #include "main.h" /* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ +/* USER CODE BEGIN Includes */ /* USER CODE END Includes */ diff --git a/OwlPedal/Src/main.c b/OwlPedal/Src/main.c index 1c5728b4..66644161 100644 --- a/OwlPedal/Src/main.c +++ b/OwlPedal/Src/main.c @@ -5,11 +5,9 @@ * @retval None */ /* USER CODE END Header */ - /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "cmsis_os.h" -#include "usb_device.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ @@ -44,8 +42,7 @@ I2S_HandleTypeDef hi2s2; DMA_HandleTypeDef hdma_spi2_tx; DMA_HandleTypeDef hdma_i2s2_ext_rx; -UART_HandleTypeDef huart4; -DMA_HandleTypeDef hdma_uart4_rx; +PCD_HandleTypeDef hpcd_USB_OTG_FS; SRAM_HandleTypeDef hsram1; @@ -62,8 +59,8 @@ static void MX_DMA_Init(void); static void MX_I2S2_Init(void); static void MX_ADC3_Init(void); static void MX_I2C2_Init(void); -static void MX_UART4_Init(void); static void MX_FSMC_Init(void); +static void MX_USB_OTG_FS_PCD_Init(void); void StartDefaultTask(void const * argument); /* USER CODE BEGIN PFP */ @@ -184,8 +181,8 @@ int main(void) MX_I2S2_Init(); MX_ADC3_Init(); MX_I2C2_Init(); - MX_UART4_Init(); MX_FSMC_Init(); + MX_USB_OTG_FS_PCD_Init(); /* USER CODE BEGIN 2 */ SDRAM_Init(); @@ -244,13 +241,13 @@ void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; - RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; /** Configure the main internal regulator output voltage */ __HAL_RCC_PWR_CLK_ENABLE(); __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); - /** Initializes the CPU, AHB and APB busses clocks + /** Initializes the RCC Oscillators according to the specified parameters + * in the RCC_OscInitTypeDef structure. */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSEState = RCC_HSE_ON; @@ -264,7 +261,7 @@ void SystemClock_Config(void) { Error_Handler(); } - /** Initializes the CPU, AHB and APB busses clocks + /** Initializes the CPU, AHB and APB buses clocks */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; @@ -277,13 +274,6 @@ void SystemClock_Config(void) { Error_Handler(); } - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2S; - PeriphClkInitStruct.PLLI2S.PLLI2SN = 258; - PeriphClkInitStruct.PLLI2S.PLLI2SR = 3; - if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) - { - Error_Handler(); - } } /** @@ -314,7 +304,7 @@ static void MX_ADC3_Init(void) hadc3.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; hadc3.Init.ExternalTrigConv = ADC_SOFTWARE_START; hadc3.Init.DataAlign = ADC_DATAALIGN_RIGHT; - hadc3.Init.NbrOfConversion = 5; + hadc3.Init.NbrOfConversion = 6; hadc3.Init.DMAContinuousRequests = ENABLE; hadc3.Init.EOCSelection = ADC_EOC_SEQ_CONV; if (HAL_ADC_Init(&hadc3) != HAL_OK) @@ -362,6 +352,14 @@ static void MX_ADC3_Init(void) { Error_Handler(); } + /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. + */ + sConfig.Channel = ADC_CHANNEL_3; + sConfig.Rank = 6; + if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK) + { + Error_Handler(); + } /* USER CODE BEGIN ADC3_Init 2 */ /* USER CODE END ADC3_Init 2 */ @@ -437,35 +435,37 @@ static void MX_I2S2_Init(void) } /** - * @brief UART4 Initialization Function + * @brief USB_OTG_FS Initialization Function * @param None * @retval None */ -static void MX_UART4_Init(void) +static void MX_USB_OTG_FS_PCD_Init(void) { - /* USER CODE BEGIN UART4_Init 0 */ + /* USER CODE BEGIN USB_OTG_FS_Init 0 */ - /* USER CODE END UART4_Init 0 */ + /* USER CODE END USB_OTG_FS_Init 0 */ - /* USER CODE BEGIN UART4_Init 1 */ + /* USER CODE BEGIN USB_OTG_FS_Init 1 */ - /* USER CODE END UART4_Init 1 */ - huart4.Instance = UART4; - huart4.Init.BaudRate = 115200; - huart4.Init.WordLength = UART_WORDLENGTH_8B; - huart4.Init.StopBits = UART_STOPBITS_1; - huart4.Init.Parity = UART_PARITY_NONE; - huart4.Init.Mode = UART_MODE_TX_RX; - huart4.Init.HwFlowCtl = UART_HWCONTROL_NONE; - huart4.Init.OverSampling = UART_OVERSAMPLING_16; - if (HAL_UART_Init(&huart4) != HAL_OK) + /* USER CODE END USB_OTG_FS_Init 1 */ + hpcd_USB_OTG_FS.Instance = USB_OTG_FS; + hpcd_USB_OTG_FS.Init.dev_endpoints = 4; + hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; + hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; + hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; + hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; + hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; + hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; + hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE; + hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE; + if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) { Error_Handler(); } - /* USER CODE BEGIN UART4_Init 2 */ + /* USER CODE BEGIN USB_OTG_FS_Init 2 */ - /* USER CODE END UART4_Init 2 */ + /* USER CODE END USB_OTG_FS_Init 2 */ } @@ -480,9 +480,6 @@ static void MX_DMA_Init(void) __HAL_RCC_DMA2_CLK_ENABLE(); /* DMA interrupt init */ - /* DMA1_Stream2_IRQn interrupt configuration */ - HAL_NVIC_SetPriority(DMA1_Stream2_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(DMA1_Stream2_IRQn); /* DMA1_Stream3_IRQn interrupt configuration */ HAL_NVIC_SetPriority(DMA1_Stream3_IRQn, 8, 0); HAL_NVIC_EnableIRQ(DMA1_Stream3_IRQn); @@ -517,17 +514,14 @@ static void MX_GPIO_Init(void) /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOE, LED_RED_Pin|LED_GREEN_Pin, GPIO_PIN_RESET); - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(EXPRESSION_PEDAL_TIP_GPIO_Port, EXPRESSION_PEDAL_TIP_Pin, GPIO_PIN_RESET); - /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOC, GPIO_PIN_4|FLASH_nCS_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(PUSH_GATE_OUT_GPIO_Port, PUSH_GATE_OUT_Pin, GPIO_PIN_SET); - /*Configure GPIO pins : PUSHBUTTON_Pin BYPASS_Pin */ - GPIO_InitStruct.Pin = PUSHBUTTON_Pin|BYPASS_Pin; + /*Configure GPIO pins : SW1_Pin FOOTSWITCH_Pin */ + GPIO_InitStruct.Pin = SW1_Pin|FOOTSWITCH_Pin; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); @@ -563,17 +557,12 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); - /*Configure GPIO pin : EXPRESSION_PEDAL_TIP_Pin */ - GPIO_InitStruct.Pin = EXPRESSION_PEDAL_TIP_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(EXPRESSION_PEDAL_TIP_GPIO_Port, &GPIO_InitStruct); - - /*Configure GPIO pins : PA4 PA5 PA6 PA7 - PA8 PA10 PA15 */ - GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7 - |GPIO_PIN_8|GPIO_PIN_10|GPIO_PIN_15; + /*Configure GPIO pins : PA0 PA1 PA4 PA5 + PA6 PA7 PA8 PA10 + PA15 */ + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5 + |GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_10 + |GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); @@ -706,8 +695,6 @@ static void MX_FSMC_Init(void) /* USER CODE END Header_StartDefaultTask */ void StartDefaultTask(void const * argument) { - /* init code for USB_DEVICE */ - MX_USB_DEVICE_Init(); /* USER CODE BEGIN 5 */ /* Infinite loop */ for(;;) diff --git a/OwlPedal/Src/stm32f4xx_hal_msp.c b/OwlPedal/Src/stm32f4xx_hal_msp.c index a3b96a2b..9b420b24 100644 --- a/OwlPedal/Src/stm32f4xx_hal_msp.c +++ b/OwlPedal/Src/stm32f4xx_hal_msp.c @@ -60,8 +60,6 @@ extern DMA_HandleTypeDef hdma_spi2_tx; extern DMA_HandleTypeDef hdma_i2s2_ext_rx; -extern DMA_HandleTypeDef hdma_uart4_rx; - /* Private typedef -----------------------------------------------------------*/ /* USER CODE BEGIN TD */ @@ -132,25 +130,26 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) /* USER CODE END ADC3_MspInit 0 */ /* Peripheral clock enable */ __HAL_RCC_ADC3_CLK_ENABLE(); - + __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); - /**ADC3 GPIO Configuration + /**ADC3 GPIO Configuration PC0 ------> ADC3_IN10 PC1 ------> ADC3_IN11 PC2 ------> ADC3_IN12 PC3 ------> ADC3_IN13 - PA2 ------> ADC3_IN2 + PA2 ------> ADC3_IN2 + PA3 ------> ADC3_IN3 */ GPIO_InitStruct.Pin = ADC1_Pin|ADC2_Pin|ADC3_Pin|ADC4_Pin; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - GPIO_InitStruct.Pin = ADC5_Pin; + GPIO_InitStruct.Pin = EXP1_RING_Pin|EXP1_TIP_Pin; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(ADC5_GPIO_Port, &GPIO_InitStruct); + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* ADC3 DMA Init */ /* ADC3 Init */ @@ -193,17 +192,18 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) /* USER CODE END ADC3_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_ADC3_CLK_DISABLE(); - - /**ADC3 GPIO Configuration + + /**ADC3 GPIO Configuration PC0 ------> ADC3_IN10 PC1 ------> ADC3_IN11 PC2 ------> ADC3_IN12 PC3 ------> ADC3_IN13 - PA2 ------> ADC3_IN2 + PA2 ------> ADC3_IN2 + PA3 ------> ADC3_IN3 */ HAL_GPIO_DeInit(GPIOC, ADC1_Pin|ADC2_Pin|ADC3_Pin|ADC4_Pin); - HAL_GPIO_DeInit(ADC5_GPIO_Port, ADC5_Pin); + HAL_GPIO_DeInit(GPIOA, EXP1_RING_Pin|EXP1_TIP_Pin); /* ADC3 DMA DeInit */ HAL_DMA_DeInit(hadc->DMA_Handle); @@ -228,11 +228,11 @@ void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c) /* USER CODE BEGIN I2C2_MspInit 0 */ /* USER CODE END I2C2_MspInit 0 */ - + __HAL_RCC_GPIOB_CLK_ENABLE(); - /**I2C2 GPIO Configuration + /**I2C2 GPIO Configuration PB10 ------> I2C2_SCL - PB11 ------> I2C2_SDA + PB11 ------> I2C2_SDA */ GPIO_InitStruct.Pin = I2C_SCK_Pin|I2C_SDA_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; @@ -265,12 +265,14 @@ void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c) /* USER CODE END I2C2_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_I2C2_CLK_DISABLE(); - - /**I2C2 GPIO Configuration + + /**I2C2 GPIO Configuration PB10 ------> I2C2_SCL - PB11 ------> I2C2_SDA + PB11 ------> I2C2_SDA */ - HAL_GPIO_DeInit(GPIOB, I2C_SCK_Pin|I2C_SDA_Pin); + HAL_GPIO_DeInit(I2C_SCK_GPIO_Port, I2C_SCK_Pin); + + HAL_GPIO_DeInit(I2C_SDA_GPIO_Port, I2C_SDA_Pin); /* USER CODE BEGIN I2C2_MspDeInit 1 */ @@ -288,21 +290,32 @@ void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c) void HAL_I2S_MspInit(I2S_HandleTypeDef* hi2s) { GPIO_InitTypeDef GPIO_InitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; if(hi2s->Instance==SPI2) { /* USER CODE BEGIN SPI2_MspInit 0 */ __HAL_RCC_PLLI2S_ENABLE(); /* USER CODE END SPI2_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2S; + PeriphClkInitStruct.PLLI2S.PLLI2SN = 258; + PeriphClkInitStruct.PLLI2S.PLLI2SR = 3; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } + /* Peripheral clock enable */ __HAL_RCC_SPI2_CLK_ENABLE(); - + __HAL_RCC_GPIOB_CLK_ENABLE(); - /**I2S2 GPIO Configuration + /**I2S2 GPIO Configuration PB12 ------> I2S2_WS PB13 ------> I2S2_CK PB14 ------> I2S2_ext_SD - PB15 ------> I2S2_SD + PB15 ------> I2S2_SD */ GPIO_InitStruct.Pin = I2S_LRCK_Pin|I2S_SCLK_Pin|I2S_SDO_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; @@ -380,12 +393,12 @@ void HAL_I2S_MspDeInit(I2S_HandleTypeDef* hi2s) /* USER CODE END SPI2_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_SPI2_CLK_DISABLE(); - - /**I2S2 GPIO Configuration + + /**I2S2 GPIO Configuration PB12 ------> I2S2_WS PB13 ------> I2S2_CK PB14 ------> I2S2_ext_SD - PB15 ------> I2S2_SD + PB15 ------> I2S2_SD */ HAL_GPIO_DeInit(GPIOB, I2S_LRCK_Pin|I2S_SCLK_Pin|I2S_SDI_Pin|I2S_SDO_Pin); @@ -403,93 +416,78 @@ void HAL_I2S_MspDeInit(I2S_HandleTypeDef* hi2s) } /** -* @brief UART MSP Initialization +* @brief PCD MSP Initialization * This function configures the hardware resources used in this example -* @param huart: UART handle pointer +* @param hpcd: PCD handle pointer * @retval None */ -void HAL_UART_MspInit(UART_HandleTypeDef* huart) +void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd) { GPIO_InitTypeDef GPIO_InitStruct = {0}; - if(huart->Instance==UART4) + if(hpcd->Instance==USB_OTG_FS) { - /* USER CODE BEGIN UART4_MspInit 0 */ + /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */ + + /* USER CODE END USB_OTG_FS_MspInit 0 */ - /* USER CODE END UART4_MspInit 0 */ - /* Peripheral clock enable */ - __HAL_RCC_UART4_CLK_ENABLE(); - __HAL_RCC_GPIOA_CLK_ENABLE(); - /**UART4 GPIO Configuration - PA0-WKUP ------> UART4_TX - PA1 ------> UART4_RX + /**USB_OTG_FS GPIO Configuration + PA9 ------> USB_OTG_FS_VBUS + PA11 ------> USB_OTG_FS_DM + PA12 ------> USB_OTG_FS_DP */ - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1; + GPIO_InitStruct.Pin = GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_PULLUP; + GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF8_UART4; + GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - /* UART4 DMA Init */ - /* UART4_RX Init */ - hdma_uart4_rx.Instance = DMA1_Stream2; - hdma_uart4_rx.Init.Channel = DMA_CHANNEL_4; - hdma_uart4_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; - hdma_uart4_rx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_uart4_rx.Init.MemInc = DMA_MINC_ENABLE; - hdma_uart4_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; - hdma_uart4_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; - hdma_uart4_rx.Init.Mode = DMA_NORMAL; - hdma_uart4_rx.Init.Priority = DMA_PRIORITY_LOW; - hdma_uart4_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE; - if (HAL_DMA_Init(&hdma_uart4_rx) != HAL_OK) - { - Error_Handler(); - } - - __HAL_LINKDMA(huart,hdmarx,hdma_uart4_rx); - - /* UART4 interrupt Init */ - HAL_NVIC_SetPriority(UART4_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(UART4_IRQn); - /* USER CODE BEGIN UART4_MspInit 1 */ + /* Peripheral clock enable */ + __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); + /* USB_OTG_FS interrupt Init */ + HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(OTG_FS_IRQn); + /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */ - /* USER CODE END UART4_MspInit 1 */ + /* USER CODE END USB_OTG_FS_MspInit 1 */ } } /** -* @brief UART MSP De-Initialization +* @brief PCD MSP De-Initialization * This function freeze the hardware resources used in this example -* @param huart: UART handle pointer +* @param hpcd: PCD handle pointer * @retval None */ -void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) +void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd) { - if(huart->Instance==UART4) + if(hpcd->Instance==USB_OTG_FS) { - /* USER CODE BEGIN UART4_MspDeInit 0 */ + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */ - /* USER CODE END UART4_MspDeInit 0 */ + /* USER CODE END USB_OTG_FS_MspDeInit 0 */ /* Peripheral clock disable */ - __HAL_RCC_UART4_CLK_DISABLE(); - - /**UART4 GPIO Configuration - PA0-WKUP ------> UART4_TX - PA1 ------> UART4_RX - */ - HAL_GPIO_DeInit(GPIOA, GPIO_PIN_0|GPIO_PIN_1); + __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); - /* UART4 DMA DeInit */ - HAL_DMA_DeInit(huart->hdmarx); + /**USB_OTG_FS GPIO Configuration + PA9 ------> USB_OTG_FS_VBUS + PA11 ------> USB_OTG_FS_DM + PA12 ------> USB_OTG_FS_DP + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_12); - /* UART4 interrupt DeInit */ - HAL_NVIC_DisableIRQ(UART4_IRQn); - /* USER CODE BEGIN UART4_MspDeInit 1 */ + /* USB_OTG_FS interrupt DeInit */ + HAL_NVIC_DisableIRQ(OTG_FS_IRQn); + /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */ - /* USER CODE END UART4_MspDeInit 1 */ + /* USER CODE END USB_OTG_FS_MspDeInit 1 */ } } @@ -508,8 +506,8 @@ static void HAL_FSMC_MspInit(void){ /* Peripheral clock enable */ __HAL_RCC_FSMC_CLK_ENABLE(); - - /** FSMC GPIO Configuration + + /** FSMC GPIO Configuration PF0 ------> FSMC_A0 PF1 ------> FSMC_A1 PF2 ------> FSMC_A2 @@ -551,8 +549,8 @@ static void HAL_FSMC_MspInit(void){ PE0 ------> FSMC_NBL0 PE1 ------> FSMC_NBL1 */ - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 - |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_12|GPIO_PIN_13 + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 + |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_12|GPIO_PIN_13 |GPIO_PIN_14|GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; @@ -560,7 +558,7 @@ static void HAL_FSMC_MspInit(void){ GPIO_InitStruct.Alternate = GPIO_AF12_FSMC; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_10; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; @@ -568,8 +566,8 @@ static void HAL_FSMC_MspInit(void){ GPIO_InitStruct.Alternate = GPIO_AF12_FSMC; HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); - GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 - |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 + GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 + |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; @@ -577,8 +575,8 @@ static void HAL_FSMC_MspInit(void){ GPIO_InitStruct.Alternate = GPIO_AF12_FSMC; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); - GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11 - |GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15 + GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11 + |GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15 |GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; @@ -613,8 +611,8 @@ static void HAL_FSMC_MspDeInit(void){ FSMC_DeInitialized = 1; /* Peripheral clock enable */ __HAL_RCC_FSMC_CLK_DISABLE(); - - /** FSMC GPIO Configuration + + /** FSMC GPIO Configuration PF0 ------> FSMC_A0 PF1 ------> FSMC_A1 PF2 ------> FSMC_A2 @@ -656,19 +654,19 @@ static void HAL_FSMC_MspDeInit(void){ PE0 ------> FSMC_NBL0 PE1 ------> FSMC_NBL1 */ - HAL_GPIO_DeInit(GPIOF, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 - |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_12|GPIO_PIN_13 + HAL_GPIO_DeInit(GPIOF, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 + |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_12|GPIO_PIN_13 |GPIO_PIN_14|GPIO_PIN_15); - HAL_GPIO_DeInit(GPIOG, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 + HAL_GPIO_DeInit(GPIOG, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_10); - HAL_GPIO_DeInit(GPIOE, GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 - |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 + HAL_GPIO_DeInit(GPIOE, GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 + |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1); - HAL_GPIO_DeInit(GPIOD, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11 - |GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15 + HAL_GPIO_DeInit(GPIOD, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11 + |GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15 |GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5); /* USER CODE BEGIN FSMC_MspDeInit 1 */ diff --git a/OwlPedal/Src/stm32f4xx_it.c b/OwlPedal/Src/stm32f4xx_it.c index b47362b1..5208f682 100644 --- a/OwlPedal/Src/stm32f4xx_it.c +++ b/OwlPedal/Src/stm32f4xx_it.c @@ -73,13 +73,11 @@ /* USER CODE END 0 */ /* External variables --------------------------------------------------------*/ -extern PCD_HandleTypeDef hpcd_USB_OTG_FS; extern DMA_HandleTypeDef hdma_adc3; extern DMA_HandleTypeDef hdma_spi2_tx; extern DMA_HandleTypeDef hdma_i2s2_ext_rx; extern I2S_HandleTypeDef hi2s2; -extern DMA_HandleTypeDef hdma_uart4_rx; -extern UART_HandleTypeDef huart4; +extern PCD_HandleTypeDef hpcd_USB_OTG_FS; /* USER CODE BEGIN EV */ /* USER CODE END EV */ @@ -144,20 +142,6 @@ void EXTI4_IRQHandler(void) /* USER CODE END EXTI4_IRQn 1 */ } -/** - * @brief This function handles DMA1 stream2 global interrupt. - */ -void DMA1_Stream2_IRQHandler(void) -{ - /* USER CODE BEGIN DMA1_Stream2_IRQn 0 */ - - /* USER CODE END DMA1_Stream2_IRQn 0 */ - HAL_DMA_IRQHandler(&hdma_uart4_rx); - /* USER CODE BEGIN DMA1_Stream2_IRQn 1 */ - - /* USER CODE END DMA1_Stream2_IRQn 1 */ -} - /** * @brief This function handles DMA1 stream3 global interrupt. */ @@ -266,33 +250,6 @@ void SPI2_IRQHandler(void) /* USER CODE END SPI2_IRQn 1 */ } -/** - * @brief This function handles UART4 global interrupt. - */ -void UART4_IRQHandler(void) -{ - /* USER CODE BEGIN UART4_IRQn 0 */ - - /* USER CODE END UART4_IRQn 0 */ - HAL_UART_IRQHandler(&huart4); - /* USER CODE BEGIN UART4_IRQn 1 */ - /* Check for IDLE flag */ - UART_HandleTypeDef *huart = &huart4; - if(huart->Instance->SR & UART_FLAG_IDLE){ - /* This part is important */ - /* Clear IDLE flag by reading status and data registers */ - volatile uint32_t tmp; /* Must be volatile to prevent optimizations */ - tmp = huart->Instance->SR; /* Read status register */ - tmp = huart->Instance->DR; /* Read data register */ - (void)tmp; /* Prevent compiler warnings */ - if(huart->hdmarx != NULL) - huart->hdmarx->Instance->CR &= ~DMA_SxCR_EN; /* Disabling DMA will force transfer complete interrupt if enabled */ - /* DMA1_Stream2->CR &= ~DMA_SxCR_EN; /\* Disabling DMA will force transfer complete interrupt if enabled *\/ */ - } - - /* USER CODE END UART4_IRQn 1 */ -} - /** * @brief This function handles DMA2 stream0 global interrupt. */ diff --git a/OwlPedal/Src/usb_device.c b/OwlPedal/Src/usb_device.c index c1cf5446..723305ee 100644 --- a/OwlPedal/Src/usb_device.c +++ b/OwlPedal/Src/usb_device.c @@ -27,6 +27,7 @@ #include "usbd_audio.h" /* USER CODE BEGIN Includes */ +#include "device.h" /* USER CODE END Includes */ @@ -41,7 +42,7 @@ /* USER CODE END PFP */ /* USB Device Core handle declaration. */ -USBD_HandleTypeDef hUsbDeviceFS; +USBD_HandleTypeDef USBD_HANDLE; /* * -- Insert your variables declaration here -- @@ -68,19 +69,19 @@ void MX_USB_DEVICE_Init(void) /* USER CODE END USB_DEVICE_Init_PreTreatment */ /* Init Device Library, add supported class and start the library. */ - if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK) + if (USBD_Init(&USBD_HANDLE, &USBD_DESC, USBD_HSFS) != USBD_OK) { Error_Handler(); } - if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_AUDIO) != USBD_OK) + if (USBD_RegisterClass(&USBD_HANDLE, &USBD_AUDIO) != USBD_OK) { Error_Handler(); } - if (USBD_AUDIO_RegisterInterface(&hUsbDeviceFS, NULL) != USBD_OK) + if (USBD_AUDIO_RegisterInterface(&USBD_HANDLE, NULL) != USBD_OK) { Error_Handler(); } - if (USBD_Start(&hUsbDeviceFS) != USBD_OK) + if (USBD_Start(&USBD_HANDLE) != USBD_OK) { Error_Handler(); } diff --git a/OwlPedal/Src/usbd_conf.c b/OwlPedal/Src/usbd_conf.c index 96f0dcfe..9460a97a 100644 --- a/OwlPedal/Src/usbd_conf.c +++ b/OwlPedal/Src/usbd_conf.c @@ -7,7 +7,7 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2020 STMicroelectronics. + *

© Copyright (c) 2019 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under Ultimate Liberty license @@ -25,6 +25,8 @@ #include "usbd_def.h" #include "usbd_core.h" +#include "usbd_audio.h" + /* USER CODE BEGIN Includes */ #include "device.h" uint8_t USBD_AUDIO_SetFiFos(PCD_HandleTypeDef *hpcd); @@ -39,7 +41,9 @@ uint8_t USBD_AUDIO_SetFiFos(PCD_HandleTypeDef *hpcd); /* USER CODE END PV */ -PCD_HandleTypeDef hpcd_USB_OTG_FS; +extern PCD_HandleTypeDef hpcd_USB_OTG_HS; +extern PCD_HandleTypeDef hpcd_USB_OTG_FS; + void Error_Handler(void); /* External functions --------------------------------------------------------*/ @@ -50,6 +54,7 @@ void SystemClock_Config(void); /* USER CODE BEGIN PFP */ /* Private function prototypes -----------------------------------------------*/ + USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status); /* USER CODE END PFP */ @@ -62,83 +67,18 @@ USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status); /******************************************************************************* LL Driver Callbacks (PCD -> USB Device Library) *******************************************************************************/ -/* MSP Init */ - -void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - if(pcdHandle->Instance==USB_OTG_FS) - { - /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */ - - /* USER CODE END USB_OTG_FS_MspInit 0 */ - - __HAL_RCC_GPIOA_CLK_ENABLE(); - /**USB_OTG_FS GPIO Configuration - PA9 ------> USB_OTG_FS_VBUS - PA11 ------> USB_OTG_FS_DM - PA12 ------> USB_OTG_FS_DP - */ - GPIO_InitStruct.Pin = GPIO_PIN_9; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* Peripheral clock enable */ - __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); - - /* Peripheral interrupt init */ - HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(OTG_FS_IRQn); - /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */ - - /* USER CODE END USB_OTG_FS_MspInit 1 */ - } -} -void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) -{ - if(pcdHandle->Instance==USB_OTG_FS) - { - /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */ - - /* USER CODE END USB_OTG_FS_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); - - /**USB_OTG_FS GPIO Configuration - PA9 ------> USB_OTG_FS_VBUS - PA11 ------> USB_OTG_FS_DM - PA12 ------> USB_OTG_FS_DP - */ - HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_12); - - /* Peripheral interrupt Deinit*/ - HAL_NVIC_DisableIRQ(OTG_FS_IRQn); - - /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */ - - /* USER CODE END USB_OTG_FS_MspDeInit 1 */ - } -} +/* defined in stm32f4xx_hal_msp.c : + * void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd) + * void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd) + */ /** * @brief Setup stage callback * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_SetupStage((USBD_HandleTypeDef*)hpcd->pData, (uint8_t *)hpcd->Setup); } @@ -149,11 +89,7 @@ void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) * @param epnum: Endpoint number * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#else void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_DataOutStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff); } @@ -164,11 +100,7 @@ void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) * @param epnum: Endpoint number * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#else void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_DataInStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff); } @@ -178,11 +110,7 @@ void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_SOFCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_SOF((USBD_HandleTypeDef*)hpcd->pData); } @@ -192,12 +120,8 @@ void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ResetCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ -{ +{ USBD_SpeedTypeDef speed = USBD_SPEED_FULL; if ( hpcd->Init.speed == PCD_SPEED_HIGH) @@ -225,11 +149,7 @@ void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { /* Inform USB library that core enters in suspend Mode. */ USBD_LL_Suspend((USBD_HandleTypeDef*)hpcd->pData); @@ -250,11 +170,7 @@ void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { /* USER CODE BEGIN 3 */ /* USER CODE END 3 */ @@ -267,11 +183,7 @@ void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) * @param epnum: Endpoint number * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#else void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_IsoOUTIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); } @@ -282,11 +194,7 @@ void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) * @param epnum: Endpoint number * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#else void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_IsoINIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum); } @@ -296,11 +204,7 @@ void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_DevConnected((USBD_HandleTypeDef*)hpcd->pData); } @@ -310,11 +214,7 @@ void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) * @param hpcd: PCD handle * @retval None */ -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) -static void PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) -#else void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ { USBD_LL_DevDisconnected((USBD_HandleTypeDef*)hpcd->pData); } @@ -330,44 +230,20 @@ void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) */ USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev) { - /* Init USB Ip. */ - if (pdev->id == DEVICE_FS) { - /* Link the driver to the stack. */ - hpcd_USB_OTG_FS.pData = pdev; - pdev->pData = &hpcd_USB_OTG_FS; - - hpcd_USB_OTG_FS.Instance = USB_OTG_FS; - hpcd_USB_OTG_FS.Init.dev_endpoints = 4; - hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; - hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; - hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; - hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; - hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; - hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; - hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE; - hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE; - if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) - { - Error_Handler( ); - } - -#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U) - /* Register USB PCD CallBacks */ - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SOF_CB_ID, PCD_SOFCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SETUPSTAGE_CB_ID, PCD_SetupStageCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESET_CB_ID, PCD_ResetCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SUSPEND_CB_ID, PCD_SuspendCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESUME_CB_ID, PCD_ResumeCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_CONNECT_CB_ID, PCD_ConnectCallback); - HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_DISCONNECT_CB_ID, PCD_DisconnectCallback); - - HAL_PCD_RegisterDataOutStageCallback(&hpcd_USB_OTG_FS, PCD_DataOutStageCallback); - HAL_PCD_RegisterDataInStageCallback(&hpcd_USB_OTG_FS, PCD_DataInStageCallback); - HAL_PCD_RegisterIsoOutIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOOUTIncompleteCallback); - HAL_PCD_RegisterIsoInIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOINIncompleteCallback); -#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */ - USBD_AUDIO_SetFiFos(&hpcd_USB_OTG_FS); - } +#ifdef USE_USBD_FS + /* if (pdev->id == DEVICE_FS) { */ + /* Link the driver to the stack. */ + hpcd_USB_OTG_FS.pData = pdev; + pdev->pData = &hpcd_USB_OTG_FS; +#endif + /* } else if (pdev->id == DEVICE_HS) { */ +#ifdef USE_USBD_HS + /* Link the driver to the stack. */ + hpcd_USB_OTG_HS.pData = pdev; + pdev->pData = &hpcd_USB_OTG_HS; +#endif + /* } */ + USBD_AUDIO_SetFiFos(pdev->pData); return USBD_OK; } @@ -384,12 +260,12 @@ USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev) hal_status = HAL_PCD_DeInit(pdev->pData); usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + return usb_status; } /** - * @brief Starts the low level portion of the device driver. + * @brief Starts the low level portion of the device driver. * @param pdev: Device handle * @retval USBD status */ @@ -397,11 +273,11 @@ USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev) { HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - + hal_status = HAL_PCD_Start(pdev->pData); - - usb_status = USBD_Get_USB_Status(hal_status); - + + usb_status = USBD_Get_USB_Status(hal_status); + return usb_status; } @@ -416,9 +292,9 @@ USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev) USBD_StatusTypeDef usb_status = USBD_OK; hal_status = HAL_PCD_Stop(pdev->pData); - + usb_status = USBD_Get_USB_Status(hal_status); - + return usb_status; } @@ -438,7 +314,7 @@ USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uin hal_status = HAL_PCD_EP_Open(pdev->pData, ep_addr, ep_mps, ep_type); usb_status = USBD_Get_USB_Status(hal_status); - + return usb_status; } @@ -452,13 +328,13 @@ USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) { HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - + USB_DISABLE_EP_BEFORE_CLOSE(ep_addr); hal_status = HAL_PCD_EP_Close(pdev->pData, ep_addr); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; } /** @@ -471,12 +347,12 @@ USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) { HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - + hal_status = HAL_PCD_EP_Flush(pdev->pData, ep_addr); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; } /** @@ -489,12 +365,12 @@ USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) { HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - + hal_status = HAL_PCD_EP_SetStall(pdev->pData, ep_addr); usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + return usb_status; } /** @@ -507,12 +383,12 @@ USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_add { HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - + hal_status = HAL_PCD_EP_ClrStall(pdev->pData, ep_addr); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; } /** @@ -524,14 +400,14 @@ USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_add uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr) { PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef*) pdev->pData; - + if((ep_addr & 0x80) == 0x80) { - return hpcd->IN_ep[ep_addr & 0x7F].is_stall; + return hpcd->IN_ep[ep_addr & 0x7F].is_stall; } else { - return hpcd->OUT_ep[ep_addr & 0x7F].is_stall; + return hpcd->OUT_ep[ep_addr & 0x7F].is_stall; } } @@ -545,12 +421,12 @@ USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_a { HAL_StatusTypeDef hal_status = HAL_OK; USBD_StatusTypeDef usb_status = USBD_OK; - + hal_status = HAL_PCD_SetAddress(pdev->pData, dev_addr); - + usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + return usb_status; } /** @@ -558,7 +434,7 @@ USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_a * @param pdev: Device handle * @param ep_addr: Endpoint number * @param pbuf: Pointer to data to be sent - * @param size: Data size + * @param size: Data size * @retval USBD status */ USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size) @@ -567,10 +443,10 @@ USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, u USBD_StatusTypeDef usb_status = USBD_OK; hal_status = HAL_PCD_EP_Transmit(pdev->pData, ep_addr, pbuf, size); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; } /** @@ -587,23 +463,44 @@ USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_a USBD_StatusTypeDef usb_status = USBD_OK; hal_status = HAL_PCD_EP_Receive(pdev->pData, ep_addr, pbuf, size); - - usb_status = USBD_Get_USB_Status(hal_status); - - return usb_status; + + usb_status = USBD_Get_USB_Status(hal_status); + + return usb_status; } /** - * @brief Returns the last transfered packet size. + * @brief Returns the last transferred packet size. * @param pdev: Device handle * @param ep_addr: Endpoint number - * @retval Recived Data Size + * @retval Received Data Size */ uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr) { return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef*) pdev->pData, ep_addr); } +/** + * @brief Static single allocation. + * @param size: Size of allocated memory + * @retval None + */ +void *USBD_static_malloc(uint32_t size) +{ + static uint32_t mem[(sizeof(USBD_AUDIO_HandleTypeDef)/4)+1];/* On 32-bit boundary */ + return mem; +} + +/** + * @brief Dummy memory free + * @param p: Pointer to allocated memory address + * @retval None + */ +void USBD_static_free(void *p) +{ + +} + /** * @brief Delays routine for the USB Device Library. * @param Delay: Delay in ms @@ -615,7 +512,7 @@ void USBD_LL_Delay(uint32_t Delay) } /** - * @brief Retuns the USB status depending on the HAL status: + * @brief Returns the USB status depending on the HAL status: * @param hal_status: HAL status * @retval USB status */ diff --git a/OwlPedal/Src/usbd_desc.c b/OwlPedal/Src/usbd_desc.c index c57c672d..5afb6ed8 100644 --- a/OwlPedal/Src/usbd_desc.c +++ b/OwlPedal/Src/usbd_desc.c @@ -7,7 +7,7 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2020 STMicroelectronics. + *

© Copyright (c) 2019 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under Ultimate Liberty license @@ -25,7 +25,7 @@ #include "usbd_conf.h" /* USER CODE BEGIN INCLUDE */ - +#include "device.h" /* USER CODE END INCLUDE */ /* Private typedef -----------------------------------------------------------*/ @@ -66,10 +66,10 @@ #define USBD_VID 0x1209 #define USBD_LANGID_STRING 1033 #define USBD_MANUFACTURER_STRING "Rebel Technology" -#define USBD_PID_FS 0xDADA -#define USBD_PRODUCT_STRING_FS "OWL-MIDI" -#define USBD_CONFIGURATION_STRING_FS "AUDIO Config" -#define USBD_INTERFACE_STRING_FS "AUDIO Interface" +#define USBD_PID_FSHS 0xDADA +#define USBD_PRODUCT_STRING_FSHS "OWL-PEDAL" +#define USBD_CONFIGURATION_STRING_FSHS "AUDIO Config" +#define USBD_INTERFACE_STRING_FSHS "AUDIO Interface" #define USB_SIZ_BOS_DESC 0x0C @@ -97,34 +97,34 @@ /** * @} */ - + /** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes * @brief Private functions declaration. * @{ */ - + static void Get_SerialNum(void); static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len); - + /** * @} - */ - + */ /** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes - * @brief Private functions declaration for FS. + * @brief Private functions declaration for HS. * @{ */ -uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); -uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); + #if (USBD_LPM_ENABLED == 1) -uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); +uint8_t * USBD_FSHS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); #endif /* (USBD_LPM_ENABLED == 1) */ /** @@ -136,17 +136,17 @@ uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); * @{ */ -USBD_DescriptorsTypeDef FS_Desc = +USBD_DescriptorsTypeDef USBD_DESC = { - USBD_FS_DeviceDescriptor -, USBD_FS_LangIDStrDescriptor -, USBD_FS_ManufacturerStrDescriptor -, USBD_FS_ProductStrDescriptor -, USBD_FS_SerialStrDescriptor -, USBD_FS_ConfigStrDescriptor -, USBD_FS_InterfaceStrDescriptor + USBD_FSHS_DeviceDescriptor +, USBD_FSHS_LangIDStrDescriptor +, USBD_FSHS_ManufacturerStrDescriptor +, USBD_FSHS_ProductStrDescriptor +, USBD_FSHS_SerialStrDescriptor +, USBD_FSHS_ConfigStrDescriptor +, USBD_FSHS_InterfaceStrDescriptor #if (USBD_LPM_ENABLED == 1) -, USBD_FS_USR_BOSDescriptor +, USBD_FSHS_USR_BOSDescriptor #endif /* (USBD_LPM_ENABLED == 1) */ }; @@ -154,7 +154,7 @@ USBD_DescriptorsTypeDef FS_Desc = #pragma data_alignment=4 #endif /* defined ( __ICCARM__ ) */ /** USB standard device descriptor. */ -__ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = +__ALIGN_BEGIN uint8_t USBD_FSHS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = { 0x12, /*bLength */ USB_DESC_TYPE_DEVICE, /*bDescriptorType*/ @@ -165,6 +165,7 @@ __ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = #else 0x00, /*bcdUSB */ #endif /* (USBD_LPM_ENABLED == 1) */ + 0x02, 0x00, /*bDeviceClass*/ 0x00, /*bDeviceSubClass*/ @@ -172,8 +173,8 @@ __ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = USB_MAX_EP0_SIZE, /*bMaxPacketSize*/ LOBYTE(USBD_VID), /*idVendor*/ HIBYTE(USBD_VID), /*idVendor*/ - LOBYTE(USBD_PID_FS), /*idProduct*/ - HIBYTE(USBD_PID_FS), /*idProduct*/ + LOBYTE(USBD_PID_FSHS), /*idProduct*/ + HIBYTE(USBD_PID_FSHS), /*idProduct*/ 0x00, /*bcdDevice rel. 2.00*/ 0x02, USBD_IDX_MFC_STR, /*Index of manufacturer string*/ @@ -182,24 +183,23 @@ __ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/ }; -/* USB_DeviceDescriptor */ /** BOS descriptor. */ #if (USBD_LPM_ENABLED == 1) #if defined ( __ICCARM__ ) /* IAR Compiler */ #pragma data_alignment=4 #endif /* defined ( __ICCARM__ ) */ -__ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = +__ALIGN_BEGIN uint8_t USBD_FSHS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = { 0x5, USB_DESC_TYPE_BOS, 0xC, 0x0, - 0x1, /* 1 device capability*/ - /* device capability*/ + 0x1, /* 1 device capability */ + /* device capability */ 0x7, USB_DEVICE_CAPABITY_TYPE, 0x2, - 0x2, /* LPM capability bit set*/ + 0x2, /*LPM capability bit set */ 0x0, 0x0, 0x0 @@ -219,7 +219,7 @@ __ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = #pragma data_alignment=4 #endif /* defined ( __ICCARM__ ) */ -/** USB lang indentifier descriptor. */ +/** USB lang identifier descriptor. */ __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = { USB_LEN_LANGID_STR_DESC, @@ -235,7 +235,7 @@ __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = __ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END; #if defined ( __ICCARM__ ) /*!< IAR Compiler */ - #pragma data_alignment=4 + #pragma data_alignment=4 #endif __ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { USB_SIZ_STRING_SERIAL, @@ -257,11 +257,11 @@ __ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); - *length = sizeof(USBD_FS_DeviceDesc); - return USBD_FS_DeviceDesc; + *length = sizeof(USBD_FSHS_DeviceDesc); + return USBD_FSHS_DeviceDesc; } /** @@ -270,7 +270,7 @@ uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); *length = sizeof(USBD_LangIDDesc); @@ -279,19 +279,19 @@ uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) /** * @brief Return the product string descriptor - * @param speed : Current device speed - * @param length : Pointer to data length variable - * @retval Pointer to descriptor buffer + * @param speed : current device speed + * @param length : pointer to data length variable + * @retval pointer to descriptor buffer */ -uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { if(speed == 0) { - USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FSHS, USBD_StrDesc, length); } else { - USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FSHS, USBD_StrDesc, length); } return USBD_StrDesc; } @@ -302,7 +302,7 @@ uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length); @@ -315,7 +315,7 @@ uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *l * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); *length = USB_SIZ_STRING_SERIAL; @@ -323,9 +323,10 @@ uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) /* Update the serial number string descriptor with the data from the unique * ID */ Get_SerialNum(); - /* USER CODE BEGIN USBD_FS_SerialStrDescriptor */ - - /* USER CODE END USBD_FS_SerialStrDescriptor */ + /* USER CODE BEGIN USBD_HS_SerialStrDescriptor */ + + /* USER CODE END USBD_HS_SerialStrDescriptor */ + return (uint8_t *) USBD_StringSerial; } @@ -335,15 +336,15 @@ uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { if(speed == USBD_SPEED_HIGH) { - USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FSHS, USBD_StrDesc, length); } else { - USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FSHS, USBD_StrDesc, length); } return USBD_StrDesc; } @@ -354,15 +355,15 @@ uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { if(speed == 0) { - USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FSHS, USBD_StrDesc, length); } else { - USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length); + USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FSHS, USBD_StrDesc, length); } return USBD_StrDesc; } @@ -374,17 +375,17 @@ uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *leng * @param length : Pointer to data length variable * @retval Pointer to descriptor buffer */ -uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) +uint8_t * USBD_FSHS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) { UNUSED(speed); - *length = sizeof(USBD_FS_BOSDesc); - return (uint8_t*)USBD_FS_BOSDesc; + *length = sizeof(USBD_FSHS_BOSDesc); + return (uint8_t*)USBD_FSHS_BOSDesc; } #endif /* (USBD_LPM_ENABLED == 1) */ /** - * @brief Create the serial number string descriptor - * @param None + * @brief Create the serial number string descriptor + * @param None * @retval None */ static void Get_SerialNum(void) @@ -405,9 +406,9 @@ static void Get_SerialNum(void) } /** - * @brief Convert Hex 32Bits value into char + * @brief Convert Hex 32Bits value into char * @param value: value to convert - * @param pbuf: pointer to the buffer + * @param pbuf: pointer to the buffer * @param len: buffer length * @retval None */ From 931b182ffaf451562e9107e9b6a802c99fda77ec Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 6 Jan 2022 21:46:36 +0100 Subject: [PATCH 261/286] fixed expression and usb audio configurations --- OwlPedal/Inc/hardware.h | 10 ++++++---- OwlPedal/Src/OwlPedal.cpp | 12 ++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/OwlPedal/Inc/hardware.h b/OwlPedal/Inc/hardware.h index 4c95e93a..8f26c612 100644 --- a/OwlPedal/Inc/hardware.h +++ b/OwlPedal/Inc/hardware.h @@ -16,9 +16,11 @@ #define HARDWARE_VERSION "OWL Pedal" #define AUDIO_INPUT_GAIN 108 #define AUDIO_OUTPUT_GAIN 115 +#define OWL_PEDAL_LEGACY #endif #define MAX_SYSEX_BOOTLOADER_SIZE (32 * 1024) + #define EXPRESSION_MODE_EXP_TRS 1 #define EXPRESSION_MODE_EXP_RTS 2 #define EXPRESSION_MODE_FS_TS 3 // single footswitch @@ -42,8 +44,8 @@ #define AUDIO_CHANNELS 2 #define USBD_AUDIO_RX_CHANNELS AUDIO_CHANNELS #define USBD_AUDIO_TX_CHANNELS AUDIO_CHANNELS -#define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) -#define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) +#define AUDIO_INT32_TO_SAMPLE(x) (x & 0xffff) +#define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)) #define USE_USBD_AUDIO #define USE_USBD_RX_FB @@ -63,8 +65,8 @@ #define ADC_B 1 #define ADC_C 2 #define ADC_D 3 -#define ADC_E 4 -#define ADC_F 5 +#define ADC_E 5 +#define ADC_F 4 #endif #define NOF_PARAMETERS 40 diff --git a/OwlPedal/Src/OwlPedal.cpp b/OwlPedal/Src/OwlPedal.cpp index bcf7712b..3ab2708f 100644 --- a/OwlPedal/Src/OwlPedal.cpp +++ b/OwlPedal/Src/OwlPedal.cpp @@ -59,7 +59,11 @@ void setBufferedBypass(bool value){ #endif bool isBypassed(){ +#ifdef OWL_PEDAL_LEGACY + return HAL_GPIO_ReadPin(FOOTSWITCH_GPIO_Port, FOOTSWITCH_Pin) == GPIO_PIN_SET; +#else return HAL_GPIO_ReadPin(FOOTSWITCH_GPIO_Port, FOOTSWITCH_Pin) == GPIO_PIN_RESET; +#endif // todo: || getBufferedBypass() } @@ -258,6 +262,13 @@ void setGateValue(uint8_t ch, int16_t value){ void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* adc_values, size_t adc_len){ if(owl.getOperationMode() == RUN_MODE){ +#ifdef OWL_MODULAR + parameter_values[0] = (parameter_values[0]*3 + 4095 - adc_values[ADC_A])>>2; + parameter_values[1] = (parameter_values[1]*3 + 4095 - adc_values[ADC_B])>>2; + parameter_values[2] = (parameter_values[2]*3 + 4095 - adc_values[ADC_C])>>2; + parameter_values[3] = (parameter_values[3]*3 + 4095 - adc_values[ADC_D])>>2; + parameter_values[4] = (parameter_values[4]*3 + adc_values[ADC_E])>>2; +#else parameter_values[0] = (parameter_values[0]*3 + adc_values[ADC_A])>>2; parameter_values[1] = (parameter_values[1]*3 + adc_values[ADC_B])>>2; parameter_values[2] = (parameter_values[2]*3 + adc_values[ADC_C])>>2; @@ -296,6 +307,7 @@ void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* break; } } +#endif } void onSetup(){ From 04210c986d655f3b85cea11b8b63b41e8d511c82 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 7 Jan 2022 15:18:34 +0100 Subject: [PATCH 262/286] configurable for inverted expression --- OwlPedal/Inc/hardware.h | 6 ++++-- OwlPedal/Src/OwlPedal.cpp | 10 ++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/OwlPedal/Inc/hardware.h b/OwlPedal/Inc/hardware.h index 8f26c612..0434ead0 100644 --- a/OwlPedal/Inc/hardware.h +++ b/OwlPedal/Inc/hardware.h @@ -21,10 +21,12 @@ #define MAX_SYSEX_BOOTLOADER_SIZE (32 * 1024) -#define EXPRESSION_MODE_EXP_TRS 1 -#define EXPRESSION_MODE_EXP_RTS 2 +#define EXPRESSION_MODE_EXP_TRS 1 // TRS expression pedal +#define EXPRESSION_MODE_EXP_RTS 2 // TRS expression pedal #define EXPRESSION_MODE_FS_TS 3 // single footswitch #define EXPRESSION_MODE_FS_TRS 4 // dual footswitch +#define EXPRESSION_MODE_EXP_ITRS 5 // inverted TRS expression pedal +#define EXPRESSION_MODE_EXP_IRTS 6 // inverted RTS expression pedal #define EXPRESSION_MODE EXPRESSION_MODE_EXP_TRS #define OWLBOOT_MAGIC_NUMBER 0xF00B4400 diff --git a/OwlPedal/Src/OwlPedal.cpp b/OwlPedal/Src/OwlPedal.cpp index 3ab2708f..c69a6fca 100644 --- a/OwlPedal/Src/OwlPedal.cpp +++ b/OwlPedal/Src/OwlPedal.cpp @@ -278,10 +278,16 @@ void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* uint8_t buttons = 0; switch(expression_mode){ case EXPRESSION_MODE_EXP_TRS: - parameter_values[4] = (parameter_values[4]*3 + 4095-adc_values[ADC_E])>>2; + parameter_values[4] = (parameter_values[4]*3 + adc_values[ADC_E])>>2; + break; + case EXPRESSION_MODE_EXP_ITRS: + parameter_values[4] = (parameter_values[4]*3 + 4095 - adc_values[ADC_E])>>2; break; case EXPRESSION_MODE_EXP_RTS: - parameter_values[4] = (parameter_values[4]*3 + 4095-adc_values[ADC_F])>>2; + parameter_values[4] = (parameter_values[4]*3 + adc_values[ADC_F])>>2; + break; + case EXPRESSION_MODE_EXP_IRTS: + parameter_values[4] = (parameter_values[4]*3 + 4095 - adc_values[ADC_F])>>2; break; case EXPRESSION_MODE_FS_TRS: buttons = (!exp1_ring_pin.get()) << BUTTON_2; From a2ad93d1d6f5a38dbc6bb2784466879b4755fe92 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 7 Jan 2022 15:20:39 +0100 Subject: [PATCH 263/286] configure bootloaders to use SPI flash for Magus, Lich, Witch, Wizard and OWL Pedal mkII --- MidiBoot/Inc/hardware.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MidiBoot/Inc/hardware.h b/MidiBoot/Inc/hardware.h index 48d1fc76..d5966bc5 100644 --- a/MidiBoot/Inc/hardware.h +++ b/MidiBoot/Inc/hardware.h @@ -14,6 +14,7 @@ #define HARDWARE_VERSION "OWL Magus Boot" #define HARDWARE_ID MAGUS_HARDWARE #define APPLICATION_ADDRESS 0x08010000 + #define USE_SPI_FLASH #elif defined OWL_LICH #define HARDWARE_VERSION "OWL Lich Boot" #define HARDWARE_ID LICH_HARDWARE @@ -26,6 +27,7 @@ #define LED1_GPIO_Port GPIOF #define LED2_Pin GPIO_PIN_8 #define LED2_GPIO_Port GPIOF + #define USE_SPI_FLASH #elif defined OWL_WITCH #define HARDWARE_VERSION "OWL Witch Boot" #define HARDWARE_ID WITCH_HARDWARE @@ -51,6 +53,7 @@ #define LED2_Pin GPIO_PIN_1 #define LED2_GPIO_Port GPIOA #define APPLICATION_ADDRESS 0x08010000 + #define USE_SPI_FLASH #elif defined OWL_WIZARD #define HARDWARE_VERSION "OWL Wizard Boot" #define HARDWARE_ID WIZARD_HARDWARE @@ -63,6 +66,7 @@ #define LED2_Pin GPIO_PIN_1 #define LED2_GPIO_Port GPIOA #define APPLICATION_ADDRESS 0x08010000 + #define USE_SPI_FLASH #elif defined OWL_PEDAL #define HARDWARE_VERSION "OWL Pedal Boot" #define HARDWARE_ID OWL_PEDAL_HARDWARE @@ -75,6 +79,7 @@ #define LED2_Pin GPIO_PIN_9 #define LED2_GPIO_Port GPIOB #define APPLICATION_ADDRESS 0x08010000 + #define USE_SPI_FLASH #elif defined OWL_NOCTUA #define HARDWARE_VERSION "OWL Noctua Boot" #define HARDWARE_ID NOCTUA_HARDWARE From 76c0c16ddf4e01a953333c9fd42592fa4cccd352 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 7 Jan 2022 15:21:42 +0100 Subject: [PATCH 264/286] cleanup code --- Source/usbh_midi.cpp | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/Source/usbh_midi.cpp b/Source/usbh_midi.cpp index ed6e298c..3124e7ad 100644 --- a/Source/usbh_midi.cpp +++ b/Source/usbh_midi.cpp @@ -41,12 +41,9 @@ static MIDI_HandleTypeDef staticMidiHandle; static USBH_StatusTypeDef USBH_MIDI_InterfaceInit (USBH_HandleTypeDef *phost){ USBH_StatusTypeDef status = USBH_FAIL ; - uint8_t interface = 0; - MIDI_HandleTypeDef *MIDI_Handle; - //USB_MIDI_ChangeConnectionState(0); - interface = USBH_FindInterface(phost, USB_AUDIO_CLASS, USB_MIDISTREAMING_SUBCLASS, 0xFF); + uint8_t interface = USBH_FindInterface(phost, USB_AUDIO_CLASS, USB_MIDISTREAMING_SUBCLASS, 0xFF); USBH_DbgLog ("USBH InterfaceInit 0x%x", interface); if(interface == 0xFF){ @@ -55,8 +52,9 @@ static USBH_StatusTypeDef USBH_MIDI_InterfaceInit (USBH_HandleTypeDef *phost){ status = USBH_FAIL; }else{ USBH_SelectInterface (phost, interface); - phost->pActiveClass->pData = &staticMidiHandle; - MIDI_Handle = &staticMidiHandle; + MIDI_HandleTypeDef* MIDI_Handle = &staticMidiHandle; + memset(MIDI_Handle, 0, sizeof(staticMidiHandle)); + phost->pActiveClass->pData = MIDI_Handle; if(phost->device.CfgDesc.Itf_Desc[phost->device.current_interface].Ep_Desc[0].bEndpointAddress & 0x80){ MIDI_Handle->InEp = (phost->device.CfgDesc.Itf_Desc[phost->device.current_interface].Ep_Desc[0].bEndpointAddress); @@ -115,22 +113,22 @@ static USBH_StatusTypeDef USBH_MIDI_InterfaceInit (USBH_HandleTypeDef *phost){ */ USBH_StatusTypeDef USBH_MIDI_InterfaceDeInit (USBH_HandleTypeDef *phost){ USBH_DbgLog ("USBH InterfaceDeInit"); - MIDI_HandleTypeDef *MIDI_Handle = &staticMidiHandle; - - if ( MIDI_Handle->OutPipe){ - USBH_ClosePipe(phost, MIDI_Handle->OutPipe); - USBH_FreePipe (phost, MIDI_Handle->OutPipe); - MIDI_Handle->OutPipe = 0; /* Reset the Channel as Free */ - } + if(phost->pActiveClass->pData){ + MIDI_HandleTypeDef* MIDI_Handle = (MIDI_HandleTypeDef*)phost->pActiveClass->pData; - if ( MIDI_Handle->InPipe){ - USBH_ClosePipe(phost, MIDI_Handle->InPipe); - USBH_FreePipe (phost, MIDI_Handle->InPipe); - MIDI_Handle->InPipe = 0; /* Reset the Channel as Free */ - } + if ( MIDI_Handle->OutPipe){ + USBH_ClosePipe(phost, MIDI_Handle->OutPipe); + USBH_FreePipe (phost, MIDI_Handle->OutPipe); + MIDI_Handle->OutPipe = 0; /* Reset the Channel as Free */ + } + + if ( MIDI_Handle->InPipe){ + USBH_ClosePipe(phost, MIDI_Handle->InPipe); + USBH_FreePipe (phost, MIDI_Handle->InPipe); + MIDI_Handle->InPipe = 0; /* Reset the Channel as Free */ + } - if(phost->pActiveClass->pData){ - /* statically allocated in init + /* statically allocated USBH_free (phost->pActiveClass->pData); */ phost->pActiveClass->pData = NULL; } @@ -409,6 +407,7 @@ void usbh_midi_tx(uint8_t* buffer, uint32_t length){ } void USBH_MIDI_TransmitCallback(USBH_HandleTypeDef *phost){ + // tx complete callback // get ready to send some data } From c573f35dca78585b335e2c7c462e5234599f2c4a Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 7 Jan 2022 15:30:31 +0100 Subject: [PATCH 265/286] updated notes --- openware-notes.txt | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/openware-notes.txt b/openware-notes.txt index 977f316b..bb28a61e 100644 --- a/openware-notes.txt +++ b/openware-notes.txt @@ -413,7 +413,20 @@ Required to compile without missing (unused) symbols ----------------------------------------------------------------- use HAL_GetUIDw[012]() -Returns first word of the unique device identifier (UID based on 96 -bits) +Returns first word of the unique device identifier (UID based on 96 bits) ----------------------------------------------------------------- + +USB audio: +- pre fx +- post fx +- interlace + +[usb] -| |- [usb] + +- fx -+ +[adc] -| |- [dac] + +e.g. 4ch adc/dac, 4ch usb tx/rx, 8 ch fx + +----------------------------------------------------------------- + From 785b13130f8e979c580bd1f29e6ee8de80216251 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 13 Jan 2022 03:51:12 +0100 Subject: [PATCH 266/286] fixes for OWL Modular build --- OwlPedal/Makefile | 4 ++- OwlPedal/Src/OwlPedal.cpp | 52 ++++++++++++++++++++++++--------------- 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/OwlPedal/Makefile b/OwlPedal/Makefile index e61deac7..f6634659 100644 --- a/OwlPedal/Makefile +++ b/OwlPedal/Makefile @@ -20,8 +20,10 @@ else ifeq ($(PLATFORM),Modular) CPPFLAGS += -DOWL_MODULAR else ifeq ($(PLATFORM),Rack) PROJECT = OwlRack - CPPFLAGS += -IOWL_PEDAL -DOWL_RACK + CPPFLAGS += -DOWL_RACK CPP_SRC += DigitalBusHandler.cpp DigitalBusReader.cpp DigitalBusStreamReader.cpp bus.cpp +else + $(error Invalid PLATFORM=$(PLATFORM)) endif include $(OPENWARE)/Hardware/sources.mk diff --git a/OwlPedal/Src/OwlPedal.cpp b/OwlPedal/Src/OwlPedal.cpp index c69a6fca..893a9181 100644 --- a/OwlPedal/Src/OwlPedal.cpp +++ b/OwlPedal/Src/OwlPedal.cpp @@ -20,8 +20,15 @@ static int16_t knobvalues[2]; static uint8_t patchselect; #define PATCH_CONFIG_KNOB_THRESHOLD (4096/8) -#define PATCH_CONFIG_PROGRAM_CONTROL 0 -#define PATCH_CONFIG_VOLUME_CONTROL 3 +#define PATCH_CONFIG_PROGRAM_CONTROL ADC_A +#define PATCH_CONFIG_VOLUME_CONTROL ADC_D + +#ifdef OWL_MODULAR +/* analogue values A, B, C, D are inverted on OWL Modular */ +#define GET_ABCD(x) (4095 - getAnalogValue(x)) +#else +#define GET_ABCD(x) (getAnalogValue(x)) +#endif #if 0 #define SW3_Pin EXP2_T_Pin @@ -75,6 +82,7 @@ bool isPushbuttonPressed(){ ; } +#ifdef OWL_PEDAL void configureExpression(uint8_t mode){ if(mode != expression_mode){ switch(mode){ @@ -107,6 +115,7 @@ void configureExpression(uint8_t mode){ setButtonValue(BUTTON_2, false); } } +#endif void initLed(){ #ifdef OWL_PEDAL_PWM_LEDS @@ -189,8 +198,7 @@ void onChangePin(uint16_t pin){ #ifdef SW1_ALT_Pin case SW1_ALT_Pin: #endif - case SW1_Pin: - { // pushbutton + case SW1_Pin: { // pushbutton bool state = isPushbuttonPressed(); setButtonValue(PUSHBUTTON, state); setButtonValue(BUTTON_1, state); @@ -198,6 +206,15 @@ void onChangePin(uint16_t pin){ midi_tx.sendCc(PATCH_BUTTON, state ? 127 : 0); break; } +#ifdef OWL_MODULAR + case PUSH_GATE_IN_Pin: { + bool state = !(PUSH_GATE_IN_GPIO_Port->IDR & PUSH_GATE_IN_Pin); + setButtonValue(PUSHBUTTON, state); + setButtonValue(BUTTON_1, state); + setLed(0, state ? RED_COLOUR : GREEN_COLOUR); + break; + } +#endif // case SW2_Pin: { // mode button // bool state = HAL_GPIO_ReadPin(SW2_GPIO_Port, SW2_Pin) == GPIO_PIN_RESET; // setButtonValue(BUTTON_2, state); @@ -246,14 +263,6 @@ void setGateValue(uint8_t ch, int16_t value){ setLed(0, value < 512 ? NO_COLOUR : RED_COLOUR); #endif break; -#ifdef OWL_MODULAR - case PUSH_GATE_IN_Pin: { - bool isSet = !(PUSH_GATE_IN_GPIO_Port->IDR & PUSH_GATE_IN_Pin); - setButtonValue(PUSHBUTTON, isSet); - setLed(0, isSet ? RED_COLOUR : GREEN_COLOUR); - break; - } -#endif } } // if(ch == 0) @@ -312,8 +321,8 @@ void updateParameters(int16_t* parameter_values, size_t parameter_len, uint16_t* } break; } - } #endif + } } void onSetup(){ @@ -325,8 +334,9 @@ void onSetup(){ bufpass_pin.low(); setBufferedBypass(false); #endif +#ifdef OWL_PEDAL configureExpression(settings.expression_mode); - +#endif setLed(0, RED_COLOUR); MX_USB_DEVICE_Init(); @@ -345,8 +355,8 @@ void onChangeMode(uint8_t new_mode, uint8_t old_mode){ } setLed(0, NO_COLOUR); if(new_mode == CONFIGURE_MODE){ - knobvalues[0] = getAnalogValue(PATCH_CONFIG_PROGRAM_CONTROL); - knobvalues[1] = getAnalogValue(PATCH_CONFIG_VOLUME_CONTROL); + knobvalues[0] = GET_ABCD(PATCH_CONFIG_PROGRAM_CONTROL); + knobvalues[1] = GET_ABCD(PATCH_CONFIG_VOLUME_CONTROL); patchselect = program.getProgramIndex(); }else if(new_mode == RUN_MODE){ setLed(0, saved_led); // restore to saved LED state @@ -419,9 +429,9 @@ void onLoop(){ } }else{ // update patch control - if(abs(knobvalues[0] - getAnalogValue(PATCH_CONFIG_PROGRAM_CONTROL)) >= PATCH_CONFIG_KNOB_THRESHOLD){ + if(abs(knobvalues[0] - GET_ABCD(PATCH_CONFIG_PROGRAM_CONTROL)) >= PATCH_CONFIG_KNOB_THRESHOLD){ knobvalues[0] = -PATCH_CONFIG_KNOB_THRESHOLD; - float pos = 0.5f + (getAnalogValue(PATCH_CONFIG_PROGRAM_CONTROL) * (registry.getNumberOfPatches() - 1)) / 4096.0f; + float pos = 0.5f + (GET_ABCD(PATCH_CONFIG_PROGRAM_CONTROL) * (registry.getNumberOfPatches() - 1)) / 4096.0f; uint8_t idx = roundf(pos); if(abs(patchselect - pos) > 0.6 && registry.hasPatch(idx)){ // ensure a small dead zone patchselect = idx; @@ -431,9 +441,9 @@ void onLoop(){ } } // update volume control - if(abs(knobvalues[1] - getAnalogValue(PATCH_CONFIG_VOLUME_CONTROL)) >= PATCH_CONFIG_KNOB_THRESHOLD){ + if(abs(knobvalues[1] - GET_ABCD(PATCH_CONFIG_VOLUME_CONTROL)) >= PATCH_CONFIG_KNOB_THRESHOLD){ knobvalues[1] = -PATCH_CONFIG_KNOB_THRESHOLD; - uint8_t value = (getAnalogValue(PATCH_CONFIG_VOLUME_CONTROL) >> 6) + 63; + uint8_t value = (GET_ABCD(PATCH_CONFIG_VOLUME_CONTROL) >> 6) + 63; if(settings.audio_output_gain != value){ settings.audio_output_gain = value; codec.setOutputGain(value); @@ -471,5 +481,7 @@ void onLoop(){ counter = PATCH_RESET_COUNTER; break; } +#ifdef OWL_PEDAL configureExpression(settings.expression_mode); +#endif } From 3c78b1ff61859df8f9126d32d1674e31ff4f2562 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 13 Jan 2022 17:08:03 +0100 Subject: [PATCH 267/286] correct CPU reading for Magus3 --- Source/MagusParameterController.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/MagusParameterController.hpp b/Source/MagusParameterController.hpp index 48434cbf..6c91762c 100644 --- a/Source/MagusParameterController.hpp +++ b/Source/MagusParameterController.hpp @@ -468,7 +468,11 @@ class ErrorPage : public Page { // draw CPU load screen.print(110, offset+8, "cpu"); screen.setCursor(110, offset+17); +#ifdef STM32H7xx + screen.print((int)((pv->cycles_per_block)/pv->audio_blocksize)/100); +#else screen.print((int)((pv->cycles_per_block)/pv->audio_blocksize)/35); +#endif screen.print("%"); } }; From 9af8d0843f432ae14927d4d72db2e91016faa444 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 13 Jan 2022 17:47:21 +0100 Subject: [PATCH 268/286] check for invalid flags --- MidiBoot/Makefile | 2 ++ MidiBoot3/Makefile | 2 ++ MidiBootOwl/Makefile | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/MidiBoot/Makefile b/MidiBoot/Makefile index e3bf4d02..b3d4806a 100644 --- a/MidiBoot/Makefile +++ b/MidiBoot/Makefile @@ -58,6 +58,8 @@ else ifeq ($(PLATFORM),Noctua) else ifeq ($(PLATFORM),BioSignals) CPPFLAGS += -Iusbd-hs -DOWL_BIOSIGNALS -DUSE_USBD_HS vpath %.c usbd-hs +else + $(error Invalid PLATFORM=$(PLATFORM)) endif CPP_SRC += $(OPENWARE)/Source/MidiController.cpp diff --git a/MidiBoot3/Makefile b/MidiBoot3/Makefile index 3312f974..ce93a408 100644 --- a/MidiBoot3/Makefile +++ b/MidiBoot3/Makefile @@ -30,6 +30,8 @@ ifeq ($(PLATFORM),Genius) else ifeq ($(PLATFORM),Magus) CPPFLAGS += -Iusbd-fs -DOWL_MAGUS -DUSE_USBD_FS vpath %.c usbd-fs +else + $(error Invalid PLATFORM=$(PLATFORM)) endif CPP_SRC += $(OPENWARE)/Source/MidiController.cpp diff --git a/MidiBootOwl/Makefile b/MidiBootOwl/Makefile index 3cf44e26..2aa4e2bd 100644 --- a/MidiBootOwl/Makefile +++ b/MidiBootOwl/Makefile @@ -33,6 +33,8 @@ else ifeq ($(PLATFORM),Modular) else ifeq ($(PLATFORM),Rack) CPPFLAGS += -Iusbd-fs -IOWL_PEDAL -DOWL_RACK # vpath %.c usbd-fs +else + $(error Invalid PLATFORM=$(PLATFORM)) endif C_SRC += $(C_SRC_SRAM) @@ -42,8 +44,6 @@ C_SRC += $(C_SRC_IWDG) include $(OPENWARE)/Hardware/f4.mk -DFUCMD = $(DFUUTIL) -d 0483:df11 -c 1 -i 0 -a 0 - .PHONY: clean deploy unlock erase upload lock info: From 7efd553da39a95cdd9dda15da806c7e998175004 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 13 Jan 2022 17:47:26 +0100 Subject: [PATCH 269/286] check for invalid flags --- Hardware/owl1.mk | 5 +++-- Hardware/owl2.mk | 5 +++-- Hardware/owl3.mk | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Hardware/owl1.mk b/Hardware/owl1.mk index a47f585e..5c7ae8b5 100644 --- a/Hardware/owl1.mk +++ b/Hardware/owl1.mk @@ -4,11 +4,12 @@ ifeq ($(CONFIG),Debug) CPPFLAGS = -g3 -Wall -Wcpp -Wunused-function -DDEBUG # -DUSE_FULL_ASSERT ASFLAGS = -g3 CFLAGS = -g3 -endif -ifeq ($(CONFIG),Release) +else ifeq ($(CONFIG),Release) CPPFLAGS = -O2 ASFLAGS = -O2 CFLAGS = -O2 +else + $(error Invalid CONFIG=$(CONFIG)) endif # compile with semihosting if Debug is selected diff --git a/Hardware/owl2.mk b/Hardware/owl2.mk index 02ff048c..f4bc10b9 100644 --- a/Hardware/owl2.mk +++ b/Hardware/owl2.mk @@ -4,11 +4,12 @@ ifeq ($(CONFIG),Debug) CPPFLAGS = -g3 -Wall -Wcpp -Wunused-function -DDEBUG # -DUSE_FULL_ASSERT ASFLAGS = -g3 CFLAGS = -g3 -endif -ifeq ($(CONFIG),Release) +else ifeq ($(CONFIG),Release) CPPFLAGS = -O2 ASFLAGS = -O2 CFLAGS = -O2 +else + $(error Invalid CONFIG=$(CONFIG)) endif # compile with semihosting if Debug is selected diff --git a/Hardware/owl3.mk b/Hardware/owl3.mk index 9ed4cbc0..f74f91e7 100644 --- a/Hardware/owl3.mk +++ b/Hardware/owl3.mk @@ -4,11 +4,12 @@ ifeq ($(CONFIG),Debug) CPPFLAGS = -g3 -Wall -Wcpp -Wunused-function -DDEBUG # -DUSE_FULL_ASSERT ASFLAGS = -g3 CFLAGS = -g3 -endif -ifeq ($(CONFIG),Release) +else ifeq ($(CONFIG),Release) CPPFLAGS = -O2 ASFLAGS = -O2 CFLAGS = -O2 +else + $(error Invalid CONFIG=$(CONFIG)) endif # compile with semihosting if Debug is selected From 1b58223849023d2af9932f55bf4a92db715f4eed Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 13 Jan 2022 17:48:12 +0100 Subject: [PATCH 270/286] DFU flash target, swapped leds --- ACDC/Core/Src/ACDC.cpp | 14 +++++++------- ACDC/Makefile | 4 ++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ACDC/Core/Src/ACDC.cpp b/ACDC/Core/Src/ACDC.cpp index a6544a84..f4c568af 100644 --- a/ACDC/Core/Src/ACDC.cpp +++ b/ACDC/Core/Src/ACDC.cpp @@ -51,10 +51,10 @@ void setLed(uint8_t led, uint32_t rgb){ case 1: if(rgb == RED_COLOUR){ led_clip1.low(); - TIM3->CCR2 = 0xFFFFFFFFU; + TIM2->CCR1 = 0xFFFFFFFFU; }else{ led_clip1.high(); - TIM3->CCR2 = pwm; + TIM2->CCR1 = pwm; } break; case 2: @@ -69,10 +69,10 @@ void setLed(uint8_t led, uint32_t rgb){ case 3: if(rgb == RED_COLOUR){ led_clip3.low(); - TIM2->CCR1 = 0xFFFFFFFFU; + TIM3->CCR2 = 0xFFFFFFFFU; }else{ led_clip3.high(); - TIM2->CCR1 = pwm; + TIM3->CCR2 = pwm; } break; case 4: @@ -115,10 +115,10 @@ void initLed(){ HAL_TIM_Base_Start(&htim3); HAL_TIM_Base_Start(&htim4); HAL_TIM_Base_Start(&htim8); - HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1); // in3 + HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1); // in1 HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2); // in4 HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_4); // in2 - HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_2); // in1 + HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_2); // in3 HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_1); // out3 HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_2); // out4 HAL_TIM_PWM_Start(&htim8, TIM_CHANNEL_1); // out1 @@ -140,7 +140,7 @@ void onSetup(){ void onLoop(void){ for(size_t i=0; i<4; ++i){ int16_t value = getParameterValue(PARAMETER_AA+i); - setLed(i+1, value >= 4095 ? RED_COLOUR : value); + setLed(i+1, value >= 4000 ? RED_COLOUR : value); setLed(i+5, getParameterValue(PARAMETER_BA+i)); } } diff --git a/ACDC/Makefile b/ACDC/Makefile index 1b0033b6..07a099a6 100644 --- a/ACDC/Makefile +++ b/ACDC/Makefile @@ -42,3 +42,7 @@ C_SRC += $(C_SRC_QSPI) C_SRC += $(C_SRC_MDMA) include $(OPENWARE)/Hardware/h7.mk + +dfu: Build/${PROJECT}.bin + $(DFUUTIL) -d 0483:df11 -c 1 -i 0 -a 0 -s 0x8000000 -D $< + @echo Uploaded $< to Xibeca bootsector From 25070e7a60fbd382754660a0ae5c384702b33e2b Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 13 Jan 2022 17:48:35 +0100 Subject: [PATCH 271/286] updated comment --- Source/ResourceHeader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ResourceHeader.h b/Source/ResourceHeader.h index 9e9db65a..1ae5e0bb 100644 --- a/Source/ResourceHeader.h +++ b/Source/ResourceHeader.h @@ -8,7 +8,7 @@ #endif struct ResourceHeader { - uint32_t magic; // 0xDADADEED for resources, 0xDADAC0DE for patches + uint32_t magic; // 0xDADADEED for resources uint32_t size; char name[20]; uint32_t flags; From 0a03794b96112fdf9ad1ce3e13a32c7d5fce2e99 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 13 Jan 2022 17:48:45 +0100 Subject: [PATCH 272/286] removed comments --- openware-notes.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/openware-notes.txt b/openware-notes.txt index bb28a61e..8f17ccd0 100644 --- a/openware-notes.txt +++ b/openware-notes.txt @@ -412,11 +412,6 @@ Required to compile without missing (unused) symbols ----------------------------------------------------------------- -use HAL_GetUIDw[012]() -Returns first word of the unique device identifier (UID based on 96 bits) - ------------------------------------------------------------------ - USB audio: - pre fx - post fx From 4c9301a8a0c482b981b08bad152fda88ce0520ee Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 13 Jan 2022 18:04:05 +0100 Subject: [PATCH 273/286] updated targets --- Tools/dist.sh | 4 +++- Tools/makeprojects.py | 6 +++--- dist.sh | 10 ---------- 3 files changed, 6 insertions(+), 14 deletions(-) delete mode 100755 dist.sh diff --git a/Tools/dist.sh b/Tools/dist.sh index 576e4d25..b727cc3e 100755 --- a/Tools/dist.sh +++ b/Tools/dist.sh @@ -1,10 +1,12 @@ #!/bin/bash mkdir -p dist # make syx files -for nm in Lich Wizard Alchemist Magus Witch +for nm in Alchemist Wizard Magus Lich Witch OwlPedal2 do make -C $nm clean all sysex && cp $nm/Build/$nm.syx dist done # make OWL Pedal and OWL Modular bin and syx files make -C OwlPedal PLATFORM=Pedal clean all sysex && cp OwlPedal/Build/OwlPedal.{syx,bin} dist make -C OwlPedal PLATFORM=Modular clean all sysex && cp OwlPedal/Build/OwlModular.{syx,bin} dist +make -C MidiBootOwl PLATFORM=Pedal clean all sysex && cp MidiBootOwl/Build/MidiBoot-Pedal.{syx,bin} dist +make -C MidiBootOwl PLATFORM=Modular clean all sysex && cp MidiBootOwl/Build/MidiBoot-Modular.{syx,bin} dist diff --git a/Tools/makeprojects.py b/Tools/makeprojects.py index 4a702b62..f8ab6593 100755 --- a/Tools/makeprojects.py +++ b/Tools/makeprojects.py @@ -13,9 +13,9 @@ } ], 'MidiBoot': [ - 'Alchemist', 'Wizard', 'Magus', 'Lich', 'Noctua', - 'BioSignals', 'Witch' - #'Effectsbox' - won't build bootloader + 'Alchemist', 'Wizard', 'Magus', 'Lich', 'Witch', 'Pedal=OwlPedal2' + # 'Noctua', 'BioSignals', not needed + # 'Effectsbox' won't build bootloader ], 'MidiBoot3': [ 'Genius' diff --git a/dist.sh b/dist.sh deleted file mode 100755 index 576e4d25..00000000 --- a/dist.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -mkdir -p dist -# make syx files -for nm in Lich Wizard Alchemist Magus Witch -do - make -C $nm clean all sysex && cp $nm/Build/$nm.syx dist -done -# make OWL Pedal and OWL Modular bin and syx files -make -C OwlPedal PLATFORM=Pedal clean all sysex && cp OwlPedal/Build/OwlPedal.{syx,bin} dist -make -C OwlPedal PLATFORM=Modular clean all sysex && cp OwlPedal/Build/OwlModular.{syx,bin} dist From c8f15d4db001fcb3bff1c8a2405cff8ea695bb2b Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Thu, 13 Jan 2022 18:06:56 +0100 Subject: [PATCH 274/286] fixed OwlPedal2 target --- Tools/makeprojects.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tools/makeprojects.py b/Tools/makeprojects.py index f8ab6593..498c6d3c 100755 --- a/Tools/makeprojects.py +++ b/Tools/makeprojects.py @@ -13,7 +13,8 @@ } ], 'MidiBoot': [ - 'Alchemist', 'Wizard', 'Magus', 'Lich', 'Witch', 'Pedal=OwlPedal2' + 'Alchemist', 'Wizard', 'Magus', 'Lich', 'Witch', + { 'OwlPedal2': ['Pedal=OwlPedal2'] } # 'Noctua', 'BioSignals', not needed # 'Effectsbox' won't build bootloader ], From a511a44aa2add2958b6e53c601acb7e781896658 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 14 Jan 2022 17:13:46 +0100 Subject: [PATCH 275/286] ensure rx/tx isn't disabled during sample conversion --- Source/ProgramManager.cpp | 96 +++++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 45 deletions(-) diff --git a/Source/ProgramManager.cpp b/Source/ProgramManager.cpp index 4c6e2cad..f4a3b63e 100644 --- a/Source/ProgramManager.cpp +++ b/Source/ProgramManager.cpp @@ -76,72 +76,78 @@ void usbd_audio_rx_stop_callback(){ } void usbd_rx_convert(int32_t* dst, size_t len){ - usbd_audio_rx_count += len; - size_t cap = usbd_rx->getReadCapacity(); - if(cap < len){ - // rx buffer underflow - memset(dst+cap, 0, (len - cap)*sizeof(int32_t)); - len = cap; + CircularBuffer* rx = usbd_rx; + if(rx){ + usbd_audio_rx_count += len; + size_t cap = rx->getReadCapacity(); + if(cap < len){ + // rx buffer underflow + memset(dst+cap, 0, (len - cap)*sizeof(int32_t)); + len = cap; #ifdef DEBUG_USBD_AUDIO - debugMessage("rx unf", (int)(len - cap)); + debugMessage("rx unf", (int)(len - cap)); #endif - } + } #if USBD_AUDIO_RX_CHANNELS == AUDIO_CHANNELS #if AUDIO_BITS_PER_SAMPLE == 32 - usbd_rx->read(dst, len); + rx->read(dst, len); #else - while(len--) - *dst++ = AUDIO_SAMPLE_TO_INT32(usbd_rx->read()); + while(len--) + *dst++ = AUDIO_SAMPLE_TO_INT32(rx->read()); #endif #else /* USBD_AUDIO_RX_CHANNELS != AUDIO_CHANNELS */ - len /= AUDIO_CHANNELS; - while(len--){ + len /= AUDIO_CHANNELS; + while(len--){ #if AUDIO_BITS_PER_SAMPLE == 32 - usbd_rx->read(dst, USBD_AUDIO_RX_CHANNELS); - dst += AUDIO_CHANNELS; + rx->read(dst, USBD_AUDIO_RX_CHANNELS); + dst += AUDIO_CHANNELS; #else - audio_t* src = usbd_rx->getReadHead(); - for(int ch=0; chmoveReadHead(USBD_AUDIO_RX_CHANNELS); - dst += AUDIO_CHANNELS - USBD_AUDIO_RX_CHANNELS; + audio_t* src = rx->getReadHead(); + for(int ch=0; chmoveReadHead(USBD_AUDIO_RX_CHANNELS); + dst += AUDIO_CHANNELS - USBD_AUDIO_RX_CHANNELS; #endif - } + } #endif + } } void usbd_tx_convert(int32_t* src, size_t len){ - size_t cap = usbd_tx->getWriteCapacity() - USBD_AUDIO_TX_CHANNELS; - // leave a bit of space to prevent wrapping read/write pointers - if(cap < len){ - // tx buffer overflow - len = cap; + CircularBuffer* tx = usbd_tx; + if(tx){ + size_t cap = tx->getWriteCapacity() - USBD_AUDIO_TX_CHANNELS; + // leave a bit of space to prevent wrapping read/write pointers + if(cap < len){ + // tx buffer overflow + len = cap; #ifdef DEBUG_USBD_AUDIO - debugMessage("tx ovf", (int)(len - cap)); + debugMessage("tx ovf", (int)(len - cap)); #endif - } + } #if USBD_AUDIO_TX_CHANNELS == AUDIO_CHANNELS #if AUDIO_BITS_PER_SAMPLE == 32 - usbd_tx->write(src, len); + tx->write(src, len); #else - while(len--) - usbd_tx->write(AUDIO_INT32_TO_SAMPLE(*src++)); + while(len--) + tx->write(AUDIO_INT32_TO_SAMPLE(*src++)); #endif #else /* USBD_AUDIO_TX_CHANNELS != AUDIO_CHANNELS */ - len /= AUDIO_CHANNELS; - while(len--){ + len /= AUDIO_CHANNELS; + while(len--){ #if AUDIO_BITS_PER_SAMPLE == 32 - usbd_tx->write(src, USBD_AUDIO_TX_CHANNELS); - src += AUDIO_CHANNELS; + tx->write(src, USBD_AUDIO_TX_CHANNELS); + src += AUDIO_CHANNELS; #else - audio_t* dst = usbd_tx->getWriteHead(); - for(int ch=0; chmoveWriteHead(USBD_AUDIO_TX_CHANNELS); - src += AUDIO_CHANNELS - USBD_AUDIO_TX_CHANNELS; + audio_t* dst = tx->getWriteHead(); + for(int ch=0; chmoveWriteHead(USBD_AUDIO_TX_CHANNELS); + src += AUDIO_CHANNELS - USBD_AUDIO_TX_CHANNELS; #endif - } + } #endif + } } #endif /* USE_USBD_AUDIO */ @@ -259,12 +265,12 @@ void setButtonValue(uint8_t ch, uint8_t value){ void onProgramReady(){ ProgramVector* pv = getProgramVector(); #ifdef USE_USBD_AUDIO_TX - if(usbd_tx) // after patch runs: convert patch output to USBD audio tx - usbd_tx_convert(pv->audio_output, pv->audio_blocksize*AUDIO_CHANNELS); + // after patch runs: convert patch output to USBD audio tx + usbd_tx_convert(pv->audio_output, pv->audio_blocksize*AUDIO_CHANNELS); #endif #ifdef USE_USBD_AUDIO_RX - if(usbd_rx) // after patch runs: convert USBD audio rx to DAC (overwriting patch output) - usbd_rx_convert(pv->audio_output, pv->audio_blocksize*AUDIO_CHANNELS); + // after patch runs: convert USBD audio rx to DAC (overwriting patch output) + usbd_rx_convert(pv->audio_output, pv->audio_blocksize*AUDIO_CHANNELS); #endif #ifdef DEBUG_DWT pv->cycles_per_block = DWT->CYCCNT; From d76605deb3f37e450c2365d095cfb3df066cff7f Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 14 Jan 2022 17:14:27 +0100 Subject: [PATCH 276/286] don't update display mode on reset. --- Genius/Inc/GeniusParameterController.hpp | 13 ++++++------- Source/MagusParameterController.hpp | 3 --- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Genius/Inc/GeniusParameterController.hpp b/Genius/Inc/GeniusParameterController.hpp index 3183b551..9eaf50ff 100644 --- a/Genius/Inc/GeniusParameterController.hpp +++ b/Genius/Inc/GeniusParameterController.hpp @@ -88,7 +88,6 @@ class GeniusParameterController : public ParameterController { for(int i=0; iencoderChanged(encoder, current, previous); } - // update value with encoder - void setUserValue(uint8_t ch, int16_t value){ - if(ch < NOF_ADC_VALUES){ - user[ch] = value; + void setValue(uint8_t pid, int16_t value){ + if(pid < NOF_ADC_VALUES){ + user[pid] = value; }else{ - parameters[ch] = value; + parameters[pid] = value; } } + int16_t getUserValue(uint8_t ch){ if(ch < NOF_ADC_VALUES) return user[ch]; @@ -343,7 +342,7 @@ class StandardPage : public Page { uint8_t select = encoder == 0 ? selectOnePage.select : selectTwoPage.select; int16_t value = getContinuousEncoderValue(current, previous); value = std::clamp(params.getUserValue(select) + value, 0, 4095); - params.setUserValue(select, value); + params.setValue(select, value); } void draw(ScreenBuffer& screen){ if(sw1()){ diff --git a/Source/MagusParameterController.hpp b/Source/MagusParameterController.hpp index 6c91762c..ead5b9fb 100644 --- a/Source/MagusParameterController.hpp +++ b/Source/MagusParameterController.hpp @@ -154,9 +154,6 @@ class MagusParameterController : public ParameterController { selectedPid[3] = PARAMETER_C; selectedPid[4] = PARAMETER_E; selectedPid[5] = PARAMETER_G; - - setDisplayMode(PROGRESS_DISPLAY_MODE); - #ifdef OWL_MAGUS for(int i=0; i<20; ++i) setPortMode(i, PORT_UNI_INPUT); From 34765a616b126e9ce1745fd862e8f479725c4630 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Fri, 14 Jan 2022 21:22:16 +0100 Subject: [PATCH 277/286] ensure display mode is initialised --- Source/MagusParameterController.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/MagusParameterController.hpp b/Source/MagusParameterController.hpp index ead5b9fb..438bc032 100644 --- a/Source/MagusParameterController.hpp +++ b/Source/MagusParameterController.hpp @@ -141,6 +141,10 @@ class MagusParameterController : public ParameterController { uint8_t selectedBlock; uint8_t selectedPid[NOF_ENCODERS]; + MagusParameterController(){ + setDisplayMode(PROGRESS_DISPLAY_MODE); + } + void reset(){ setTitle("Magus"); ParameterController::reset(); @@ -465,11 +469,7 @@ class ErrorPage : public Page { // draw CPU load screen.print(110, offset+8, "cpu"); screen.setCursor(110, offset+17); -#ifdef STM32H7xx - screen.print((int)((pv->cycles_per_block)/pv->audio_blocksize)/100); -#else - screen.print((int)((pv->cycles_per_block)/pv->audio_blocksize)/35); -#endif + screen.print((int)((pv->cycles_per_block)/pv->audio_blocksize)/(ARM_CYCLES_PER_SAMPLE/100)); screen.print("%"); } }; From 522f28480c717c4499b24b4f21039a4f07b93a89 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Sat, 15 Jan 2022 01:34:58 +0100 Subject: [PATCH 278/286] Wait for and reset iwdg timer when initialising (in case it is not done in bootloader). Update boot magic right before reset. --- Source/Owl.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Source/Owl.cpp b/Source/Owl.cpp index 81c237d4..c1384891 100644 --- a/Source/Owl.cpp +++ b/Source/Owl.cpp @@ -85,11 +85,15 @@ void Owl::setup(void){ IWDG1->KR = 0x5555; // ensure watchdog register write is allowed IWDG1->PR = 0x05; // prescaler 128 IWDG1->RLR = 0x753; // reload 8 seconds + while(IWDG1->SR != 0x00u); // wait to count down + IWDG1->KR = 0xaaaa; // reset the watchdog timer #else IWDG->KR = 0xCCCC; // Enable IWDG and turn on LSI IWDG->KR = 0x5555; // ensure watchdog register write is allowed IWDG->PR = 0x05; // prescaler 128 IWDG->RLR = 0x753; // reload 8 seconds + while(IWDG->SR != 0x00u); // wait to count down + IWDG->KR = 0xaaaa; // reset the watchdog timer #endif #endif #ifdef USE_BKPSRAM @@ -184,12 +188,7 @@ void Owl::loop(){ #ifdef USE_DIGITALBUS busstatus = bus_status(); #endif -#ifdef OLED_DMA - // When using OLED_DMA this must delay for a minimum amount to allow screen to update - vTaskDelay(xFrequency); -#else vTaskDelayUntil(&xLastWakeTime, xFrequency); -#endif #ifdef USE_IWDG #ifdef STM32H7xx IWDG1->KR = 0xaaaa; // reset the watchdog timer (if enabled) @@ -219,7 +218,6 @@ void jump_to_bootloader(void){ // extern USBD_HandleTypeDef USBD_HANDLE; // USBD_DeInit(&USBD_HANDLE); // #endif - *OWLBOOT_MAGIC_ADDRESS = OWLBOOT_MAGIC_NUMBER; #ifdef USE_BKPSRAM extern RTC_HandleTypeDef hrtc; HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_DR1, 0); @@ -230,13 +228,13 @@ void jump_to_bootloader(void){ #else RCC->CIR = 0x00000000; #endif + *OWLBOOT_MAGIC_ADDRESS = OWLBOOT_MAGIC_NUMBER; NVIC_SystemReset(); /* Shouldn't get here */ while(1); } void device_reset(){ - *OWLBOOT_MAGIC_ADDRESS = 0; #ifdef USE_BKPSRAM extern RTC_HandleTypeDef hrtc; HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_DR1, 0); @@ -247,6 +245,7 @@ void device_reset(){ #else RCC->CIR = 0x00000000; #endif + *OWLBOOT_MAGIC_ADDRESS = 0; NVIC_SystemReset(); /* Shouldn't get here */ while(1); From ae786a5dc5ec88205947071b37ea2ae4e10d1414 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Sat, 15 Jan 2022 01:35:45 +0100 Subject: [PATCH 279/286] check for low power and brownout resets --- MidiBoot/Inc/hardware.h | 3 --- MidiBoot/Src/main.c | 16 +++++++++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/MidiBoot/Inc/hardware.h b/MidiBoot/Inc/hardware.h index d5966bc5..4e4eb29a 100644 --- a/MidiBoot/Inc/hardware.h +++ b/MidiBoot/Inc/hardware.h @@ -95,6 +95,3 @@ #else #error Invalid configuration #endif - -/* #define USE_IWDG */ -/* #define INIT_FMC */ diff --git a/MidiBoot/Src/main.c b/MidiBoot/Src/main.c index 7123715c..b9beb1c8 100644 --- a/MidiBoot/Src/main.c +++ b/MidiBoot/Src/main.c @@ -100,6 +100,16 @@ static int testWatchdogReset(){ return __HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) != RESET; } +static int testPowerLowReset(){ + return __HAL_RCC_GET_FLAG(RCC_FLAG_LPWRRST) != RESET; +} + +static int testBrownOutReset(){ + return __HAL_RCC_GET_FLAG(RCC_FLAG_BORRST) != RESET && // Power down or Brown out + __HAL_RCC_GET_FLAG(RCC_FLAG_PORRST) == RESET; // Not power down + +} + /* USER CODE END PFP */ /* Private user code ---------------------------------------------------------*/ @@ -138,9 +148,13 @@ int main(void) }else if(testButton()){ setMessage("Bootloader requested"); }else if(testLoop()){ - error(RUNTIME_ERROR, "Unexpected firmware reset"); + error(RUNTIME_ERROR, "Unexpected reset"); }else if(testWatchdogReset()){ error(RUNTIME_ERROR, "Watchdog reset"); + }else if(testPowerLowReset()){ + error(RUNTIME_ERROR, "Low power reset"); + }else if(testBrownOutReset()){ + error(RUNTIME_ERROR, "Brown out reset"); }else if(testNoProgram()){ error(RUNTIME_ERROR, "No valid firmware"); }else{ From 182fcea3e618ae06655e646e046267a5f1f8ce83 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Sat, 15 Jan 2022 01:50:31 +0100 Subject: [PATCH 280/286] cleanup --- Source/MagusParameterController.hpp | 45 ++++------------------------- 1 file changed, 5 insertions(+), 40 deletions(-) diff --git a/Source/MagusParameterController.hpp b/Source/MagusParameterController.hpp index 438bc032..46e3fb23 100644 --- a/Source/MagusParameterController.hpp +++ b/Source/MagusParameterController.hpp @@ -748,49 +748,14 @@ class StatusPage : public Page { screen.print(1, offset + 17, "cpu "); screen.print((int)((pv->cycles_per_block) / pv->audio_blocksize) / 35); screen.print("%"); - + // draw firmware version screen.print(1, offset+26, getFirmwareVersion()); - if (bootloader_token->magic == BOOTLOADER_MAGIC){ - screen.print(" (bt."); - screen.print(getBootloaderVersion()); - screen.print(")"); - } +#ifdef DEBUG_BOOTLOADER + if (bootloader_token->magic == BOOTLOADER_MAGIC) + screen.print(1, offset+35, getBootloaderVersion()); +#endif } - -// void drawStats(ScreenBuffer& screen){ -// screen.setTextSize(1); -// ProgramVector* pv = getProgramVector(); -// if(pv->message != NULL) -// screen.print(2, 16, pv->message); -// screen.print(2, 26, "cpu/mem: "); -// float percent = (pv->cycles_per_block/pv->audio_blocksize) / (float)ARM_CYCLES_PER_SAMPLE; -// screen.print((int)(percent*100)); -// screen.print("% "); -// screen.print((int)(pv->heap_bytes_used)/1024); -// screen.print("kB"); -// // draw firmware version -// screen.print(1, 36, getFirmwareVersion()); -// if (bootloader_token->magic == BOOTLOADER_MAGIC){ -// screen.print(" bt."); -// screen.print(getBootloaderVersion()); -// } -// #ifdef USE_DIGITALBUS -// screen.print(1, 56, "Bus: "); -// screen.print(bus.getStatusString()); -// screen.print(" "); -// extern uint32_t bus_tx_packets, bus_rx_packets; -// screen.print((int)bus_tx_packets); -// screen.print("/"); -// screen.print((int)bus_rx_packets); -// if (bus.getStatus() == BUS_STATUS_CONNECTED) { -// screen.print(", "); -// screen.print(bus.getPeers()); -// screen.print(" peers"); -// } -// #endif -// } -}; class ProgressPage : public Page { void draw(ScreenBuffer& screen){ From 1f6d3b1bfabe4bc89dd818220de127c9bd2454a6 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Sat, 15 Jan 2022 01:50:41 +0100 Subject: [PATCH 281/286] config comments --- Magus3/Inc/hardware.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Magus3/Inc/hardware.h b/Magus3/Inc/hardware.h index 904422c9..11e31232 100644 --- a/Magus3/Inc/hardware.h +++ b/Magus3/Inc/hardware.h @@ -35,7 +35,8 @@ #define AUDIO_INT32_TO_SAMPLE(x) ((x)>>8) #define AUDIO_SAMPLE_TO_INT32(x) ((int32_t)(x)<<8) -/* #define MAIN_LOOP_SLEEP_MS 2 */ +/* #define SCREEN_LOOP_SLEEP_MS 20 /\* 40mS = 25 fps *\/ */ +/* #define MAIN_LOOP_SLEEP_MS 5 /\* 2mS = 500 Hz *\/ */ #define ARM_CYCLES_PER_SAMPLE (480000000/AUDIO_SAMPLINGRATE) /* 480MHz / 48kHz */ #define USE_USBD_AUDIO From d1336b7fe3e5efa06d3754fa4e46e3d9ceb402cf Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Sat, 15 Jan 2022 01:50:56 +0100 Subject: [PATCH 282/286] removed irrelevant comment --- Source/ProgramManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ProgramManager.cpp b/Source/ProgramManager.cpp index f4a3b63e..6b50a2b5 100644 --- a/Source/ProgramManager.cpp +++ b/Source/ProgramManager.cpp @@ -518,7 +518,7 @@ __weak void onStartProgram(){ void runScreenTask(void* p){ TickType_t xLastWakeTime; TickType_t xFrequency; - xFrequency = SCREEN_LOOP_SLEEP_MS / portTICK_PERIOD_MS; // 20mS = 50Hz refresh rate + xFrequency = SCREEN_LOOP_SLEEP_MS / portTICK_PERIOD_MS; xLastWakeTime = xTaskGetTickCount(); for(;;){ vTaskDelayUntil(&xLastWakeTime, xFrequency); From 93dd9cad818e33e84ebe1be1a8851446c2be9a6e Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Sat, 15 Jan 2022 03:03:11 +0100 Subject: [PATCH 283/286] removed redundant flash target --- BioSignals/Makefile | 3 --- 1 file changed, 3 deletions(-) diff --git a/BioSignals/Makefile b/BioSignals/Makefile index 5ee67eec..1a7776a8 100644 --- a/BioSignals/Makefile +++ b/BioSignals/Makefile @@ -21,6 +21,3 @@ C_SRC += $(C_SRC_I2S) C_SRC += $(C_SRC_RTC) include $(OPENWARE)/Hardware/f4.mk - -flash: - openocd -f openocd.cfg -c "program Build/$(PROJECT).elf verify reset exit" From 606b5e5b131def9199f12c853b8ffc3055022468 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Sat, 15 Jan 2022 03:03:43 +0100 Subject: [PATCH 284/286] fix misedit --- Source/MagusParameterController.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/MagusParameterController.hpp b/Source/MagusParameterController.hpp index 46e3fb23..d438a30d 100644 --- a/Source/MagusParameterController.hpp +++ b/Source/MagusParameterController.hpp @@ -756,7 +756,8 @@ class StatusPage : public Page { screen.print(1, offset+35, getBootloaderVersion()); #endif } - +}; + class ProgressPage : public Page { void draw(ScreenBuffer& screen){ drawLoadProgress(screen); From b84c2f36256e508d86326c7afaa234ace3b65e76 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Sat, 15 Jan 2022 04:04:23 +0100 Subject: [PATCH 285/286] use new callbacks --- Lich/Src/Lich.cpp | 39 ++++++++++++--------------------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/Lich/Src/Lich.cpp b/Lich/Src/Lich.cpp index cffc5867..2a28ed5a 100644 --- a/Lich/Src/Lich.cpp +++ b/Lich/Src/Lich.cpp @@ -56,7 +56,6 @@ Pin seg_pins[8] = Pin(DISPLAY_DP_GPIO_Port, DISPLAY_DP_Pin), }; -// set value to 10 for no display static void setSegmentDisplay(int value, bool dot=false){ seg_pins[7].set(!dot); // HAL_GPIO_WritePin(seg_ports[7], seg_pins[7], dot ? GPIO_PIN_RESET : GPIO_PIN_SET); @@ -138,11 +137,10 @@ void setEncoderValue(int value){ __HAL_TIM_SET_COUNTER(&htim2, value<<2); } -void setup(){ +void onSetup(){ // __HAL_TIM_SET_COUNTER(&htim2, INT16_MAX/2); HAL_TIM_Encoder_Start(&htim2, TIM_CHANNEL_ALL); setSegmentDisplay(SEG_DISPLAY_L, true); - owl.setup(); setEncoderValue(program.getProgramIndex()); setLed(1, 0); setLed(2, 0); @@ -162,7 +160,17 @@ void onChangeMode(uint8_t new_mode, uint8_t old_mode){ setEncoderValue(patchselect); } -static void update_preset(){ +extern "C" { + void usbh_midi_reset(void){ + HAL_GPIO_WritePin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin, GPIO_PIN_RESET); + HAL_Delay(100); // wait 100mS + HAL_GPIO_WritePin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin, GPIO_PIN_SET); + // extern USBH_HandleTypeDef USBH_HANDLE; // defined in usb_host.c + // USBH_LL_ResetPort(&USBH_HANDLE); + } +} + +void onLoop(void){ static uint32_t counter = PATCH_RESET_COUNTER; switch(owl.getOperationMode()){ case STARTUP_MODE: @@ -226,26 +234,3 @@ static void update_preset(){ break; } } - -extern "C" { - void usbh_midi_reset(void){ - HAL_GPIO_WritePin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin, GPIO_PIN_RESET); - HAL_Delay(100); // wait 100mS - HAL_GPIO_WritePin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin, GPIO_PIN_SET); - // extern USBH_HandleTypeDef USBH_HANDLE; // defined in usb_host.c - // USBH_LL_ResetPort(&USBH_HANDLE); - } -} - -void loop(void){ - if(HAL_GPIO_ReadPin(USB_HOST_PWR_FAULT_GPIO_Port, USB_HOST_PWR_FAULT_Pin) == GPIO_PIN_RESET){ - if(HAL_GPIO_ReadPin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin) == GPIO_PIN_SET){ - HAL_GPIO_WritePin(USB_HOST_PWR_EN_GPIO_Port, USB_HOST_PWR_EN_Pin, GPIO_PIN_RESET); - error(USB_ERROR, "USBH PWR Fault"); - } - }else{ - MX_USB_HOST_Process(); - } - update_preset(); - owl.loop(); -} From 2185efd2eaa2ffaca12e216dff885e6c13da66c6 Mon Sep 17 00:00:00 2001 From: Martin Klang Date: Sat, 15 Jan 2022 04:12:02 +0100 Subject: [PATCH 286/286] latest libs --- Libraries | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries b/Libraries index fc02729c..5a3f9643 160000 --- a/Libraries +++ b/Libraries @@ -1 +1 @@ -Subproject commit fc02729cafd3a3581e8faa06184d04a4ea88044c +Subproject commit 5a3f9643d27bf1a26b5e712bea81df4bb593c5fb