فهرست منبع

Add __weak directive to read/write registers routines

Added __weak directive to registers read/write routines,
to allow the final application to overwrite them with a
custom implementation.

The driver keeps offering a default implementation based
on function pointers to read/write routines for backward
compatibility.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
Armando Visconti 3 سال پیش
والد
کامیت
1b4f9e3ea6
2فایلهای تغییر یافته به همراه19 افزوده شده و 6 حذف شده
  1. 6 6
      lsm6ds3tr-c_reg.c
  2. 13 0
      lsm6ds3tr-c_reg.h

+ 6 - 6
lsm6ds3tr-c_reg.c

@@ -46,9 +46,9 @@
   * @retval       interface status (MANDATORY: return 0 -> no Error)
   *
   */
-int32_t lsm6ds3tr_c_read_reg(stmdev_ctx_t *ctx, uint8_t reg,
-                             uint8_t *data,
-                             uint16_t len)
+int32_t __weak lsm6ds3tr_c_read_reg(stmdev_ctx_t *ctx, uint8_t reg,
+                                    uint8_t *data,
+                                    uint16_t len)
 {
   int32_t ret;
 
@@ -67,9 +67,9 @@ int32_t lsm6ds3tr_c_read_reg(stmdev_ctx_t *ctx, uint8_t reg,
   * @retval       interface status (MANDATORY: return 0 -> no Error)
   *
   */
-int32_t lsm6ds3tr_c_write_reg(stmdev_ctx_t *ctx, uint8_t reg,
-                              uint8_t *data,
-                              uint16_t len)
+int32_t __weak lsm6ds3tr_c_write_reg(stmdev_ctx_t *ctx, uint8_t reg,
+                                     uint8_t *data,
+                                     uint16_t len)
 {
   int32_t ret;
 

+ 13 - 0
lsm6ds3tr-c_reg.h

@@ -1700,6 +1700,19 @@ typedef union
   *
   */
 
+#ifndef __weak
+#define __weak __attribute__((weak))
+#endif /* __weak */
+
+/*
+ * These are the basic platform dependent I/O routines to read
+ * and write device registers connected on a standard bus.
+ * The driver keeps offering a default implementation based on function
+ * pointers to read/write routines for backward compatibility.
+ * The __weak directive allows the final application to overwrite
+ * them with a custom implementation.
+ */
+
 int32_t lsm6ds3tr_c_read_reg(stmdev_ctx_t *ctx, uint8_t reg,
                              uint8_t *data,
                              uint16_t len);