添加一些关于midi播放的项目

This commit is contained in:
terryLP
2025-03-24 14:30:56 +08:00
parent e31eb22077
commit 498b4ef13b
699 changed files with 186162 additions and 1 deletions
@@ -0,0 +1,170 @@
//#ifdef RUN_TEST
#include "SynthCore.h"
#include "Player.h"
#include <stdint.h>
#include <stdio.h>
#define TEST_LOOP_NUN 10000
Synthesizer synthesizerC;
Synthesizer synthesizerASM;
void TestInit(void)
{
SynthInit(&synthesizerC);
SynthInit(&synthesizerASM);
}
int32_t abs_s32(int32_t num)
{
return num>0?num:-num;
}
void PrintParameters(Synthesizer* synth)
{
SoundUnit* soundUnits = synth->SoundUnitList;
printf("MixOut:%d\n",synth->mixOut);
printf("LastSoundUnit:%d\n",synth->lastSoundUnit);
printf("%12s","Chn Val");
for(uint8_t k=0;k<POLY_NUM;k++)
{
printf("%6d ",soundUnits[k].val);
}
printf("\n");
printf("%12s","Chn Sample");
for(uint8_t k=0;k<POLY_NUM;k++)
{
printf("%6d ",soundUnits[k].sampleVal);
}
printf("\n");
printf("%12s","Chn EnvLevel");
for(uint8_t k=0;k<POLY_NUM;k++)
{
printf("%6d ",soundUnits[k].envelopeLevel);
}
printf("\n");
printf("%12s","Chn WavePos");
for(uint8_t k=0;k<POLY_NUM;k++)
{
printf("%6lu ",soundUnits[k].wavetablePos);
}
printf("\n");
printf("%12s","Chn EnvlPos");
for(uint8_t k=0;k<POLY_NUM;k++)
{
printf("%6d ",soundUnits[k].envelopePos);
}
printf("\n");
printf("%12s","Chn NoteIncr");
for(uint8_t k=0;k<POLY_NUM;k++)
{
printf("%6x ",soundUnits[k].increment);
}
printf("\n");
}
void TestUpdateTickFunc(void)
{
uint32_t i;
Player player;
PlayerInit(&player);
printf("~~~~~~~Start testing updateTickFunc.~~~~~~~\n");
for(i=0;i<0xffff;i++)
{
if(i!=player.currentTick)
{
printf("UpdateTickFunc get wrong in %ld loop.\n",i);
break;
}
UpdateTick(&player);
}
if(i==player.currentTick)
printf("UpdateTickFunc passed the test.\n");
}
uint8_t SynthParamterCompare(Synthesizer* synthA,Synthesizer* synthB)
{
uint32_t error=0;
SoundUnit* sa=synthA->SoundUnitList;
SoundUnit* sb=synthB->SoundUnitList;
if(abs_s32(synthA->mixOut-synthB->mixOut)>POLY_NUM)
error++;
for(uint32_t k=0;k<POLY_NUM;k++)
{
if(abs_s32(sa[k].val-sb[k].val)>2)
error++;
if(sa[k].sampleVal!=sb[k].sampleVal)
error++;
if(sa[k].envelopeLevel!=sb[k].envelopeLevel)
error++;
if(sa[k].envelopePos!=sb[k].envelopePos)
error++;
if(sa[k].wavetablePos!=sb[k].wavetablePos)
error++;
if(sa[k].increment!=sb[k].increment)
error++;
}
if(error>0)
{
printf("%lu error(s) found:\n",error);
printf("Synth C:\n");
PrintParameters(&synthesizerC);
printf("Synth ASM:\n");
PrintParameters(&synthesizerASM);
}
else
{
printf("Passed.\n");
}
return error;
}
extern Player mainPlayer;
void TestSynth(void)
{
uint32_t errorTimes=0;
printf("~~~~~~~Start testing synthesizer.~~~~~~~\n");
for(uint32_t i=40;i<40+POLY_NUM;i++)
{
NoteOnC(&synthesizerC,i%56);
NoteOnAsm(&synthesizerASM,i%56);
}
printf("After NoteOn Test:\n");
printf("Synth C:\n");
PrintParameters(&synthesizerC);
printf("Synth ASM:\n");
PrintParameters(&synthesizerASM);
for(uint32_t i=0;i<TEST_LOOP_NUN;i++)
{
SynthAsm(&synthesizerASM);
SynthC(&synthesizerC);
GenDecayEnvlopeC(&synthesizerC);
GenDecayEnvlopeAsm(&synthesizerASM);
printf("=============%lu==============\n",i);
if(SynthParamterCompare(&synthesizerC,&synthesizerASM)>0)
errorTimes++;
if(errorTimes>6)
break;
}
}
void TestProcess(void)
{
TestInit();
TestUpdateTickFunc();
TestSynth();
}
//#endif
@@ -0,0 +1,19 @@
#include <stdint.h>
const uint8_t EnvelopeTable[] = {
255, 252, 250, 247, 245, 243, 240, 238, 235, 233, 231, 228, 226, 224, 222, 219,
217, 215, 213, 211, 209, 207, 205, 203, 201, 199, 197, 195, 193, 191, 189, 187,
185, 183, 182, 180, 178, 176, 174, 173, 171, 169, 168, 166, 164, 163, 161, 159,
158, 156, 155, 153, 152, 150, 149, 147, 146, 144, 143, 141, 140, 139, 137, 136,
134, 133, 132, 130, 129, 128, 127, 125, 124, 123, 122, 120, 119, 118, 117, 116,
115, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 99,
98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 87, 86, 85, 84,
83, 82, 82, 81, 80, 79, 78, 78, 77, 76, 75, 75, 74, 73, 72, 72,
71, 70, 69, 69, 68, 67, 67, 66, 65, 65, 64, 64, 63, 62, 62, 61,
60, 60, 59, 59, 58, 57, 57, 56, 56, 55, 55, 54, 54, 53, 53, 52,
51, 51, 50, 50, 49, 49, 48, 48, 48, 47, 47, 46, 46, 45, 45, 44,
44, 43, 43, 43, 42, 42, 41, 40, 40, 39, 39, 38, 38, 37, 37, 36,
35, 35, 34, 34, 33, 33, 32, 31, 31, 30, 30, 29, 29, 28, 28, 27,
26, 26, 25, 25, 24, 24, 23, 22, 22, 21, 21, 20, 20, 19, 19, 18,
17, 17, 16, 16, 15, 15, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9,
8, 8, 7, 7, 6, 6, 5, 4, 4, 3, 3, 2, 2, 1, 0, 0};
@@ -0,0 +1,8 @@
#ifndef __ENVELOP_TABLE_H__
#define __ENVELOP_TABLE_H__
#include <stdint.h>
extern uint8_t EnvelopeTable[256];
#endif
@@ -0,0 +1,111 @@
#include <errno.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/unistd.h>
#include "uart_log.h"
#undef errno
extern int errno;
/******************************************************************************
*
******************************************************************************/
void stdio_setup(void)
{
// Turn off buffers, so I/O occurs immediately
setvbuf(stdin, NULL, _IONBF, 0);
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);
}
/******************************************************************************
*
******************************************************************************/
int _read(int file, char *data, int len)
{
int bytes_read;
if (file != STDIN_FILENO)
{
errno = EBADF;
return -1;
}
for (bytes_read = 0; bytes_read < len; bytes_read++)
{
*data = (char) uart_getchar();
data++;
}
return bytes_read;
}
/******************************************************************************
*
******************************************************************************/
int _write(int file, char *data, int len)
{
int bytes_written;
if ((file != STDOUT_FILENO) && (file != STDERR_FILENO))
{
errno = EBADF;
return -1;
}
for (bytes_written = 0; bytes_written < len; bytes_written++)
{
uart_putchar(*data);
data++;
}
return bytes_written;
}
/******************************************************************************
*
******************************************************************************/
int _close(int file)
{
return -1;
}
/******************************************************************************
*
******************************************************************************/
int _lseek(int file, int ptr, int dir)
{
return 0;
}
/******************************************************************************
*
******************************************************************************/
int _fstat(int file, struct stat *st)
{
st->st_mode = S_IFCHR;
return 0;
}
/******************************************************************************
*
******************************************************************************/
int _isatty(int file)
{
if ((file == STDOUT_FILENO) ||
(file == STDIN_FILENO) ||
(file == STDERR_FILENO))
{
return 1;
}
errno = EBADF;
return 0;
}
@@ -0,0 +1,363 @@
/**
******************************************************************************
* @file hw_config.c
* @author MCD Application Team
* @version V4.1.0
* @date 26-May-2017
* @brief Hardware Configuration & Setup
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
*
* 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.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32_it.h"
#include "usb_lib.h"
#include "usb_prop.h"
#include "usb_desc.h"
#include "hal.h"
#include "usb_pwr.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
ErrorStatus HSEStartUpStatus;
EXTI_InitTypeDef EXTI_InitStructure;
extern __IO uint32_t packet_sent;
extern __IO uint8_t Send_Buffer[MIDI_CDC_DEV_DATA_SIZE] ;
extern __IO uint32_t packet_receive;
extern __IO uint8_t Receive_length;
uint8_t Receive_Buffer[64];
uint32_t Send_length;
/* Extern variables ----------------------------------------------------------*/
extern LINE_CODING linecoding;
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/*******************************************************************************
* Function Name : Set_System
* Description : Configures Main system clocks & power
* Input : None.
* Return : None.
*******************************************************************************/
void Set_System(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32xxx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32xxx.c file
*/
#if defined(STM32L1XX_MD) || defined(STM32L1XX_HD) || defined(STM32F37X) || defined(STM32F303xC) || defined(STM32F303xE) || defined(STM32F302x8)
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
#else /* defined(STM32F10X_HD) || defined(STM32F10X_MD) defined(STM32F10X_XL)*/
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
#endif
/********************************************/
/* Configure USB DM/DP pins */
/********************************************/
#if defined(STM32L1XX_MD) || defined(STM32L1XX_HD)
/* Configure USB DM/DP pin. This is optional, and maintained only for user guidance.
For the STM32L products there is no need to configure the PA12/PA11 pins couple
as Alternate Function */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
#elif defined(STM32F10X_HD) || defined(STM32F10X_MD) || defined(STM32F10X_XL)
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Enable all GPIOs Clock*/
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ALLGPIO, ENABLE);
#else /* defined(STM32F37X) || defined(STM32F303xC) */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/*SET PA11,12 for USB: USB_DM,DP*/
GPIO_PinAFConfig(GPIOA, GPIO_PinSource11, GPIO_AF_14);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_14);
#endif
#if ! defined(USE_NUCLEO)
/********************************************/
/* Enable the USB PULL UP */
/********************************************/
#if defined(STM32L1XX_MD) || defined(STM32L1XX_HD)
/* Enable integrated STM32L15xx internal pull up
Enable the SYSCFG module clock*/
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
#elif defined(STM32F10X_HD) || defined(STM32F10X_MD) || defined(STM32F10X_XL)
/* USB_DISCONNECT used as USB pull-up */
GPIO_InitStructure.GPIO_Pin = USB_DISCONNECT_PIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
GPIO_Init(USB_DISCONNECT, &GPIO_InitStructure);
/* Enable the USB disconnect GPIO clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIO_DISCONNECT, ENABLE);
#else /* defined(STM32F37X) || defined(STM32F303xC) */
/* Enable the USB disconnect GPIO clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIO_DISCONNECT, ENABLE);
/* USB_DISCONNECT used as USB pull-up */
GPIO_InitStructure.GPIO_Pin = USB_DISCONNECT_PIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(USB_DISCONNECT, &GPIO_InitStructure);
#endif
#endif /* USE_NUCLEO */
#ifdef USB_LOW_PWR_MGMT_SUPPORT
/**********************************************************************/
/* Configure the EXTI line 18 connected internally to the USB IP */
/**********************************************************************/
EXTI_ClearITPendingBit(EXTI_Line18);
EXTI_InitStructure.EXTI_Line = EXTI_Line18;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
#endif /* USB_LOW_PWR_MGMT_SUPPORT */
}
/*******************************************************************************
* Function Name : Set_USBClock
* Description : Configures USB Clock input (48MHz)
* Input : None.
* Return : None.
*******************************************************************************/
void Set_USBClock(void)
{
#if defined(STM32L1XX_MD) || defined(STM32L1XX_HD) || defined(STM32L1XX_MD_PLUS)
/* Enable USB clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE);
#else
/* Select USBCLK source */
RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_1Div5);
/* Enable the USB clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE);
#endif /* STM32L1XX_MD */
}
/*******************************************************************************
* Function Name : Leave_LowPowerMode
* Description : Restores system clocks and power while exiting suspend mode
* Input : None.
* Return : None.
*******************************************************************************/
void Leave_LowPowerMode(void)
{
DEVICE_INFO *pInfo = &Device_Info;
/* Set the device state to the correct state */
if (pInfo->Current_Configuration != 0)
{
/* Device configured */
bDeviceState = CONFIGURED;
}
else
{
bDeviceState = ATTACHED;
}
/*Enable SystemCoreClock*/
SystemInit();
}
/*******************************************************************************
* Function Name : USB_Interrupts_Config
* Description : Configures the USB interrupts
* Input : None.
* Return : None.
*******************************************************************************/
void USB_Interrupts_Config(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
/* 4 bits for pre-emption priority, 0 bit for subpriority */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
#if defined(STM32L1XX_MD)|| defined(STM32L1XX_HD) || defined(STM32L1XX_MD_PLUS)
/* Enable the USB interrupt */
NVIC_InitStructure.NVIC_IRQChannel = USB_LP_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* Enable the USB Wake-up interrupt */
NVIC_InitStructure.NVIC_IRQChannel = USB_FS_WKUP_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
#elif defined(STM32F37X)
/* Enable the USB interrupt */
NVIC_InitStructure.NVIC_IRQChannel = USB_LP_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* Enable the USB Wake-up interrupt */
NVIC_InitStructure.NVIC_IRQChannel = USBWakeUp_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
#else
/* Enable the USB interrupt */
NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* Enable the USB Wake-up interrupt */
NVIC_InitStructure.NVIC_IRQChannel = USBWakeUp_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_Init(&NVIC_InitStructure);
#endif
}
/*******************************************************************************
* Function Name : USB_Cable_Config
* Description : Software Connection/Disconnection of USB Cable
* Input : None.
* Return : Status
*******************************************************************************/
void USB_Cable_Config (FunctionalState NewState)
{
if (NewState != DISABLE)
{
GPIO_ResetBits(USB_DISCONNECT, USB_DISCONNECT_PIN);
}
else
{
GPIO_SetBits(USB_DISCONNECT, USB_DISCONNECT_PIN);
}
}
/*******************************************************************************
* Function Name : HAL_GetHwSerialNum.
* Description : Create the serial number string descriptor.
* Input : None.
* Output : None.
* Return : None.
*******************************************************************************/
uint64_t HAL_GetHwSerialNum(void)
{
uint32_t Device_Serial0, Device_Serial1, Device_Serial2;
Device_Serial0 = *(uint32_t*)ID1;
Device_Serial1 = *(uint32_t*)ID2;
Device_Serial2 = *(uint32_t*)ID3;
Device_Serial0 += Device_Serial2;
return (uint64_t)Device_Serial0|((uint64_t)Device_Serial1<<32);
}
/*******************************************************************************
* Function Name : Send DATA .
* Description : send the data received from the STM32 to the PC through USB
* Input : None.
* Output : None.
* Return : None.
*******************************************************************************/
uint32_t CDC_Send_DATA (uint8_t *ptrBuffer, uint8_t Send_length)
{
/*if max buffer is Not reached*/
if(Send_length < MIDI_CDC_DEV_DATA_SIZE)
{
/*Sent flag*/
packet_sent = 0;
/* send packet to PMA*/
UserToPMABufferCopy((unsigned char*)ptrBuffer, ENDP1_TXADDR, Send_length);
SetEPTxCount(ENDP1, Send_length);
SetEPTxValid(ENDP1);
}
else
{
return 0;
}
return 1;
}
/*******************************************************************************
* Function Name : Receive DATA .
* Description : receive the data from the PC to STM32 and send it through USB
* Input : None.
* Output : None.
* Return : None.
*******************************************************************************/
uint32_t CDC_Receive_DATA(void)
{
/*Receive flag*/
packet_receive = 0;
SetEPRxValid(ENDP3);
SetEPRxValid(ENDP4);
return 1 ;
}
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
@@ -0,0 +1,85 @@
/**
******************************************************************************
* @file hw_config.h
* @author MCD Application Team
* @version V4.1.0
* @date 26-May-2017
* @brief Hardware Configuration & Setup
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
*
* 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.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __HAL_H
#define __HAL_H
/* Includes ------------------------------------------------------------------*/
#include "stm32f10x.h"
#include "usb_type.h"
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported define -----------------------------------------------------------*/
#define LED_ON 0xF0
#define LED_OFF 0xFF
/*Unique Devices IDs register set*/
#define ID1 (0x1FFFF7E8)
#define ID2 (0x1FFFF7EC)
#define ID3 (0x1FFFF7F0)
/* Define the STM32F10x hardware depending on the used evaluation board */
#define USB_DISCONNECT GPIOB
#define USB_DISCONNECT_PIN GPIO_Pin_5
#define RCC_APB2Periph_GPIO_DISCONNECT RCC_APB2Periph_GPIOB
#define RCC_APB2Periph_ALLGPIO (RCC_APB2Periph_GPIOA \
| RCC_APB2Periph_GPIOB \
| RCC_APB2Periph_GPIOC \
| RCC_APB2Periph_GPIOD \
| RCC_APB2Periph_GPIOE )
/* Exported functions ------------------------------------------------------- */
void Set_System(void);
void Set_USBClock(void);
void Enter_LowPowerMode(void);
void Leave_LowPowerMode(void);
void USB_Interrupts_Config(void);
void USB_Cable_Config (FunctionalState NewState);
uint64_t HAL_GetHwSerialNum(void);
uint32_t CDC_Send_DATA (uint8_t *ptrBuffer, uint8_t Send_length);
uint32_t CDC_Receive_DATA(void);
/* External variables --------------------------------------------------------*/
#endif /*__HW_CONFIG_H*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
@@ -0,0 +1,47 @@
/**
******************************************************************************
* @file hw_config.h
* @author MCD Application Team
* @version V4.1.0
* @date 26-May-2017
* @brief Hardware Configuration & Setup
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
*
* 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.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __HW_CONFIG_H
#define __HW_CONFIG_H
#include "stm32f10x.h"
#include "usb_type.h"
/*Dummy header merely because of the st usb lib require it.*/
#endif /*__HW_CONFIG_H*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
@@ -0,0 +1,221 @@
/**
******************************************************************************
* @file stm32_it.c
* @author MCD Application Team
* @version V4.1.0
* @date 26-May-2017
* @brief Main Interrupt Service Routines.
* This file provides template for all exceptions handler and peripherals
* interrupt service routine.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
*
* 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.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "hal.h"
#include "stm32_it.h"
#include "usb_lib.h"
#include "usb_istr.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/******************************************************************************/
/* Cortex-M Processor Exceptions Handlers */
/******************************************************************************/
/*******************************************************************************
* Function Name : NMI_Handler
* Description : This function handles NMI exception.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void NMI_Handler(void)
{
}
/*******************************************************************************
* Function Name : HardFault_Handler
* Description : This function handles Hard Fault exception.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void HardFault_Handler(void)
{
/* Go to infinite loop when Hard Fault exception occurs */
while (1)
{
}
}
/*******************************************************************************
* Function Name : MemManage_Handler
* Description : This function handles Memory Manage exception.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void MemManage_Handler(void)
{
/* Go to infinite loop when Memory Manage exception occurs */
while (1)
{
}
}
/*******************************************************************************
* Function Name : BusFault_Handler
* Description : This function handles Bus Fault exception.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void BusFault_Handler(void)
{
/* Go to infinite loop when Bus Fault exception occurs */
while (1)
{
}
}
/*******************************************************************************
* Function Name : UsageFault_Handler
* Description : This function handles Usage Fault exception.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void UsageFault_Handler(void)
{
/* Go to infinite loop when Usage Fault exception occurs */
while (1)
{
}
}
/*******************************************************************************
* Function Name : SVC_Handler
* Description : This function handles SVCall exception.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
// void SVC_Handler(void)
// {
// }
/*******************************************************************************
* Function Name : DebugMon_Handler
* Description : This function handles Debug Monitor exception.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void DebugMon_Handler(void)
{
}
/*******************************************************************************
* Function Name : PendSV_Handler
* Description : This function handles PendSVC exception.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
// void PendSV_Handler(void)
// {
// }
/*******************************************************************************
* Function Name : SysTick_Handler
* Description : This function handles SysTick Handler.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
/*******************************************************************************
* Function Name : USB_IRQHandler
* Description : This function handles USB Low Priority interrupts
* requests.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
#if defined(STM32L1XX_MD) || defined(STM32L1XX_HD)|| defined(STM32L1XX_MD_PLUS)|| defined (STM32F37X)
void USB_LP_IRQHandler(void)
#else
void USB_LP_CAN1_RX0_IRQHandler(void)
#endif
{
USB_Istr();
}
/*******************************************************************************
* Function Name : USB_FS_WKUP_IRQHandler
* Description : This function handles USB WakeUp interrupt request.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
#if defined(STM32L1XX_MD) || defined(STM32L1XX_HD)|| defined(STM32L1XX_MD_PLUS)
void USB_FS_WKUP_IRQHandler(void)
#else
void USBWakeUp_IRQHandler(void)
#endif
{
EXTI_ClearITPendingBit(EXTI_Line18);
}
/******************************************************************************/
/* STM32 Peripherals Interrupt Handlers */
/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */
/* available peripheral interrupt handler's name please refer to the startup */
/* file (startup_stm32xxx.s). */
/******************************************************************************/
/*******************************************************************************
* Function Name : PPP_IRQHandler
* Description : This function handles PPP interrupt request.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
/*void PPP_IRQHandler(void)
{
}*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
@@ -0,0 +1,64 @@
/**
******************************************************************************
* @file stm32_it.h
* @author MCD Application Team
* @version V4.1.0
* @date 26-May-2017
* @brief This file contains the headers of the interrupt handlers.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
*
* 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.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32_IT_H
#define __STM32_IT_H
/* Includes ------------------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
void NMI_Handler(void);
void HardFault_Handler(void);
void MemManage_Handler(void);
void BusFault_Handler(void);
void UsageFault_Handler(void);
void SVC_Handler(void);
void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
void USBWakeUp_IRQHandler(void);
void USB_FS_WKUP_IRQHandler(void);
#endif /* __STM32_IT_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
@@ -0,0 +1,253 @@
//
// Created by YangYongbao on 2017/3/18.
//
#include "uart_log.h"
#include "stm32f10x.h"
#include "stm32f10x_conf.h"
void uart_log_init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA, ENABLE);
RCC_APB1PeriphClockCmd( RCC_APB1Periph_USART2, ENABLE);
/* USART2 GPIO config */
/* Configure USART2 Tx (PA2) as alternate function push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Configure USART2 Rx (PA3) as input floating */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* USART2 mode config */
USART_InitStructure.USART_BaudRate = 115200;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No ;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(USART2, &USART_InitStructure);
USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);
USART_Cmd(USART2, ENABLE);
}
void uart_putchar(unsigned int c)
{
while (USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET);
USART_SendData(USART2, (uint16_t)c);
}
int uart_getchar(void)
{
return 0;
}
static void printchar(char **str, unsigned int c)
{
while (USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET);
USART_SendData(USART2, (uint16_t)c);
}
#ifdef USE_CUSTOM_PRINTF
#define PAD_RIGHT 1
#define PAD_ZERO 2
static int prints(char **out, const char *string, int width, int pad)
{
register int pc = 0, padchar = ' ';
if (width > 0) {
register int len = 0;
register const char *ptr;
for (ptr = string; *ptr; ++ptr) ++len;
if (len >= width) width = 0;
else width -= len;
if (pad & PAD_ZERO) padchar = '0';
}
if (!(pad & PAD_RIGHT)) {
for ( ; width > 0; --width) {
printchar (out, padchar);
++pc;
}
}
for ( ; *string ; ++string) {
printchar (out, *string);
++pc;
}
for ( ; width > 0; --width) {
printchar (out, padchar);
++pc;
}
return pc;
}
/* the following should be enough for 32 bit int */
#define PRINT_BUF_LEN 12
static int printi(char **out, int i, int b, int sg, int width, int pad, int letbase)
{
char print_buf[PRINT_BUF_LEN];
register char *s;
register int t, neg = 0, pc = 0;
register unsigned int u = i;
if (i == 0) {
print_buf[0] = '0';
print_buf[1] = '\0';
return prints (out, print_buf, width, pad);
}
if (sg && b == 10 && i < 0) {
neg = 1;
u = -i;
}
s = print_buf + PRINT_BUF_LEN-1;
*s = '\0';
while (u) {
t = u % b;
if( t >= 10 )
t += letbase - '0' - 10;
*--s = t + '0';
u /= b;
}
if (neg) {
if( width && (pad & PAD_ZERO) ) {
printchar (out, '-');
++pc;
--width;
}
else {
*--s = '-';
}
}
return pc + prints (out, s, width, pad);
}
static int print( char **out, const char *format, va_list args )
{
register int width, pad;
register int pc = 0;
char scr[2];
for (; *format != 0; ++format) {
if (*format == '%') {
++format;
width = pad = 0;
if (*format == '\0') break;
if (*format == '%') goto out;
if (*format == '-') {
++format;
pad = PAD_RIGHT;
}
while (*format == '0') {
++format;
pad |= PAD_ZERO;
}
for ( ; *format >= '0' && *format <= '9'; ++format) {
width *= 10;
width += *format - '0';
}
if( *format == 's' ) {
register char *s = (char *)va_arg( args, int );
pc += prints (out, s?s:"(null)", width, pad);
continue;
}
if( *format == 'd' ) {
pc += printi (out, va_arg( args, int ), 10, 1, width, pad, 'a');
continue;
}
if( *format == 'x' ) {
pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'a');
continue;
}
if( *format == 'X' ) {
pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'A');
continue;
}
if( *format == 'u' ) {
pc += printi (out, va_arg( args, int ), 10, 0, width, pad, 'a');
continue;
}
if( *format == 'c' ) {
/* char are converted to int then pushed on the stack */
scr[0] = (char)va_arg( args, int );
scr[1] = '\0';
pc += prints (out, scr, width, pad);
continue;
}
}
else {
out:
printchar (out, *format);
++pc;
}
}
if (out) **out = '\0';
va_end( args );
return pc;
}
int printf(const char *format, ...)
{
va_list args;
va_start( args, format );
return print( 0, format, args );
}
void debug(const char *format, ...)
{
va_list args;
va_start( args, format );
print( 0, format, args );
print(0, "\n", args);
}
int sprintf(char *out, const char *format, ...)
{
va_list args;
va_start( args, format );
return print( &out, format, args );
}
int snprintf( char *buf, unsigned int count, const char *format, ... )
{
va_list args;
( void ) count;
va_start( args, format );
return print( &buf, format, args );
}
#endif
// UART2 interrupt
void USART2_IRQHandler(void)
{
uint8_t data;
if (USART_GetITStatus(USART2, USART_IT_RXNE) != RESET)
{
data = USART_ReceiveData(USART2);
// add usart receive here
// uart_receive_input(data);
USART_ClearFlag(USART2, USART_FLAG_RXNE);
USART_ClearITPendingBit(USART2, USART_IT_RXNE);
}
}
@@ -0,0 +1,21 @@
//
// Created by YangYongbao on 2017/3/18.
//
#ifndef STM32F10X_MAKEFILE_FREERTOS_UART_LOG_H
#define STM32F10X_MAKEFILE_FREERTOS_UART_LOG_H
#include <stdarg.h>
#include <stdio.h>
void uart_log_init(void);
void uart_putchar(unsigned int c);
int uart_getchar(void);
#ifdef USE_CUSTOM_PRINTF
void debug(const char *format, ...);
#else
#define debug(f_, ...) printf((f_), ##__VA_ARGS__)
#endif
#endif //STM32F10X_MAKEFILE_FREERTOS_UART_LOG_H
@@ -0,0 +1,82 @@
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "SynthCore.h"
#include "Player.h"
extern unsigned char Score[];
void Player32kProc(Player *player)
{
SynthAsm(&(player->mainSynthesizer));
player->currentTick++;
if(player->decayGenTick<200)
player->decayGenTick+=1;
}
void PlayerProcess(Player *player)
{
uint8_t temp;
if (player->decayGenTick >= 150)
{
GenDecayEnvlopeAsm(&(player->mainSynthesizer));
player->decayGenTick = 0;
}
if (player->status == STATUS_PLAYING)
{
if ((player->currentTick >> 8) >= player->lastScoreTick)
{
do
{
temp = *(player->scorePointer);
player->scorePointer++;
if (temp == 0xFF)
{
player->status = STATUS_STOP;
}
else
{
NoteOnAsm(&(player->mainSynthesizer), temp);
}
} while ((temp & 0x80) == 0);
PlayUpdateNextScoreTick(player);
}
}
}
void PlayUpdateNextScoreTick(Player *player)
{
uint32_t tempU32;
uint8_t temp;
tempU32 = player->lastScoreTick;
do
{
temp = *(player->scorePointer);
player->scorePointer++;
tempU32 += temp;
} while (temp == 0xFF);
player->lastScoreTick = tempU32;
}
void PlayerPlay(Player *player)
{
player->currentTick = 0;
player->lastScoreTick = 0;
player->decayGenTick = 0;
player->scorePointer = Score;
PlayUpdateNextScoreTick(player);
player->status = STATUS_PLAYING;
}
void PlayerInit(Player *player)
{
player->status = STATUS_STOP;
player->currentTick = 0;
player->lastScoreTick = 0;
player->decayGenTick = 0;
player->scorePointer = Score;
SynthInit(&(player->mainSynthesizer));
}
@@ -0,0 +1,33 @@
#ifndef __PLAYER_H__
#define __PLAYER_H__
#include <stdint.h>
#include "SynthCore.h"
enum PLAY_STATUS{
STATUS_STOP=0,
STATUS_REDAY_TO_PLAY=1,
STATUS_PLAYING=2
};
typedef struct _Player
{
uint32_t currentTick;
uint32_t lastScoreTick;
uint32_t status;
uint32_t decayGenTick;
uint8_t* scorePointer;
Synthesizer mainSynthesizer;
} Player;
extern void PlayerInit(Player* player);
extern void Player32kProc(Player* player);
extern void PlayerProcess(Player* player);
extern void PlayerPlay(Player* player);
extern void UpdateTick(Player* player);
extern uint8_t PlayNoteTimingCheck(Player* player);
extern void PlayUpdateNextScoreTick(Player* player);
#endif
@@ -0,0 +1,15 @@
.syntax unified
.section .text
.thumb_func
.global UpdateTick
.global PlayNoteTimingCheck
.func UpdateTick
UpdateTick:
bx lr
.endfunc
.func PlayNoteTimingCheck
PlayNoteTimingCheck:
bx lr
.endfunc
@@ -0,0 +1,87 @@
#include "SynthCore.h"
#include <stdint.h>
#include <stdio.h>
#include "WaveTable_Celesta_C5.h"
#include "WaveTable_Celesta_C6.h"
#include "EnvelopeTable.h"
void SynthInit(Synthesizer* synth)
{
SoundUnit* soundUnits = synth->SoundUnitList;
for (uint8_t i = 0; i < POLY_NUM; i++)
{
soundUnits[i].increment = 0;
soundUnits[i].wavetablePos = 0;
soundUnits[i].envelopeLevel = 0;
soundUnits[i].envelopePos = 0;
soundUnits[i].val = 0;
soundUnits[i].waveTableAddress = (uint32_t)WaveTable_Celesta_C5;
soundUnits[i].waveTableLen = WAVETABLE_CELESTA_C5_LEN;
soundUnits[i].waveTableLoopLen = WAVETABLE_CELESTA_C5_LOOP_LEN;
soundUnits[i].waveTableAttackLen = WAVETABLE_CELESTA_C5_ATTACK_LEN;
}
synth->lastSoundUnit=0;
}
//#ifdef RUN_TEST
void NoteOnC(Synthesizer* synth,uint8_t note)
{
uint32_t lastSoundUnit = synth->lastSoundUnit;
SoundUnit* soundUnits = synth->SoundUnitList;
//disable_interrupts();
soundUnits[lastSoundUnit].increment = WaveTable_Celesta_C5_Increment[note&0x7F];
soundUnits[lastSoundUnit].wavetablePos = 0;
soundUnits[lastSoundUnit].waveTableAddress = (uint32_t)WaveTable_Celesta_C5;
soundUnits[lastSoundUnit].waveTableLen = WAVETABLE_CELESTA_C5_LEN;
soundUnits[lastSoundUnit].waveTableLoopLen = WAVETABLE_CELESTA_C5_LOOP_LEN;
soundUnits[lastSoundUnit].waveTableAttackLen = WAVETABLE_CELESTA_C5_ATTACK_LEN;
soundUnits[lastSoundUnit].envelopeLevel = 255;
soundUnits[lastSoundUnit].envelopePos = 0;
//enable_interrupts();
lastSoundUnit++;
if (lastSoundUnit== POLY_NUM)
lastSoundUnit = 0;
synth->lastSoundUnit=lastSoundUnit;
}
void SynthC(Synthesizer* synth)
{
synth->mixOut=0;
int16_t* pWaveTable;
uint32_t waveTablePosInt;
SoundUnit* soundUnits = synth->SoundUnitList;
for(uint32_t i=0;i<POLY_NUM;i++)
{
pWaveTable=(int16_t*)soundUnits[i].waveTableAddress;
waveTablePosInt= (soundUnits[i].wavetablePos)>>8;
soundUnits[i].val=((int32_t)soundUnits[i].envelopeLevel)*pWaveTable[waveTablePosInt]/256;
soundUnits[i].sampleVal=pWaveTable[waveTablePosInt];
uint32_t waveTablePos=soundUnits[i].increment+
soundUnits[i].wavetablePos;
waveTablePosInt= waveTablePos>>8;
if(waveTablePosInt>=soundUnits[i].waveTableLen)
waveTablePosInt-=soundUnits[i].waveTableLoopLen;
soundUnits[i].wavetablePos= waveTablePosInt<<8|(0xFF&waveTablePos);
synth->mixOut+=soundUnits[i].val;
}
}
void GenDecayEnvlopeC(Synthesizer* synth)
{
SoundUnit* soundUnits = synth->SoundUnitList;
for (uint32_t i = 0; i < POLY_NUM; i++)
{
if((soundUnits[i].wavetablePos>>8) >=soundUnits[i].waveTableAttackLen &&
soundUnits[i].envelopePos <(sizeof(EnvelopeTable)-1))
{
soundUnits[i].envelopeLevel = EnvelopeTable[soundUnits[i].envelopePos];
soundUnits[i].envelopePos += 1;
}
}
}
//#endif
@@ -0,0 +1,45 @@
#ifndef __SYNTH_CORE_H__
#define __SYNTH_CORE_H__
#include <stdint.h>
#define POLY_NUM 32
typedef struct _SoundUnit
{
uint32_t wavetablePos;
uint32_t waveTableAddress;
uint32_t waveTableLen;
uint32_t waveTableLoopLen;
uint32_t waveTableAttackLen;
uint32_t envelopePos;
uint32_t increment;
int32_t val;
int32_t sampleVal;
uint32_t envelopeLevel;
}SoundUnit;
typedef struct _Synthesizer
{
SoundUnit SoundUnitList[POLY_NUM];
int32_t mixOut;
uint32_t lastSoundUnit;
}Synthesizer;
extern void SynthInit(Synthesizer* synth);
//#ifdef RUN_TEST
extern void NoteOnC(Synthesizer* synth,uint8_t note);
extern void SynthC(Synthesizer* synth);
extern void GenDecayEnvlopeC(Synthesizer* synth);
//#endif
extern void NoteOnAsm(Synthesizer* synth,uint8_t note);
extern void GenDecayEnvlopeAsm(Synthesizer* synth);
extern void SynthAsm(Synthesizer* synth);
#endif
@@ -0,0 +1,214 @@
.syntax unified
.section .text
.thumb_func
.global SynthAsm
.global GenDecayEnvlopeAsm
.global NoteOnAsm
@ typedef struct _SoundUnit
@ {
@ uint32_t wavetablePos;
@ uint32_t waveTableAddress;
@ uint32_t waveTableLen;
@ uint32_t waveTableLoopLen;
@ uint32_t waveTableAttackLen;
@ uint32_t envelopePos;
@ uint32_t increment;
@ int32_t val;
@ int32_t sampleVal;
@ uint32_t envelopeLevel;
@ }SoundUnit;
@ typedef struct _Synthesizer
@ {
@ SoundUnit SoundUnitList[POLY_NUM];
@ int32_t mixOut;
@ uint32_t lastSoundUnit;
@ }Synthesizer;
.equ pWavetablePos , 0
.equ pWaveTableAddress , 4
.equ pWaveTableLen , 8
.equ pWaveTableLoopLen , 12
.equ pWaveTableAttackLen , 16
.equ pEnvelopePos ,20
.equ pIncrement , 24
.equ pVal , 28
.equ pSampleVal , 32
.equ pEnvelopeLevel , 36
.equ SoundUnitSize,40
.equ ENVELOP_LEN,256
.equ POLY_NUM,32
.equ pMixOut,SoundUnitSize*POLY_NUM
.equ pLastSoundUnit,pMixOut+4
.equ WAVETABLE_CELESTA_C5_LEN,2608
.equ WAVETABLE_CELESTA_C5_ATTACK_LEN,1998
.equ WAVETABLE_CELESTA_C5_LOOP_LEN,610
.equ WAVETABLE_CELESTA_C6_LEN, 1358
.equ WAVETABLE_CELESTA_C6_ATTACK_LEN, 838
.equ WAVETABLE_CELESTA_C6_LOOP_LEN, 520
.equ TIM3_CCR2,0x40000438
.equ TIM3_CCR3,0x4000043C
.func SynthAsm
SynthAsm:
stmfd sp!,{r0-r1,r4-r11,lr}
pSoundUnit .req r1
loopIndex .req r4
mixOut .req r8
mov loopIndex,#POLY_NUM
mov mixOut,#0
mov pSoundUnit,r0
loopSynth:
ldr r7,[pSoundUnit,#pEnvelopeLevel]
cmp r7,#0
beq loopSynthEnd
ldr r5,[pSoundUnit,#pWaveTableAddress]
ldr r6,[pSoundUnit,#pWavetablePos]
lsr r6,r6,#8 @wavetablePos /= 256
lsl r6,r6,#1 @wavetablePos *= 2
ldrsh r6,[r5,r6] @ Load signed 16bit sample to r6
@ str r6,[pSoundUnit,#pSampleVal]
@ mul r7,r6,r7 @sample*envelope/256
@ asr r7,r7,#8
@ str r7,[pSoundUnit,#pVal]
@ add mixOut,r7,mixOut @mixOut+=sample*envelope/256
mla mixOut,r6,r7,mixOut
ldr r6,[pSoundUnit,#pWavetablePos]
ldr r5,[pSoundUnit,#pIncrement]
add r6,r5,r6
ldr r5,[pSoundUnit,#pWaveTableLen]
lsl r5,r5,#8 @pWaveTableLen*=256
cmp r5,r6
bhi wavePosUpdateEnd @bhi : HI C = 1 and Z = 0 Higher, unsigned
ldr r5,[pSoundUnit,#pWaveTableLoopLen]
lsl r5,r5,#8 @waveTableLoopLen*=256
sub r6,r6,r5
wavePosUpdateEnd:
str r6,[pSoundUnit,#pWavetablePos]
loopSynthEnd:
subs loopIndex,loopIndex,#1 @ set n = n-1
add pSoundUnit,pSoundUnit,#SoundUnitSize
bne loopSynth
mov pSoundUnit,r0
str mixOut,[pSoundUnit,#pMixOut]
ssat mixOut,#10,mixOut,asr #14 @ mixOut /=1<<14, 2^(9-1)<= mixOut <=2^(9-1)-1
add mixOut,mixOut,#512
ldr r5,=#TIM3_CCR2
strh mixOut,[r5]
ldr r5,=#TIM3_CCR3
strh mixOut,[r5]
ldmfd sp!,{r0-r1,r4-r11,pc}
.endfunc
.func GenDecayEnvlopeAsm
GenDecayEnvlopeAsm:
pSoundUnitGenEnv .req r0
loopIndexGenEnv .req r4
stmfd sp!,{r0-r1,r4-r11,lr}
mov loopIndexGenEnv,#POLY_NUM
loopGenDecayEnvlope:
@ void GenDecayEnvlopeC(Synthesizer* synth)
@ {
@ SoundUnit* soundUnits = synth->SoundUnitList;
@ for (uint32_t i = 0; i < POLY_NUM; i++)
@ {
@ if((soundUnits[i].wavetablePos>>8) >=soundUnits[i].waveTableAttackLen &&
@ soundUnits[i].envelopePos <sizeof(EnvelopeTable)-1)
@ {
@ soundUnits[i].envelopeLevel = EnvelopeTable[soundUnits[i].envelopePos];
@ soundUnits[i].envelopePos += 1;
@ }
@ }
@ }
ldr r5,[pSoundUnitGenEnv,#pWavetablePos]
ldr r6,[pSoundUnitGenEnv,#pWaveTableAttackLen]
lsl r6,r6,#8 @WaveTableAttackLen*=WaveTableAttackLen*256
cmp r5,r6
blo conditionEnd @ blo Lower (unsigned < )
ldr r5,[pSoundUnitGenEnv,#pEnvelopePos]
ldr r6,=#(ENVELOP_LEN-1)
cmp r5,r6
bhs conditionEnd @ bhs Higher or same (unsigned >= )
ldr r6,=EnvelopeTable
ldrb r6,[r6,r5] @ Load envelope to r6
str r6,[pSoundUnitGenEnv,#pEnvelopeLevel]
add r5,r5,#1
str r5,[pSoundUnitGenEnv,#pEnvelopePos]
conditionEnd:
subs loopIndexGenEnv,loopIndexGenEnv,#1 @ set n = n-1
add pSoundUnitGenEnv,pSoundUnitGenEnv,#SoundUnitSize
bne loopGenDecayEnvlope
ldmfd sp!,{r0-r1,r4-r11,pc}
.endfunc
.func NoteOnAsm
NoteOnAsm:
pSynth .req r2
note .req r1
stmfd sp!,{r0-r2,r4-r11,lr}
mov pSynth,r0
@ void NoteOnC(Synthesizer* synth,uint8_t note)
@ {
@ uint8_t lastSoundUnit = synth->lastSoundUnit;
@ SoundUnit* soundUnits = synth->SoundUnitList;
@ //disable_interrupts();
@ soundUnits[lastSoundUnit].increment = WaveTable_Celesta_C5_Increment[note&0x7F];
@ soundUnits[lastSoundUnit].wavetablePos = 0;
@ soundUnits[lastSoundUnit].waveTableAddress = (uint32_t)WaveTable_Celesta_C5;
@ soundUnits[lastSoundUnit].waveTableLen = WAVETABLE_CELESTA_C5_LEN;
@ soundUnits[lastSoundUnit].waveTableLoopLen = WAVETABLE_CELESTA_C5_LOOP_LEN;
@ soundUnits[lastSoundUnit].waveTableAttackLen = WAVETABLE_CELESTA_C5_ATTACK_LEN;
@ //enable_interrupts();
@ lastSoundUnit++;
@ if (lastSoundUnit== POLY_NUM)
@ lastSoundUnit = 0;
@ synth->lastSoundUnit=lastSoundUnit;
@ }
ldr r5,[pSynth,#pLastSoundUnit]
mov r6,#SoundUnitSize
mul r5,r5,r6
add pSynth,pSynth,r5
and note,note,#0x7F
lsl note,note,#1
ldr r5,=WaveTable_Celesta_C5_Increment
ldrh r5,[r5,note]
cpsid i @ PRIMASK=1 Disable all interrupt except NMI and Hardfault
str r5,[pSynth,#pIncrement]
mov r5,#0
str r5,[pSynth,#pWavetablePos]
ldr r5,=WaveTable_Celesta_C5
str r5,[pSynth,#pWaveTableAddress]
ldr r5,=#WAVETABLE_CELESTA_C5_LEN
str r5,[pSynth,#pWaveTableLen]
ldr r5,=#WAVETABLE_CELESTA_C5_LOOP_LEN
str r5,[pSynth,#pWaveTableLoopLen]
ldr r5,=#WAVETABLE_CELESTA_C5_ATTACK_LEN
str r5,[pSynth,#pWaveTableAttackLen]
ldr r5,=#0
str r5,[pSynth,#pEnvelopePos]
ldr r5,=#255
str r5,[pSynth,#pEnvelopeLevel]
cpsie i @ PRIMASK=0 enable all interrupt
mov pSynth,r0
ldr r5,[pSynth,#pLastSoundUnit]
add r5,r5,#1
cmp r5,#POLY_NUM
bne updateLastSoundUnitEnd
mov r5,#0
updateLastSoundUnitEnd:
str r5,[pSynth,#pLastSoundUnit]
ldmfd sp!,{r0-r2,r4-r11,pc}
.endfunc
@@ -0,0 +1,115 @@
/**
******************************************************************************
* @file usb_conf.h
* @author MCD Application Team
* @version V4.1.0
* @date 26-May-2017
* @brief Midi CDC Device Demo configuration header
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
*
* 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.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USB_CONF_H
#define __USB_CONF_H
/* Includes ------------------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
/* External variables --------------------------------------------------------*/
/*-------------------------------------------------------------*/
/* EP_NUM */
/* defines how many endpoints are used by the device */
/*-------------------------------------------------------------*/
#define EP_NUM (6)
/*-------------------------------------------------------------*/
/* -------------- Buffer Description Table -----------------*/
/*-------------------------------------------------------------*/
/* buffer table base address */
/* buffer table base address */
#define BTABLE_ADDRESS (0x00)
/* EP0 */
/* rx/tx buffer base address */
#define ENDP0_RXADDR (0x40)
#define ENDP0_TXADDR (0x80)
/* EP1 */
/* tx buffer base address */
#define ENDP1_TXADDR (0xC0)
#define ENDP2_TXADDR (0x100)
#define ENDP3_RXADDR (0x110)
#define ENDP4_RXADDR (0x150)
#define ENDP5_TXADDR (0x190)
/*-------------------------------------------------------------*/
/* ------------------- ISTR events -------------------------*/
/*-------------------------------------------------------------*/
/* IMR_MSK */
/* mask defining which events has to be handled */
/* by the device application software */
#define IMR_MSK (CNTR_CTRM | CNTR_WKUPM | CNTR_SUSPM | CNTR_ERRM | CNTR_SOFM \
| CNTR_ESOFM | CNTR_RESETM )
/*#define CTR_CALLBACK*/
/*#define DOVR_CALLBACK*/
/*#define ERR_CALLBACK*/
/*#define WKUP_CALLBACK*/
/*#define SUSP_CALLBACK*/
/*#define RESET_CALLBACK*/
/*#define SOF_CALLBACK*/
/*#define ESOF_CALLBACK*/
/* CTR service routines */
/* associated to defined endpoints */
/*#define EP1_IN_Callback NOP_Process*/
#define EP2_IN_Callback NOP_Process
#define EP3_IN_Callback NOP_Process
#define EP4_IN_Callback NOP_Process
/*#define EP5_IN_Callback NOP_Process*/
#define EP6_IN_Callback NOP_Process
#define EP7_IN_Callback NOP_Process
#define EP1_OUT_Callback NOP_Process
#define EP2_OUT_Callback NOP_Process
/*#define EP3_OUT_Callback NOP_Process*/
/*#define EP4_OUT_Callback NOP_Process*/
#define EP5_OUT_Callback NOP_Process
#define EP6_OUT_Callback NOP_Process
#define EP7_OUT_Callback NOP_Process
#endif /* __USB_CONF_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
@@ -0,0 +1,345 @@
/**
******************************************************************************
* @file usb_desc.c
* @author MCD Application Team
* @version V4.1.0
* @date 26-May-2017
* @brief Descriptors for Usb midi and Cdc composite device.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
*
* 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.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "usb_lib.h"
#include "usb_desc.h"
/* USB Standard Device Descriptor */
const uint8_t Midi_CDC_Device_DeviceDescriptor[] =
{
0x12, /* bLength */
USB_DEVICE_DESCRIPTOR_TYPE, /* bDescriptorType */
0x00,
0x02, /* bcdUSB = 2.00 */
0xEF, // Class Code
0x02, // Subclass code
0x01, // Protocol code
0x40, /* bMaxPacketSize0 */
0x83,
0x04, /* idVendor = 0x0483 */
0x66,
0x67, /* idProduct = 0x7666 */
0x00,
0x02, /* bcdDevice = 2.00 */
1, /* Index of string descriptor describing manufacturer */
2, /* Index of string descriptor describing product */
3, /* Index of string descriptor describing the device's serial number */
0x01 /* bNumConfigurations */
};
const uint8_t Midi_CDC_Device_ConfigDescriptor[] =
{
/*Configuration Descriptor*/
0x09, /* bLength: Configuration Descriptor size */
USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */
MIDI_CDC_DEV_SIZ_CONFIG_DESC, /* wTotalLength:no of returned bytes */
0x00,
0x04, /* bNumInterfaces: 4 interface */
0x01, /* bConfigurationValue: Configuration value */
0x00, /* iConfiguration: Index of string descriptor describing the configuration */
0xC0, /* bmAttributes: self powered */
0x32, /* MaxPower 0 mA */
/* Interface Association Descriptor: Audio Function 1*/
0x08, // Size of this descriptor in bytes
0x0B, // Interface assocication descriptor type
MIDI_IF_0_ID, // The first associated interface
0x02, // Number of contiguous associated interface
0x01, // bInterfaceClass of the first interface
0x01, // bInterfaceSubclass of the first interface
0x00, // bInterfaceProtocol of the first interface
0x00, // Interface string index
0x09, //sizeof(USB_INTF_DSC), // Size of this descriptor in bytes
USB_INTERFACE_DESCRIPTOR_TYPE, // INTERFACE descriptor type
MIDI_IF_0_ID, // Interface Number
0, // Alternate Setting Number
0, // Number of endpoints in this intf
1, // Class code
1, // Subclass code
0, // Protocol code
0, // Interface string index
/* MIDI Adapter Class-specific AC Interface Descriptor */
0x09, //bLength
0x24, //bDescriptorType - CS_INTERFACE
0x01, //bDescriptorSubtype - HEADER
0x00, 0x01, //bcdADC
0x09, 0x00, //wTotalLength
0x01, //bInCollection
0x01, //baInterfaceNr(1)
/* MIDI Adapter Standard MS Interface Descriptor */
0x09, //bLength
USB_INTERFACE_DESCRIPTOR_TYPE, //bDescriptorType
MIDI_IF_1_ID, //bInterfaceNumber
0x00, //bAlternateSetting
0x02, //bNumEndpoints
0x01, //bInterfaceClass
0x03, //bInterfaceSubclass
0x00, //bInterfaceProtocol
0x00, //iInterface
/* MIDI Adapter Class-specific MS Interface Descriptor */
0x07, //bLength
0x24, //bDescriptorType - CS_INTERFACE
0x01, //bDescriptorSubtype - MS_HEADER
0x00, 0x01, //BcdADC
0x41, 0x00, //wTotalLength
/* MIDI Adapter MIDI IN Jack Descriptor (Embedded) */
0x06, //bLength
0x24, //bDescriptorType - CS_INTERFACE
0x02, //bDescriptorSubtype - MIDI_IN_JACK
0x01, //bJackType - EMBEDDED
0x01, //bJackID
0x00, //iJack
/* MIDI Adapter MIDI IN Jack Descriptor (External) */
0x06, //bLength
0x24, //bDescriptorType - CS_INTERFACE
0x02, //bDescriptorSubtype - MIDI_IN_JACK
0x02, //bJackType - EXTERNAL
0x02, //bJackID
0x00, //iJack
/* MIDI Adapter MIDI OUT Jack Descriptor (Embedded) */
0x09, //bLength
0x24, //bDescriptorType - CS_INTERFACE
0x03, //bDescriptorSubtype - MIDI_OUT_JACK
0x01, //bJackType - EMBEDDED
0x03, //bJackID
0x01, //bNrInputPins
0x02, //BaSourceID(1)
0x01, //BaSourcePin(1)
0x00, //iJack
/* MIDI Adapter MIDI OUT Jack Descriptor (External) */
0x09, //bLength
0x24, //bDescriptorType - CS_INTERFACE
0x03, //bDescriptorSubtype - MIDI_OUT_JACK
0x02, //bJackType - EXTERNAL
0x04, //bJackID
0x01, //bNrInputPins
0x01, //BaSourceID(1)
0x01, //BaSourcePin(1)
0x00, //iJack
/* MIDI Adapter Standard Bulk OUT Endpoint Descriptor */
0x09, //bLength
USB_ENDPOINT_DESCRIPTOR_TYPE, //bDescriptorType - ENDPOINT
0x04, //bEndpointAddress - OUT
0x02, //bmAttributes
MIDI_CDC_DEV_DATA_SIZE, 0x00, //wMaxPacketSize
0x00, //bInterval
0x00, //bRefresh
0x00, //bSynchAddress
/* MIDI Adapter Class-specific Bulk OUT Endpoint Descriptor */
0x05, //bLength
0x25, //bDescriptorType - CS_ENDPOINT
0x01, //bDescriptorSubtype - MS_GENERAL
0x01, //bNumEmbMIDIJack
0x01, //BaAssocJackID(1)
/* MIDI Adapter Standard Bulk IN Endpoint Descriptor */
0x09, //bLength
USB_ENDPOINT_DESCRIPTOR_TYPE, //bDescriptorType
0x85, //bEndpointAddress
0x02, //bmAttributes
MIDI_CDC_DEV_DATA_SIZE, 0x00, //wMaxPacketSize
0x00, //bInterval
0x00, //bRefresh
0x00, //bSynchAddress
/* MIDI Adapter Class-specific Bulk IN Endpoint Descriptor */
0x05, //bLength
0x25, //bDescriptorType - CS_ENDPOINT
0x01, //bDescriptorSubtype - MS_GENERAL
0x01, //bNumEmbMIDIJack
0x03, //BaAssocJackID(1)
// IAD ------------------------------------------------------------------------------------------------------------
// Interface Association Descriptor
0x08, // Size of this descriptor in bytes
0x0B, // Interface association descriptor type
CDC_COM_IF_ID, // First associated interface
0x02, // Number of contiguous associated interfaces
0x02, // bInterfaceClass of the first interface
0x02, // bInterfaceSubClass of the first interface
0x01, // bInterfaceProtocol of the first interface
0x00, // Interface string index
/*Interface Descriptor*/
0x09, /* bLength: Interface Descriptor size */
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType: Interface */
/* Interface descriptor type */
CDC_COM_IF_ID, /* bInterfaceNumber: Number of Interface */
0x00, /* bAlternateSetting: Alternate setting */
0x01, /* bNumEndpoints: One endpoints used */
0x02, /* bInterfaceClass: Communication Interface Class */
0x02, /* bInterfaceSubClass: Abstract Control Model */
0x01, /* bInterfaceProtocol: Common AT commands */
0x00, /* iInterface: */
/*Header Functional Descriptor*/
0x05, /* bLength: Endpoint Descriptor size */
0x24, /* bDescriptorType: CS_INTERFACE */
0x00, /* bDescriptorSubtype: Header Func Desc */
0x10, /* bcdCDC: spec release number */
0x01,
/*Call Management Functional Descriptor*/
0x05, /* bFunctionLength */
0x24, /* bDescriptorType: CS_INTERFACE */
0x01, /* bDescriptorSubtype: Call Management Func Desc */
0x00, /* bmCapabilities: D0+D1 */
CDC_DATA_IF_ID, /* bDataInterface: 1 */
/*ACM Functional Descriptor*/
0x04, /* bFunctionLength */
0x24, /* bDescriptorType: CS_INTERFACE */
0x02, /* bDescriptorSubtype: Abstract Control Management desc */
0x02, /* bmCapabilities */
/*Union Functional Descriptor*/
0x05, /* bFunctionLength */
0x24, /* bDescriptorType: CS_INTERFACE */
0x06, /* bDescriptorSubtype: Union func desc */
CDC_COM_IF_ID, /* bMasterInterface: Communication class interface */
CDC_DATA_IF_ID, /* bSlaveInterface0: Data Class Interface */
/*Endpoint 2 Descriptor*/
0x07, /* bLength: Endpoint Descriptor size */
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */
0x82, /* bEndpointAddress: (IN2) */
0x03, /* bmAttributes: Interrupt */
MIDI_CDC_DEV_INT_SIZE, /* wMaxPacketSize: */
0x00,
0xFF, /* bInterval: */
/*Data class interface descriptor*/
0x09, /* bLength: Endpoint Descriptor size */
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType: */
CDC_DATA_IF_ID, /* bInterfaceNumber: Number of Interface */
0x00, /* bAlternateSetting: Alternate setting */
0x02, /* bNumEndpoints: Two endpoints used */
0x0A, /* bInterfaceClass: CDC */
0x00, /* bInterfaceSubClass: */
0x00, /* bInterfaceProtocol: */
0x00, /* iInterface: */
/*Endpoint 3 Descriptor*/
0x07, /* bLength: Endpoint Descriptor size */
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */
0x03, /* bEndpointAddress: (OUT3) */
0x02, /* bmAttributes: Bulk */
MIDI_CDC_DEV_DATA_SIZE, /* wMaxPacketSize: */
0x00,
0x00, /* bInterval: ignore for Bulk transfer */
/*Endpoint 1 Descriptor*/
0x07, /* bLength: Endpoint Descriptor size */
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */
0x81, /* bEndpointAddress: (IN1) */
0x02, /* bmAttributes: Bulk */
MIDI_CDC_DEV_DATA_SIZE, /* wMaxPacketSize: */
0x00,
0x00, /* bInterval */
};
/* USB String Descriptors */
const uint8_t Midi_CDC_Device_StringLangID[MIDI_CDC_DEV_SIZ_STRING_LANGID] =
{
MIDI_CDC_DEV_SIZ_STRING_LANGID,
USB_STRING_DESCRIPTOR_TYPE,
0x09,
0x04 /* LangID = 0x0409: U.S. English */
};
const uint8_t Midi_CDC_Device_StringVendor[MIDI_CDC_DEV_SIZ_STRING_VENDOR] =
{
MIDI_CDC_DEV_SIZ_STRING_VENDOR, /* Size of Vendor string */
USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType*/
/* Manufacturer: "STMicroelectronics" */
'Y',
0,
'u',
0,
'a',
0,
'n',
};
const uint8_t Midi_CDC_Device_StringProduct[MIDI_CDC_DEV_SIZ_STRING_PRODUCT] =
{
MIDI_CDC_DEV_SIZ_STRING_PRODUCT, /* bLength */
USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
/* Product name: "STM32 Midi CDC Device" */
'Y',
0,
'U',
0,
'A',
0,
'N',
0,
'\'',
0,
'S',
0,
' ',
0,
'M',
0,
'U',
0,
'S',
0,
'I',
0,
'C',
0,
' ',
0,
'B',
0,
'O',
0,
'X',
0,
};
uint8_t Midi_CDC_Device_StringSerial[MIDI_CDC_DEV_SIZ_STRING_SERIAL] =
{
MIDI_CDC_DEV_SIZ_STRING_SERIAL, /* bLength */
USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
'S', 0, 'T', 0, 'M', 0, '3', 0, '2', 0};
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
@@ -0,0 +1,81 @@
/**
******************************************************************************
* @file usb_desc.h
* @author MCD Application Team
* @version V4.1.0
* @date 26-May-2017
* @brief Descriptor Header for Midi CDC Device Device
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
*
* 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.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USB_DESC_H
#define __USB_DESC_H
/* Includes ------------------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported define -----------------------------------------------------------*/
#define USB_DEVICE_DESCRIPTOR_TYPE 0x01
#define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02
#define USB_STRING_DESCRIPTOR_TYPE 0x03
#define USB_INTERFACE_DESCRIPTOR_TYPE 0x04
#define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05
#define MIDI_CDC_DEV_DATA_SIZE 64
#define MIDI_CDC_DEV_INT_SIZE 8
#define MIDI_CDC_DEV_SIZ_DEVICE_DESC 18
#define MIDI_CDC_DEV_SIZ_CONFIG_DESC 67+92+8+8
#define MIDI_CDC_DEV_SIZ_STRING_LANGID 4
#define MIDI_CDC_DEV_SIZ_STRING_VENDOR 10
#define MIDI_CDC_DEV_SIZ_STRING_PRODUCT 41
#define MIDI_CDC_DEV_SIZ_STRING_SERIAL 26
#define STANDARD_ENDPOINT_DESC_SIZE 0x09
#define MIDI_IF_0_ID 0
#define MIDI_IF_1_ID 1
#define CDC_COM_IF_ID 2
#define CDC_DATA_IF_ID 3
/* Exported functions ------------------------------------------------------- */
extern const uint8_t Midi_CDC_Device_DeviceDescriptor[MIDI_CDC_DEV_SIZ_DEVICE_DESC];
extern const uint8_t Midi_CDC_Device_ConfigDescriptor[MIDI_CDC_DEV_SIZ_CONFIG_DESC];
extern const uint8_t Midi_CDC_Device_StringLangID[MIDI_CDC_DEV_SIZ_STRING_LANGID];
extern const uint8_t Midi_CDC_Device_StringVendor[MIDI_CDC_DEV_SIZ_STRING_VENDOR];
extern const uint8_t Midi_CDC_Device_StringProduct[MIDI_CDC_DEV_SIZ_STRING_PRODUCT];
extern uint8_t Midi_CDC_Device_StringSerial[MIDI_CDC_DEV_SIZ_STRING_SERIAL];
#endif /* __USB_DESC_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
@@ -0,0 +1,115 @@
/**
******************************************************************************
* @file usb_endp.c
* @author MCD Application Team
* @version V4.1.0
* @date 26-May-2017
* @brief Endpoint routines
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
*
* 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.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "usb_lib.h"
#include "usb_desc.h"
#include "usb_mem.h"
#include "hal.h"
#include "usb_istr.h"
#include "usb_pwr.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Interval between sending IN packets in frame number (1 frame = 1ms) */
#define VCOMPORT_IN_FRAME_INTERVAL 5
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
extern __IO uint32_t packet_sent;
extern __IO uint32_t packet_receive;
extern __IO uint8_t Receive_Buffer[64];
uint32_t Receive_length;
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/*******************************************************************************
* Function Name : EP1_IN_Callback
* Description :
* Input : None.
* Output : None.
* Return : None.
*******************************************************************************/
void EP1_IN_Callback (void)
{
packet_sent = 1;
}
/*******************************************************************************
* Function Name : EP3_OUT_Callback
* Description :
* Input : None.
* Output : None.
* Return : None.
*******************************************************************************/
void EP3_OUT_Callback(void)
{
packet_receive = 1;
Receive_length = GetEPRxCount(ENDP3);
PMAToUserBufferCopy((unsigned char*)Receive_Buffer, ENDP3_RXADDR, Receive_length);
}
/*******************************************************************************
* Function Name : EP5_IN_Callback
* Description :
* Input : None.
* Output : None.
* Return : None.
*******************************************************************************/
void EP5_IN_Callback (void)
{
}
/*******************************************************************************
* Function Name : EP4_OUT_Callback
* Description :
* Input : None.
* Output : None.
* Return : None.
*******************************************************************************/
void EP4_OUT_Callback(void)
{
packet_receive = 1;
Receive_length = GetEPRxCount(ENDP4);
PMAToUserBufferCopy((unsigned char*)Receive_Buffer, ENDP4_RXADDR, Receive_length);
}
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
@@ -0,0 +1,242 @@
/**
******************************************************************************
* @file usb_istr.c
* @author MCD Application Team
* @version V4.1.0
* @date 26-May-2017
* @brief ISTR events interrupt service routines
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
*
* 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.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "usb_lib.h"
#include "usb_prop.h"
#include "usb_pwr.h"
#include "usb_istr.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
__IO uint16_t wIstr; /* ISTR register last read value */
__IO uint8_t bIntPackSOF = 0; /* SOFs received between 2 consecutive packets */
__IO uint32_t esof_counter =0; /* expected SOF counter */
__IO uint32_t wCNTR=0;
/* Extern variables ----------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/* function pointers to non-control endpoints service routines */
void (*pEpInt_IN[7])(void) =
{
EP1_IN_Callback,
EP2_IN_Callback,
EP3_IN_Callback,
EP4_IN_Callback,
EP5_IN_Callback,
EP6_IN_Callback,
EP7_IN_Callback,
};
void (*pEpInt_OUT[7])(void) =
{
EP1_OUT_Callback,
EP2_OUT_Callback,
EP3_OUT_Callback,
EP4_OUT_Callback,
EP5_OUT_Callback,
EP6_OUT_Callback,
EP7_OUT_Callback,
};
/*******************************************************************************
* Function Name : USB_Istr
* Description : ISTR events interrupt service routine
* Input :
* Output :
* Return :
*******************************************************************************/
void USB_Istr(void)
{
uint32_t i=0;
__IO uint32_t EP[8];
wIstr = _GetISTR();
#if (IMR_MSK & ISTR_SOF)
if (wIstr & ISTR_SOF & wInterrupt_Mask)
{
_SetISTR((uint16_t)CLR_SOF);
bIntPackSOF++;
#ifdef SOF_CALLBACK
SOF_Callback();
#endif
}
#endif
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if (IMR_MSK & ISTR_CTR)
if (wIstr & ISTR_CTR & wInterrupt_Mask)
{
/* servicing of the endpoint correct transfer interrupt */
/* clear of the CTR flag into the sub */
CTR_LP();
#ifdef CTR_CALLBACK
CTR_Callback();
#endif
}
#endif
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if (IMR_MSK & ISTR_RESET)
if (wIstr & ISTR_RESET & wInterrupt_Mask)
{
_SetISTR((uint16_t)CLR_RESET);
Device_Property.Reset();
#ifdef RESET_CALLBACK
RESET_Callback();
#endif
}
#endif
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if (IMR_MSK & ISTR_DOVR)
if (wIstr & ISTR_DOVR & wInterrupt_Mask)
{
_SetISTR((uint16_t)CLR_DOVR);
#ifdef DOVR_CALLBACK
DOVR_Callback();
#endif
}
#endif
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if (IMR_MSK & ISTR_ERR)
if (wIstr & ISTR_ERR & wInterrupt_Mask)
{
_SetISTR((uint16_t)CLR_ERR);
#ifdef ERR_CALLBACK
ERR_Callback();
#endif
}
#endif
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if (IMR_MSK & ISTR_WKUP)
if (wIstr & ISTR_WKUP & wInterrupt_Mask)
{
_SetISTR((uint16_t)CLR_WKUP);
Resume(RESUME_EXTERNAL);
#ifdef WKUP_CALLBACK
WKUP_Callback();
#endif
}
#endif
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if (IMR_MSK & ISTR_SUSP)
if (wIstr & ISTR_SUSP & wInterrupt_Mask)
{
/* check if SUSPEND is possible */
if (fSuspendEnabled)
{
Suspend();
}
else
{
/* if not possible then resume after xx ms */
Resume(RESUME_LATER);
}
/* clear of the ISTR bit must be done after setting of CNTR_FSUSP */
_SetISTR((uint16_t)CLR_SUSP);
#ifdef SUSP_CALLBACK
SUSP_Callback();
#endif
}
#endif
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#if (IMR_MSK & ISTR_ESOF)
if (wIstr & ISTR_ESOF & wInterrupt_Mask)
{
/* clear ESOF flag in ISTR */
_SetISTR((uint16_t)CLR_ESOF);
if ((_GetFNR()&FNR_RXDP)!=0)
{
/* increment ESOF counter */
esof_counter ++;
/* test if we enter in ESOF more than 3 times with FSUSP =0 and RXDP =1=>> possible missing SUSP flag*/
if ((esof_counter >3)&&((_GetCNTR()&CNTR_FSUSP)==0))
{
/* this a sequence to apply a force RESET*/
/*Store CNTR value */
wCNTR = _GetCNTR();
/*Store endpoints registers status */
for (i=0;i<8;i++) EP[i] = _GetENDPOINT(i);
/*apply FRES */
wCNTR|=CNTR_FRES;
_SetCNTR(wCNTR);
/*clear FRES*/
wCNTR&=~CNTR_FRES;
_SetCNTR(wCNTR);
/*poll for RESET flag in ISTR*/
while((_GetISTR()&ISTR_RESET) == 0);
/* clear RESET flag in ISTR */
_SetISTR((uint16_t)CLR_RESET);
/*restore Enpoints*/
for (i=0;i<8;i++)
_SetENDPOINT(i, EP[i]);
esof_counter = 0;
}
}
else
{
esof_counter = 0;
}
/* resume handling timing is made with ESOFs */
Resume(RESUME_ESOF); /* request without change of the machine state */
#ifdef ESOF_CALLBACK
ESOF_Callback();
#endif
}
#endif
} /* USB_Istr */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
@@ -0,0 +1,104 @@
/**
******************************************************************************
* @file usb_istr.h
* @author MCD Application Team
* @version V4.1.0
* @date 26-May-2017
* @brief This file includes the peripherals header files in the user application.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
*
* 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.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USB_ISTR_H
#define __USB_ISTR_H
/* Includes ------------------------------------------------------------------*/
#include "usb_conf.h"
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
void USB_Istr(void);
/* function prototypes Automatically built defining related macros */
void EP1_IN_Callback(void);
void EP2_IN_Callback(void);
void EP3_IN_Callback(void);
void EP4_IN_Callback(void);
void EP5_IN_Callback(void);
void EP6_IN_Callback(void);
void EP7_IN_Callback(void);
void EP1_OUT_Callback(void);
void EP2_OUT_Callback(void);
void EP3_OUT_Callback(void);
void EP4_OUT_Callback(void);
void EP5_OUT_Callback(void);
void EP6_OUT_Callback(void);
void EP7_OUT_Callback(void);
#ifdef CTR_CALLBACK
void CTR_Callback(void);
#endif
#ifdef DOVR_CALLBACK
void DOVR_Callback(void);
#endif
#ifdef ERR_CALLBACK
void ERR_Callback(void);
#endif
#ifdef WKUP_CALLBACK
void WKUP_Callback(void);
#endif
#ifdef SUSP_CALLBACK
void SUSP_Callback(void);
#endif
#ifdef RESET_CALLBACK
void RESET_Callback(void);
#endif
#ifdef SOF_CALLBACK
void SOF_Callback(void);
#endif
#ifdef ESOF_CALLBACK
void ESOF_Callback(void);
#endif
#endif /*__USB_ISTR_H*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
@@ -0,0 +1,468 @@
/**
******************************************************************************
* @file usb_prop.c
* @author MCD Application Team
* @version V4.1.0
* @date 26-May-2017
* @brief All processing related to Virtual Com Port Demo
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
*
* 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.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "usb_lib.h"
#include "usb_conf.h"
#include "usb_prop.h"
#include "usb_desc.h"
#include "usb_pwr.h"
#include "hal.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
uint8_t Request = 0;
LINE_CODING linecoding =
{
115200, /* baud rate*/
0x00, /* stop bits-1*/
0x00, /* parity - none*/
0x08 /* no. of bits 8*/
};
/* -------------------------------------------------------------------------- */
/* Structures initializations */
/* -------------------------------------------------------------------------- */
DEVICE Device_Table =
{
EP_NUM,
1};
DEVICE_PROP Device_Property =
{
Midi_CDC_Device_init,
Midi_CDC_Device_Reset,
Midi_CDC_Device_Status_In,
Midi_CDC_Device_Status_Out,
Midi_CDC_Device_Data_Setup,
Midi_CDC_Device_NoData_Setup,
Midi_CDC_Device_Get_Interface_Setting,
Midi_CDC_Device_GetDeviceDescriptor,
Midi_CDC_Device_GetConfigDescriptor,
Midi_CDC_Device_GetStringDescriptor,
0,
0x40 /*MAX PACKET SIZE*/
};
USER_STANDARD_REQUESTS User_Standard_Requests =
{
Midi_CDC_Device_GetConfiguration,
Midi_CDC_Device_SetConfiguration,
Midi_CDC_Device_GetInterface,
Midi_CDC_Device_SetInterface,
Midi_CDC_Device_GetStatus,
Midi_CDC_Device_ClearFeature,
Midi_CDC_Device_SetEndPointFeature,
Midi_CDC_Device_SetDeviceFeature,
Midi_CDC_Device_SetDeviceAddress};
ONE_DESCRIPTOR Device_Descriptor =
{
(uint8_t *)Midi_CDC_Device_DeviceDescriptor,
MIDI_CDC_DEV_SIZ_DEVICE_DESC};
ONE_DESCRIPTOR Config_Descriptor =
{
(uint8_t *)Midi_CDC_Device_ConfigDescriptor,
MIDI_CDC_DEV_SIZ_CONFIG_DESC};
ONE_DESCRIPTOR String_Descriptor[4] =
{
{(uint8_t *)Midi_CDC_Device_StringLangID, MIDI_CDC_DEV_SIZ_STRING_LANGID},
{(uint8_t *)Midi_CDC_Device_StringVendor, MIDI_CDC_DEV_SIZ_STRING_VENDOR},
{(uint8_t *)Midi_CDC_Device_StringProduct, MIDI_CDC_DEV_SIZ_STRING_PRODUCT},
{(uint8_t *)Midi_CDC_Device_StringSerial, MIDI_CDC_DEV_SIZ_STRING_SERIAL}};
/* Extern variables ----------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Extern function prototypes ------------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/*******************************************************************************
* Function Name : Midi_CDC_Device_init.
* Description : Midi CDC Device Mouse init routine.
* Input : None.
* Output : None.
* Return : None.
*******************************************************************************/
void Midi_CDC_Device_init(void)
{
/* Update the serial number string descriptor with the data from the unique
ID*/
InitSnStringWith64bitId();
pInformation->Current_Configuration = 0;
/* Connect the device */
PowerOn();
/* Perform basic device initialization operations */
USB_SIL_Init();
bDeviceState = UNCONNECTED;
}
/*******************************************************************************
* Function Name : Midi_CDC_Device_Reset
* Description : Virtual_Com_Port Mouse reset routine
* Input : None.
* Output : None.
* Return : None.
*******************************************************************************/
void Midi_CDC_Device_Reset(void)
{
/* Set Virtual_Com_Port DEVICE as not configured */
pInformation->Current_Configuration = 0;
/* Current Feature initialization */
pInformation->Current_Feature = Midi_CDC_Device_ConfigDescriptor[7];
/* Set Virtual_Com_Port DEVICE with the default Interface*/
pInformation->Current_Interface = 0;
SetBTABLE(BTABLE_ADDRESS);
/* Initialize Endpoint 0 */
SetEPType(ENDP0, EP_CONTROL);
SetEPTxStatus(ENDP0, EP_TX_STALL);
SetEPRxAddr(ENDP0, ENDP0_RXADDR);
SetEPTxAddr(ENDP0, ENDP0_TXADDR);
Clear_Status_Out(ENDP0);
SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);
SetEPRxValid(ENDP0);
/* Initialize Endpoint 1 */
SetEPType(ENDP1, EP_BULK);
SetEPTxAddr(ENDP1, ENDP1_TXADDR);
SetEPTxStatus(ENDP1, EP_TX_NAK);
SetEPRxStatus(ENDP1, EP_RX_DIS);
/* Initialize Endpoint 2 */
SetEPType(ENDP2, EP_INTERRUPT);
SetEPTxAddr(ENDP2, ENDP2_TXADDR);
SetEPRxStatus(ENDP2, EP_RX_DIS);
SetEPTxStatus(ENDP2, EP_TX_NAK);
/* Initialize Endpoint 3 */
SetEPType(ENDP3, EP_BULK);
SetEPRxAddr(ENDP3, ENDP3_RXADDR);
SetEPRxCount(ENDP3, MIDI_CDC_DEV_DATA_SIZE);
SetEPRxStatus(ENDP3, EP_RX_VALID);
SetEPTxStatus(ENDP3, EP_TX_DIS);
/* Initialize Endpoint 5 */
SetEPType(ENDP5, EP_BULK);
SetEPTxAddr(ENDP5, ENDP5_TXADDR);
SetEPRxStatus(ENDP5, EP_RX_DIS);
SetEPTxStatus(ENDP5, EP_TX_NAK);
/* Initialize Endpoint 4 */
SetEPType(ENDP4, EP_BULK);
SetEPRxAddr(ENDP4, ENDP4_RXADDR);
SetEPRxCount(ENDP4, MIDI_CDC_DEV_DATA_SIZE);
SetEPRxStatus(ENDP4, EP_RX_VALID);
SetEPTxStatus(ENDP4, EP_TX_DIS);
/* Set this device to response on default address */
SetDeviceAddress(0);
bDeviceState = ATTACHED;
}
/*******************************************************************************
* Function Name : Midi_CDC_Device_SetConfiguration.
* Description : Update the device state to configured.
* Input : None.
* Output : None.
* Return : None.
*******************************************************************************/
void Midi_CDC_Device_SetConfiguration(void)
{
DEVICE_INFO *pInfo = &Device_Info;
if (pInfo->Current_Configuration != 0)
{
/* Device configured */
bDeviceState = CONFIGURED;
}
}
/*******************************************************************************
* Function Name : Midi_CDC_Device_SetConfiguration.
* Description : Update the device state to addressed.
* Input : None.
* Output : None.
* Return : None.
*******************************************************************************/
void Midi_CDC_Device_SetDeviceAddress(void)
{
bDeviceState = ADDRESSED;
}
/*******************************************************************************
* Function Name : Midi_CDC_Device_Status_In.
* Description : Midi CDC Device Status In Routine.
* Input : None.
* Output : None.
* Return : None.
*******************************************************************************/
void Midi_CDC_Device_Status_In(void)
{
if (Request == SET_LINE_CODING)
{
Request = 0;
}
}
/*******************************************************************************
* Function Name : Midi_CDC_Device_Status_Out
* Description : Midi CDC Device Status OUT Routine.
* Input : None.
* Output : None.
* Return : None.
*******************************************************************************/
void Midi_CDC_Device_Status_Out(void)
{
}
/*******************************************************************************
* Function Name : Midi_CDC_Device_Data_Setup
* Description : handle the data class specific requests
* Input : Request Nb.
* Output : None.
* Return : USB_UNSUPPORT or USB_SUCCESS.
*******************************************************************************/
RESULT Midi_CDC_Device_Data_Setup(uint8_t RequestNo)
{
uint8_t *(*CopyRoutine)(uint16_t);
CopyRoutine = NULL;
if (RequestNo == GET_LINE_CODING)
{
if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT))
{
CopyRoutine = Midi_CDC_Device_GetLineCoding;
}
}
else if (RequestNo == SET_LINE_CODING)
{
if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT))
{
CopyRoutine = Midi_CDC_Device_SetLineCoding;
}
Request = SET_LINE_CODING;
}
if (CopyRoutine == NULL)
{
return USB_UNSUPPORT;
}
pInformation->Ctrl_Info.CopyData = CopyRoutine;
pInformation->Ctrl_Info.Usb_wOffset = 0;
(*CopyRoutine)(0);
return USB_SUCCESS;
}
/*******************************************************************************
* Function Name : Midi_CDC_Device_NoData_Setup.
* Description : handle the no data class specific requests.
* Input : Request Nb.
* Output : None.
* Return : USB_UNSUPPORT or USB_SUCCESS.
*******************************************************************************/
RESULT Midi_CDC_Device_NoData_Setup(uint8_t RequestNo)
{
if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT))
{
if (RequestNo == SET_COMM_FEATURE)
{
return USB_SUCCESS;
}
else if (RequestNo == SET_CONTROL_LINE_STATE)
{
return USB_SUCCESS;
}
}
return USB_UNSUPPORT;
}
/*******************************************************************************
* Function Name : Midi_CDC_Device_GetDeviceDescriptor.
* Description : Gets the device descriptor.
* Input : Length.
* Output : None.
* Return : The address of the device descriptor.
*******************************************************************************/
uint8_t *Midi_CDC_Device_GetDeviceDescriptor(uint16_t Length)
{
return Standard_GetDescriptorData(Length, &Device_Descriptor);
}
/*******************************************************************************
* Function Name : Midi_CDC_Device_GetConfigDescriptor.
* Description : get the configuration descriptor.
* Input : Length.
* Output : None.
* Return : The address of the configuration descriptor.
*******************************************************************************/
uint8_t *Midi_CDC_Device_GetConfigDescriptor(uint16_t Length)
{
return Standard_GetDescriptorData(Length, &Config_Descriptor);
}
/*******************************************************************************
* Function Name : Midi_CDC_Device_GetStringDescriptor
* Description : Gets the string descriptors according to the needed index
* Input : Length.
* Output : None.
* Return : The address of the string descriptors.
*******************************************************************************/
uint8_t *Midi_CDC_Device_GetStringDescriptor(uint16_t Length)
{
uint8_t wValue0 = pInformation->USBwValue0;
if (wValue0 >= 4)
{
return NULL;
}
else
{
return Standard_GetDescriptorData(Length, &String_Descriptor[wValue0]);
}
}
/*******************************************************************************
* Function Name : Midi_CDC_Device_Get_Interface_Setting.
* Description : test the interface and the alternate setting according to the
* supported one.
* Input1 : uint8_t: Interface : interface number.
* Input2 : uint8_t: AlternateSetting : Alternate Setting number.
* Output : None.
* Return : The address of the string descriptors.
*******************************************************************************/
RESULT Midi_CDC_Device_Get_Interface_Setting(uint8_t Interface, uint8_t AlternateSetting)
{
if (AlternateSetting > 0)
{
return USB_UNSUPPORT;
}
else if (Interface > 1)
{
return USB_UNSUPPORT;
}
return USB_SUCCESS;
}
/*******************************************************************************
* Function Name : Midi_CDC_Device_GetLineCoding.
* Description : send the linecoding structure to the PC host.
* Input : Length.
* Output : None.
* Return : Linecoding structure base address.
*******************************************************************************/
uint8_t *Midi_CDC_Device_GetLineCoding(uint16_t Length)
{
if (Length == 0)
{
pInformation->Ctrl_Info.Usb_wLength = sizeof(linecoding);
return NULL;
}
return (uint8_t *)&linecoding;
}
/*******************************************************************************
* Function Name : Midi_CDC_Device_SetLineCoding.
* Description : Set the linecoding structure fields.
* Input : Length.
* Output : None.
* Return : Linecoding structure base address.
*******************************************************************************/
uint8_t *Midi_CDC_Device_SetLineCoding(uint16_t Length)
{
if (Length == 0)
{
pInformation->Ctrl_Info.Usb_wLength = sizeof(linecoding);
return NULL;
}
return (uint8_t *)&linecoding;
}
void InitSnStringWith64bitId(void)
{
uint64_t id = HAL_GetHwSerialNum();
if (id != 0)
{
IntToUnicode(id & 0xFFFFFFFF, &Midi_CDC_Device_StringSerial[2], 8);
IntToUnicode((id >> 32) & 0xFFFFFFFF, &Midi_CDC_Device_StringSerial[18], 4);
}
}
/*******************************************************************************
* Function Name : HexToChar.
* Description : Convert Hex 32Bits value into char.
* Input : None.
* Output : None.
* Return : None.
*******************************************************************************/
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****/
@@ -0,0 +1,100 @@
/**
******************************************************************************
* @file usb_prop.h
* @author MCD Application Team
* @version V4.1.0
* @date 26-May-2017
* @brief All processing related to Midi CDC Device Demo (Endpoint 0)
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
*
* 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.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __usb_prop_H
#define __usb_prop_H
/* Includes ------------------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/
typedef struct
{
uint32_t bitrate;
uint8_t format;
uint8_t paritytype;
uint8_t datatype;
}LINE_CODING;
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported define -----------------------------------------------------------*/
#define Midi_CDC_Device_GetConfiguration NOP_Process
//#define Midi_CDC_Device_SetConfiguration NOP_Process
#define Midi_CDC_Device_GetInterface NOP_Process
#define Midi_CDC_Device_SetInterface NOP_Process
#define Midi_CDC_Device_GetStatus NOP_Process
#define Midi_CDC_Device_ClearFeature NOP_Process
#define Midi_CDC_Device_SetEndPointFeature NOP_Process
#define Midi_CDC_Device_SetDeviceFeature NOP_Process
//#define Midi_CDC_Device_SetDeviceAddress NOP_Process
#define SEND_ENCAPSULATED_COMMAND 0x00
#define GET_ENCAPSULATED_RESPONSE 0x01
#define SET_COMM_FEATURE 0x02
#define GET_COMM_FEATURE 0x03
#define CLEAR_COMM_FEATURE 0x04
#define SET_LINE_CODING 0x20
#define GET_LINE_CODING 0x21
#define SET_CONTROL_LINE_STATE 0x22
#define SEND_BREAK 0x23
/* Exported functions ------------------------------------------------------- */
void Midi_CDC_Device_init(void);
void Midi_CDC_Device_Reset(void);
void Midi_CDC_Device_SetConfiguration(void);
void Midi_CDC_Device_SetDeviceAddress (void);
void Midi_CDC_Device_Status_In (void);
void Midi_CDC_Device_Status_Out (void);
RESULT Midi_CDC_Device_Data_Setup(uint8_t);
RESULT Midi_CDC_Device_NoData_Setup(uint8_t);
RESULT Midi_CDC_Device_Get_Interface_Setting(uint8_t Interface, uint8_t AlternateSetting);
uint8_t *Midi_CDC_Device_GetDeviceDescriptor(uint16_t );
uint8_t *Midi_CDC_Device_GetConfigDescriptor(uint16_t);
uint8_t *Midi_CDC_Device_GetStringDescriptor(uint16_t);
uint8_t *Midi_CDC_Device_GetLineCoding(uint16_t Length);
uint8_t *Midi_CDC_Device_SetLineCoding(uint16_t Length);
void InitSnStringWith64bitId(void);
void IntToUnicode (uint32_t value , uint8_t *pbuf , uint8_t len);
#endif /* __usb_prop_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
@@ -0,0 +1,351 @@
/**
******************************************************************************
* @file usb_pwr.c
* @author MCD Application Team
* @version V4.1.0
* @date 26-May-2017
* @brief Connection/disconnection & power management
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
*
* 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.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "usb_lib.h"
#include "usb_pwr.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
__IO uint32_t bDeviceState = UNCONNECTED; /* USB device status */
__IO bool fSuspendEnabled = TRUE; /* true when suspend is possible */
__IO uint32_t EP[8];
struct
{
__IO RESUME_STATE eState;
__IO uint8_t bESOFcnt;
}
ResumeS;
__IO uint32_t remotewakeupon=0;
/* Extern variables ----------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Extern function prototypes ------------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/**
* Function Name : PowerOn
* Description :
* Input : None.
* Output : None.
* Return : USB_SUCCESS.
*/
RESULT PowerOn(void)
{
uint16_t wRegVal;
#if !defined (USE_NUCLEO)
/*** cable plugged-in ? ***/
USB_Cable_Config(ENABLE);
#endif
/*** CNTR_PWDN = 0 ***/
wRegVal = CNTR_FRES;
_SetCNTR(wRegVal);
/* The following sequence is recommended:
1- FRES = 0
2- Wait until RESET flag = 1 (polling)
3- clear ISTR register */
/*** CNTR_FRES = 0 ***/
wInterrupt_Mask = 0;
_SetCNTR(wInterrupt_Mask);
/* Wait until RESET flag = 1 (polling) */
while((_GetISTR()&ISTR_RESET) == 1);
/*** Clear pending interrupts ***/
SetISTR(0);
/*** Set interrupt mask ***/
wInterrupt_Mask = CNTR_RESETM | CNTR_SUSPM | CNTR_WKUPM;
_SetCNTR(wInterrupt_Mask);
return USB_SUCCESS;
}
/**
* Function Name : PowerOff
* Description : handles switch-off conditions
* Input : None.
* Output : None.
* Return : USB_SUCCESS.
**/
RESULT PowerOff()
{
/* disable all interrupts and force USB reset */
_SetCNTR(CNTR_FRES);
/* clear interrupt status register */
_SetISTR(0);
#if !defined (USE_NUCLEO)
/* Disable the Pull-Up*/
USB_Cable_Config(DISABLE);
#endif
/* switch-off device */
_SetCNTR(CNTR_FRES + CNTR_PDWN);
/* sw variables reset */
/* ... */
return USB_SUCCESS;
}
/**
* Function Name : Suspend
* Description : sets suspend mode operating conditions
* Input : None.
* Output : None.
* Return : USB_SUCCESS.
*/
void Suspend(void)
{
uint32_t i =0;
uint16_t wCNTR;
#ifdef USB_LOW_PWR_MGMT_SUPPORT
uint32_t tmpreg = 0;
__IO uint32_t savePWR_CR=0;
#endif
/* suspend preparation */
/* ... */
/*Store CNTR value */
wCNTR = _GetCNTR();
/* This a sequence to apply a force RESET to handle a robustness case */
/*Store endpoints registers status */
for (i=0;i<8;i++) EP[i] = _GetENDPOINT(i);
/* unmask RESET flag */
wCNTR|=CNTR_RESETM;
_SetCNTR(wCNTR);
/*apply FRES */
wCNTR|=CNTR_FRES;
_SetCNTR(wCNTR);
/*clear FRES*/
wCNTR&=~CNTR_FRES;
_SetCNTR(wCNTR);
/*poll for RESET flag in ISTR*/
while((_GetISTR()&ISTR_RESET) == 0);
/* clear RESET flag in ISTR */
_SetISTR((uint16_t)CLR_RESET);
/*restore Enpoints*/
for (i=0;i<8;i++)
_SetENDPOINT(i, EP[i]);
/* Now it is safe to enter macrocell in suspend mode */
wCNTR |= CNTR_FSUSP;
_SetCNTR(wCNTR);
/* force low-power mode in the macrocell */
wCNTR = _GetCNTR();
wCNTR |= CNTR_LPMODE;
_SetCNTR(wCNTR);
#ifdef USB_LOW_PWR_MGMT_SUPPORT
/*prepare entry in low power mode (STOP mode)*/
/* Select the regulator state in STOP mode*/
savePWR_CR = PWR->CR;
tmpreg = PWR->CR;
/* Clear PDDS and LPDS bits */
tmpreg &= ((uint32_t)0xFFFFFFFC);
/* Set LPDS bit according to PWR_Regulator value */
tmpreg |= PWR_Regulator_LowPower;
/* Store the new value */
PWR->CR = tmpreg;
/* Set SLEEPDEEP bit of Cortex System Control Register */
#if defined(STM32F303xE) || defined(STM32F302x8) || defined(STM32F303xC) || defined (STM32F37X)
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
#else
SCB->SCR |= SCB_SCR_SLEEPDEEP;
#endif
/* enter system in STOP mode, only when wakeup flag in not set */
if((_GetISTR()&ISTR_WKUP)==0)
{
__WFI();
/* Reset SLEEPDEEP bit of Cortex System Control Register */
#if defined(STM32F303xE) || defined(STM32F302x8) || defined(STM32F303xC) || defined (STM32F37X)
SCB->SCR &= (uint32_t)~((uint32_t)SCB_SCR_SLEEPDEEP_Msk);
#else
SCB->SCR &= (uint32_t)~((uint32_t)SCB_SCR_SLEEPDEEP);
#endif
}
else
{
/* Clear Wakeup flag */
_SetISTR(CLR_WKUP);
/* clear FSUSP to abort entry in suspend mode */
wCNTR = _GetCNTR();
wCNTR&=~CNTR_FSUSP;
_SetCNTR(wCNTR);
/*restore sleep mode configuration */
/* restore Power regulator config in sleep mode*/
PWR->CR = savePWR_CR;
/* Reset SLEEPDEEP bit of Cortex System Control Register */
#if defined(STM32F303xE) || defined(STM32F302x8) || defined(STM32F303xC) || defined (STM32F37X)
SCB->SCR &= (uint32_t)~((uint32_t)SCB_SCR_SLEEPDEEP_Msk);
#else
SCB->SCR &= (uint32_t)~((uint32_t)SCB_SCR_SLEEPDEEP);
#endif
}
#endif /* USB_LOW_PWR_MGMT_SUPPORT */
}
/**
* Function Name : Resume_Init
* Description : Handles wake-up restoring normal operations
* Input : None.
* Output : None.
* Return : USB_SUCCESS.
*/
void Resume_Init(void)
{
uint16_t wCNTR;
/* ------------------ ONLY WITH BUS-POWERED DEVICES ---------------------- */
/* restart the clocks */
/* ... */
/* CNTR_LPMODE = 0 */
wCNTR = _GetCNTR();
wCNTR &= (~CNTR_LPMODE);
_SetCNTR(wCNTR);
#ifdef USB_LOW_PWR_MGMT_SUPPORT
/* restore full power */
/* ... on connected devices */
Leave_LowPowerMode();
#endif /* USB_LOW_PWR_MGMT_SUPPORT */
/* reset FSUSP bit */
_SetCNTR(IMR_MSK);
/* reverse suspend preparation */
/* ... */
}
/*******************************************************************************
* Function Name : Resume
* Description : This is the state machine handling resume operations and
* timing sequence. The control is based on the Resume structure
* variables and on the ESOF interrupt calling this subroutine
* without changing machine state.
* Input : a state machine value (RESUME_STATE)
* RESUME_ESOF doesn't change ResumeS.eState allowing
* decrementing of the ESOF counter in different states.
* Output : None.
* Return : None.
*******************************************************************************/
void Resume(RESUME_STATE eResumeSetVal)
{
uint16_t wCNTR;
if (eResumeSetVal != RESUME_ESOF)
ResumeS.eState = eResumeSetVal;
switch (ResumeS.eState)
{
case RESUME_EXTERNAL:
if (remotewakeupon ==0)
{
Resume_Init();
ResumeS.eState = RESUME_OFF;
}
else /* RESUME detected during the RemoteWAkeup signalling => keep RemoteWakeup handling*/
{
ResumeS.eState = RESUME_ON;
}
break;
case RESUME_INTERNAL:
Resume_Init();
ResumeS.eState = RESUME_START;
remotewakeupon = 1;
break;
case RESUME_LATER:
ResumeS.bESOFcnt = 2;
ResumeS.eState = RESUME_WAIT;
break;
case RESUME_WAIT:
ResumeS.bESOFcnt--;
if (ResumeS.bESOFcnt == 0)
ResumeS.eState = RESUME_START;
break;
case RESUME_START:
wCNTR = _GetCNTR();
wCNTR |= CNTR_RESUME;
_SetCNTR(wCNTR);
ResumeS.eState = RESUME_ON;
ResumeS.bESOFcnt = 10;
break;
case RESUME_ON:
ResumeS.bESOFcnt--;
if (ResumeS.bESOFcnt == 0)
{
wCNTR = _GetCNTR();
wCNTR &= (~CNTR_RESUME);
_SetCNTR(wCNTR);
ResumeS.eState = RESUME_OFF;
remotewakeupon = 0;
}
break;
case RESUME_OFF:
case RESUME_ESOF:
default:
ResumeS.eState = RESUME_OFF;
break;
}
}
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
@@ -0,0 +1,82 @@
/**
******************************************************************************
* @file usb_pwr.h
* @author MCD Application Team
* @version V4.1.0
* @date 26-May-2017
* @brief Connection/disconnection & power management header
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
*
* 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.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USB_PWR_H
#define __USB_PWR_H
/* Includes ------------------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/
typedef enum _RESUME_STATE
{
RESUME_EXTERNAL,
RESUME_INTERNAL,
RESUME_LATER,
RESUME_WAIT,
RESUME_START,
RESUME_ON,
RESUME_OFF,
RESUME_ESOF
} RESUME_STATE;
typedef enum _DEVICE_STATE
{
UNCONNECTED,
ATTACHED,
POWERED,
SUSPENDED,
ADDRESSED,
CONFIGURED
} DEVICE_STATE;
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
void Suspend(void);
void Resume_Init(void);
void Resume(RESUME_STATE eResumeSetVal);
RESULT PowerOn(void);
RESULT PowerOff(void);
/* External variables --------------------------------------------------------*/
extern __IO uint32_t bDeviceState; /* USB device status */
extern __IO bool fSuspendEnabled; /* true when suspend is possible */
#endif /*__USB_PWR_H*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
@@ -0,0 +1,284 @@
#include <stdint.h>
#include <WaveTable_Celesta_C5.h>
// Sample's base frequency: 523.629906 Hz
// Sample's sample rate: 32000 Hz
const int16_t WaveTable_Celesta_C5[WAVETABLE_CELESTA_C5_LEN]={
// Attack Samples:
12, -142, -127, -198, 8, 109, -157, 345, -189, -106,
555, -508, 495, 830, -452, 1372, 803, 5, 2262, -224,
-1899, -3465, -8020, -4, 12132, 13671, 9428, -971, -8338, -6442,
-5111, 5753, 20020, 11950, 1296, 271, -335, 2992, -1258, -4801,
5142, 446,-10050, -8540,-11166, 615, 9248,-12360,-20813,-15906,
-13506, -1591, -7745,-16060, 66, 2383, -771, 3063, -8204, -8016,
405, -7026, -4286, -5091,-10862, 5080, 7819, 3408, 16251, 9561,
3014, 13811, 11067, 18011, 21869, 3746, 3866, 1190, -6815, 9137,
7598, 1737, 12925, 4893, 7198, 17180, 1671, 1833, 2974, -9887,
3148, 4349, -8280, -2972,-14283,-17634, -3157,-15288,-18315,-12318,
-22975,-10004, -2219,-15243, -7346,-11649,-18505, -313, -3194, -4113,
7957, -4112, -430, 10244, -1330, 6128, 6397, -6745, 8285, 10752,
5334, 19596, 10687, 5795, 19976, 12492, 19691, 27097, 7486, 9830,
8733, -547, 16003, 10205, -1175, 8520, -4603, -2802, 12726, -237,
3620, 5677, -9882, 3838, 6263, -6100, 287,-16399,-25604, -8070,
-16325,-15758,-11106,-30641,-19901, -8537,-19154, -8239,-14949,-24755,
-4541, -8448, -8318, 5556, -8723, -2357, 10395, -1011, 11228, 9853,
-4992, 13007, 11261, 7661, 24438, 6800, 2570, 14614, -888, 11310,
17960, -710, 11895, 8750, -994, 17081, 5885, 280, 12376, -3797,
2598, 13728, -235, 10517, 6177,-10520, 6549, 1710, -3613, 10163,
-8948,-10933, 2230,-11585, -2025, -2458,-24629,-11380,-12566,-17938,
217,-14711,-19395, -5625,-19874, -9185, 858,-17572, -5671, -6524,
-18001, 2183, -5250,-11091, 4658,-10280, -4999, 9121, -5884, 6428,
9024, -4779, 16264, 13835, 5675, 21595, 6257, 6481, 22836, 6658,
14174, 17375, -3306, 13173, 14319, 3012, 19927, 6175, -1422, 15664,
2259, 7995, 16975, -3898, 4853, 4064,-11587, 5137, -2835,-13780,
-858,-18616,-18229, -2435,-19190,-12564, -9124,-25166, -5514, -3092,
-13191, 1908,-11082,-15162, 2896, -9710, -5123, 1418,-18583, -5671,
-501,-12076, 4410, -3432,-12848, 4432, -4237, 463, 15442, -625,
6675, 13311, 918, 17746, 16371, 3385, 17205, 8206, 6559, 22470,
7028, 7806, 14967, -562, 11477, 14104, -1303, 10109, 3543, -3077,
13524, 2515, -184, 7958, -9765, -4051, 2637,-11070, 336, -3645,
-17977, -4177,-10205,-13044, 493,-14509,-12695, -1521,-13072, -1591,
1610,-13316, -1775, -5132,-11604, 3545, -7647,-11578, -134,-12170,
-4685, 3905,-11238, -2887, -3259,-11762, 6124, 2020, -3193, 9773,
-2480, 446, 14056, 2565, 10276, 12506, -2309, 10755, 10922, 4117,
17918, 6310, 1891, 15164, 3653, 8408, 15292, -484, 8766, 11025,
-383, 11674, 4221, -4921, 7293, -3485, -3789, 6226, -9263, -5270,
-896,-13788, -830, -1213,-13134, -2683,-10502,-11443, 3752, -8243,
-8102, -2302,-16442, -6687, -2418,-13318, -1378, -7077,-15430, -692,
-7290, -6728, 3868,-10765, -6658, 1336, -7981, 4798, 4929, -5687,
6543, 1671, -719, 12453, 1278, 1715, 10990, 509, 9742, 14189,
2827, 12442, 8600, 1987, 15888, 8505, 5457, 14583, 2705, 6834,
13473, 850, 7502, 5855, -4290, 7202, 1371, -4798, 4789, -6683,
-6557, 2664, -8236, -1272, 1271,-11718, -2227, -2725, -7487, 4563,
-5891,-12251, -3244,-12427, -7504, -1632,-15400, -8890, -7384,-15047,
-2063, -5458,-10632, 262, -8852, -7089, 4404, -4877, 976, 4289,
-6133, 5343, 5650, -1519, 8941, 1555, -557, 11514, 3094, 6728,
13229, 1792, 10207, 13667, 6057, 17156, 12063, 5356, 16617, 8860,
8330, 15169, 1619, 4446, 8501, -1700, 6736, 4032, -6053, 3416,
-3062, -5983, 4192, -6589, -5964, 67,-11099, -4036, -1908,-11542,
-2871, -8359,-15857, -5488,-12380,-12749, -5136,-16498,-11083, -3859,
-12302, -3542, -3866,-10853, 1335, -2310, -4805, 5008, -4030, -2060,
5492, -3334, 4176, 6712, -3042, 5913, 4756, 1707, 13515, 6940,
4996, 12795, 4584, 10617, 16757, 6730, 13105, 12316, 4985, 14736,
9102, 3372, 10108, 652, 1504, 7416, -3396, 975, 2060, -7491,
1170, -1143, -7114, 1614, -5970, -7703, 870, -7647, -4985, -2190,
-13000, -6223, -5849,-12941, -4163, -9063,-13249, -4342,-10756, -8195,
-362, -9179, -4505, -1880, -8735, 1217, 263, -5547, 2435, -3726,
-4142, 5420, -1943, 563, 4433, -4097, 3988, 6091, 256, 9135,
5431, 2174, 11701, 6476, 8753, 15514, 6224, 10494, 13365, 5610,
12206, 8597, 1352, 8810, 3100, 1191, 7734, -1396, 267, 4698,
-3443, 2164, 1955, -5790, 1409, -2257, -5983, 1800, -5766, -7373,
-3063,-11472, -6652, -3598,-11637, -6115, -8385,-12818, -3347, -7220,
-8620, -1940, -9427, -6742, -1543, -8144, -1723, -1382, -8669, -1260,
-3309, -5418, 2924, -3359, -3174, 3263, -2795, 2677, 6250, -151,
7101, 6936, 3562, 12846, 9183, 7952, 14322, 7327, 10000, 13919,
5250, 8987, 8484, 2124, 9069, 5115, 590, 6553, -83, 232,
5758, -1781, 1454, 2804, -4926, 823, -920, -6101, 58, -6128,
-8530, -2447, -8844, -6073, -2393,-10416, -6030, -5990,-11547, -4118,
-6855,-10136, -3319, -8385, -7051, -1230, -8164, -4707, -2816, -9000,
-1956, -2744, -7239, -141, -3956, -4150, 3593, -1389, 1674, 6082,
184, 6782, 9019, 4490, 11534, 8645, 5462, 12516, 7606, 7627,
11706, 4005, 6791, 9024, 3039, 8582, 6737, 1769, 8133, 4110,
2609, 8124, 1330, 1778, 4241, -3418, 156, 240, -6130, -1543,
-5158, -8791, -2889, -8262, -9021, -4925,-11493, -8304, -5227,-10665,
-5682, -6857,-11005, -3947, -6623, -8215, -3426, -9359, -7333, -2650,
-7990, -3543, -2453, -7162, -746, -1408, -2683, 4602, 1204, 1580,
7059, 2659, 6918, 10583, 5338, 9754, 8970, 4904, 11003, 7890,
5900, 10982, 5714, 6655, 10322, 4625, 7933, 8626, 3398, 8461,
6284, 2270, 6654, 1627, 244, 3731, -2847, -2179, -1298, -7908,
-4507, -5187, -9290, -4174, -7652,-10055, -5081, -9187, -7399, -3113,
-8631, -6186, -5470, -9962, -4545, -5723, -8952, -4117, -7896, -8004,
-2949, -7289, -4978, -2262, -6438, -948, 730, -1745, 4243, 2539,
1614, 7676, 4287, 5256, 8727, 3679, 6861, 8504, 4316, 8978,
7855, 5068, 10119, 6833, 6263, 10401, 5513, 7000, 9195, 4379,
8143, 7655, 2638, 6201, 2780, -414, 3092, -2124, -3093, -1080,
-6939, -4912, -4019, -8455, -4490, -5771, -8601, -3470, -5897, -6604,
-3140, -8287, -7212, -4787, -9181, -6002, -6508,-10823, -6243, -7354,
-8211, -3069, -6673, -6162, -1719, -4688, -890, 1786, -1498, 3120,
3232, 1609, 7485, 5413, 4313, 8049, 4184, 5886, 8799, 4597,
7502, 7937, 4638, 9371, 8313, 6276, 10348, 7030, 7159, 10641,
6185, 7279, 7786, 2518, 4884, 3318, -1002, 1684, -2159, -4610,
-1676, -5753, -5068, -2742, -7327, -5003, -4074, -7121, -2800, -4182,
-7254, -4025, -7350, -7914, -4689, -8843, -7733, -6255, -9992, -6275,
-5767, -8520, -4372, -5731, -6170, -1122, -3223, -1907, 1587, -1380,
1953, 4366, 1663, 5224, 4305, 2034, 6561, 5044, 4861, 8275,
4688, 5824, 8436, 5647, 9043, 9719, 6849, 10537, 9250, 7512,
10534, 6536, 5306, 7047, 2783, 3566, 3439, -1537, -136, -1876,
-5203, -2003, -4149, -5326, -2543, -5952, -5262, -2960, -6228, -4315,
-4461, -7894, -4939, -6146, -8269, -5670, -8503, -8727, -5796, -8567,
-7020, -5497, -8131, -4797, -4041, -5487, -1407, -1953, -2151, 1540,
-101, 1478, 4147, 1560, 3888, 5019, 3060, 6312, 5519, 3625,
6706, 5545, 6396, 9607, 7394, 8905, 10319, 7597, 9803, 9494,
6914, 8730, 6245, 4380, 6228, 2902, 1853, 1913, -2190, -1389,
-1253, -4023, -2140, -3363, -5205, -2651, -4241, -4323, -2305, -5203,
-4830, -4078, -6790, -5083, -5634, -8471, -6938, -8434, -9098, -6470,
-8414, -7943, -5794, -7247, -4793, -3340, -4718, -1877, -1614, -2058,
1006, 21, 260, 2357, 278, 1669, 3618, 2131, 4162, 4432,
3455, 6651, 6699, 6799, 9549, 8307, 8978, 10730, 8826, 9949,
9881, 7012, 7899, 6594, 4620, 5738, 3122, 1353, 1897, -855,
-888, -502, -2961, -1882, -2007, -3689, -2031, -3233, -4662, -3620,
-5854, -6322, -5404, -7702, -7378, -7454, -9600, -8019, -8215, -9243,
-7132, -7749, -7288, -4611, -5255, -3998, -2509, -3920, -2178, -1512,
-2449, -155, -243, -353, 2168, 1550, 2166, 3970, 2696, 4238,
5876, 5378, 7881, 8454, 7920, 10172, 9495, 9094, 10514, 8703,
8508, 8966, 6747, 7218, 6671, 4123, 4447, 2730, 884, 1813,
-17, -843, -266, -2490, -2240, -1909, -3963, -3309, -4256, -6252,
-5198, -6352, -7250, -6333, -8189, -8082, -7160, -8719, -7593, -7086,
-8083, -5878, -5509, -5729, -3710, -4411, -4193, -2498, -3471, -2513,
-1596, -2828, -1006, -139, -374, 1888, 1699, 1664, 3707, 3300,
4768, 7086, 6541, 8003, 8624, 7369, 8982, 8913, 8010, 9198,
7769, 7087, 7841, 5902, 5798, 5782, 3361, 3511, 2937, 1284,
2000, 502, -796, 117, -1505, -2043, -1912, -4170, -3996, -4107,
-6126, -5587, -6233, -7414, -6314, -7432, -7785, -6398, -7441, -6749,
-5585, -6548, -5065, -4485, -5433, -3981, -4331, -4803, -3310, -4415,
-4267, -2626, -3196, -1679, -246, -676, 1355, 2163, 2292, 4857,
5267, 5714, 7307, 6285, 7023, 8460, 7416, 8223, 8054, 6543,
7587, 6857, 5969, 7253, 6046, 5365, 5607, 3686, 3993, 4299,
2649, 3241, 2441, 717, 1241, -525, -2143, -2035, -3990, -4258,
-4017, -6174, -6077, -6244, -7423, -6084, -6693, -7629, -6233, -6928,
-6627, -5340, -6502, -5732, -5024, -6274, -5120, -5069, -5946, -4549,
-4914, -4735, -2813, -3088, -1911, -117, -433, 1313, 2531, 2405,
4681, 5374, 5573, 7405, 6858, 7090, 8281, 7054, 7561, 8173,
7039, 7993, 7756, 6554, 7508, 6619, 5945, 6801, 5268, 4852,
5011, 3079, 3036, 2394, 200, 182, -1263, -3123, -2863, -4530,
-5428, -5165, -7194, -7393, -6889, -7837, -6621, -6338, -7087, -5629,
-5833, -6120, -4898, -5927, -5977, -4997, -5967, -5242, -4865, -6085,
-5037, -4756, -4791, -2585, -2213, -1670, 397, 401, 1693, 3436,
3160, 4768, 5699, 5195, 6671, 6629, 6311, 7825, 7150, 7057,
8082, 6988, 7414, 7901, 6596, 7420, 7347, 6153, 6897, 5854,
4623, 4866, 2919, 1962, 1786, -413, -878, -1584, -3686, -3634,
-4656, -6304, -5889, -6830, -7090, -5941, -6717, -6235, -5373, -6349,
-5532, -5281, -6179, -5111, -5416, -5946, -4930, -5974, -6317, -5515,
-6288, -5125, -3801, -4165, -2702, -1922, -1499, 944, 1619, 2240,
4079, 4006, 4817, 5921, 5221, 6130, 6677, 5941, 6893, 6575,
5970, 6903, 6174, 6085, 6955, 6238, 6922, 7579, 6615, 7017,
6438, 4999, 5094, 3755, 2187, 1594, -401, -1334, -1850, -3935,
-4619, -5195, -6346, -5793, -6058, -6412, -5287, -5592, -5531, -4689,
-5237, -4797, -4494, -5619, -5392, -5554, -6218, -5745, -6357, -6566,
-5471, -5578, -4881, -3738, -3631, -2193, -953, -608, 928, 1696,
2060, 3344, 3483, 3916, 4769, 4227, 4518, 5158, 4969, 5705,
5771, 5319, 6032, 6186, 6511, 7617, 7556, 7823, 8251, 7458,
7373, 6996, 5678, 4991, 3524, 1707, 985, -366, -1514, -2071,
-3634, -4422, -4603, -5291, -4967, -4747, -5020, -4496, -4618, -4919,
-4622, -5273, -5660, -5480, -6163, -6403, -6551, -7207, -6945, -6735,
-6755, -5922, -5653, -5423, -4374, -3771, -2572, -824, -49, 735,
1403, 1561, 2514, 3225, 3382, 4063, 4111, 4089, 4663, 4678,
5060, 5979, 6340, 7079, 7775, 7960, 8772, 8928, 8398, 8420,
7962, 7139, 6312, 4669, 3417, 2621, 1209, 143, -938, -2203,
-2561, -3074, -3762, -3670, -3772, -3872, -3739, -4210, -4448, -4498,
-5110, -5410, -5821, -6456, -6428, -6621, -7130, -7276, -7469, -7140,
-6346, -5955, -5340, -4621, -4180, -3220, -2103, -1175, -262, 157,
522, 1240, 1653, 2061, 2629, 2880, 3102, 3354, 3637, 4467,
5389, 5940, 6451, 6765, 7225, 8000, 8410, 8396, 8198, 7866,
7529, 6947, 5933, 4866, 3893, 3013, 2211, 1398, 562, -187,
-963, -1643, -1896, -2009, -2343, -2876, -3510, -4004, -4266, -4603,
-5057, -5645, -6411, -6885, -6913, -6994, -7132, -7364, -7502, -7086,
-6520, -6016, -5395, -4895, -4320, -3437, -2706, -1817, -952, -548,
-237, -19, 303, 1008, 1388, 1560, 1989, 2434, 3258, 4293,
4810, 5365, 5955, 6475, 7390, 8050, 8364, 8618, 8297, 8025,
7945, 7335, 6636, 5803, 4808, 4272, 3526, 2506, 1736, 627,
-275, -660, -1235, -1563, -1995, -2942, -3521, -4065, -4568, -4530,
-5064, -5911, -6330, -6929, -7031, -6996, -7672, -7836, -7662, -7389,
-6399, -5798, -5503, -4751, -4277, -3476, -2441, -2078, -1565, -1324,
-1603, -1178, -682, -220, 569, 657, 1030, 2135, 2858, 3879,
4811, 5063, 5947, 6729, 7252, 8262, 8454, 8285, 8403, 7887,
7675, 7590, 6498, 5614, 4743, 3758, 3614, 2972, 1874, 1162,
33, -467, -125, -478, -853, -1380, -2374, -2646, -3069, -3969,
-4464, -5553, -6456, -6432, -6812, -6934, -6822, -7232, -6903, -6337,
-6095, -5267, -4831, -4587, -3633, -3217, -2922, -2459, -2675, -2537,
-2199, -2180, -1406, -824, -749, -69, 465, 1303, 2787, 3504,
4150, 4965, 5274, 6231, 7218, 7415, 7750, 7509, 6917, 7092,
6823, 6358, 6069, 5071, 4511, 4349, 3662, 3384, 2981, 2177,
2083, 1684, 1146, 1065, 232, -560, -919, -1859, -2415, -3141,
-4629, -5334, -5874, -6440, -6326, -6886, -7442, -6983, -6733, -6070,
-5269, -5380, -4987, -4528, -4445, -3563, -3196, -3342, -3005, -3381,
-3522, -2858, -2688, -1998, -1309, -1287, -266, 708, 1354, 2624,
3043, 3483, 4769, 5273, 5919, 6669, 6434, 6874, 7145, 6518,
6629, 6386, 5886, 6060, 5427, 4975, 5179, 4472, 4135, 3847,
2892, 2964, 2792, 1924, 1610, 513, -589, -911, -2076, -2971,
-3578, -4936, -5356, -5565, -6336, -6223, -6439, -6679, -5821, -5672,
-5566, -5030, -5291, -4857, -4183, -4449, -4224, -4382, -4872, -4283,
-4070, -3874, -3084, -3070, -2649, -1732, -1334, -133, 1051, 1594,
2684, 3262, 3721, 5036, 5624, 6102, 6655, 6215, 6309, 6601,
6236, 6441, 6348, 5868, 6040, 5656, 5340, 5646, 5244, 5100,
4993, 3970, 3516, 2992, 1939, 1434, 476, -683, -1263, -2661,
-3768, -4086, -4817, -5045, -5314, -6202, -6031, -5727, -5605, -4827,
-4801, -4929, -4471, -4767, -4927, -4928, -5577, -5453, -5203, -5385,
-5036, -5044, -4941, -3830, -3511, -2835, -1608, -653,
// Loop Samples:
-82, 926,
1357, 2135, 3431, 3817, 4539, 4993, 5010, 5783, 6097, 5795,
6130, 6076, 6276, 6848, 6456, 6434, 6837, 6617, 6874, 6685,
5792, 5694, 5264, 4523, 4039, 2555, 1265, 443, -1124, -1957,
-2579, -3739, -4123, -4796, -5708, -5569, -5590, -5475, -4961, -5391,
-5479, -5173, -5566, -5465, -5509, -6095, -5969, -6236, -6546, -6082,
-6201, -6103, -5405, -5179, -4338, -3301, -2761, -1482, -409, 292,
1614, 2272, 2801, 3893, 4303, 4893, 5613, 5410, 5570, 5779,
5700, 6549, 7118, 7216, 7720, 7599, 7676, 8231, 7930, 7661,
7211, 6015, 5515, 4940, 3729, 2786, 1336, -123, -946, -2206,
-3101, -3437, -4195, -4490, -4739, -5387, -5245, -5227, -5634, -5503,
-5774, -5960, -5760, -6401, -6790, -6638, -6741, -6363, -6205, -6582,
-6270, -5941, -5512, -4366, -3731, -3012, -1877, -1267, -276, 796,
1269, 2168, 2760, 2873, 3667, 4074, 4201, 4742, 4667, 5029,
5986, 6356, 6976, 7374, 7167, 7628, 7915, 7781, 7984, 7509,
6964, 6786, 5851, 5022, 4233, 2712, 1757, 794, -631, -1313,
-2144, -3090, -3428, -4328, -4798, -4522, -4866, -4892, -4892, -5514,
-5392, -5475, -6064, -6076, -6540, -6860, -6430, -6735, -6783, -6394,
-6528, -5834, -4874, -4385, -3193, -2371, -1908, -736, -165, 502,
1602, 1688, 2053, 2580, 2462, 3136, 3546, 3346, 3952, 4145,
4372, 5473, 5901, 6555, 7553, 7538, 7902, 8191, 7552, 7467,
7054, 6346, 6162, 4912, 3384, 2460, 1023, 354, 100, -1028,
-1564, -2194, -3243, -3264, -3459, -3754, -3542, -4409, -5105, -4919,
-5300, -5303, -5425, -6315, -6242, -6324, -6720, -6186, -6306, -6370,
-5460, -5130, -4244, -3030, -2855, -2149, -1396, -1176, -161, 197,
247, 952, 714, 640, 1301, 1164, 1538, 2123, 2079, 3142,
4105, 4479, 5655, 6064, 6309, 7276, 7119, 7123, 7426, 6681,
6596, 6473, 5466, 5105, 4081, 2765, 2564, 1686, 928, 793,
-323, -840, -879, -1527, -1332, -1632, -2778, -2928, -3469, -3948,
-3540, -4200, -4841, -5117, -6233, -6249, -5837, -6139, -5629, -5665,
-5996, -5089, -4808, -4496, -3488, -3446, -2772, -1777, -1933, -1388,
-1096, -1450, -697, -495, -477, 484, 557, 1091, 2543, 2973,
3984, 4863, 4657, 5638, 6384, 6479, 7333, 7068, 6608, 7075,
6541, 6331, 6300, 4853, 4278, 3992, 3089, 3156, 2532, 1382,
1338, 556, 69, 397, -689, -1314, -1494, -2602, -2532, -2727,
-3927, -4081, -5033, -6057, -5724, -6274, -6529, -6161, -6886, -6453,
-5540, -5628, -4785, -4566, -4818, -3632, -3331, -3218, -2188, -2377,
-2111, -1306, -1602, -882, -187, -437, 643, 1347, 1798, 3219,
3289, 3437, 4582, 4715, 5540, 6449, 5933, 6424, 6768, 6360,
6978, 6410, 5320, 5383, 4514, 4077, 4318, 3251, 2955, 2710,
1489, 1792, 1743, 885, 874, -223, -1186, -1105, -2204, -2875,
-3217, -4806, -5346, -5645, -6297, -5595, -5747, -6410, -5682, -5544,
-5103, -4192, -4738, -4562, -3845, -3888, -2992, -2715, -3225, -2638,
-2757, -2912, -2091, -2277, -1985, -995, -817, 298, 1354, 1365,
2387, 3117, 3602, 5171, 5615, 5792, 6441, 5968, 6258, 6977,
6420, 6324, 5836, 4765, 5095, 4953, 4388, 4572, 3805, 3319,
3554, 2710, 2342, 1925, 445, 56, -431, -1463, -1602, -2582,
-3775, -3945, -4871, -5171, -4838, -5542, -5494, -5357, -5835, -5047,
-4643, -4947, -4484, -4739, -4638, -3651, -3897, -3948, -3644, -4059,
-3394, -2838, -3176, -2637, -2488, -2229, -783, -163, 457, 1575,
1705, 2646, 4021, 4446, 5417, 5689, 5127, 5554, 5545, 5526,
6062, 5304, 4883, 5295, 4956, 5288, 5444, 4624, 4748, 4579,
4047, 4289, 3523, 2578, 2302, 1187, 656, 320, -1208, -1978,
-2585, -3596, -3690, -4393, -5212, -4913, -5206, -5244, -4723, -5124,
-4949, -4683, -5177, -4661, -4265, -4508, -4253, -4836, -5282, -4657,
-4625, -4300, -3663, -3831, -3162, -2155, -1523, -165, 569, 882,
1994, 2574, 3343, 4450, 4308, 4270, 4527, 4398, 5139, 5575,
5179, 5362, 5106, 4992, 5711, 5693, 5763, 6012, 5509, 5670,
5726, 4795, 4195, 3214, 2264, 2211, 1267, -118, -1181, -2584,
-3170, -3342, -4062, -4255, -4600, -5292, -5138, -5214, -5253, -4684,
-4875, -5050, -4866, -5169, -4837, -4485, -4940, -5025, -5291, -5490,
-4852, -4582, -4238, -3163, -2620, -1760, -867, -326,};
const uint16_t WaveTable_Celesta_C5_Increment[]={
3, 4, 4, 4, 5, 5, 5, 5, 6, 6,
7, 7, 7, 8, 8, 9, 10, 10, 11, 11,
12, 13, 14, 15, 15, 16, 17, 18, 20, 21,
22, 23, 25, 26, 28, 30, 31, 33, 35, 37,
40, 42, 45, 47, 50, 53, 56, 60, 63, 67,
71, 75, 80, 85, 90, 95, 101, 107, 113, 120,
127, 134, 143, 151, 160, 170, 180, 190, 202, 214,
227, 240, 254, 269, 286, 303, 321, 340, 360, 381,
404, 428, 454, 481, 509, 539, 572, 606, 642, 680,
720, 763, 808, 857, 908, 962, 1019, 1079, 1144, 1212,
1284, 1360, 1441, 1527, 1617, 1714, 1816, 1924, 2038, 2159,
2288, 2424, 2568, 2721, 2882, 3054, 3235, 3428, 3632, 3848,
4077, 4319, 4576, 4848, 5136, 5442, 5765, 6108,};
@@ -0,0 +1,11 @@
#ifndef __WAVETABLE_CELESTA_C5__
#define __WAVETABLE_CELESTA_C5__
#include <stdint.h>
// Sample's base frequency: 523.629906 Hz
// Sample's sample rate: 32000 Hz
#define WAVETABLE_CELESTA_C5_LEN 2608
#define WAVETABLE_CELESTA_C5_ATTACK_LEN 1998
#define WAVETABLE_CELESTA_C5_LOOP_LEN 610
extern const int16_t WaveTable_Celesta_C5[WAVETABLE_CELESTA_C5_LEN];
extern const uint16_t WaveTable_Celesta_C5_Increment[];
#endif
@@ -0,0 +1,159 @@
#include <stdint.h>
#include <WaveTable_Celesta_C6.h>
// Sample's base frequency: 1046.832025 Hz
// Sample's sample rate: 32000 Hz
const int16_t WaveTable_Celesta_C6[WAVETABLE_CELESTA_C6_LEN]={
// Attack Samples:
-126, 46, -68, 105, 10, -80, 274, 20, 228, 11,
473, 139, 568, 381, 707, 739, 1340, 1598, -872, -9072,
-9845, -6181, -452, 1399, -2002, 3272, 24345, 20587, 1495, 8390,
13074, -727,-10282, -8426,-15230, -9923, 1271,-10785,-18202, -3907,
-9044,-18986, -1366, 11172, -2065, 4477, 22083, 12858, -934, 13767,
16147, -8430, -210, 25642, 6687,-14206, 4064, 10394,-13637, -8863,
13332, -6710,-20858, 2819, 7017,-23088,-19545, 3804,-10445,-27497,
-2276, 10614, -7921, -7660, 14779, 9302, -7892, 7849, 24858, 2573,
-5891, 20419, 20469, -1111, 8924, 25426, 5732, -8190, 9350, 6885,
-17177,-12737, 4010, -8145,-22227, -4557, 490,-18971,-18781, -352,
-6672,-18313, -4794, 5930, -7894, -7792, 11093, 11323, 220, 8065,
18507, 9227, 3540, 15268, 15245, 2260, 5068, 13361, 2266, -3987,
5155, 4588, -6511, -4701, 2018, -8411,-15680, -7738, -5391,-14110,
-9207, 294, -6612,-12654, -2209, 1454, -7512, -5351, 6788, 4439,
-2401, 7843, 15983, 6112, 3851, 15440, 13451, 1676, 4888, 10797,
-121, -5472, 3390, 1115,-10786, -8034, -1660,-10756,-15741, -5493,
-3904,-11654, -6414, 2998, -3024, -7609, 2822, 5893, -1397, 1095,
11822, 8914, 2517, 8857, 12677, 2978, 359, 8812, 5621, -3907,
831, 5493, -2903, -6917, -117, -2528,-11805, -9230, -3398, -8260,
-12108, -4882, -2315, -8113, -5136, 3049, -1433, -5643, 3357, 9042,
3150, 4640, 12173, 9543, 4080, 9652, 12398, 5237, 3691, 9381,
6185, -1346, -259, 1316, -6232, -9920, -7007, -9056,-14989,-11920,
-6122, -8336,-10292, -3678, -765, -5709, -3474, 3773, 2840, 676,
7196, 10743, 5948, 5640, 10910, 8668, 4192, 7455, 9881, 5007,
4456, 8281, 4712, -1845, -37, -128, -7236,-10954, -7675, -9569,
-14589,-11405, -6840, -9929,-11589, -5365, -2638, -5478, 549, 8235,
7011, 5777, 11695, 13268, 8260, 7698, 10390, 7149, 3451, 5610,
7212, 1977, -115, 2527, -1434, -7140, -5667, -4592, -9792, -9621,
-5122, -6096, -8898, -4883, -2251, -6181, -7127, -1320, -164, -1504,
2628, 6878, 4743, 3920, 6924, 8036, 5598, 6188, 8628, 7909,
5915, 6959, 6844, 3198, 579, 46, -3276, -7620, -8134, -8096,
-10719,-11316, -8502, -8214, -9749, -7734, -4790, -5000, -3575, 1865,
4546, 3773, 6370, 9386, 8995, 8246, 10135, 10393, 8042, 7793,
9381, 7039, 2939, 2288, 1320, -3401, -5709, -5767, -7856,-10682,
-9578, -8561,-10194,-10353, -7673, -6946, -8165, -5923, -1202, -432,
479, 5396, 7850, 6245, 7626, 10846, 9529, 7720, 9967, 10411,
7367, 6586, 7625, 4661, 662, -3, -1392, -5445, -7511, -7115,
-9155,-11655,-10648, -9137,-10281,-10298, -7652, -5607, -5586, -3079,
1226, 2828, 3383, 6765, 8296, 7102, 7671, 10103, 9778, 8883,
10225, 10197, 6631, 4842, 4595, 1766, -2018, -2691, -3488, -6940,
-9028, -8454, -9381,-11072, -9529, -7398, -8173, -7890, -4312, -2362,
-2525, 160, 3744, 3975, 4543, 6652, 7508, 6434, 7344, 9293,
8873, 7459, 7684, 7019, 4239, 2148, 1962, -452, -3646, -4559,
-5393, -8586,-10155, -8845, -8942,-10038, -8460, -6044, -5489, -4633,
-1414, 681, 1349, 3803, 6182, 6011, 5906, 7447, 7895, 7092,
7279, 7936, 6798, 4582, 3797, 3089, 801, -830, -1683, -3483,
-5870, -6779, -7542, -9043, -9103, -7790, -7321, -7179, -5634, -3282,
-2321, -1130, 1378, 3266, 3903, 5013, 6439, 6662, 6418, 7199,
7906, 7183, 6443, 6138, 4784, 2795, 1825, 1111, -1107, -3213,
-4226, -5988, -8346, -8790, -8535, -9168, -8912, -6765, -5516, -5016,
-3110, -821, -121, 1180, 3788, 5135, 5225, 6842, 8443, 7725,
7164, 7810, 7284, 5507, 5077, 4860, 2656, 922, 784, -1004,
-4162, -5868, -6706, -8411, -9647, -9533, -8941, -8585, -7218, -5347,
-4368, -3858, -1687, 1031, 2348, 3615, 6177, 7302, 7199, 8240,
9219, 8184, 7266, 7380, 6251, 4058, 3482, 3144, 847, -1415,
-2077, -3623, -6660, -8229, -8466, -9495,-10073, -8765, -7636, -7258,
-6013, -3928, -2791, -1423, 1135, 3484, 4533, 5983, 7669, 8062,
7437, 7645, 7767, 7006, 6209, 5902, 5143, 3929, 2722, 1206,
-952, -2974, -4932, -6932, -8309, -8937, -9172, -8896, -8187, -7312,
-6434, -5522, -4206, -2551, -553, 1630, 3592, 5373, 6768, 7511,
7793, 7665, 7410, 6913, 6472, 6016, 5284, 4278, 3365, 2095,
384, -1515, -3612, -5839, -7574, -8884, -9822, -9656, -8710, -7927,
-7028, -5773, -4507, -3171, -1288, 1149, 3383, 5016, 6536, 7589,
7828, 7628, 7561, 7268, 6811, 6601, 6343, 5261, 3749, 2370,
821, -1321, -3759, -5596, -7145, -8544, -9380, -9570, -9270, -8629,
-7694, -6705, -5749, -4125, -2028, -4, 2258, 4634, 6296, 7275,
7737, 7998, 8092, 8194, 8094, 7522, 6741, 5924, 4414, 2355,
580, -1052, -3107, -5112, -6592, -7831, -8716, -9024, -9034, -8677,
-7597, -6593, -5923, -4636, -2698, -936, 927, 3232, 4895, 5791,
6416, 7018, 7097, 7104, 7554, 7626, 7142, 6796, 6000, 4412,
2701, 1023, -1208, -3576, -5245, -6797, -8360, -9147, -9058, -8905,
-8516, -7509, -6292, -5407, -4193, -2338, -203, 1904, 3856, 5452,
6611, 7060, 7354, 7534, 7469, 7186, 6811, 6304, 5564, 4431,
3074, 1740, 13, -1949, -3665, -5439, -7303, -8342, -8801, -9191,
-8756, -7433, -6562, -5919, -4378, -2569, -1418, 122, 2680, 4648,
5269, 6141, 7250, 7469, 7523, 8127, 7836, 6765, 6227, 5646,
3954, 2196, 779, -1198, -3524, -5194, -6574, -8287, -9386, -9394,
-9169, -8761, -7510, -6218, -5268, -3717, -1490, 478, 2199, 4377,
6152, 6853, 7398, 7991, 7817, 7290, 7481, 7346, 6083, 5100,
4604, 2978, 816, -530, -1812, -4104, -6062, -7103, -8421, -9667,
-9441, -8554, -8167, -7375, -5634, -4275, -3306, -1312, 1229, 3064,
4704, 6452, 7462, 7489, 7633, 7913, 7600, 7192, 7086, 6460,
5187, 4134, 2963, 978, -1387, -3095, -4915, -7193, -8872, -9352,
-9579, -9500, -8588, -7252, -6501, -5262, -3588, -1759,
// Loop Samples:
210, 2125,
4206, 5781, 6747, 7399, 7717, 7732, 7615, 7590, 7138, 6312,
5399, 4406, 2932, 1339, -196, -2176, -4336, -6138, -7518, -8674,
-9458, -9363, -8752, -7970, -6803, -5288, -4028, -2848, -971, 1154,
2907, 4646, 6358, 7170, 7431, 7840, 7918, 7415, 7188, 7088,
6257, 4906, 3705, 2251, 192, -1843, -3583, -5326, -7006, -8167,
-8875, -9230, -8796, -7926, -6993, -5973, -4597, -3232, -2040, -277,
1973, 3673, 4961, 6317, 7156, 7393, 7578, 7695, 7472, 7168,
6774, 5911, 4768, 3559, 1911, 65, -1741, -3797, -5842, -7372,
-8701, -9725, -9749, -8991, -8346, -7522, -6089, -4758, -3548, -1558,
766, 2646, 4347, 6144, 7329, 7628, 8174, 8751, 8459, 7859,
7737, 7165, 5514, 3956, 2706, 650, -1792, -3375, -4931, -7157,
-8563, -8780, -9319, -9884, -8838, -7411, -6981, -5951, -3715, -2143,
-861, 1573, 3987, 5070, 6071, 7679, 8203, 7760, 8042, 8414,
7477, 6454, 5972, 4716, 2978, 1745, 369, -1641, -3538, -5088,
-6799, -8449, -9335, -9357, -9119, -8680, -7502, -6050, -4936, -3642,
-1805, -104, 1645, 3724, 5608, 6700, 7495, 8402, 8860, 8353,
7754, 7594, 6907, 5408, 4475, 3483, 1213, -1003, -2476, -4635,
-7330, -8486, -8774, -9701,-10004, -8459, -7179, -7056, -6020, -3894,
-2573, -1173, 1428, 3776, 4776, 6052, 7698, 8025, 7471, 8081,
8747, 7691, 6550, 6575, 5748, 3582, 2090, 984, -1473, -4165,
-5435, -7010, -9407,-10202, -9342, -9458, -9519, -7591, -5808, -5566,
-4169, -1302, 504, 1908, 4593, 6613, 6747, 7248, 8729, 8833,
7857, 7870, 8116, 6906, 5339, 4602, 3229, 808, -1061, -2477,
-4745, -6885, -7833, -8704, -9976, -9865, -8464, -7846, -7475, -5840,
-4231, -3305, -1451, 1231, 3178, 4608, 6317, 7367, 7464, 7913,
8501, 8151, 7378, 7201, 6785, 5384, 3913, 2746, 869, -1505,
-3290, -4892, -7024, -8644, -9021, -9201, -9407, -8584, -7215, -6587,
-5889, -4158, -2248, -661, 1386, 3825, 5427, 6280, 7393, 8209,
8140, 8126, 8486, 7998, 6922, 6291, 5329, 3325, 1322, -166,
-2311, -4780, -6330, -7451, -8871, -9713, -9273, -8709, -8515, -7581,
-6027, -4963, -3802, -1535, 925, 2655, 4502, 6543, 7518, 7638,
8286, 8877, 8447, 8009, 8077, 7325, 5698, 4349, 2871, 476,
-1881, -3560, -5420, -7659, -9053, -9383, -9828,-10079, -9139, -7866,
-7211, -6025, -3796, -1974, -466, 2088, 4569, 5666, 6657, 8094,
8555, 8235, 8729, 9121, 8139, 6991, 6371, 4920, 2777, 1206,
-272, -2584, -4804, -6118, -7560, -9218, -9816, -9553, -9508, -9101,
-7680, -6236, -5358, -3735, -1298, 726, 2494, 4696, 6514, 7419,
8080, 8792, 8950, 8704, 8630, 8237, 6921, 5324, 4093, 2593,
466, -1576, -3291, -5191, -6981, -8300, -9325, -9967, -9819, -9147,
-8293, -7188, -5736, -4245, -2734, -892, 1396, 3498, 5189, 6627,
7778, 8454, 8800, 8803, 8530, 8078, 7415, 6323, 4967, 3499,
1797, -17, -1876, -4087, -6187, -7605, -8684, -9554, -9816, -9185,
-8265, -7320, -6258, -4967, -3480, -1699, 218, 2172, 3987, 5614,
6852, 7601, 7892, 8218, 8446, 8100, 7312, 6623, 5738, 4342,
2786, 1369, -397, -2610, -4462, -5920, -7692, -9136, -9398, -9330,
-8986, -8019, -6868, -5983, -4467, -2578, -1031, 705, 2916, 4426,
5514, 6983, 8075, 8159, 8333, 8578, 8121, 7243, 6541, 5425,
3709, 2328, 1041, -1249, -3791, -5410, -7024, -8895, -9747, -9539,
-9512, -9056, -7596, -6346, -5686, -4145, -1797, 111, 1820, 4183,
6067, 6843, 7445, 8272, 8309, 7860, 7956, 7892, 6882, 5740,
4855, 3401, 1468, -257, -2103, -4386, -6454, -7942, -9125, -9897,
-9668, -8949, -8218, -7304, -5857, -4482, -3074, -1103,};
const uint16_t WaveTable_Celesta_C6_Increment[]={
1, 2, 2, 2, 2, 2, 2, 2, 3, 3,
3, 3, 3, 4, 4, 4, 5, 5, 5, 5,
6, 6, 7, 7, 7, 8, 8, 9, 10, 10,
11, 11, 12, 13, 14, 15, 15, 16, 17, 18,
20, 21, 22, 23, 25, 26, 28, 30, 31, 33,
35, 37, 40, 42, 45, 47, 50, 53, 56, 60,
63, 67, 71, 75, 80, 85, 90, 95, 101, 107,
113, 120, 127, 135, 143, 151, 160, 170, 180, 190,
202, 214, 227, 240, 254, 270, 286, 303, 321, 340,
360, 381, 404, 428, 454, 481, 509, 540, 572, 606,
642, 680, 721, 763, 809, 857, 908, 962, 1019, 1080,
1144, 1212, 1284, 1361, 1442, 1527, 1618, 1714, 1816, 1924,
2039, 2160, 2289, 2425, 2569, 2722, 2884, 3055,};
@@ -0,0 +1,11 @@
#ifndef __WAVETABLE_CELESTA_C6__
#define __WAVETABLE_CELESTA_C6__
#include <stdint.h>
// Sample's base frequency: 1046.832025 Hz
// Sample's sample rate: 32000 Hz
#define WAVETABLE_CELESTA_C6_LEN 1358
#define WAVETABLE_CELESTA_C6_ATTACK_LEN 838
#define WAVETABLE_CELESTA_C6_LOOP_LEN 520
extern const int16_t WaveTable_Celesta_C6[WAVETABLE_CELESTA_C6_LEN];
extern const uint16_t WaveTable_Celesta_C6_Increment[];
#endif
+207
View File
@@ -0,0 +1,207 @@
//
// Created by YangYongbao on 2017/3/16.
//
#include "stm32f10x.h"
#include "stm32f10x_conf.h"
#include "FreeRTOS.h"
#include "task.h"
#include "uart_log.h"
#include "hal.h"
#include "usb_lib.h"
#include "usb_desc.h"
#include "usb_pwr.h"
#include "Player.h"
extern __IO uint8_t Receive_Buffer[64];
extern __IO uint32_t Receive_length;
extern __IO uint32_t length;
uint8_t Send_Buffer[64];
uint32_t packet_sent = 1;
uint32_t packet_receive = 1;
Player mPlayer;
void RCC_Configuration(void)
{
/* GPIOA, GPIOB clock enable */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOC, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
}
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
}
void TIM2_IRQHandler()
{
if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET)
{
TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
Player32kProc(&mPlayer);
}
//GPIO_ResetBits(GPIOC, GPIO_Pin_13);
}
void TIMER_Config(void)
{
TIM_TimeBaseInitTypeDef timerInitStructure;
timerInitStructure.TIM_Prescaler = 1;
timerInitStructure.TIM_CounterMode = TIM_CounterMode_Up;
timerInitStructure.TIM_Period = 1124;
timerInitStructure.TIM_ClockDivision = TIM_CKD_DIV1;
timerInitStructure.TIM_RepetitionCounter = 0;
TIM_TimeBaseInit(TIM2, &timerInitStructure);
TIM_ClearFlag(TIM2, TIM_IT_Update);
TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE);
TIM_Cmd(TIM2, ENABLE);
NVIC_InitTypeDef nvicStructure;
nvicStructure.NVIC_IRQChannel = TIM2_IRQn;
nvicStructure.NVIC_IRQChannelPreemptionPriority = 0;
nvicStructure.NVIC_IRQChannelSubPriority = 1;
nvicStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&nvicStructure);
}
//TIM3 PWM部分初始化
//PWM输出初始化
//arr:自动重装值
//psc:时钟预分频数
void TIM3_PWM_Init(u16 arr, u16 psc)
{
GPIO_InitTypeDef GPIO_InitStructure;
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_OCInitTypeDef TIM_OCInitStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); //使能定时器3时钟
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO, ENABLE); //使能GPIO外设和AFIO复用功能模块时钟
//GPIO_PinRemapConfig(GPIO_PartialRemap_TIM3, ENABLE); //Timer3部分重映射 TIM3_CH2->PB5
//设置该引脚为复用输出功能,输出TIM3 CH2的PWM脉冲波形 GPIOB.5
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; //TIM_CH2
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //复用推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure); //初始化GPIO
// GPIO_PinRemapConfig(GPIO_PartialRemap_TIM3, ENABLE);
//设置该引脚为复用输出功能,输出TIM3 CH3的PWM脉冲波形 GPIOB.0
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; //TIM_CH3
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //复用推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure); //初始化GPIO
//初始化TIM3
TIM_TimeBaseStructure.TIM_Period = arr; //设置在下一个更新事件装入活动的自动重装载寄存器周期的值
TIM_TimeBaseStructure.TIM_Prescaler = psc; //设置用来作为TIMx时钟频率除数的预分频值
TIM_TimeBaseStructure.TIM_ClockDivision = 0; //设置时钟分割:TDTS = Tck_tim
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; //TIM向上计数模式
TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure); //根据TIM_TimeBaseInitStruct中指定的参数初始化TIMx的时间基数单位
//初始化TIM3 Channel2 PWM模式
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2; //选择定时器模式:TIM脉冲宽度调制模式2
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; //比较输出使能
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; //输出极性:TIM输出比较极性高
TIM_OC2Init(TIM3, &TIM_OCInitStructure); //根据T指定的参数初始化外设TIM3 OC2
TIM_OC2PreloadConfig(TIM3, TIM_OCPreload_Enable); //使能TIM3在CCR2上的预装载寄存器
//初始化TIM3 Channel2 PWM模式
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2; //选择定时器模式:TIM脉冲宽度调制模式2
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; //比较输出使能
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low; //输出极性:TIM输出比较极性高
TIM_OC3Init(TIM3, &TIM_OCInitStructure); //根据T指定的参数初始化外设TIM3 OC3
TIM_OC3PreloadConfig(TIM3, TIM_OCPreload_Enable);
TIM_Cmd(TIM3, ENABLE); //使能TIM3
}
void vTaskFunction(void *pvParameters)
{
debug("start task");
while (1)
{
debug("led on ");
GPIO_SetBits(GPIOC, GPIO_Pin_13);
vTaskDelay(100);
debug("led off ");
GPIO_ResetBits(GPIOC, GPIO_Pin_13);
vTaskDelay(100);
}
}
void vPlayTask(void *pvParameters)
{
PlayerInit(&mPlayer);
PlayerPlay(&mPlayer);
TIM3_PWM_Init(1023, 0);
TIMER_Config();
while (1)
{
PlayerProcess(&mPlayer);
vTaskDelay(1);
}
}
void vTaskUsb(void *pvParameters)
{
while (1)
{
if (bDeviceState == CONFIGURED)
{
CDC_Receive_DATA();
/*Check to see if we have data yet */
if (Receive_length != 0)
{
if (packet_sent == 1)
CDC_Send_DATA((unsigned char *)Receive_Buffer, Receive_length);
for (int32_t i = 0; i < Receive_length; i += 4)
{
if (Receive_Buffer[i] == 0x09 && Receive_Buffer[i + 3] != 0x00)
{
NoteOnAsm(&mPlayer.mainSynthesizer, Receive_Buffer[i + 2]);
}
}
Receive_length = 0;
}
}
vTaskDelay(1);
}
}
extern void stdio_setup(void);
extern void TestProcess(void);
int main()
{
// init uart log
stdio_setup();
uart_log_init();
RCC_Configuration();
GPIO_Configuration();
Set_System();
//Set_USBClock();
//USB_Interrupts_Config();
//USB_Init();
debug("start main ");
const char *pcTextForTask1 = "Task1 is running\r\n";
// TestProcess();
xTaskCreate(vTaskFunction, "Task 1", 512, (void *)pcTextForTask1, 1, NULL);
//xTaskCreate(vTaskUsb, "Task usb", 1024, NULL, 1, NULL);
xTaskCreate(vPlayTask, "Task play", 512, NULL, 1, NULL);
vTaskStartScheduler();
while (1)
;
return 0;
}
+137
View File
@@ -0,0 +1,137 @@
#ifdef __AVR_ARCH__
#include <avr/pgmspace.h>
const unsigned char Score[] PROGMEM ={
#else
const unsigned char Score[]={
#endif
0x00,0x4b,0x4f,0x52,0xbf,0x25,0xc6,0x26,0xcb,0x25,0xcf,0x26,0xcb,0x25,0xc6,0x26,0xbf,0x25,
0xc6,0x26,0xcb,0x25,0xcf,0x26,0xcb,0x25,0xc6,0x26,0x57,0x4b,0x52,0xbf,0x25,0xc6,0x26,
0x5e,0xcb,0x25,0xcf,0x26,0xcb,0x25,0x57,0xc6,0x26,0x56,0x4b,0x52,0xc3,0x25,0xca,0x26,
0x5e,0xcd,0x25,0xd2,0x26,0xcd,0x25,0x5e,0xca,0x26,0x60,0x50,0x54,0xc4,0x25,0xcb,0x26,
0x5e,0xd0,0x25,0xd4,0x26,0x5c,0xd0,0x25,0xcb,0x26,0x5e,0x4f,0x52,0xc3,0x25,0xcb,0x26,
0xd2,0x25,0xcb,0x26,0x60,0xd2,0x25,0x62,0xcb,0x26,0x63,0x50,0x54,0xc4,0x25,0x54,0xcb,
0x26,0x62,0xd4,0x25,0xcb,0x26,0x60,0xd4,0x25,0xcb,0x26,0x5e,0x4f,0x52,0xc3,0x25,0xcb,
0x26,0x63,0xd2,0x25,0xcb,0x26,0x57,0xd2,0x25,0x59,0xcb,0x26,0x5b,0x4f,0x51,0x54,0xc1,
0x25,0xcb,0x26,0x54,0xd0,0x25,0x60,0xcb,0x26,0x5b,0x54,0xd0,0x25,0x57,0xcb,0x26,0x59,
0x52,0x57,0xc6,0x25,0xcd,0x26,0x57,0xd0,0x25,0xcd,0x26,0x52,0x56,0xd0,0x25,0xcd,0x26,
0x57,0x52,0x57,0xbf,0x25,0xc6,0x26,0x5e,0x52,0xcb,0x25,0xcf,0x26,0xcb,0x25,0x57,0xc6,
0x26,0x56,0x4b,0x52,0xc3,0x25,0xca,0x26,0x5e,0xcd,0x25,0xd2,0x26,0xcd,0x25,0x5e,0xca,
0x26,0x60,0x50,0x54,0xc4,0x25,0xcb,0x26,0x5e,0xd0,0x25,0xd4,0x26,0x5c,0xd0,0x25,0xcb,
0x26,0x5e,0x4f,0x52,0xc3,0x25,0xcb,0x26,0xcd,0x25,0xd2,0x26,0x60,0x4f,0x52,0xcd,0x25,
0x62,0x4f,0x52,0xcb,0x26,0x63,0x52,0x57,0xc8,0x25,0xcf,0x26,0x62,0xd4,0x25,0xd7,0x26,
0x60,0xd4,0x25,0xcf,0x26,0x5e,0xcf,0x25,0xcd,0x26,0x63,0x52,0xcf,0x25,0xd7,0x26,0x67,
0x52,0xcf,0x25,0xcd,0x26,0x68,0x50,0xd4,0x4b,0x60,0x52,0x56,0xd4,0x25,0x62,0x52,0x56,
0xd7,0x26,0x67,0xd6,0x25,0xe5,0x26,0x63,0x52,0x57,0x4f,0xcb,0x4b,0xd2,0x25,0xd2,0x26,
0xd7,0x25,0xdb,0x26,0x59,0xba,0x25,0xc1,0x26,0x59,0xc6,0x25,0xca,0x26,0xcd,0x25,0x52,
0xca,0x26,0x59,0x5b,0xbf,0x25,0xc6,0x26,0x57,0xcf,0x25,0xc6,0x26,0xcf,0x25,0x52,0x5b,
0xc6,0x26,0x5c,0x54,0xbf,0x25,0xc8,0x26,0x5c,0x54,0xd0,0x25,0xc8,0x26,0x52,0x59,0x5b,
0xd0,0x25,0x52,0x5c,0xc8,0x26,0x5e,0x5b,0x56,0xbf,0x25,0xc6,0x26,0x5b,0xcf,0x25,0xc6,
0x26,0x57,0xcf,0x25,0x5e,0xc6,0x26,0x5e,0x5a,0xbe,0x25,0x5d,0xc5,0x26,0x5d,0xce,0x25,
0xc5,0x26,0x5e,0xce,0x25,0x60,0xc5,0x26,0x60,0x5d,0xc3,0x25,0xca,0x26,0x5e,0x5b,0x56,
0xd2,0x25,0xca,0x26,0x5e,0xcf,0x25,0x60,0xca,0x17,0xd9,0x05,0xdc,0x05,0xe1,0x05,0xc3,
0x25,0xc9,0x26,0x60,0xcd,0x25,0xcf,0x26,0x5e,0xd2,0x3c,0xd8,0x05,0xdb,0x05,0xdc,0x05,
0xbc,0x25,0xc3,0x26,0x5b,0xc8,0x25,0xcc,0x26,0x5c,0xcf,0x25,0x5e,0xcc,0x17,0xd9,0x05,
0xdc,0x05,0xe0,0x05,0xc1,0x25,0xc8,0x26,0x5e,0xd0,0x25,0xc8,0x26,0x5c,0xd0,0x25,0xc8,
0x17,0xc1,0x05,0xc6,0x02,0xd6,0x03,0xca,0x05,0xdb,0x4b,0x54,0xda,0x4b,0x54,0xd9,0x4b,
0x57,0x52,0x57,0x3f,0xb7,0x25,0xc6,0x26,0x5e,0xcb,0x25,0xcf,0x26,0xcb,0x25,0x57,0xc6,
0x26,0x56,0x52,0x43,0xb7,0x25,0xca,0x26,0x5e,0x52,0x56,0xcd,0x25,0xd2,0x26,0xcd,0x25,
0x5e,0x52,0xca,0x26,0x60,0x5c,0x5c,0x59,0x44,0xb8,0x25,0xcb,0x26,0x5e,0x5b,0x5b,0xd0,
0x25,0xd4,0x26,0x5c,0x59,0x59,0xd0,0x25,0xcb,0x26,0x5e,0x5b,0x5e,0x5b,0x56,0x43,0xb7,
0x25,0xca,0x26,0xcd,0x25,0xd2,0x26,0x60,0x5c,0xcd,0x25,0x62,0x5c,0xcb,0x26,0x63,0x5b,
0x63,0x60,0x5b,0x52,0xc8,0x25,0xcf,0x26,0xd4,0x25,0xd7,0x26,0x62,0x59,0x5f,0x59,0x56,
0xc7,0x25,0x65,0x5c,0x62,0x5c,0xd9,0x26,0x63,0x5b,0x63,0x60,0x5b,0x52,0xc6,0x25,0xcf,
0x26,0xd4,0x25,0xd7,0x26,0x65,0x60,0x62,0x5c,0x54,0xc5,0x25,0xcf,0x26,0x67,0x5e,0x63,
0x5e,0x5b,0x57,0x52,0xcf,0x4b,0x68,0x60,0x63,0x5e,0x5b,0x57,0x54,0xcd,0x4b,0x67,0x5e,
0x62,0x5c,0x59,0x56,0x52,0xcd,0x25,0x65,0x5c,0xd0,0x26,0x63,0x5b,0x63,0x5e,0x57,0x52,
0x4f,0xcb,0x4b,0xcf,0x25,0xcf,0x26,0xd2,0x4b,0x62,0x5f,0x37,0x3b,0xc1,0x25,0x60,0xb7,
0x09,0xc3,0x0a,0xb7,0x09,0xc3,0x0a,0x5f,0xb7,0x09,0xc3,0x09,0xb7,0x0a,0xc3,0x09,0x5c,
0x5f,0xb7,0x09,0xc3,0x0a,0xb7,0x09,0xc3,0x0a,0x5b,0xb7,0x09,0xc3,0x09,0xb7,0x0a,0xc3,
0x09,0x59,0xb7,0x09,0xc3,0x0a,0xb7,0x09,0xc3,0x0a,0x54,0x4c,0x54,0x30,0xbc,0x4b,0xdb,
0x4b,0x30,0xbc,0x25,0x54,0x4d,0xd4,0x26,0x53,0x4c,0x4f,0x53,0x56,0x34,0xc0,0x4b,0x5b,
0xd1,0x4b,0x4f,0x34,0xc0,0x25,0x5b,0xd6,0x26,0x5d,0x53,0x54,0x35,0xc1,0x4b,0xdb,0x4b,
0x59,0x51,0x54,0x35,0xc1,0x4b,0x5b,0x4c,0x56,0x34,0xc0,0x96,0x5d,0x4f,0x54,0x34,0xc0,
0x25,0x5f,0x4f,0xd3,0x26,0x60,0x51,0x35,0xc1,0x4b,0x5f,0x35,0xc1,0x25,0x53,0x37,0xc3,
0x26,0x5d,0x4d,0x51,0x39,0xc5,0x25,0x35,0xc1,0x26,0x5b,0x4c,0x54,0x34,0xc0,0x4b,0x60,
0x34,0xc0,0x25,0x37,0xc3,0x26,0x54,0x4c,0x54,0x34,0xc0,0x25,0xd6,0x26,0x58,0x4e,0x54,
0x32,0xbe,0x70,0x5d,0xcc,0x26,0x58,0x4e,0x53,0x32,0xbe,0x25,0x54,0xd4,0x26,0x56,0x4f,
0x56,0x37,0xc3,0x4b,0x37,0xc3,0x25,0x39,0xc5,0x26,0x3b,0xc7,0x25,0x37,0xc3,0x17,0xe0,
0x05,0xe2,0x05,0xe7,0x05,0x60,0x30,0x37,0xbc,0x25,0xc3,0x26,0x67,0x6c,0x64,0x60,0x48,
0xcc,0x25,0x6b,0x62,0x5f,0xc3,0x26,0x6e,0x65,0x62,0x4c,0xc8,0x25,0x60,0x6c,0x64,0x60,
0xc3,0x17,0xdb,0x05,0xdd,0x05,0xe2,0x05,0x5f,0x40,0x3b,0xb4,0x25,0xc7,0x26,0x67,0x6b,
0x5f,0x4f,0xcc,0x25,0x69,0x5d,0xc7,0x26,0x6c,0x60,0x4f,0xcc,0x25,0x67,0x6b,0x5f,0xc7,
0x17,0xd8,0x07,0xe0,0x08,0x69,0x41,0x3c,0xb5,0x25,0xc8,0x26,0x67,0x6c,0x60,0x51,0xcd,
0x25,0x6b,0x5f,0xc8,0x26,0x65,0x6e,0x62,0x51,0xcd,0x25,0x6c,0x60,0xc8,0x17,0xd8,0x07,
0xe0,0x08,0x67,0x40,0x3c,0xb4,0x25,0xc8,0x26,0x70,0x64,0x4f,0xcc,0x25,0x6e,0x62,0xc8,
0x26,0x69,0x71,0x65,0x4f,0xcc,0x25,0x6b,0x70,0x64,0xc8,0x17,0xd8,0x04,0xdb,0x03,0xe0,
0x04,0xe4,0x04,0x6c,0x45,0x40,0xb9,0x25,0xcc,0x26,0x6b,0x70,0x64,0xd1,0x25,0x6f,0x63,
0xcc,0x26,0x69,0x71,0x65,0xd1,0x25,0x70,0x64,0xcc,0x26,0x67,0x6e,0x62,0x40,0x3c,0xb4,
0x25,0x6c,0x60,0xc8,0x26,0x6c,0x6b,0x5f,0x4f,0xcc,0x25,0x69,0x5d,0xc8,0x26,0x70,0x67,
0x5b,0x4f,0xcc,0x25,0x65,0x59,0xc8,0x17,0xd8,0x05,0xdb,0x05,0xe0,0x05,0x71,0x32,0x39,
0xbe,0x25,0xc5,0x26,0x69,0x64,0x58,0x4a,0xcd,0x25,0x6b,0x62,0x56,0xc5,0x26,0x70,0x67,
0x5b,0x4f,0x4a,0xc7,0x25,0x6e,0x62,0xd6,0x1b,0xd4,0x03,0xd8,0x04,0xdb,0x04,0x6c,0x60,
0x40,0x43,0xc8,0x4b,0x4f,0xcc,0x25,0x5d,0xc8,0x26,0xdf,0x25,0xe0,0x26,0x62,0x43,0xb7,
0x25,0xca,0x26,0x62,0xcd,0x25,0xca,0x26,0xcd,0x25,0x5b,0xca,0x26,0x64,0x43,0xbc,0x25,
0xc8,0x26,0x4f,0xca,0x25,0xc8,0x26,0x4f,0xca,0x25,0x64,0xc8,0x26,0x65,0x5d,0xbc,0x25,
0xc5,0x26,0x65,0x5d,0x4d,0xd1,0x25,0xc5,0x26,0x64,0x5b,0x51,0xcd,0x25,0x65,0x5d,0xc5,
0x26,0x67,0x5f,0xbc,0x25,0xc8,0x26,0x4f,0xca,0x25,0xc8,0x26,0x4f,0xca,0x25,0x5b,0xc8,
0x26,0x69,0x53,0x58,0x5b,0x4b,0xc7,0x25,0x57,0x5a,0xcb,0x26,0x57,0x5a,0xce,0x25,0xcb,
0x26,0x58,0x5b,0xd1,0x25,0x5a,0x5d,0xcb,0x26,0x5d,0x5a,0x4c,0xc7,0x25,0xcc,0x26,0x58,
0x5b,0xd8,0x25,0xcc,0x26,0x58,0x5b,0xcf,0x25,0x5a,0x5d,0xcc,0x26,0x69,0x5e,0x5b,0x56,
0x4a,0xc6,0x25,0xca,0x26,0x5d,0xcf,0x25,0xd2,0x26,0x58,0x5b,0xd6,0x4b,0x51,0x55,0x59,
0x49,0xc5,0x25,0xcc,0x26,0x55,0x58,0xcf,0x25,0xd1,0x26,0x59,0xd5,0x25,0x58,0x5b,0xd1,
0x26,0x54,0x59,0x5d,0x48,0xbe,0x25,0xc5,0x26,0x58,0x5b,0xd1,0x25,0xca,0x26,0x56,0x59,
0xd1,0x25,0xca,0x26,0x53,0x58,0x4f,0x4a,0x47,0xc1,0x4b,0x51,0xd7,0x4b,0x62,0x51,0xd6,
0x19,0xe3,0x18,0xe5,0x19,0x67,0x6c,0xde,0x26,0xe7,0x25,0x65,0xdb,0x26,0x60,0xde,0x25,
0x65,0x6c,0xde,0x26,0x63,0x67,0xdb,0x25,0x62,0xec,0x26,0x67,0xdd,0x25,0x60,0x65,0xdb,
0x26,0x60,0xdd,0x25,0x6c,0xdd,0x26,0x62,0x67,0xdb,0x13,0xe3,0x12,0x65,0xec,0x26,0x67,
0xdc,0x25,0x65,0xd9,0x26,0x60,0xdc,0x25,0x63,0x6c,0xdc,0x26,0x61,0x67,0xd9,0x25,0x60,
0xec,0x26,0x67,0xdb,0x25,0x5f,0x64,0xd8,0x13,0xe1,0x13,0x5e,0xdb,0x13,0xdb,0x12,0x5e,
0x58,0xdb,0x19,0xd5,0x0d,0xd8,0x0c,0xd2,0x19,0x50,0x38,0xc4,0x4b,0x57,0x4b,0xc8,0x4b,
0x4b,0xc8,0x26,0xd0,0x17,0xc4,0x05,0xc6,0x05,0xc8,0x04,0xcf,0x4b,0x57,0x4b,0xc6,0x4b,
0x4b,0xc6,0x26,0xd7,0x25,0x59,0x49,0xbd,0x4b,0x57,0x4d,0xc9,0x4b,0x55,0x4d,0xc9,0x4b,
0x57,0x48,0xbc,0x4b,0x48,0xc4,0x4b,0x4b,0xc8,0x26,0xd4,0x25,0x55,0x3a,0xc6,0x4b,0x54,
0x4d,0xc9,0x4b,0x52,0x4d,0xc9,0x3d,0xc4,0x05,0xc8,0x05,0xcd,0x04,0xd4,0x4b,0x4d,0xc8,
0x4b,0x4d,0x4d,0xc8,0x26,0xd0,0x25,0x52,0x37,0xc3,0x26,0xd4,0x13,0xd2,0x12,0x50,0x49,
0xc6,0x4b,0x4f,0x48,0xc6,0x4b,0x50,0x35,0xc1,0x4b,0xb5,0x05,0xc1,0x05,0xb5,0x05,0xc1,
0x04,0xb5,0x05,0xc1,0x05,0xb5,0x04,0xc1,0x05,0x5c,0xb5,0x05,0xc1,0x04,0xb5,0x05,0xc1,
0x05,0xb5,0x04,0xc1,0x05,0xb5,0x05,0xc1,0x04,0x60,0xb5,0x05,0xc1,0x05,0xb5,0x05,0xc1,
0x04,0xb5,0x05,0xc1,0x05,0xb5,0x04,0xc1,0x05,0x63,0xb5,0x05,0xc1,0x04,0xb5,0x05,0xc1,
0x05,0xb5,0x04,0xc1,0x05,0xb5,0x05,0xc1,0x04,0x67,0x6d,0x61,0x3d,0xc9,0x13,0x6c,0xe0,
0x13,0x6a,0x5e,0x3d,0xc9,0x13,0x68,0xdc,0x12,0x67,0x5b,0x3d,0xc9,0x13,0x65,0xd9,0x13,
0x68,0x63,0x57,0x3d,0xc9,0x13,0x61,0xd5,0x12,0x65,0x54,0x60,0x3d,0xc9,0x13,0x52,0xde,
0x13,0x50,0x5c,0x3d,0xc9,0x13,0x4f,0xdb,0x12,0x63,0x50,0x5c,0x3c,0xc8,0x13,0x52,0xde,
0x13,0x54,0x60,0x3c,0xc8,0x13,0x55,0xe1,0x12,0x63,0x57,0x3c,0xc8,0x13,0x65,0xd9,0x13,
0x67,0x5b,0x3c,0xc8,0x13,0x68,0xdc,0x12,0x5c,0x63,0x57,0x3c,0xc8,0x13,0x65,0xd9,0x13,
0x67,0x5b,0x3c,0xc8,0x13,0x68,0xdc,0x12,0x63,0x6a,0x5e,0x3a,0xc6,0x13,0x6c,0xe0,0x13,
0x6d,0x61,0x3a,0xc6,0x13,0x6f,0xe3,0x12,0x6d,0x61,0x3a,0xc6,0x13,0x6c,0xe0,0x13,0x6a,
0x5e,0x3a,0xc6,0x13,0x68,0xdc,0x12,0x6c,0x60,0x3a,0xc6,0x13,0x6a,0xde,0x13,0x68,0x5c,
0x3a,0xc6,0x13,0x67,0xdb,0x12,0x62,0x65,0x59,0x3a,0xc6,0x13,0x63,0xd7,0x13,0x62,0x56,
0x3a,0xc6,0x13,0x60,0xd4,0x12,0x52,0x5e,0x3a,0xc6,0x13,0x50,0xdc,0x13,0x4f,0x5b,0x3a,
0xc6,0x13,0x4d,0xd9,0x12,0x52,0x5e,0x3a,0xc6,0x13,0x50,0xdc,0x13,0x4f,0x5b,0x3a,0xc6,
0x13,0x4d,0xd9,0x12,0x57,0xbf,0x26,0xc6,0x25,0x5e,0xcf,0x26,0xc6,0x25,0xcb,0x26,0x57,
0xc6,0x25,0x56,0xc3,0x26,0xca,0x25,0x5e,0xd2,0x26,0xca,0x25,0xcf,0x26,0x5e,0xca,0x25,
0x60,0xc4,0x26,0xcb,0x25,0x5e,0xd4,0x26,0xcb,0x25,0x5c,0xd0,0x26,0xcb,0x25,0x5e,0xc3,
0x26,0xcb,0x25,0xd2,0x26,0xcb,0x25,0x60,0xcf,0x26,0x62,0xcb,0x17,0xdc,0x05,0xde,0x05,
0xe3,0x04,0xc4,0x26,0xcb,0x25,0x62,0xd4,0x26,0xcb,0x25,0x60,0xd0,0x26,0xcb,0x25,0x5e,
0xc3,0x26,0xcb,0x25,0x63,0xd2,0x26,0xcb,0x25,0x57,0xd2,0x26,0xd9,0x25,0x5b,0xc1,0x26,
0xc8,0x25,0xd1,0x26,0xe0,0x25,0x5b,0xcb,0x26,0xd7,0x25,0x59,0xc6,0x26,0xcd,0x25,0x50,
0x57,0x5c,0xae,0x05,0xba,0x05,0xae,0x05,0xba,0x04,0xae,0x05,0xba,0x05,0xae,0x04,0xba,
0x05,0xae,0x05,0xba,0x04,0xae,0x05,0xba,0x05,0xae,0x04,0xba,0x05,0xae,0x05,0xba,0x04,
0x56,0xae,0x05,0xba,0x05,0xae,0x05,0xba,0x04,0xae,0x05,0xba,0x05,0xae,0x04,0xba,0x05,
0xae,0x05,0xba,0x04,0xae,0x05,0xba,0x05,0xae,0x04,0xba,0x05,0xae,0x05,0xba,0x04,0x57,
0x52,0x5b,0x3f,0x43,0x46,0xcb,0x4b,0x5e,0x63,0x5b,0x57,0x52,0xcf,0x26,0x62,0x59,0x56,
0xc6,0x25,0x65,0x5c,0x59,0x4f,0xcb,0x26,0x57,0x63,0x5b,0x57,0x4d,0x44,0xc1,0x25,0x56,
0x52,0x59,0x4f,0x46,0xc3,0x4b,0x5e,0x62,0x59,0x56,0x52,0xcf,0x26,0x60,0x57,0x54,0xc6,
0x25,0x63,0x5b,0x57,0x4f,0xcb,0x26,0x5e,0x62,0x59,0x56,0xc6,0x25,0x60,0x54,0x5c,0x50,
0x4b,0x48,0xc4,0x4b,0x5e,0x63,0x5b,0x57,0x54,0xd0,0x26,0x62,0x59,0x56,0xcb,0x25,0x5c,
0x65,0x5c,0x59,0x50,0xcd,0x26,0x63,0x5b,0x57,0xcb,0x25,0x5e,0x56,0x5e,0x4f,0x46,0xc3,
0x4b,0x67,0x5e,0x5b,0x52,0xcf,0x26,0x65,0x5c,0x59,0xc6,0x25,0x60,0x68,0x60,0x5c,0x4f,
0xcb,0x26,0x62,0x67,0x5e,0x5b,0xc6,0x25,0x63,0x60,0x57,0x54,0x4b,0xc8,0x4b,0x67,0x5e,
0xdb,0x26,0x66,0x5d,0xda,0x25,0x62,0x68,0x60,0x5c,0x53,0x4a,0xc7,0x26,0x65,0x67,0x5e,
0xdb,0x25,0x63,0x5e,0x57,0x52,0x4a,0xc6,0x4b,0x6c,0xe0,0x26,0x6b,0xdf,0x25,0x65,0x6e,
0x62,0x51,0x49,0xc5,0x26,0x6c,0xe0,0x25,0x67,0x5c,0x54,0x50,0x48,0xc4,0x4b,0x68,0x6f,
0x63,0x41,0x44,0xcd,0x26,0x6e,0xe2,0x25,0x67,0x73,0x67,0x52,0x4a,0xc6,0x26,0x65,0x6e,
0xe2,0x25,0x63,0x4b,0x4f,0x4f,0x4b,0xc3,0x4b,0x60,0xd4,0x4b,0x63,0xd7,0x26,0xdb,0x25,
0x60,0x65,0x59,0x4d,0x48,0xc1,0x4b,0x6a,0xde,0x4b,0x67,0xdb,0x4b,0x65,0x65,0x5e,0x5b,
0x4b,0x46,0xbf,0x4b,0xcd,0x26,0xcf,0x25,0xd2,0x26,0xd7,0x25,0xd9,0x26,0xdb,0x25,0xde,
0x26,0xe3,0x25,0xe5,0x26,0xea,0x25,0xef,0xe1,0xff,};