EasyManua.ls Logo

ST STEVAL-WLC38RX - Source Files; Reference Code Porting Procedure

ST STEVAL-WLC38RX
81 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
9.5.4 Source files
The source files included in the reference code are listed below.
1. STWLC38.h
Provides NVM programming API and holds the structure and register definitions of STWLC38.
2. STWLC38.c
Main file which describes the NVM related programming sequences and I
2
C Write/WriteRead
operations.
3. nvm_data.h
Patch and Configuration data in header file format to be programmed into the chip.
9.5.5 Reference code porting procedure
Step 1. Create a new project in the STM32CubeIDE with a STM32 development board. Visit the ST website for
STM32CubeIDE documentation.
Step 2. Copy STWLC38.h, STWLC38.c, and nvm_data.h into the main directory (Core/Src).
Step 3. Add the following code into Core/Src/main.c.
Step 4. Include the Header file
/* USER CODE BEGIN Includes */
#include "STWLC38.h"
/* USER CODE END Includes */
Step 5. Define platform functions and variables to be used by driver API. See below for the function definitions.
int32_t platform_write(void *phandle, uint8_t *wbuf, int32_t wlen);
int32_t platform_write_read(void *phandle, uint8_t *wbuf, int32_t wlen, uint8_t
*rbuf, int32_t rlen);
void platform_delay(uint32_t millisec);
void *platform_alloc_mem(size_t size);
void platform_free_mem(void *ptr);
Step 6. Declare and assign the platform functions to mandatory interfaces.
/** stwlcxx is the used part number **/
struct stwlcxx_dev stwlc38 = { 0 };
stwlc38.bus_write = platform_write;
stwlc38.bus_write_read = platform_write_read;
stwlc38.mdelay = HAL_Delay;
stwlc38.alloc_mem = malloc;
stwlc38.free_mem = free;
Step 7. If user data is needed by the platform functions, initialize the phandle parameter.
struct stmdev_platform platform = {
.hi2c = &hi2c1,
.huart = &huart3,
};
stwlc38.phandle = &platform;
Step 8. Optionally, initialize log parameters and set log_info to 1 to print more information logs.
stwlc38.log = platform_log;
stwlc38.log_info = 1;
Step 9. Execute NVM programming
/* Start FW update */
stwlc38_fw_update(&stwlc38, STWLC38_FW_PATCH_CFG, 0);
UM3154
Reference code with STM32 development boards
UM3154 - Rev 2
page 65/81

Table of Contents