As5047 encoder fixes

This commit is contained in:
Benjamin Vedder 2022-02-28 14:30:48 +01:00
parent 18a683fc7d
commit 5609b31d42
3 changed files with 8 additions and 2 deletions

View File

@ -147,6 +147,11 @@ void enc_as504x_routine(AS504x_config_t *cfg) {
}
}
float enc_as504x_read_angle(AS504x_config_t *cfg) {
enc_as504x_routine(cfg);
return cfg->state.last_enc_angle;
}
static void long_delay(void) {
for (volatile int i = 0; i < 40; i++) {
__NOP();

View File

@ -27,6 +27,7 @@
bool enc_as504x_init(AS504x_config_t *AS504x_config);
void enc_as504x_deinit(AS504x_config_t *cfg);
void enc_as504x_routine(AS504x_config_t *cfg);
float enc_as504x_read_angle(AS504x_config_t *cfg);
// Macros
#define AS504x_LAST_ANGLE(cfg) ((cfg)->state.last_enc_angle)

View File

@ -39,8 +39,8 @@ AS504x_config_t encoder_cfg_as504x = {
{
HW_HALL_ENC_GPIO3, HW_HALL_ENC_PIN3,
HW_HALL_ENC_GPIO1, HW_HALL_ENC_PIN1,
#if defined(HW_SPI_PORT_MOSI) && AS504x_USE_SW_MOSI_PIN
HW_SPI_PORT_MOSI, HW_SPI_PIN_MOSI,
#ifdef AS504x_MOSI_GPIO
AS504x_MOSI_GPIO, AS504x_MOSI_PIN,
#else
0, 0,
#endif