[fix] longest timout for spi

This commit is contained in:
2023-08-12 19:14:47 +02:00
parent 527585217c
commit 843e74ded0
3 changed files with 17 additions and 5 deletions

View File

@@ -7,15 +7,25 @@
// static uint32_t ad9833_calcFreq(float f); // Calculate AD9833 frequency register from a frequency
// static uint16_t ad9833_calcPhase(float a); // Calculate AD9833 phase register from phase
void ad9833_spi_activate(ad9833_handle_t *hfg)
{
HAL_GPIO_WritePin(hfg->cs_port, hfg->cs_pin, GPIO_PIN_RESET);
}
void ad9833_spi_deactivate(ad9833_handle_t *hfg)
{
HAL_GPIO_WritePin(hfg->cs_port, hfg->cs_pin, GPIO_PIN_SET);
}
static void ad9833_transmit16(ad9833_handle_t *hfg, uint16_t data)
{
uint8_t data8;
HAL_GPIO_WritePin(hfg->cs_port, hfg->cs_pin, GPIO_PIN_RESET);
ad9833_spi_activate(hfg);
data8 = (uint8_t)((data >> 8) & 0x00FF);
HAL_SPI_Transmit(hfg->hspi, &data8, 1, 1);
HAL_SPI_Transmit(hfg->hspi, &data8, 1, HAL_MAX_DELAY);
data8 = (uint8_t)(data & 0x00FF);
HAL_SPI_Transmit(hfg->hspi, &data8, 1, 1);
HAL_GPIO_WritePin(hfg->cs_port, hfg->cs_pin, GPIO_PIN_SET);
HAL_SPI_Transmit(hfg->hspi, &data8, 1, HAL_MAX_DELAY);
ad9833_spi_deactivate(hfg);
}
void ad9833_reset(ad9833_handle_t *hfg, uint8_t hold)