各位大佬前辈,最近从CH32F103转CH32V203和CH32V003系列,下载EVT后发现库代码冗沉太厉害,各种代码和函数嵌套,好不习惯这种代码结构,我之前用寄存器设置STM32F系列的GPIO从GPIOA到GPIOE只要25行简洁代码,昨天开始查手册研究CH32V203的寄存器代码,好费时间.我想问下各位大佬前辈有没有CH32V203系列寄存器设置相关范例代码,我想省点时间做底层驱动,谢谢!
==================
CH32F103 系列的GPIO设置范例源码.要改变哪个IO的属性只要更改GPIOA->CRL |= 0x******** 相关位即可,简单的一塌糊涂.
RCC->APB2ENR |= 1<<2 ; //打开GPIOA时钟
GPIOA->CRL &= 0x00000000; //所有通道清零
GPIOA->CRL |= 0xA8A48A22; //2为通用推挽输出2M @PA4567浮空输入,防止串扰.
//GPIOA->CRL |= 0x44448A22; //关闭GPIOA 4-7PIN ,芯片2
GPIOA->CRH &= 0x00000000; //4为浮空输入
GPIOA->CRH |= 0x888888AA;
RCC->APB2ENR |= 1<<3 ; //打开GPIOB时钟
GPIOB->CRL &= 0x00000000;
GPIOB->CRL |= 0x2222222A; //A为复用推挽输出2M
GPIOB->CRH &= 0x00000000;
GPIOB->CRH |= 0x88888822; //8为输入上拉模式
RCC->APB2ENR |= 1<<4 ; //打开GPIOC时钟
GPIOC->CRL &= 0x00000000;
GPIOC->CRL |= 0x82222222; //PC7上拉输入.
//GPIOC->CRL |= 0x82442222; //PC4-5浮空输入,芯片2
GPIOC->CRH &= 0x00000000;
GPIOC->CRH |= 0x22288888;
RCC->APB2ENR |= 1<<5 ; //打开GPIOD时钟
GPIOD->CRL &= 0x00000000;
GPIOD->CRL |= 0x88888888;
GPIOD->CRH &= 0x00000000;
GPIOD->CRH |= 0x88888888;
RCC->APB2ENR |= 1<<6 ; //打开GPIOE时钟
GPIOE->CRL &= 0x00000000;
GPIOE->CRL |= 0x22222222;
GPIOE->CRH &= 0x00000000;
GPIOE->CRH |= 0x88888888;