@@ -104,39 +104,39 @@ int main(void)
|
|||||||
// Generate dummy data
|
// Generate dummy data
|
||||||
#if CFG_TUD_AUDIO_ENABLE_ENCODING
|
#if CFG_TUD_AUDIO_ENABLE_ENCODING
|
||||||
uint16_t * p_buff = i2s_dummy_buffer[0];
|
uint16_t * p_buff = i2s_dummy_buffer[0];
|
||||||
uint16_t dataVal = 1;
|
uint16_t dataVal = 0;
|
||||||
for (uint16_t cnt = 0; cnt < AUDIO_SAMPLE_RATE/1000; cnt++)
|
for (uint16_t cnt = 0; cnt < AUDIO_SAMPLE_RATE/1000; cnt++)
|
||||||
{
|
{
|
||||||
// CH0 saw wave
|
// CH0 saw wave
|
||||||
*p_buff++ = dataVal;
|
*p_buff++ = dataVal;
|
||||||
// CH1 inverted saw wave
|
// CH1 inverted saw wave
|
||||||
*p_buff++ = 60 + AUDIO_SAMPLE_RATE/1000 - dataVal;
|
*p_buff++ = 3200 + AUDIO_SAMPLE_RATE/1000 - dataVal;
|
||||||
dataVal++;
|
dataVal+= 32;
|
||||||
}
|
}
|
||||||
p_buff = i2s_dummy_buffer[1];
|
p_buff = i2s_dummy_buffer[1];
|
||||||
for (uint16_t cnt = 0; cnt < AUDIO_SAMPLE_RATE/1000; cnt++)
|
for (uint16_t cnt = 0; cnt < AUDIO_SAMPLE_RATE/1000; cnt++)
|
||||||
{
|
{
|
||||||
// CH3 square wave
|
// CH3 square wave
|
||||||
*p_buff++ = cnt < (AUDIO_SAMPLE_RATE/1000/2) ? 120:170;
|
*p_buff++ = cnt < (AUDIO_SAMPLE_RATE/1000/2) ? 3400:5000;
|
||||||
// CH4 sinus wave
|
// CH4 sinus wave
|
||||||
float t = 2*3.1415f * cnt / (AUDIO_SAMPLE_RATE/1000);
|
float t = 2*3.1415f * cnt / (AUDIO_SAMPLE_RATE/1000);
|
||||||
*p_buff++ = (uint16_t)(sinf(t) * 25) + 200;
|
*p_buff++ = (uint16_t)((int16_t)(sinf(t) * 750) + 6000);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
uint16_t * p_buff = i2s_dummy_buffer;
|
uint16_t * p_buff = i2s_dummy_buffer;
|
||||||
uint16_t dataVal = 1;
|
uint16_t dataVal = 0;
|
||||||
for (uint16_t cnt = 0; cnt < AUDIO_SAMPLE_RATE/1000; cnt++)
|
for (uint16_t cnt = 0; cnt < AUDIO_SAMPLE_RATE/1000; cnt++)
|
||||||
{
|
{
|
||||||
// CH0 saw wave
|
// CH0 saw wave
|
||||||
*p_buff++ = dataVal;
|
*p_buff++ = dataVal;
|
||||||
// CH1 inverted saw wave
|
// CH1 inverted saw wave
|
||||||
*p_buff++ = 60 + AUDIO_SAMPLE_RATE/1000 - dataVal;
|
*p_buff++ = 3200 + AUDIO_SAMPLE_RATE/1000 - dataVal;
|
||||||
dataVal++;
|
dataVal+= 32;
|
||||||
// CH3 square wave
|
// CH3 square wave
|
||||||
*p_buff++ = cnt < (AUDIO_SAMPLE_RATE/1000/2) ? 120:170;
|
*p_buff++ = cnt < (AUDIO_SAMPLE_RATE/1000/2) ? 3400:5000;
|
||||||
// CH4 sinus wave
|
// CH4 sinus wave
|
||||||
float t = 2*3.1415f * cnt / (AUDIO_SAMPLE_RATE/1000);
|
float t = 2*3.1415f * cnt / (AUDIO_SAMPLE_RATE/1000);
|
||||||
*p_buff++ = (uint16_t)(sinf(t) * 25) + 200;
|
*p_buff++ = (uint16_t)((int16_t)(sinf(t) * 750) + 6000);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -35,11 +35,7 @@
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
// List of supported sample rates
|
// List of supported sample rates
|
||||||
#if defined(__RX__)
|
const uint32_t sample_rates[] = {44100, 48000};
|
||||||
const uint32_t sample_rates[] = {44100, 48000};
|
|
||||||
#else
|
|
||||||
const uint32_t sample_rates[] = {44100, 48000, 88200, 96000};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint32_t current_sample_rate = 44100;
|
uint32_t current_sample_rate = 44100;
|
||||||
|
|
||||||
|
@@ -114,11 +114,9 @@ extern "C" {
|
|||||||
#define CFG_TUD_AUDIO_FUNC_1_N_FORMATS 2
|
#define CFG_TUD_AUDIO_FUNC_1_N_FORMATS 2
|
||||||
|
|
||||||
// Audio format type I specifications
|
// Audio format type I specifications
|
||||||
#if defined(__RX__)
|
/* 24bit/48kHz is the best quality for headset or 24bit/96kHz for 2ch speaker,
|
||||||
#define CFG_TUD_AUDIO_FUNC_1_MAX_SAMPLE_RATE 48000 // 16bit/48kHz is the best quality for Renesas RX
|
high-speed is needed beyond this */
|
||||||
#else
|
#define CFG_TUD_AUDIO_FUNC_1_MAX_SAMPLE_RATE 48000
|
||||||
#define CFG_TUD_AUDIO_FUNC_1_MAX_SAMPLE_RATE 96000 // 24bit/96kHz is the best quality for full-speed, high-speed is needed beyond this
|
|
||||||
#endif
|
|
||||||
#define CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX 1
|
#define CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX 1
|
||||||
#define CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_RX 2
|
#define CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_RX 2
|
||||||
|
|
||||||
|
@@ -35,12 +35,12 @@ extern "C" {
|
|||||||
// LED
|
// LED
|
||||||
#define LED_PORT GPIOI
|
#define LED_PORT GPIOI
|
||||||
#define LED_PIN GPIO_PIN_9
|
#define LED_PIN GPIO_PIN_9
|
||||||
#define LED_STATE_ON 0
|
#define LED_STATE_ON 1
|
||||||
|
|
||||||
// Button
|
// Button
|
||||||
#define BUTTON_PORT GPIOC
|
#define BUTTON_PORT GPIOC
|
||||||
#define BUTTON_PIN GPIO_PIN_13
|
#define BUTTON_PIN GPIO_PIN_13
|
||||||
#define BUTTON_STATE_ACTIVE 0
|
#define BUTTON_STATE_ACTIVE 1
|
||||||
|
|
||||||
// UART Enable for STLink VCOM
|
// UART Enable for STLink VCOM
|
||||||
#define UART_DEV USART1
|
#define UART_DEV USART1
|
||||||
|
@@ -73,10 +73,10 @@ void board_init(void) {
|
|||||||
__HAL_RCC_GPIOE_CLK_ENABLE();
|
__HAL_RCC_GPIOE_CLK_ENABLE();
|
||||||
#endif
|
#endif
|
||||||
#ifdef __HAL_RCC_GPIOG_CLK_ENABLE
|
#ifdef __HAL_RCC_GPIOG_CLK_ENABLE
|
||||||
__HAL_RCC_GPIOE_CLK_ENABLE();
|
__HAL_RCC_GPIOG_CLK_ENABLE();
|
||||||
#endif
|
#endif
|
||||||
#ifdef __HAL_RCC_GPIOI_CLK_ENABLE
|
#ifdef __HAL_RCC_GPIOI_CLK_ENABLE
|
||||||
__HAL_RCC_GPIOE_CLK_ENABLE();
|
__HAL_RCC_GPIOI_CLK_ENABLE();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
UART_CLK_EN();
|
UART_CLK_EN();
|
||||||
|
@@ -163,7 +163,7 @@ uint32_t board_millis(void)
|
|||||||
|
|
||||||
void HardFault_Handler (void)
|
void HardFault_Handler (void)
|
||||||
{
|
{
|
||||||
asm("bkpt");
|
__asm("BKPT #0\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_FULL_ASSERT
|
#ifdef USE_FULL_ASSERT
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -298,6 +298,9 @@ TU_ATTR_ALWAYS_INLINE static inline uint32_t pcd_get_ep_rx_cnt(USB_TypeDef * USB
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define pcd_get_ep_dbuf0_cnt pcd_get_ep_tx_cnt
|
||||||
|
#define pcd_get_ep_dbuf1_cnt pcd_get_ep_rx_cnt
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Sets address in an endpoint register.
|
* @brief Sets address in an endpoint register.
|
||||||
* @param USBx USB peripheral instance register address.
|
* @param USBx USB peripheral instance register address.
|
||||||
@@ -331,6 +334,9 @@ TU_ATTR_ALWAYS_INLINE static inline uint32_t pcd_get_ep_rx_address(USB_TypeDef *
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define pcd_get_ep_dbuf0_address pcd_get_ep_tx_address
|
||||||
|
#define pcd_get_ep_dbuf1_address pcd_get_ep_rx_address
|
||||||
|
|
||||||
TU_ATTR_ALWAYS_INLINE static inline void pcd_set_ep_tx_address(USB_TypeDef * USBx, uint32_t bEpIdx, uint32_t addr) {
|
TU_ATTR_ALWAYS_INLINE static inline void pcd_set_ep_tx_address(USB_TypeDef * USBx, uint32_t bEpIdx, uint32_t addr) {
|
||||||
#ifdef FSDEV_BUS_32BIT
|
#ifdef FSDEV_BUS_32BIT
|
||||||
(void) USBx;
|
(void) USBx;
|
||||||
@@ -349,6 +355,9 @@ TU_ATTR_ALWAYS_INLINE static inline void pcd_set_ep_rx_address(USB_TypeDef * USB
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define pcd_set_ep_dbuf0_address pcd_set_ep_tx_address
|
||||||
|
#define pcd_set_ep_dbuf1_address pcd_set_ep_rx_address
|
||||||
|
|
||||||
TU_ATTR_ALWAYS_INLINE static inline void pcd_set_ep_tx_cnt(USB_TypeDef * USBx, uint32_t bEpIdx, uint32_t wCount) {
|
TU_ATTR_ALWAYS_INLINE static inline void pcd_set_ep_tx_cnt(USB_TypeDef * USBx, uint32_t bEpIdx, uint32_t wCount) {
|
||||||
#ifdef FSDEV_BUS_32BIT
|
#ifdef FSDEV_BUS_32BIT
|
||||||
(void) USBx;
|
(void) USBx;
|
||||||
@@ -359,7 +368,9 @@ TU_ATTR_ALWAYS_INLINE static inline void pcd_set_ep_tx_cnt(USB_TypeDef * USBx, u
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
TU_ATTR_ALWAYS_INLINE static inline void pcd_set_ep_rx_cnt(USB_TypeDef * USBx, uint32_t bEpIdx, uint32_t wCount) {
|
#define pcd_set_ep_tx_dbuf0_cnt pcd_set_ep_tx_cnt
|
||||||
|
|
||||||
|
TU_ATTR_ALWAYS_INLINE static inline void pcd_set_ep_tx_dbuf1_cnt(USB_TypeDef * USBx, uint32_t bEpIdx, uint32_t wCount) {
|
||||||
#ifdef FSDEV_BUS_32BIT
|
#ifdef FSDEV_BUS_32BIT
|
||||||
(void) USBx;
|
(void) USBx;
|
||||||
pma32[2*bEpIdx + 1] = (pma32[2*bEpIdx + 1] & ~0x03FF0000u) | ((wCount & 0x3FFu) << 16);
|
pma32[2*bEpIdx + 1] = (pma32[2*bEpIdx + 1] & ~0x03FF0000u) | ((wCount & 0x3FFu) << 16);
|
||||||
@@ -395,14 +406,16 @@ TU_ATTR_ALWAYS_INLINE static inline void pcd_set_ep_bufsize(USB_TypeDef * USBx,
|
|||||||
pcd_set_ep_blsize_num_blocks(USBx, rxtx_idx, blocksize, numblocks);
|
pcd_set_ep_blsize_num_blocks(USBx, rxtx_idx, blocksize, numblocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
TU_ATTR_ALWAYS_INLINE static inline void pcd_set_ep_tx_bufsize(USB_TypeDef * USBx, uint32_t bEpIdx, uint32_t wCount) {
|
TU_ATTR_ALWAYS_INLINE static inline void pcd_set_ep_rx_dbuf0_cnt(USB_TypeDef * USBx, uint32_t bEpIdx, uint32_t wCount) {
|
||||||
pcd_set_ep_bufsize(USBx, 2*bEpIdx, wCount);
|
pcd_set_ep_bufsize(USBx, 2*bEpIdx, wCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
TU_ATTR_ALWAYS_INLINE static inline void pcd_set_ep_rx_bufsize(USB_TypeDef * USBx, uint32_t bEpIdx, uint32_t wCount) {
|
TU_ATTR_ALWAYS_INLINE static inline void pcd_set_ep_rx_cnt(USB_TypeDef * USBx, uint32_t bEpIdx, uint32_t wCount) {
|
||||||
pcd_set_ep_bufsize(USBx, 2*bEpIdx + 1, wCount);
|
pcd_set_ep_bufsize(USBx, 2*bEpIdx + 1, wCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define pcd_set_ep_rx_dbuf1_cnt pcd_set_ep_rx_cnt
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief sets the status for tx transfer (bits STAT_TX[1:0]).
|
* @brief sets the status for tx transfer (bits STAT_TX[1:0]).
|
||||||
* @param USBx USB peripheral instance register address.
|
* @param USBx USB peripheral instance register address.
|
||||||
|
Reference in New Issue
Block a user