各位大佬前輩,最近從CH32F103轉CH32V203和CH32V003系列,下載EVT后發(fā)現(xiàn)庫代碼冗沉太厲害,各種代碼和函數(shù)嵌套,好不習慣這種代碼結構,我之前用寄存器設置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;