drivers/sensors/as5048b: fix lower half init issue

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
This commit is contained in:
Petro Karashchenko 2022-01-02 21:54:05 +02:00 committed by Xiang Xiao
parent d2309195da
commit c7d3a674fd
9 changed files with 46 additions and 40 deletions

View File

@ -292,7 +292,7 @@ struct imxrt_enc_lowerhalf_s
static inline uint16_t imxrt_enc_getreg16 static inline uint16_t imxrt_enc_getreg16
(FAR struct imxrt_enc_lowerhalf_s *priv, int offset); (FAR struct imxrt_enc_lowerhalf_s *priv, int offset);
static inline void imxrt_enc_putreg16(FAR struct imxrt_enc_lowerhalf_s *priv, static inline void imxrt_enc_putreg16(FAR struct imxrt_enc_lowerhalf_s *priv,
int offset, uint16_t value); int offset, uint16_t value);
static inline void imxrt_enc_modifyreg16 static inline void imxrt_enc_modifyreg16
(FAR struct imxrt_enc_lowerhalf_s *priv, int offset, (FAR struct imxrt_enc_lowerhalf_s *priv, int offset,
uint16_t clearbits, uint16_t setbits); uint16_t clearbits, uint16_t setbits);
@ -300,22 +300,21 @@ static inline void imxrt_enc_modifyreg16
static void imxrt_enc_clock_enable (uint32_t base); static void imxrt_enc_clock_enable (uint32_t base);
static void imxrt_enc_clock_disable (uint32_t base); static void imxrt_enc_clock_disable (uint32_t base);
static inline int imxrt_enc_sem_wait( static inline int imxrt_enc_sem_wait(FAR struct imxrt_enc_lowerhalf_s *priv);
FAR struct imxrt_enc_lowerhalf_s *priv); static inline void imxrt_enc_sem_post
static inline void imxrt_enc_sem_post( (FAR struct imxrt_enc_lowerhalf_s *priv);
FAR struct imxrt_enc_lowerhalf_s *priv);
static int imxrt_enc_reconfig(FAR struct imxrt_enc_lowerhalf_s *priv, static int imxrt_enc_reconfig(FAR struct imxrt_enc_lowerhalf_s *priv,
uint16_t args); uint16_t args);
static void imxrt_enc_set_initial_val(FAR struct imxrt_enc_lowerhalf_s *priv, static void imxrt_enc_set_initial_val(FAR struct imxrt_enc_lowerhalf_s *priv,
uint32_t value); uint32_t value);
static void imxrt_enc_modulo_enable(FAR struct imxrt_enc_lowerhalf_s *priv, static void imxrt_enc_modulo_enable(FAR struct imxrt_enc_lowerhalf_s *priv,
uint32_t modulus); uint32_t modulus);
static void imxrt_enc_modulo_disable(FAR struct imxrt_enc_lowerhalf_s *priv); static void imxrt_enc_modulo_disable(FAR struct imxrt_enc_lowerhalf_s *priv);
#ifdef CONFIG_DEBUG_SENSORS #ifdef CONFIG_DEBUG_SENSORS
static int imxrt_enc_test_gen(FAR struct imxrt_enc_lowerhalf_s *priv, static int imxrt_enc_test_gen(FAR struct imxrt_enc_lowerhalf_s *priv,
uint16_t value); uint16_t value);
#endif #endif
/* Lower-half Quadrature Encoder Driver Methods */ /* Lower-half Quadrature Encoder Driver Methods */
@ -326,7 +325,7 @@ static int imxrt_position(FAR struct qe_lowerhalf_s *lower,
FAR int32_t *pos); FAR int32_t *pos);
static int imxrt_reset(FAR struct qe_lowerhalf_s *lower); static int imxrt_reset(FAR struct qe_lowerhalf_s *lower);
static int imxrt_ioctl(FAR struct qe_lowerhalf_s *lower, int cmd, static int imxrt_ioctl(FAR struct qe_lowerhalf_s *lower, int cmd,
unsigned long arg); unsigned long arg);
/**************************************************************************** /****************************************************************************
* Private Data * Private Data
@ -341,6 +340,7 @@ static const struct qe_ops_s g_qecallbacks =
.position = imxrt_position, .position = imxrt_position,
.setposmax = NULL, /* not supported yet */ .setposmax = NULL, /* not supported yet */
.reset = imxrt_reset, .reset = imxrt_reset,
.setindex = NULL, /* not supported yet */
.ioctl = imxrt_ioctl, .ioctl = imxrt_ioctl,
}; };
@ -513,7 +513,7 @@ static inline void imxrt_enc_modifyreg16
* *
****************************************************************************/ ****************************************************************************/
void imxrt_enc_clock_enable (uint32_t base) void imxrt_enc_clock_enable(uint32_t base)
{ {
if (base == IMXRT_ENC1_BASE) if (base == IMXRT_ENC1_BASE)
{ {
@ -545,7 +545,7 @@ void imxrt_enc_clock_enable (uint32_t base)
* *
****************************************************************************/ ****************************************************************************/
void imxrt_enc_clock_disable (uint32_t base) void imxrt_enc_clock_disable(uint32_t base)
{ {
if (base == IMXRT_ENC1_BASE) if (base == IMXRT_ENC1_BASE)
{ {
@ -612,7 +612,7 @@ static inline void imxrt_enc_sem_post(struct imxrt_enc_lowerhalf_s *priv)
****************************************************************************/ ****************************************************************************/
static int imxrt_enc_reconfig(FAR struct imxrt_enc_lowerhalf_s *priv, static int imxrt_enc_reconfig(FAR struct imxrt_enc_lowerhalf_s *priv,
uint16_t args) uint16_t args)
{ {
uint16_t clear = 0; uint16_t clear = 0;
uint16_t set = 0; uint16_t set = 0;
@ -773,7 +773,7 @@ static void imxrt_enc_modulo_disable(FAR struct imxrt_enc_lowerhalf_s *priv)
****************************************************************************/ ****************************************************************************/
static int imxrt_enc_test_gen(FAR struct imxrt_enc_lowerhalf_s *priv, static int imxrt_enc_test_gen(FAR struct imxrt_enc_lowerhalf_s *priv,
uint16_t value) uint16_t value)
{ {
if (value >> 9) if (value >> 9)
{ {
@ -1024,7 +1024,7 @@ static int imxrt_reset(FAR struct qe_lowerhalf_s *lower)
****************************************************************************/ ****************************************************************************/
static int imxrt_ioctl(FAR struct qe_lowerhalf_s *lower, int cmd, static int imxrt_ioctl(FAR struct qe_lowerhalf_s *lower, int cmd,
unsigned long arg) unsigned long arg)
{ {
struct imxrt_enc_lowerhalf_s *priv = (struct imxrt_enc_lowerhalf_s *)lower; struct imxrt_enc_lowerhalf_s *priv = (struct imxrt_enc_lowerhalf_s *)lower;
switch (cmd) switch (cmd)

View File

@ -476,7 +476,7 @@ static bool sam_checkreg(struct sam_chan_s *chan, bool wr, uint32_t regaddr,
* Name: sam_chan_getreg * Name: sam_chan_getreg
* *
* Description: * Description:
* Read an SPI register * Read an TC register
* *
****************************************************************************/ ****************************************************************************/
@ -500,7 +500,7 @@ static inline uint32_t sam_chan_getreg(struct sam_chan_s *chan,
* Name: sam_chan_putreg * Name: sam_chan_putreg
* *
* Description: * Description:
* Write a value to an SPI register * Write a value to an TC register
* *
****************************************************************************/ ****************************************************************************/

View File

@ -587,7 +587,7 @@ static bool sam_checkreg(struct sam_tc_s *tc, bool wr, uint32_t regaddr,
* Name: sam_tc_getreg * Name: sam_tc_getreg
* *
* Description: * Description:
* Read an SPI register * Read an TC register
* *
****************************************************************************/ ****************************************************************************/
@ -612,7 +612,7 @@ static inline uint32_t sam_tc_getreg(struct sam_chan_s *chan,
* Name: sam_tc_putreg * Name: sam_tc_putreg
* *
* Description: * Description:
* Write a value to an SPI register * Write a value to an TC register
* *
****************************************************************************/ ****************************************************************************/
@ -636,7 +636,7 @@ static inline void sam_tc_putreg(struct sam_chan_s *chan, uint32_t regval,
* Name: sam_chan_getreg * Name: sam_chan_getreg
* *
* Description: * Description:
* Read an SPI register * Read an TC channel register
* *
****************************************************************************/ ****************************************************************************/
@ -660,7 +660,7 @@ static inline uint32_t sam_chan_getreg(struct sam_chan_s *chan,
* Name: sam_chan_putreg * Name: sam_chan_putreg
* *
* Description: * Description:
* Write a value to an SPI register * Write a value to an TC channel register
* *
****************************************************************************/ ****************************************************************************/

View File

@ -737,7 +737,7 @@ static bool sam_checkreg(struct sam_tc_s *tc, bool wr, uint32_t regaddr,
* Name: sam_tc_getreg * Name: sam_tc_getreg
* *
* Description: * Description:
* Read an SPI register * Read an TC register
* *
****************************************************************************/ ****************************************************************************/
@ -762,7 +762,7 @@ static inline uint32_t sam_tc_getreg(struct sam_chan_s *chan,
* Name: sam_tc_putreg * Name: sam_tc_putreg
* *
* Description: * Description:
* Write a value to an SPI register * Write a value to an TC register
* *
****************************************************************************/ ****************************************************************************/
@ -786,7 +786,7 @@ static inline void sam_tc_putreg(struct sam_chan_s *chan, uint32_t regval,
* Name: sam_chan_getreg * Name: sam_chan_getreg
* *
* Description: * Description:
* Read an SPI register * Read an TC channel register
* *
****************************************************************************/ ****************************************************************************/
@ -810,7 +810,7 @@ static inline uint32_t sam_chan_getreg(struct sam_chan_s *chan,
* Name: sam_chan_putreg * Name: sam_chan_putreg
* *
* Description: * Description:
* Write a value to an SPI register * Write a value to an TC channel register
* *
****************************************************************************/ ****************************************************************************/

View File

@ -224,15 +224,15 @@ struct stm32_lowerhalf_s
static uint16_t stm32_getreg16(FAR struct stm32_lowerhalf_s *priv, static uint16_t stm32_getreg16(FAR struct stm32_lowerhalf_s *priv,
int offset); int offset);
static void stm32_putreg16(FAR struct stm32_lowerhalf_s *priv, int offset, static void stm32_putreg16(FAR struct stm32_lowerhalf_s *priv, int offset,
uint16_t value); uint16_t value);
static uint32_t stm32_getreg32(FAR struct stm32_lowerhalf_s *priv, static uint32_t stm32_getreg32(FAR struct stm32_lowerhalf_s *priv,
int offset); int offset);
static void stm32_putreg32(FAR struct stm32_lowerhalf_s *priv, int offset, static void stm32_putreg32(FAR struct stm32_lowerhalf_s *priv, int offset,
uint32_t value); uint32_t value);
#if defined(CONFIG_DEBUG_SENSORS) && defined(CONFIG_DEBUG_INFO) #if defined(CONFIG_DEBUG_SENSORS) && defined(CONFIG_DEBUG_INFO)
static void stm32_dumpregs(FAR struct stm32_lowerhalf_s *priv, static void stm32_dumpregs(FAR struct stm32_lowerhalf_s *priv,
FAR const char *msg); FAR const char *msg);
#else #else
# define stm32_dumpregs(priv,msg) # define stm32_dumpregs(priv,msg)
#endif #endif
@ -253,7 +253,7 @@ static int stm32_position(FAR struct qe_lowerhalf_s *lower,
FAR int32_t *pos); FAR int32_t *pos);
static int stm32_reset(FAR struct qe_lowerhalf_s *lower); static int stm32_reset(FAR struct qe_lowerhalf_s *lower);
static int stm32_ioctl(FAR struct qe_lowerhalf_s *lower, int cmd, static int stm32_ioctl(FAR struct qe_lowerhalf_s *lower, int cmd,
unsigned long arg); unsigned long arg);
/**************************************************************************** /****************************************************************************
* Private Data * Private Data
@ -268,6 +268,7 @@ static const struct qe_ops_s g_qecallbacks =
.position = stm32_position, .position = stm32_position,
.setposmax = NULL, /* not supported yet */ .setposmax = NULL, /* not supported yet */
.reset = stm32_reset, .reset = stm32_reset,
.setindex = NULL, /* not supported yet */
.ioctl = stm32_ioctl, .ioctl = stm32_ioctl,
}; };

View File

@ -224,15 +224,15 @@ struct stm32_lowerhalf_s
static uint16_t stm32_getreg16(FAR struct stm32_lowerhalf_s *priv, static uint16_t stm32_getreg16(FAR struct stm32_lowerhalf_s *priv,
int offset); int offset);
static void stm32_putreg16(FAR struct stm32_lowerhalf_s *priv, int offset, static void stm32_putreg16(FAR struct stm32_lowerhalf_s *priv, int offset,
uint16_t value); uint16_t value);
static uint32_t stm32_getreg32(FAR struct stm32_lowerhalf_s *priv, static uint32_t stm32_getreg32(FAR struct stm32_lowerhalf_s *priv,
int offset); int offset);
static void stm32_putreg32(FAR struct stm32_lowerhalf_s *priv, int offset, static void stm32_putreg32(FAR struct stm32_lowerhalf_s *priv, int offset,
uint32_t value); uint32_t value);
#if defined(CONFIG_DEBUG_SENSORS) && defined(CONFIG_DEBUG_INFO) #if defined(CONFIG_DEBUG_SENSORS) && defined(CONFIG_DEBUG_INFO)
static void stm32_dumpregs(FAR struct stm32_lowerhalf_s *priv, static void stm32_dumpregs(FAR struct stm32_lowerhalf_s *priv,
FAR const char *msg); FAR const char *msg);
#else #else
# define stm32_dumpregs(priv,msg) # define stm32_dumpregs(priv,msg)
#endif #endif
@ -253,7 +253,7 @@ static int stm32_position(FAR struct qe_lowerhalf_s *lower,
FAR int32_t *pos); FAR int32_t *pos);
static int stm32_reset(FAR struct qe_lowerhalf_s *lower); static int stm32_reset(FAR struct qe_lowerhalf_s *lower);
static int stm32_ioctl(FAR struct qe_lowerhalf_s *lower, int cmd, static int stm32_ioctl(FAR struct qe_lowerhalf_s *lower, int cmd,
unsigned long arg); unsigned long arg);
/**************************************************************************** /****************************************************************************
* Private Data * Private Data
@ -268,6 +268,7 @@ static const struct qe_ops_s g_qecallbacks =
.position = stm32_position, .position = stm32_position,
.setposmax = NULL, /* not supported yet */ .setposmax = NULL, /* not supported yet */
.reset = stm32_reset, .reset = stm32_reset,
.setindex = NULL, /* not supported yet */
.ioctl = stm32_ioctl, .ioctl = stm32_ioctl,
}; };

View File

@ -247,8 +247,8 @@ static int stm32l4_shutdown(FAR struct qe_lowerhalf_s *lower);
static int stm32l4_position(FAR struct qe_lowerhalf_s *lower, static int stm32l4_position(FAR struct qe_lowerhalf_s *lower,
FAR int32_t *pos); FAR int32_t *pos);
static int stm32l4_reset(FAR struct qe_lowerhalf_s *lower); static int stm32l4_reset(FAR struct qe_lowerhalf_s *lower);
static int stm32l4_ioctl(FAR struct qe_lowerhalf_s *lower, static int stm32l4_ioctl(FAR struct qe_lowerhalf_s *lower, int cmd,
int cmd, unsigned long arg); unsigned long arg);
/**************************************************************************** /****************************************************************************
* Private Data * Private Data
@ -263,6 +263,7 @@ static const struct qe_ops_s g_qecallbacks =
.position = stm32l4_position, .position = stm32l4_position,
.setposmax = NULL, /* not supported yet */ .setposmax = NULL, /* not supported yet */
.reset = stm32l4_reset, .reset = stm32l4_reset,
.setindex = NULL, /* not supported yet */
.ioctl = stm32l4_ioctl, .ioctl = stm32l4_ioctl,
}; };

View File

@ -112,6 +112,7 @@ static const struct qe_ops_s g_qe_ops =
.position = tiva_qe_position, .position = tiva_qe_position,
.setposmax = NULL, /* not supported yet */ .setposmax = NULL, /* not supported yet */
.reset = tiva_qe_reset, .reset = tiva_qe_reset,
.setindex = NULL, /* not supported yet */
.ioctl = tiva_qe_ioctl, .ioctl = tiva_qe_ioctl,
}; };

View File

@ -91,11 +91,13 @@ static int as5048b_ioctl(FAR struct qe_lowerhalf_s *lower, int cmd,
static const struct qe_ops_s g_qeops = static const struct qe_ops_s g_qeops =
{ {
as5048b_setup, .setup = as5048b_setup,
as5048b_shutdown, .shutdown = as5048b_shutdown,
as5048b_position, .position = as5048b_position,
as5048b_reset, .setposmax = NULL, /* not supported yet */
as5048b_ioctl .reset = as5048b_reset,
.setindex = NULL, /* not supported yet */
.ioctl = as5048b_ioctl
}; };
/**************************************************************************** /****************************************************************************