MCPcopy Create free account
hub / github.com/ZhuYanzhen1/miniFOC / encoder_read_data

Function encoder_read_data

program/algorithm/encoder.c:56–70  ·  view source on GitHub ↗

! \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 */

Source from the content-addressed store, hash-verified

54 \retval data read from magnetic encoder
55*/
56unsigned 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

Callers 2

encoder_zeroingFunction · 0.85

Calls 3

gpio_bit_writeFunction · 0.85
encoder_delayFunction · 0.85
spi_readwrite_halfworldFunction · 0.85

Tested by

no test coverage detected