mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-09-23 09:03:40 +08:00
Fixing error code assignment. Adding SPI ready check.
This commit is contained in:
committed by
Paul Guenette
parent
7440d982e3
commit
31a143a500
@@ -13,8 +13,10 @@ Encoder::Encoder(const EncoderHardwareConfig_t& hw_config,
|
||||
is_ready_ = true;
|
||||
}
|
||||
|
||||
decode_abs_spi_cs_pin();
|
||||
HAL_GPIO_WritePin(abs_spi_cs_port_, abs_spi_cs_pin_, GPIO_PIN_SET);
|
||||
if(config.mode & Encoder::MODE_FLAG_ABS){
|
||||
decode_abs_spi_cs_pin();
|
||||
HAL_GPIO_WritePin(abs_spi_cs_port_, abs_spi_cs_pin_, GPIO_PIN_SET);
|
||||
}
|
||||
}
|
||||
|
||||
static void enc_index_cb_wrapper(void* ctx) {
|
||||
@@ -340,8 +342,10 @@ bool Encoder::abs_spi_init(){
|
||||
|
||||
bool Encoder::abs_spi_start_transaction(){
|
||||
if (config_.mode & MODE_FLAG_ABS){
|
||||
//TODO semaphore take
|
||||
|
||||
if(hw_config_.spi->State != HAL_SPI_STATE_READY){
|
||||
set_error(ERROR_ABS_SPI_NOT_READY);
|
||||
return false;
|
||||
}
|
||||
//apply the stashed configuration
|
||||
hw_config_.spi->Instance->CR1 = abs_spi_cr1;
|
||||
hw_config_.spi->Instance->CR2 = abs_spi_cr2;
|
||||
@@ -359,7 +363,6 @@ uint8_t parity(uint16_t v){
|
||||
return v & 1;
|
||||
}
|
||||
void Encoder::abs_spi_cb(){
|
||||
//TODO semaphore release
|
||||
HAL_GPIO_WritePin(abs_spi_cs_port_, abs_spi_cs_pin_, GPIO_PIN_SET);
|
||||
switch (config_.mode) {
|
||||
case MODE_SPI_ABS_AMS: {
|
||||
|
||||
@@ -15,8 +15,9 @@ public:
|
||||
ERROR_UNSUPPORTED_ENCODER_MODE = 0x08,
|
||||
ERROR_ILLEGAL_HALL_STATE = 0x10,
|
||||
ERROR_INDEX_NOT_FOUND_YET = 0x20,
|
||||
ERROR_ABS_SPI_TIMEOUT = 0x30,
|
||||
ERROR_ABS_SPI_COM_FAIL = 0x40,
|
||||
ERROR_ABS_SPI_TIMEOUT = 0x40,
|
||||
ERROR_ABS_SPI_COM_FAIL = 0x80,
|
||||
ERROR_ABS_SPI_NOT_READY = 0x100,
|
||||
};
|
||||
|
||||
enum Mode_t {
|
||||
|
||||
Reference in New Issue
Block a user