CH32V307是款國產的基于CORTEX-M4的高性能32位單片機,本例程在CH32V307單片機上移植RT-THREAD操作系統,正常運行。
以下是工程目錄:
捕獲.PNG (21.37 KB, 下載次數: 32)
下載附件
這是整個工程文件目錄
2024-1-4 20:32 上傳
以下是主文件所在目錄:
捕獲qqqq.PNG (12.41 KB, 下載次數: 31)
下載附件
主文件目錄
2024-1-4 20:35 上傳
以下是部分代碼顯示:
- /********************************** (C) COPYRIGHT *******************************
- * File Name : main.c
- * Author : WCH
- * Version : V1.0.0
- * Date : 2020/04/30
- * Description : Main program body.
- *********************************************************************************
- * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
- * Attention: This software (modified or not) and binary are used for
- * microcontroller manufactured by Nanjing Qinheng Microelectronics.
- *******************************************************************************/
- #include "ch32v30x.h"
- #include <rtthread.h>
- #include <rthw.h>
- #include "drivers/pin.h"
- /* Global typedef */
- /* Global define */
- /* LED0 is driven by the pin driver interface of rt */
- #define LED0_PIN 18 //PC3
- /* Global Variable */
- /*********************************************************************
- * @fn LED1_BLINK_INIT
- *
- * @brief LED1 directly calls the underlying driver
- *
- * @return none
- */
- void LED1_BLINK_INIT(void)
- {
- GPIO_InitTypeDef GPIO_InitStructure={0};
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
- GPIO_Init(GPIOA, &GPIO_InitStructure);
- }
- /*********************************************************************
- * @fn main
- *
- * @brief main is just one of the threads, in addition to tshell,idle
- * This main is just a flashing LED, the main thread is registered in
- * rtthread_startup, tshell uses the serial port to receive interrupts,
- * and the interrupt stack and thread stack are used separately.
- *
- * @return none
- */
- int main(void)
- {
- rt_kprintf("\r\n MCU: CH32V307\r\n");
- SystemCoreClockUpdate();
- rt_kprintf(" SysClk: %dHz\r\n",SystemCoreClock);
- rt_kprintf(" ChipID: %08x\r\n",DBGMCU_GetCHIPID());
- rt_kprintf(" wwwwchcn\r\n");
- LED1_BLINK_INIT();
- GPIO_ResetBits(GPIOA,GPIO_Pin_0);
- while(1)
- {
- GPIO_SetBits(GPIOA,GPIO_Pin_0);
- rt_thread_mdelay(500);
- GPIO_ResetBits(GPIOA,GPIO_Pin_0);
- rt_thread_mdelay(500);
- }
- }
- /*********************************************************************
- * @fn led
- *
- * @brief Test using the driver interface to operate the I/O port
- *
- * @return none
- */
- int led(void)
- {
- rt_uint8_t count;
- rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
- printf("led_SP:%08x\r\n",__get_SP());
- for(count = 0 ; count < 10 ;count++)
- {
- rt_pin_write(LED0_PIN, PIN_LOW);
- rt_kprintf("led on, count : %d\r\n", count);
- rt_thread_mdelay(500);
- rt_pin_write(LED0_PIN, PIN_HIGH);
- rt_kprintf("led off\r\n");
- rt_thread_mdelay(500);
- }
- return 0;
- }
- MSH_CMD_EXPORT(led, led sample by using I/O drivers);
復制代碼 原理圖: 無
仿真: 無
代碼:
RT-Thread.7z
(101.89 KB, 下載次數: 5)
2024-1-4 21:44 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|