daily pastebin goal
40%
SHARE
TWEET

Untitled

a guest Dec 13th, 2018 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top