Skip to content

Commit

Permalink
fix #4
Browse files Browse the repository at this point in the history
  • Loading branch information
hanliumaozhi committed Mar 19, 2019
1 parent 98d2152 commit 98cf5d6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions as5048a/as5048a.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 25,18 @@ void as5048a_setup(SPI_HandleTypeDef* spiHandle, GPIO_TypeDef* as5048a_port, uin
bool as5048a_read()
{
HAL_GPIO_WritePin(AS5048A_PORT, AS5048A_PIN, GPIO_PIN_RESET);
HAL_SPI_TransmitReceive(&hspi2, (uint8_t *)&cmd_word, (uint8_t *)&position_val_raw, 1, HAL_MAX_DELAY);
HAL_SPI_TransmitReceive(&hspi2, (uint8_t *)&cmd_word, (uint8_t *)&position_val_raw, 1, 0);
HAL_GPIO_WritePin(AS5048A_PORT, AS5048A_PIN, GPIO_PIN_SET);

HAL_GPIO_WritePin(AS5048A_PORT, AS5048A_PIN, GPIO_PIN_RESET);
HAL_SPI_TransmitReceive(&hspi2, (uint8_t *)&cmd_word, (uint8_t *)&position_val_raw, 1, HAL_MAX_DELAY);
HAL_SPI_TransmitReceive(&hspi2, (uint8_t *)&cmd_word, (uint8_t *)&position_val_raw, 1, 0);
HAL_GPIO_WritePin(AS5048A_PORT, AS5048A_PIN, GPIO_PIN_SET);

falut_status = position_val_raw & 0x4000;
position_val_raw &= 0x3fff;
if (falut_status == 0){
position_val_raw_f = (float)position_val_raw;
position_val = ((position_val_raw_f) / (16383.0f)) * 3.14159265;
position_val = ((position_val_raw_f) / (16383.0f)) * 3.14159265f;
return true;
}else{
// implement some funciton
Expand Down
1 change: 1 addition & 0 deletions motor_control/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 157,7 @@ int main(void)
total_time = 0;
falut_counter = 0;
}
//HAL_Delay(1);


/* USER CODE BEGIN 3 */
Expand Down

0 comments on commit 98cf5d6

Please sign in to comment.