write_buf[0] = SPICMD_READREG;
write_buf[1] = 0x04; // myAddrH // Write CHIPID register
write_buf[2] = 0x04; // myAddrL // Write CHIPID register
// Read data from the register. Step 3 in page 99 of the AD5940 datasheet.
HAL_GPIO_WritePin(SPI3_CS_GPIO_Port, SPI3_CS_Pin, GPIO_PIN_RESET);
HAL_SPI_Transmit(&hspi3, (uint8_t *)write_buf, 3, 100);
HAL_GPIO_WritePin(SPI3_CS_GPIO_Port, SPI3_CS_Pin, GPIO_PIN_SET);
HAL_GPIO_WritePin(SPI3_CS_GPIO_Port, SPI3_CS_Pin, GPIO_PIN_RESET);
HAL_SPI_Receive(&hspi3, (uint8_t *)read_buf, 3, 100);
HAL_GPIO_WritePin(SPI3_CS_GPIO_Port, SPI3_CS_Pin, GPIO_PIN_SET);