nRF5340 Audio DK: Auto-Switch Input Between UART (USB) and BLE

Hi,

We are working on a project using the nRF5340 Audio DK. We want to take user input either from UART or BLE, and switch between them based on the connection status.

Here’s what we want to do:

  1. If the USB is connected to a PC, the device should automatically detect it and use UART for user input.

  2. If the USB is not connected (running on battery), it should automatically switch to BLE for user input.

How can we make this work?
Can we start with the USB CDC ACM example?
Also, how can we use USBREG on the nRF5340 Audio DK?

Thanks,
Aditya

Parents Reply Children
  • I want to send audio control commands as input. I am trying this on both nRF5340 Audio DK and nRF52832 DK, but not able to detect the USB when plugged. So, because of that, we are not able to switch to UART mode for user input.

  • Hi,

    Do you use LE Audio?
    Can you describe your use case in more detail? What is user scenario in your case?
    What kind of features are you trying to achieve?
    What do you refer to as "audio control commands"?

    Best regards,
    Dejan

  • No, I am not using LE audio. I am working on an audio project, and I am interfacing an external CODEC to produce sound/audio at different frequency and volume (dB). So, I want to implement a feature that can automatically switch between BLE and UART to take user based audio commands. 

    User input parameters:
    1. Frequency
    2. Volume level 

    These parameters can be passed via UART/BLE. Whenever the device works on battery, it should take user I/P using BLE. When the device is connected to a computer, the device should automatically turn off its BLE and start taking user input from UART (USB) 

    "audio control commands" refers to frequency and volume level. We have implemented an algorithm in software to produce audio with different frequency and volume as per the user's input.

  • Hi,

    Since you are using nrf5340 which has USB interface, this interface should be able to detect if it is connected to USB host. It is possible to know if USB interface is connected or not. You can look at this example from nRF Desktop. 

    Best regards,
    Dejan

  • I tried using the usb_state.c example libraries and API to handle USB detection. It kind of works, the USB-C port is connected through J-Link, and I can detect the device. But the problem is that the connection isn't stable. It shows up for just a brief moment and then drops, so I can’t really make use of it in the code. Seems like the issue is coming from the J-Link interfering with the USB connection.

Related