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

Replace HAL function (+SPI)

Hello

I am currently porting nRF52833 using SPI communication with other MCU (AD5940).

AD5940 provides an example of porting with stm32, which we are referring to.

Currently, no function is found to replace the Clock Enable used by stm32.

Can I get some help? Related photos are as follows.

----------------------------The code in the example.

  

   

 I'm sorry I brought you a question about another MCU..!

Best regards.

Parents
  • You need to separate-out what's specific to STM32 from what is independent of the microcontroller used.

    There's no point in looking at the STM32-specific code - RCCs and such - that's not relevant to nRF.

    You can look at Nordic's examples for the nRF52-specific details of getting its SPI hardware working.

    not as an image!

  • Hi.
    I'm trying to understand as much as I can by looking at the SPI master example.

    I'm converting the Stm32 example codes to the nrf format.

    Then I got a question, so can you answer it?

    This picture is a system architecture of stm32. This picture is trying to use USART1 and the corresponding APB2 will be given a clark signal.  The code for this role is "RCC->APB2ENR |= RCC_APB2Periph_USART1;"

    Is there a code that plays this role in nrf?

    Best regards.

  • Is there a code that plays this role in nrf

    Again, the STM32 is an entirely different product from an entirely different manufacturer - so its internal details are entirely different.

    What you need to be looking for are functions that will send & receive stuff over SPI without any concern for the underlying hardware; eg,

    /*
     * Platform-independent function to perform an SPI transfer
     *
     * Parameters:
     *   p_tx_buffer - buffer of data to be transmitted;
     *   p_rx_buffer - buffer to receive incoming data;
     *   length      - length of the buffers
     *
     * Returns:
     *   status code indicating success/failure
     */
    status_t spi_transfer( uint8_t *p_tx_buffer, uint8_t *p_rx_buffer, uint8_t length );

    As you can see, that is entirely independent of any of the underlying hardware implementation details.

    You would have a separate implementation for STM32, which does all the STM32-specific stuff, and a separate implantation for nRF, which does all nRF-specific stuff.

    But the code which calls this function remains entirely unaware and independent of the underlying implementation details.

    This is standard software engineering stuff.

    If the code you've got doesn't provide such an isolation of the "General" code from the platform-specific code, then your first step would be to implement such a layer.

    For using nRF's SPI, see the SDK documentation.

Reply
  • Is there a code that plays this role in nrf

    Again, the STM32 is an entirely different product from an entirely different manufacturer - so its internal details are entirely different.

    What you need to be looking for are functions that will send & receive stuff over SPI without any concern for the underlying hardware; eg,

    /*
     * Platform-independent function to perform an SPI transfer
     *
     * Parameters:
     *   p_tx_buffer - buffer of data to be transmitted;
     *   p_rx_buffer - buffer to receive incoming data;
     *   length      - length of the buffers
     *
     * Returns:
     *   status code indicating success/failure
     */
    status_t spi_transfer( uint8_t *p_tx_buffer, uint8_t *p_rx_buffer, uint8_t length );

    As you can see, that is entirely independent of any of the underlying hardware implementation details.

    You would have a separate implementation for STM32, which does all the STM32-specific stuff, and a separate implantation for nRF, which does all nRF-specific stuff.

    But the code which calls this function remains entirely unaware and independent of the underlying implementation details.

    This is standard software engineering stuff.

    If the code you've got doesn't provide such an isolation of the "General" code from the platform-specific code, then your first step would be to implement such a layer.

    For using nRF's SPI, see the SDK documentation.

Children
No Data
Related