添加bsp gpio的支持

This commit is contained in:
NeoZng 2023-02-02 14:15:57 +08:00
parent 38e1eabc2d
commit 2576befb80
8 changed files with 97 additions and 1 deletions

View File

@ -106,6 +106,7 @@ bsp/pwm/bsp_pwm.c \
bsp/bsp_legacy_support/bsp_temperature.c \
bsp/bsp_legacy_support/bsp_buzzer.c \
bsp/bsp_legacy_support/bsp_led.c \
bsp/gpio/bsp_gpio.c \
bsp/spi/bsp_spi.c \
bsp/iic/bsp_iic.c \
bsp/can/bsp_can.c \
@ -229,6 +230,7 @@ C_INCLUDES = \
-Ibsp/dwt \
-Ibsp/can \
-Ibsp/usart \
-Ibsp/gpio \
-Ibsp/spi \
-Ibsp/iic \
-Ibsp/log \

View File

@ -293,6 +293,8 @@ NVIC.DMA2_Stream5_IRQn=true\:5\:0\:false\:false\:true\:false\:false\:true\:true
NVIC.DMA2_Stream6_IRQn=true\:5\:0\:true\:false\:true\:true\:false\:true\:true
NVIC.DMA2_Stream7_IRQn=true\:5\:0\:true\:false\:true\:true\:false\:true\:true
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
NVIC.EXTI3_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
NVIC.EXTI4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
NVIC.ForceEnableDMAVector=true
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
NVIC.I2C2_ER_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
@ -440,11 +442,12 @@ PG3.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_FALLING
PG3.GPIO_PuPd=GPIO_PULLUP
PG3.Locked=true
PG3.Signal=GPXTI3
PG6.GPIOParameters=GPIO_Speed,GPIO_PuPd,GPIO_Label
PG6.GPIOParameters=GPIO_Speed,PinState,GPIO_PuPd,GPIO_Label
PG6.GPIO_Label=MAG_RST
PG6.GPIO_PuPd=GPIO_PULLUP
PG6.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM
PG6.Locked=true
PG6.PinState=GPIO_PIN_SET
PG6.Signal=GPIO_Output
PG9.Locked=true
PG9.Mode=Asynchronous

View File

@ -0,0 +1,49 @@
#include "bsp_gpio.h"
#include "memory.h"
#include "stdlib.h"
static uint8_t idx;
static GPIOInstance* gpio_instance[GPIO_MX_DEVICE_NUM] = {NULL};
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
}
GPIOInstance *GPIORegister(GPIO_Init_Config_s *GPIO_config)
{
GPIOInstance *ins=(GPIOInstance*)malloc(sizeof(GPIOInstance));
memset(ins,0,sizeof(GPIOInstance));
ins->GPIOx=GPIO_config->GPIOx;
ins->GPIO_Pin=GPIO_config->GPIO_Pin;
ins->id=GPIO_config->id;
ins->gpio_model_callback=GPIO_config->gpio_model_callback;
gpio_instance[idx++]=ins;
return ins;
}
// ----------------- GPIO API -----------------
// 都是对HAL的形式上的封装,后续考虑增加GPIO state变量,可以直接读取state
void GPIOToggel(GPIOInstance *_instance)
{
HAL_GPIO_TogglePin(_instance->GPIOx,_instance->GPIO_Pin);
}
void GPIOSet(GPIOInstance *_instance)
{
HAL_GPIO_WritePin(_instance->GPIOx,_instance->GPIO_Pin,GPIO_PIN_SET);
}
void GPIOReset(GPIOInstance *_instance)
{
HAL_GPIO_WritePin(_instance->GPIOx,_instance->GPIO_Pin,GPIO_PIN_RESET);
}
GPIO_PinState GPIORead(GPIOInstance *_instance)
{
return HAL_GPIO_ReadPin(_instance->GPIOx,_instance->GPIO_Pin);
}

View File

@ -1,2 +1,38 @@
#include "gpio.h"
#include "stdint.h"
#define GPIO_MX_DEVICE_NUM 10
/**
* @brief GPIO实例结构体定义
*
*/
typedef struct tmpgpio
{
GPIO_TypeDef *GPIOx;
uint16_t GPIO_Pin;
void* id;
void (*gpio_model_callback)(struct tmpgpio*); // 随便取个名字当临时声明
} GPIOInstance;
/**
* @brief GPIO初始化配置结构体定义
*
*/
typedef struct
{
GPIO_TypeDef *GPIOx;
uint16_t GPIO_Pin;
void* id;
void (*gpio_model_callback)(GPIOInstance*);
} GPIO_Init_Config_s;
GPIOInstance* GPIORegister(GPIO_Init_Config_s* GPIO_config);
void GPIOToggel(GPIOInstance* _instance);
void GPIOSet(GPIOInstance* _instance);
void GPIOReset(GPIOInstance* _instance);
GPIO_PinState GPIORead(GPIOInstance* _instance);

View File

@ -0,0 +1 @@
#include "ist8310.h"

View File

@ -0,0 +1,5 @@
#pragma once
#include "bsp_i2c.h"
#include "stdint.h"

View File

0
modules/oled/oled.md Normal file
View File