本帖最后由 740071911 于 2020-11-19 13:13 编辑
第一次体验risc-v的板子,真的是不错,快递也很迅速。而且cortex m系列挺像的,这样上手就很容易了,
体验一下点灯操作。
点灯需要注意的是,
led小灯没有连接到mcu的引脚上,需要自己用杜邦线连接一下
代码也很简单,有stm32经验的很容易
- /********************************** (C) COPYRIGHT *******************************
- * File Name : main.c
- * Author : WCH
- * Version : V1.0.0
- * Date : 2020/04/30
- * Description : Main program body.
- *******************************************************************************/
- #include "debug.h"
- void LED_Init(void)
- {
- GPIO_InitTypeDef GPIO_InitStructure;
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
- GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
- GPIO_Init(GPIOA, &GPIO_InitStructure);
- }
- void GPIO_TogglePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
- {
- GPIOx->OUTDR ^= GPIO_Pin;
- }
- int main(void)
- {
- Delay_Init();
- //USART_Printf_Init(115200);
- //printf("SystemClk:%d\r\n",SystemCoreClock);
- LED_Init();
- while(1)
- {
- Delay_Ms(1000);
- GPIO_TogglePin(GPIOA, GPIO_Pin_0);
- }
- }
|