### Handle Parameter Initialization Source: https://github.com/stmicroelectronics/lis2mdl-pid/blob/master/README.md If required by your platform read and write functions, initialize the handle parameter within the device context. ```c dev_ctx.handle = &platform_handle; ``` -------------------------------- ### Device Context Initialization Source: https://github.com/stmicroelectronics/lis2mdl-pid/blob/master/README.md Declare and initialize the device context structure with the platform-specific read, write, and delay functions. ```c xxxxxxx_ctx_t dev_ctx; /** xxxxxxx is the used part number **/ dev_ctx.write_reg = platform_write; dev_ctx.read_reg = platform_read; dev_ctx.mdelay = platform_delay; ``` -------------------------------- ### Optional Platform Delay Function Source: https://github.com/stmicroelectronics/lis2mdl-pid/blob/master/README.md Optionally define this C function if the driver requires a delay with millisecond granularity. ```c void platform_delay(uint32_t millisec) ``` -------------------------------- ### Platform Read/Write Functions Source: https://github.com/stmicroelectronics/lis2mdl-pid/blob/master/README.md Define these C functions to handle sensor hardware bus transactions (SPI or I²C). The write function must return 0 for success. ```c int32_t platform_write(void *handle, uint8_t reg, const uint8_t *bufp, uint16_t len) int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp, uint16_t len) ``` -------------------------------- ### Clone LIS2MDL-PID Repository Source: https://github.com/stmicroelectronics/lis2mdl-pid/blob/master/README.md Use this command to clone the complete content of the LIS2MDL-PID repository. ```bash git clone https://github.com/STMicroelectronics/LIS2MDL-PID/ ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.