Guest User

Untitled

a guest
Dec 13th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. uint8_t AT86RF2XX::reg_read(const uint8_t addr)
  2. {
  3. uint8_t value;
  4. uint8_t readCommand = addr | AT86RF2XX_ACCESS_REG | AT86RF2XX_ACCESS_READ; //never mind for these constants, they're correct
  5. HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_RESET);
  6. // PA8 is set as GPIO output from CubemMX, and plays the role of the SS pin, now it goes off to wake up the slave
  7.  
  8. HAL_SPI_TransmitReceive(spi, &readCommand, &value, 1, 100);
  9. while(HAL_SPI_GetState(spi) != HAL_SPI_STATE_READY);
  10.  
  11. HAL_SPI_TransmitReceive(spi, &readCommand, &value, 1, 100);
  12. HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_SET); // set it back to high to terminate the communication.
  13.  
  14. return (uint8_t)value;
  15. }
Add Comment
Please, Sign In to add comment