leakage
This commit is contained in:
113
calib_board/usr/bsp/bsp_74HC4067.c
Normal file
113
calib_board/usr/bsp/bsp_74HC4067.c
Normal file
@@ -0,0 +1,113 @@
|
||||
#include "bsp_74HC4067.h"
|
||||
#include "os_timer.h"
|
||||
|
||||
/*<2A><>Ƭ74HC4067<36><37>һƬTX һƬRX ÿƬ16ͨ<36><CDA8>*/
|
||||
|
||||
#define BSP_74HC4067_CH_MAX 16
|
||||
|
||||
/*TX*/
|
||||
#define TX_EN_ENABLE HAL_GPIO_WritePin (TX_EN_GPIO_Port, TX_EN_Pin, GPIO_PIN_RESET)
|
||||
#define TX_EN_DISENABLE HAL_GPIO_WritePin (TX_EN_GPIO_Port, TX_EN_Pin, GPIO_PIN_SET)
|
||||
|
||||
/*RX*/
|
||||
#define RX_EN_ENABLE HAL_GPIO_WritePin (RX_EN_GPIO_Port, RX_EN_Pin, GPIO_PIN_RESET)
|
||||
#define RX_EN_DISENABLE HAL_GPIO_WritePin (RX_EN_GPIO_Port, RX_EN_Pin, GPIO_PIN_SET)
|
||||
|
||||
|
||||
/*LEDͨ<44><CDA8>ָʾ*/
|
||||
#define LED_CH0_ON HAL_GPIO_WritePin (RX_S3_GPIO_Port, RX_S3_Pin, GPIO_PIN_RESET)
|
||||
#define LED_CH0_OFF HAL_GPIO_WritePin (RX_S3_GPIO_Port, RX_S3_Pin, GPIO_PIN_SET)
|
||||
|
||||
#define BSP_LOW GPIO_PIN_RESET
|
||||
#define BSP_HIG GPIO_PIN_SET
|
||||
|
||||
#define BSP_LED_ON GPIO_PIN_RESET
|
||||
#define BSP_LED_OFF GPIO_PIN_SET
|
||||
|
||||
static GPIO_TypeDef* bsp_74HC4067_TX_SW_GPIO[4] = {TX_S0_GPIO_Port,TX_S1_GPIO_Port,TX_S2_GPIO_Port,TX_S3_GPIO_Port};
|
||||
static uint16_t bsp_74HC4067_TX_SW_Pin[4] = {TX_S0_Pin, TX_S1_Pin, TX_S2_Pin, TX_S3_Pin};
|
||||
|
||||
static GPIO_TypeDef* bsp_74HC4067_RX_SW_GPIO[4] = {RX_S0_GPIO_Port,RX_S1_GPIO_Port,RX_S2_GPIO_Port,RX_S3_GPIO_Port};
|
||||
static uint16_t bsp_74HC4067_RX_SW_Pin[4] = {RX_S0_Pin, RX_S1_Pin, RX_S2_Pin, RX_S3_Pin};
|
||||
|
||||
static GPIO_TypeDef* bsp_74HC4067_LED_CH_GPIO[BSP_74HC4067_CH_MAX] = {LED_CH1_GPIO_Port, LED_CH2_GPIO_Port, LED_CH3_GPIO_Port, LED_CH4_GPIO_Port, LED_CH5_GPIO_Port, LED_CH6_GPIO_Port, LED_CH7_GPIO_Port, LED_CH8_GPIO_Port, LED_CH9_GPIO_Port, LED_CH10_GPIO_Port, LED_CH11_GPIO_Port, LED_CH12_GPIO_Port, LED_CH13_GPIO_Port, LED_CH14_GPIO_Port, LED_CH15_GPIO_Port, LED_CH16_GPIO_Port};
|
||||
static uint16_t bsp_74HC4067_LED_CH_Pin[BSP_74HC4067_CH_MAX] = {LED_CH1_Pin, LED_CH2_Pin, LED_CH3_Pin, LED_CH4_Pin, LED_CH5_Pin, LED_CH6_Pin, LED_CH7_Pin, LED_CH8_Pin, LED_CH9_Pin, LED_CH10_Pin, LED_CH11_Pin, LED_CH12_Pin, LED_CH13_Pin, LED_CH14_Pin, LED_CH15_Pin, LED_CH16_Pin};
|
||||
|
||||
/*ͨ<><CDA8>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>Ӳ<EFBFBD><D3B2>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>оƬ<D0BE><C6AC><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>*/
|
||||
static u8 bsp_74HC4067_TX_CH_Conv[BSP_74HC4067_CH_MAX] = {13,14,15,12,11,10,9, 8, 7, 4, 3, 2, 1, 0, 6, 5};
|
||||
static u8 bsp_74HC4067_RX_CH_Conv[BSP_74HC4067_CH_MAX] = {13,14,15,8, 9, 10,11,12,0, 1, 2, 3, 4, 5, 6, 7};
|
||||
|
||||
|
||||
static void bsp_74HC4067_Init(void);
|
||||
static void bsp_74HC4067_Set_CH(u8 CH);
|
||||
static u8 bsp_74HC4067_Get_CH(void);
|
||||
|
||||
static u8 bsp_74HC4067_CH;
|
||||
|
||||
bsp_74HC4067_t UartCH_Config =
|
||||
{
|
||||
.init = bsp_74HC4067_Init,
|
||||
.ch_set = bsp_74HC4067_Set_CH,
|
||||
.ch_get = bsp_74HC4067_Get_CH,
|
||||
};
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˸<EFBFBD><CBB8><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
static void bsp_74HC4067_Init(void)
|
||||
{
|
||||
bsp_74HC4067_CH = 0;
|
||||
TX_EN_ENABLE;
|
||||
RX_EN_ENABLE;
|
||||
bsp_74HC4067_Set_CH(0);
|
||||
}
|
||||
|
||||
|
||||
//static u8 CH;
|
||||
static void bsp_74HC4067_Set_CH(u8 CH1)
|
||||
{
|
||||
u8 CH = 0;
|
||||
if(CH >= BSP_74HC4067_CH_MAX)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
u8 i,TX_CH,RX_CH;
|
||||
bsp_74HC4067_CH = CH;
|
||||
TX_CH = bsp_74HC4067_TX_CH_Conv[CH];
|
||||
RX_CH = bsp_74HC4067_RX_CH_Conv[CH];
|
||||
/*ѡ<><D1A1><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
for(i=0;i<4;i++)
|
||||
{
|
||||
if((TX_CH >> i) & 0x01)
|
||||
{
|
||||
HAL_GPIO_WritePin(bsp_74HC4067_TX_SW_GPIO[i],bsp_74HC4067_TX_SW_Pin[i],BSP_HIG);
|
||||
}
|
||||
else
|
||||
{
|
||||
HAL_GPIO_WritePin(bsp_74HC4067_TX_SW_GPIO[i],bsp_74HC4067_TX_SW_Pin[i],BSP_LOW);
|
||||
}
|
||||
if((RX_CH >> i) & 0x01)
|
||||
{
|
||||
HAL_GPIO_WritePin(bsp_74HC4067_RX_SW_GPIO[i],bsp_74HC4067_RX_SW_Pin[i],BSP_HIG);
|
||||
}
|
||||
else
|
||||
{
|
||||
HAL_GPIO_WritePin(bsp_74HC4067_RX_SW_GPIO[i],bsp_74HC4067_RX_SW_Pin[i],BSP_LOW);
|
||||
}
|
||||
}
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧָʾ<D6B8><CABE>*/
|
||||
for(i=0;i<BSP_74HC4067_CH_MAX;i++)
|
||||
{
|
||||
if(i == CH)
|
||||
{
|
||||
HAL_GPIO_WritePin(bsp_74HC4067_LED_CH_GPIO[i],bsp_74HC4067_LED_CH_Pin[i],BSP_LED_ON);
|
||||
}
|
||||
else
|
||||
{
|
||||
HAL_GPIO_WritePin(bsp_74HC4067_LED_CH_GPIO[i],bsp_74HC4067_LED_CH_Pin[i],BSP_LED_OFF);
|
||||
}
|
||||
}
|
||||
// HAL_Delay(20);
|
||||
}
|
||||
|
||||
static u8 bsp_74HC4067_Get_CH(void)
|
||||
{
|
||||
return bsp_74HC4067_CH;
|
||||
}
|
||||
Reference in New Issue
Block a user