[refactor] prepare for link gen

This commit is contained in:
2023-08-15 16:18:48 +02:00
parent 76ba24e527
commit 3e7c5c5089
30 changed files with 1387 additions and 1076 deletions

View File

@@ -5,20 +5,19 @@ static uint32_t pot_value[MCP41X_RES_MAX] = {10000, 50000, 100000};
static void mcp41x_transmit(mcp41x_handle_t *hpot, uint8_t *data)
{
HAL_GPIO_WritePin(hpot->cs_port, hpot->cs_pin, GPIO_PIN_RESET);
hpot->hcs->cs_on(hpot->hcs);
HAL_SPI_Transmit(hpot->hspi, data, 2, HAL_MAX_DELAY);
HAL_GPIO_WritePin(hpot->cs_port, hpot->cs_pin, GPIO_PIN_SET);
hpot->hcs->cs_off(hpot->hcs);
}
void mcp41x_init(mcp41x_handle_t *hpot, SPI_HandleTypeDef *hspi, GPIO_TypeDef *cs_port, uint16_t cs_pin, mcp41x_res_t res)
void mcp41x_init(mcp41x_handle_t *hpot, SPI_HandleTypeDef *hspi, cs_handle_t *hcs, mcp41x_res_t res)
{
hpot->hspi = hspi;
hpot->cs_port = cs_port;
hpot->cs_pin = cs_pin;
hpot->hcs = hcs;
hpot->max_res = res;
hpot->dir = MCP41X_ATOB;
HAL_GPIO_WritePin(hpot->cs_port, hpot->cs_pin, GPIO_PIN_SET);
hpot->hcs->cs_off(hcs);
}
void mcp41x_setValue(mcp41x_handle_t *hpot, uint8_t value)