This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Code for multiple interfaces (I2C, UART, and USB)

I am currently using the ble_app_uart example but I want to add USB and I2C interface to this solution. Would I need to find what files differ/need to be added from USB and 12C examples in the peripheral folder and incorporate those? Or would I also have to change pin mapping, memory, etc.?

Parents
  • Hello,

    Would I need to find what files differ/need to be added from USB and 12C examples in the peripheral folder and incorporate those?

     Yes, for example, to add TWI to the ble_app_uart example, you will need to add the nrfx_twim driver ( or nrfx_twis if the device is acting as slave ) to your project files, and along with the configuration defines to the sdk_config file. You should also check that the peripheral you are adding does not use the same shared resources as already present peripherals.
    I have included an example to demonstrate how this might be done - however, I unfortunately do not have a TWI sensor with me right now to test the functionality of the example, but this is how you may go about adding a peripheral to one of the examples.

    Bear in mind that the included example is created to demonstrate how you may add a peripheral to your example, and I would recommend that you yourself make these changes to your own project rather than to use this example as basis for your development. I would recommend against the latter.

    Or would I also have to change pin mapping, memory, etc.?

    You might have to change pin mapping, depending on which pins are already in use by the different examples you are merging - so as to avoid using the same pin for multiple purposes.

    Please do not hesitate to let me know if anything still should be unclear, or if you have any other questions or issues!

    Best regards,
    Karl
    _ble_app_uart_with_twim.zip

  • Thanks Karl. Would you recommend starting with the USBD__BLE_UART example file because I have two different data signals (one coming from USB, one from UART) that I need to transmit via Bluetooth. The I2C is more for in board stuff and that data does not need to be transmitted via BT.

  • No problem at all, I am happy to help!

    I would recommend that you start with the ble_app_uart example in this case, and then add both the TWIM and USBD peripheral like I showed in the provided example.
    I would recommend this so that you do not have to add the BLE functions to another example yourself, as it is much more things to add to configure and enable BLE compared to adding hardware peripherals to your project.

    Best regards,
    Karl

Reply
  • No problem at all, I am happy to help!

    I would recommend that you start with the ble_app_uart example in this case, and then add both the TWIM and USBD peripheral like I showed in the provided example.
    I would recommend this so that you do not have to add the BLE functions to another example yourself, as it is much more things to add to configure and enable BLE compared to adding hardware peripherals to your project.

    Best regards,
    Karl

Children
Related