[fix] longest timout for spi
This commit is contained in:
@@ -7,15 +7,25 @@
|
|||||||
// static uint32_t ad9833_calcFreq(float f); // Calculate AD9833 frequency register from a frequency
|
// 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
|
// 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)
|
static void ad9833_transmit16(ad9833_handle_t *hfg, uint16_t data)
|
||||||
{
|
{
|
||||||
uint8_t data8;
|
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);
|
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);
|
data8 = (uint8_t)(data & 0x00FF);
|
||||||
HAL_SPI_Transmit(hfg->hspi, &data8, 1, 1);
|
HAL_SPI_Transmit(hfg->hspi, &data8, 1, HAL_MAX_DELAY);
|
||||||
HAL_GPIO_WritePin(hfg->cs_port, hfg->cs_pin, GPIO_PIN_SET);
|
ad9833_spi_deactivate(hfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ad9833_reset(ad9833_handle_t *hfg, uint8_t hold)
|
void ad9833_reset(ad9833_handle_t *hfg, uint8_t hold)
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ typedef struct
|
|||||||
} ad9833_handle_t;
|
} ad9833_handle_t;
|
||||||
|
|
||||||
void ad9833_init(ad9833_handle_t *hfg, SPI_HandleTypeDef *hspi, GPIO_TypeDef *cs_port, uint16_t cs_pin);
|
void ad9833_init(ad9833_handle_t *hfg, SPI_HandleTypeDef *hspi, GPIO_TypeDef *cs_port, uint16_t cs_pin);
|
||||||
|
void ad9833_spi_activate(ad9833_handle_t *hfg);
|
||||||
|
void ad9833_spi_deactivate(ad9833_handle_t *hfg);
|
||||||
void ad9833_reset(ad9833_handle_t *hfg, uint8_t hold);
|
void ad9833_reset(ad9833_handle_t *hfg, uint8_t hold);
|
||||||
void ad9833_setActiveChannelFreq(ad9833_handle_t *hfg, AD_channel_t chan);
|
void ad9833_setActiveChannelFreq(ad9833_handle_t *hfg, AD_channel_t chan);
|
||||||
AD_channel_t ad9833_getActiveChannelFreq(ad9833_handle_t *hfg);
|
AD_channel_t ad9833_getActiveChannelFreq(ad9833_handle_t *hfg);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ static uint32_t pot_value[MCP41X_RES_MAX] = {10000, 50000, 100000};
|
|||||||
static void mcp41x_transmit(mcp41x_handle_t *hpot, uint8_t *data)
|
static void mcp41x_transmit(mcp41x_handle_t *hpot, uint8_t *data)
|
||||||
{
|
{
|
||||||
HAL_GPIO_WritePin(hpot->cs_port, hpot->cs_pin, GPIO_PIN_RESET);
|
HAL_GPIO_WritePin(hpot->cs_port, hpot->cs_pin, GPIO_PIN_RESET);
|
||||||
HAL_SPI_Transmit(hpot->hspi, data, 2, 1);
|
HAL_SPI_Transmit(hpot->hspi, data, 2, HAL_MAX_DELAY);
|
||||||
HAL_GPIO_WritePin(hpot->cs_port, hpot->cs_pin, GPIO_PIN_SET);
|
HAL_GPIO_WritePin(hpot->cs_port, hpot->cs_pin, GPIO_PIN_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user