本帖最后由 袁胜富 于 2024-9-3 10:51 编辑
此部分内容已被设置为付费内容,您可以在支付 1 元 人民币后浏览本楼层全部付费内容。点击购买
typedef union
{
volatile uint32_t all;
struct
{
volatile uint32_t bit0:1;
volatile uint32_t bit1:1;
volatile uint32_t bit2:1;
volatile uint32_t bit3:1;
volatile uint32_t bit4:1;
volatile uint32_t bit5:1;
volatile uint32_t bit6:1;
volatile uint32_t bit7:1;
volatile uint32_t bit8:1;
volatile uint32_t bit9:1;
volatile uint32_t bit10:1;
volatile uint32_t bit11:1;
volatile uint32_t bit12:1;
volatile uint32_t bit13:1;
volatile uint32_t bit14:1;
volatile uint32_t bit15:1;
volatile uint32_t :16;//占位,不使用
}bit;
struct
{
volatile uint32_t bytes0:8;
volatile uint32_t bytes1:8;
volatile uint32_t bytes2:8;
volatile uint32_t bytes3:8;
}bytes;
}GPIO_Bit_Field_TypeDef;
#define PA_OUT ((GPIO_Bit_Field_TypeDef*)((volatile uint32_t *)(0x4001080C)))
#define PAOut(n) (PA_OUT->bit.bit##n)
#define PB_OUT ((GPIO_Bit_Field_TypeDef*)((volatile uint32_t *)(0x40010C0C)))
#define PBOut(n) (PB_OUT->bit.bit##n)
#define PC_OUT ((GPIO_Bit_Field_TypeDef*)((volatile uint32_t *)(0x4001100C)))
#define PCOut(n) (PC_OUT->bit.bit##n)
#define PD_OUT ((GPIO_Bit_Field_TypeDef*)((volatile uint32_t *)(0x4001140C)))
#define PDOut(n) (PD_OUT->bit.bit##n)
#define PE_OUT ((GPIO_Bit_Field_TypeDef*)((volatile uint32_t *)(0x4001180C)))
#define PEOut(n) (PE_OUT->bit.bit##n)
#define PF_OUT ((GPIO_Bit_Field_TypeDef*)((volatile uint32_t *)(0x40011C0C)))
#define PFOut(n) (PF_OUT->bit.bit##n)
#define PA_IN ((GPIO_Bit_Field_TypeDef*)((volatile uint32_t *)(0x40010808)))
#define PAIn(n) (PA_IN->bit.bit##n)
#define PB_IN ((GPIO_Bit_Field_TypeDef*)((volatile uint32_t *)(0x40010C08)))
#define PBIn(n) (PB_IN->bit.bit##n)
#define PC_IN ((GPIO_Bit_Field_TypeDef*)((volatile uint32_t *)(0x40011008)))
#define PCIn(n) (PC_IN->bit.bit##n)
#define PD_IN ((GPIO_Bit_Field_TypeDef*)((volatile uint32_t *)(0x40011408)))
#define PDIn(n) (PD_IN->bit.bit##n)
#define PE_IN ((GPIO_Bit_Field_TypeDef*)((volatile uint32_t *)(0x40011808)))
#define PEIn(n) (PE_IN->bit.bit##n)
#define PF_IN ((GPIO_Bit_Field_TypeDef*)((volatile uint32_t *)(0x40011C08)))
#define PFIn(n) (PF_IN->bit.bit##n)
#define LED2 PBOut(7)
#define LED3 PBOut(8)
#define LED4 PBOut(9)
__weak void application_entry(void *arg)
{
while (1) {
printf("This is a demo task,please use your task entry!\r\n");
LED2 =!LED2;
LED3 =!LED3;
LED4 =!LED4;
tos_task_delay(100);
}
}
|