[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

@@ -0,0 +1,24 @@
#include "mcu_cs.h"
// static cs_handle_t const _cs_handle = {.cs_on = mcu_cs_on, .cs_off = mcu_cs_off};
void mcu_cs_init(MCU_cs_t *hcs, GPIO_TypeDef *cs_port, uint16_t cs_pin, uint8_t cs_idle)
{
hcs->super.cs_on = mcu_cs_on;
hcs->super.cs_off = mcu_cs_off;
hcs->cs_port = cs_port;
hcs->cs_pin = cs_pin;
hcs->cs_idle = cs_idle;
}
void mcu_cs_on(cs_handle_t *hcs)
{
MCU_cs_t *_hcs = (MCU_cs_t *)hcs;
HAL_GPIO_WritePin(_hcs->cs_port, _hcs->cs_pin, !_hcs->cs_idle);
}
void mcu_cs_off(cs_handle_t *hcs)
{
MCU_cs_t *_hcs = (MCU_cs_t *)hcs;
HAL_GPIO_WritePin(_hcs->cs_port, _hcs->cs_pin, _hcs->cs_idle);
}

View File

@@ -0,0 +1,16 @@
#pragma once
#include "main.h"
#include "spi_cs_if.h"
typedef struct
{
cs_handle_t super;
GPIO_TypeDef *cs_port;
uint16_t cs_pin;
uint8_t cs_idle;
} MCU_cs_t;
void mcu_cs_init(MCU_cs_t *hcs, GPIO_TypeDef *cs_port, uint16_t cs_pin, uint8_t cs_idle);
void mcu_cs_on(cs_handle_t *me);
void mcu_cs_off(cs_handle_t *me);