44#include "bsp/board_api.h"
55#define STK_MINIMAL_STACK_SIZE 128U
58#define USBD_STACK_SIZE ((4U * STK_MINIMAL_STACK_SIZE / 2U) * (CFG_TUSB_DEBUG ? 2U : 1U))
60#define BLINKY_STACK_SIZE STK_MINIMAL_STACK_SIZE
61#define AUDIO_STACK_SIZE STK_MINIMAL_STACK_SIZE
149 tusb_rhport_init_t dev_init =
151 .role = TUSB_ROLE_DEVICE,
152 .speed = TUSB_SPEED_AUTO
192int main(
int argc,
char* argv[])
202 SysTick->CTRL &= ~1U;
212 sampleFreqRng.wNumSubRanges = 1;
215 sampleFreqRng.subrange[0].bRes = 0;
272 (void) remote_wakeup_en;
293 TU_VERIFY(p_request->bRequest == AUDIO20_CS_REQ_CUR);
296 uint8_t channelNum = TU_U16_LOW(p_request->wValue);
297 uint8_t ctrlSel = TU_U16_HIGH(p_request->wValue);
298 uint8_t ep = TU_U16_LOW(p_request->wIndex);
314 TU_VERIFY(p_request->bRequest == AUDIO20_CS_REQ_CUR);
317 uint8_t channelNum = TU_U16_LOW(p_request->wValue);
318 uint8_t ctrlSel = TU_U16_HIGH(p_request->wValue);
319 uint8_t itf = TU_U16_LOW(p_request->wIndex);
334 uint8_t channelNum = TU_U16_LOW(p_request->wValue);
335 uint8_t ctrlSel = TU_U16_HIGH(p_request->wValue);
336 uint8_t itf = TU_U16_LOW(p_request->wIndex);
337 uint8_t entityID = TU_U16_HIGH(p_request->wIndex);
342 TU_VERIFY(p_request->bRequest == AUDIO20_CS_REQ_CUR);
349 case AUDIO20_FU_CTRL_MUTE:
351 TU_VERIFY(p_request->wLength ==
sizeof(audio20_control_cur_1_t));
353 mute[channelNum] = ((audio20_control_cur_1_t *) pBuff)->bCur;
355 TU_LOG1(
" Set Mute: %d of channel: %u\r\n",
mute[channelNum], channelNum);
358 case AUDIO20_FU_CTRL_VOLUME:
360 TU_VERIFY(p_request->wLength ==
sizeof(audio20_control_cur_2_t));
362 volume[channelNum] = (uint16_t) ((audio20_control_cur_2_t *) pBuff)->bCur;
363 TU_LOG1(
" Set Volume: %d dB of channel: %u\r\n",
volume[channelNum], channelNum);
381 uint8_t channelNum = TU_U16_LOW(p_request->wValue);
382 uint8_t ctrlSel = TU_U16_HIGH(p_request->wValue);
383 uint8_t ep = TU_U16_LOW(p_request->wIndex);
398 uint8_t channelNum = TU_U16_LOW(p_request->wValue);
399 uint8_t ctrlSel = TU_U16_HIGH(p_request->wValue);
400 uint8_t itf = TU_U16_LOW(p_request->wIndex);
415 uint8_t channelNum = TU_U16_LOW(p_request->wValue);
416 uint8_t ctrlSel = TU_U16_HIGH(p_request->wValue);
418 uint8_t entityID = TU_U16_HIGH(p_request->wIndex);
425 case AUDIO20_TE_CTRL_CONNECTOR:
428 audio20_desc_channel_cluster_t ret;
432 ret.bmChannelConfig = (audio20_channel_config_t) 0;
433 ret.iChannelNames = 0;
435 TU_LOG1(
" Get terminal connector\r\n");
437 return tud_audio_buffer_and_schedule_control_xfer(rhport, p_request, (
void *) &ret,
sizeof(ret));
453 case AUDIO20_FU_CTRL_MUTE:
456 TU_LOG1(
" Get Mute of channel: %u\r\n", channelNum);
457 return tud_audio_buffer_and_schedule_control_xfer(rhport, p_request, &
mute[channelNum], 1);
459 case AUDIO20_FU_CTRL_VOLUME:
460 switch (p_request->bRequest)
462 case AUDIO20_CS_REQ_CUR:
463 TU_LOG1(
" Get Volume of channel: %u\r\n", channelNum);
464 return tud_audio_buffer_and_schedule_control_xfer(rhport, p_request, &
volume[channelNum],
sizeof(
volume[channelNum]));
466 case AUDIO20_CS_REQ_RANGE:
467 TU_LOG1(
" Get Volume range of channel: %u\r\n", channelNum);
473 ret.wNumSubRanges = 1;
474 ret.subrange[0].bMin = -90;
475 ret.subrange[0].bMax = 90;
476 ret.subrange[0].bRes = 1;
478 return tud_audio_buffer_and_schedule_control_xfer(rhport, p_request, (
void *) &ret,
sizeof(ret));
499 case AUDIO20_CS_CTRL_SAM_FREQ:
501 switch (p_request->bRequest)
503 case AUDIO20_CS_REQ_CUR:
504 TU_LOG1(
" Get Sample Freq.\r\n");
505 return tud_audio_buffer_and_schedule_control_xfer(rhport, p_request, &
sampFreq,
sizeof(
sampFreq));
507 case AUDIO20_CS_REQ_RANGE:
508 TU_LOG1(
" Get Sample Freq. range\r\n");
509 return tud_audio_buffer_and_schedule_control_xfer(rhport, p_request, &sampleFreqRng,
sizeof(sampleFreqRng));
518 case AUDIO20_CS_CTRL_CLK_VALID:
520 TU_LOG1(
" Get Sample Freq. valid\r\n");
521 return tud_audio_buffer_and_schedule_control_xfer(rhport, p_request, &
clkValid,
sizeof(
clkValid));
530 TU_LOG1(
" Unsupported entity: %d\r\n", entityID);
static bool led_state[LED_MAX]
#define STK_CORTEX_M_SVCALL_ISR_PRIORITY
Priority of the SVCall exception (the most urgent one used by the kernel).
Top-level STK include. Provides the Kernel class template and all built-in task-switching strategies.
#define STK_ASSERT(e)
Runtime assertion. Halts execution if the expression e evaluates to false.
Namespace of STK package.
static bool SleepMs(Timeout ms)
Put calling process into a sleep state.
int32_t Timeout
Timeout time (ticks).
int32_t Weight
Weight value (aka priority).
@ KERNEL_TICKLESS
Tickless mode. To use this mode STK_TICKLESS_IDLE must be defined to 1 in stk_config....
@ KERNEL_SYNC
Synchronization support (see Event).
@ KERNEL_STATIC
All tasks are static and can not exit.
Concrete implementation of IKernel.
void Start() override
Start the scheduler. This call does not return until all tasks have exited (KERNEL_DYNAMIC mode) or i...
EAddResult AddTask(ITask *user_task) override
Register task for a soft real-time (SRT) scheduling.
void Initialize(uint32_t resolution_us=PERIODICITY_DEFAULT) override
Initialize kernel.
Partial implementation of the user task.
void Run() override
Entry point of the user task.
stk::Weight GetWeight() const override
Get static base weight of the task.
const char * GetTraceName() const override
Get task trace name set by application.
stk::Weight GetWeight() const override
Get static base weight of the task.
const char * GetTraceName() const override
Get task trace name set by application.
void Run() override
Entry point of the user task.
const char * GetTraceName() const override
Get task trace name set by application.
void Run() override
Entry point of the user task.
stk::Weight GetWeight() const override
Get static base weight of the task.
bool tud_audio_get_req_itf_cb(uint8_t rhport, tusb_control_request_t const *p_request)
static uint32_t blink_interval_ms
audio20_control_range_4_n_t(1) sampleFreqRng
uint16_t volume[CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX+1]
bool tud_audio_get_req_ep_cb(uint8_t rhport, tusb_control_request_t const *p_request)
void board_init_after_tusb(void)
audio20_control_range_2_n_t(1) volumeRng[CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX+1]
bool mute[CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX+1]
void tud_suspend_cb(bool remote_wakeup_en)
bool tud_audio_get_req_entity_cb(uint8_t rhport, tusb_control_request_t const *p_request)
bool tud_audio_set_req_ep_cb(uint8_t rhport, tusb_control_request_t const *p_request, uint8_t *pBuff)
bool tud_audio_set_itf_close_ep_cb(uint8_t rhport, tusb_control_request_t const *p_request)
uint16_t test_buffer_audio[CFG_TUD_AUDIO_FUNC_1_SAMPLE_RATE/1000 *CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX *CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX/2]
bool tud_audio_set_req_entity_cb(uint8_t rhport, tusb_control_request_t const *p_request, uint8_t *pBuff)
bool tud_audio_set_req_itf_cb(uint8_t rhport, tusb_control_request_t const *p_request, uint8_t *pBuff)
void usb_device_task(void *param)
#define CFG_TUD_AUDIO_FUNC_1_SAMPLE_RATE
#define CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX
#define CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX