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

Serialization between STM32 and ISP1705/nRF52

I am trying to use serialization to connect an STM32F4 to an ISP1705. My goal is too connect to other BLE devices and read some measurements. I have tried a few of the examples (uart over ble etc) and got them working on the ISP itself. I have tried the BLE AT commands and got them working after some time as well. This doesn't have enough functionality for me to read measurements though. I have the connectivity firmware flashed on the nRF52, and can talk to it over UART from my STM. I have a basic code example working for this allowing me to send RAW uart messages and get a response. The binary message is the mesage from UART RAW protocol

uint8_t buff[] = {0x04, 0x00, 0x00, 0x78, 0x41, 0x03};
ble_send_raw(buff, 6);

which gives me the following response:

0x06
0x00
0x01
0x78
0x01
0x30
0x00
0x00

So the communication between the STM32 and nRF52 is working. 

The next step is to get the serialization library working on the host chip (STM32) so that i can use all API calls. This is where i am stuck, i have seen the Serialization page and Running a serialized application . I tried to look at the Heart rate application and base the files that i need on that. I copied the /components/serialization folder to my STM32 project, and the softdevice/s132/headers since it looked like it needed some of those files. But after this i dont know where to continue, how i need to compile all files correctly, where i need to start porting, what files to include to start using functions. I see the API functions in the middleware files. For example 'sd_ble_gap_appearance_set' in 'serialization/application/codecs/ble/middlewares/app_mw_ble_gap.c' yet i dont see where these functions are included from since the file doesnt have a corresponding header. When i try to call that function and go to its defenition it goes to the 'SVCALL(SD_BLE_GAP_APPEARANCE_SET, uint32_t, sd_ble_gap_appearance_set(uint16_t appearance))' line in ble_gap.h and doesn't reach the function implementation in the middleware. 

I would love some direction in where to start actually porting the serialization library to a different processor and what needs to be done to compile and include everything correctly. Or maybe there an STM32 port that's already available?

Greetings

  • Yes. The serialized examples have SVCALL_AS_NORMAL_FUNCTION defined.

    This means that when it says e.g.:

    SVCALL(SD_BLE_GAP_ADV_SET_CONFIGURE, uint32_t, sd_ble_gap_adv_set_configure(uint8_t *p_adv_handle, ble_gap_adv_data_t const *p_adv_data, ble_gap_adv_params_t const *p_adv_params));

    It means:

    uint32_t sd_ble_gap_adv_set_configure(uint8_t *p_adv_handle, ble_gap_adv_data_t const *p_adv_data, ble_gap_adv_params_t *p_adv_params);

    This is the declaration of this function. 

    Additionally, we have the define in app_mw_ble_gap.c:

    #ifndef _sd_ble_gap_adv_set_configure
    #define _sd_ble_gap_adv_set_configure sd_ble_gap_adv_set_configure
    #endif
    uint32_t _sd_ble_gap_adv_set_configure(uint8_t *p_adv_handle,
                                           ble_gap_adv_data_t const *p_adv_data,
                                           ble_gap_adv_params_t const *p_adv_params)
    {
        ...

    It is a bit confusing, but try to follow this:

    if _sd_ble_gap_adv_set_configure is not defined (which it is not), then define it to mean sd_ble_gap_adv_set_configure. Done.

    Then it says:

    uint32_t _sd_ble_gap_adv_set_configure(...), but this is a macro that we just defined, so what it really says is:

    uint32_t sd_ble_gap_adv_set_configure(...).

    So this is the definition of the softdevice call sd_ble_gap_adv_set_configure() when SVCALL_AS_NORMAL_FUNCTION is defined. 

    If SVCALL_AS_NORMAL_FUNCTION is not defined, then you would have a double definition of the softdevice call, sd_ble_gap_adv_set_configure(), but the non-serialized examples doesn't contain the app_mw_ble_gap.c file, so that is why it works in the non-serialized examples.

    Does that clarify things a bit?

    If you have the defines correct, then you should be able to call sd_ble_gap_adv_set_configure() from main, and then set a breakpoint inside _sd_ble_gap_adv_set_configure(), and it should be hit (try to turn off optimization on the STM if you want to test this). Obviously, in order to compile, then ble_gap_adv_set_configure_rec_enc() needs to be defined, which leads to a tunnel of new requirements, but they should all lead out in not too many files, requiring you to implement the serialization layer that you are using, such as for example UART. 

    Best regards,

    Edvin

Related