[refactor] prepare for link gen
This commit is contained in:
24
firmware/shared_libs/drivers/mcu_cs/mcu_cs.c
Normal file
24
firmware/shared_libs/drivers/mcu_cs/mcu_cs.c
Normal 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);
|
||||
}
|
||||
16
firmware/shared_libs/drivers/mcu_cs/mcu_cs.h
Normal file
16
firmware/shared_libs/drivers/mcu_cs/mcu_cs.h
Normal 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);
|
||||
Reference in New Issue
Block a user