Skip to content

Commit 1546727

Browse files
Gioelioavisconti
authored andcommitted
restore reset_set/get boot_set/get APIs for consistency
Marked as deprecated to give users time to transition to the new APIs Signed-off-by: Gioele Fiorenza <gioele.fiorenza2000@gmail.com>
1 parent e81f8e5 commit 1546727

2 files changed

Lines changed: 106 additions & 0 deletions

File tree

lis2mdl_reg.c

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,102 @@ int32_t lis2mdl_device_id_get(const stmdev_ctx_t *ctx, uint8_t *buff)
772772
return ret;
773773
}
774774

775+
/**
776+
* @brief Software reset. Restore the default values in user registers.[set]
777+
*
778+
* @param ctx read / write interface definitions.(ptr)
779+
* @param val change the values of soft_rst in reg CFG_REG_A
780+
* @retval interface status.(MANDATORY: return 0 -> no Error)
781+
*
782+
*/
783+
[[deprecated("Please use sw_reset to align with the AN")]]
784+
int32_t lis2mdl_reset_set(const stmdev_ctx_t *ctx, uint8_t val)
785+
{
786+
lis2mdl_cfg_reg_a_t reg;
787+
int32_t ret;
788+
789+
ret = lis2mdl_read_reg(ctx, LIS2MDL_CFG_REG_A, (uint8_t *)&reg, 1);
790+
791+
if (ret == 0)
792+
{
793+
reg.soft_rst = val;
794+
ret = lis2mdl_write_reg(ctx, LIS2MDL_CFG_REG_A, (uint8_t *)&reg, 1);
795+
}
796+
797+
return ret;
798+
}
799+
800+
/**
801+
* @brief Software reset. Restore the default values in user registers.[get]
802+
*
803+
* @param ctx read / write interface definitions.(ptr)
804+
* @param val change the values of soft_rst in reg CFG_REG_A.(ptr)
805+
* @retval interface status.(MANDATORY: return 0 -> no Error)
806+
*
807+
*/
808+
[[deprecated("Please use sw_reset to align with the AN")]]
809+
int32_t lis2mdl_reset_get(const stmdev_ctx_t *ctx, uint8_t *val)
810+
{
811+
lis2mdl_cfg_reg_a_t reg;
812+
int32_t ret;
813+
814+
ret = lis2mdl_read_reg(ctx, LIS2MDL_CFG_REG_A, (uint8_t *)&reg, 1);
815+
816+
if (ret != 0) { return ret; }
817+
818+
*val = reg.soft_rst;
819+
820+
return ret;
821+
}
822+
823+
/**
824+
* @brief Reboot memory content. Reload the calibration parameters.[set]
825+
*
826+
* @param ctx read / write interface definitions.(ptr)
827+
* @param val change the values of reboot in reg CFG_REG_A
828+
* @retval interface status.(MANDATORY: return 0 -> no Error)
829+
*
830+
*/
831+
[[deprecated("Please use reboot to align with the AN")]]
832+
int32_t lis2mdl_boot_set(const stmdev_ctx_t *ctx, uint8_t val)
833+
{
834+
lis2mdl_cfg_reg_a_t reg;
835+
int32_t ret;
836+
837+
ret = lis2mdl_read_reg(ctx, LIS2MDL_CFG_REG_A, (uint8_t *)&reg, 1);
838+
839+
if (ret == 0)
840+
{
841+
reg.reboot = val;
842+
ret = lis2mdl_write_reg(ctx, LIS2MDL_CFG_REG_A, (uint8_t *)&reg, 1);
843+
}
844+
845+
return ret;
846+
}
847+
848+
/**
849+
* @brief Reboot memory content. Reload the calibration parameters.[get]
850+
*
851+
* @param ctx read / write interface definitions.(ptr)
852+
* @param val change the values of reboot in reg CFG_REG_A.(ptr)
853+
* @retval interface status.(MANDATORY: return 0 -> no Error)
854+
*
855+
*/
856+
[[deprecated("Please use reboot to align with the AN")]]
857+
int32_t lis2mdl_boot_get(const stmdev_ctx_t *ctx, uint8_t *val)
858+
{
859+
lis2mdl_cfg_reg_a_t reg;
860+
int32_t ret;
861+
862+
ret = lis2mdl_read_reg(ctx, LIS2MDL_CFG_REG_A, (uint8_t *)&reg, 1);
863+
864+
if (ret != 0) { return ret; }
865+
866+
*val = reg.reboot;
867+
868+
return ret;
869+
}
870+
775871
/**
776872
* @brief Software reset. Restore the default values in user registers.
777873
*

lis2mdl_reg.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,16 @@ int32_t lis2mdl_temperature_raw_get(const stmdev_ctx_t *ctx, int16_t *val);
459459

460460
int32_t lis2mdl_device_id_get(const stmdev_ctx_t *ctx, uint8_t *buff);
461461

462+
// deprecated: Please use sw_reset to align with the AN
463+
int32_t lis2mdl_reset_set(const stmdev_ctx_t *ctx, uint8_t val);
464+
// deprecated: Please use sw_reset to align with the AN
465+
int32_t lis2mdl_reset_get(const stmdev_ctx_t *ctx, uint8_t *val);
466+
467+
// deprecated: Please use reboot to align with the AN
468+
int32_t lis2mdl_boot_set(const stmdev_ctx_t *ctx, uint8_t val);
469+
// deprecated: Please use reboot to align with the AN
470+
int32_t lis2mdl_boot_get(const stmdev_ctx_t *ctx, uint8_t *val);
471+
462472
int32_t lis2mdl_sw_reset(const stmdev_ctx_t *ctx);
463473

464474
int32_t lis2mdl_reboot(const stmdev_ctx_t *ctx);

0 commit comments

Comments
 (0)