! \brief read data from the register of the magnetic encoder \param[in] TxData: data to be sent to magnetic encoder \retval data read from magnetic encoder */
| 54 | \retval data read from magnetic encoder |
| 55 | */ |
| 56 | unsigned short encoder_read_data(unsigned short TxData) { |
| 57 | unsigned short data; |
| 58 | |
| 59 | /* pull down the CS pin and prepare to send data */ |
| 60 | gpio_bit_write(GPIOA, GPIO_PIN_4, RESET); |
| 61 | encoder_delay(); |
| 62 | |
| 63 | /* call SPI related functions to send and receive data */ |
| 64 | data = spi_readwrite_halfworld(TxData); |
| 65 | encoder_delay(); |
| 66 | |
| 67 | /* pull up CS pin to end sending data */ |
| 68 | gpio_bit_write(GPIOA, GPIO_PIN_4, SET); |
| 69 | return data; |
| 70 | } |
| 71 | |
| 72 | /*! |
| 73 | \brief read mechanical angle directly from encoder |
no test coverage detected