format codes

pull/91/head
Meco Man 5 years ago
parent 9bacff022c
commit befe7c1034

@ -32,20 +32,20 @@
*/ */
static void RCC_Configuration(void) static void RCC_Configuration(void)
{ {
//下面是给各模块开启时钟 //下面是给各模块开启时钟
//启动GPIO //启动GPIO
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | \ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | \
RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | \ RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | \
RCC_APB2Periph_GPIOE | RCC_APB2Periph_GPIOG, RCC_APB2Periph_GPIOE | RCC_APB2Periph_GPIOG,
ENABLE); ENABLE);
//启动AFIO //启动AFIO
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
//启动USART1时钟 //启动USART1时钟
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
//启动USART2时钟 //启动USART2时钟
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
//启动DMA时钟 //启动DMA时钟
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
/* Enable ADC1 and GPIOC clock */ /* Enable ADC1 and GPIOC clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);

@ -26,38 +26,38 @@
*/ */
/* board configuration */ /* board configuration */
// <o> SDCard Driver <1=>SDIO sdcard <0=>SPI MMC card // <o> SDCard Driver <1=>SDIO sdcard <0=>SPI MMC card
// <i>Default: 1 // <i>Default: 1
#define STM32_USE_SDIO 0 #define STM32_USE_SDIO 0
/* whether use board external SRAM memory */ /* whether use board external SRAM memory */
// <e>Use external SRAM memory on the board // <e>Use external SRAM memory on the board
// <i>Enable External SRAM memory // <i>Enable External SRAM memory
#define STM32_EXT_SRAM 0 #define STM32_EXT_SRAM 0
// <o>Begin Address of External SRAM // <o>Begin Address of External SRAM
// <i>Default: 0x68000000 // <i>Default: 0x68000000
#define STM32_EXT_SRAM_BEGIN 0x68000000 /* the begining address of external SRAM */ #define STM32_EXT_SRAM_BEGIN 0x68000000 /* the begining address of external SRAM */
// <o>End Address of External SRAM // <o>End Address of External SRAM
// <i>Default: 0x68080000 // <i>Default: 0x68080000
#define STM32_EXT_SRAM_END 0x68080000 /* the end address of external SRAM */ #define STM32_EXT_SRAM_END 0x68080000 /* the end address of external SRAM */
// </e> // </e>
// <o> Internal SRAM memory size[Kbytes] <8-64> // <o> Internal SRAM memory size[Kbytes] <8-64>
// <i>Default: 64 // <i>Default: 64
#define STM32_SRAM_SIZE 64 #define STM32_SRAM_SIZE 64
#define STM32_SRAM_END (SRAM_BASE + STM32_SRAM_SIZE * 1024) #define STM32_SRAM_END (SRAM_BASE + STM32_SRAM_SIZE * 1024)
#define VECT_TAB_FLASH /* use Flash to store vector table */ #define VECT_TAB_FLASH /* use Flash to store vector table */
#define LED_RUN_ON GPIO_SetBits (GPIOB,GPIO_Pin_5) //RUN #define LED_RUN_ON GPIO_SetBits (GPIOB,GPIO_Pin_5) //RUN
#define LED_RUN_OFF GPIO_ResetBits(GPIOB,GPIO_Pin_5) //RUN #define LED_RUN_OFF GPIO_ResetBits(GPIOB,GPIO_Pin_5) //RUN
/*********************************************************************************************************/ /*********************************************************************************************************/
/** MACRO'S */ /** MACRO'S */
/***********************************************************************************************************/ /***********************************************************************************************************/
/***********************************************************************************************************/ /***********************************************************************************************************/
/* DATA TYPES */ /* DATA TYPES */
/***********************************************************************************************************/ /***********************************************************************************************************/

@ -7,15 +7,15 @@
typedef int bool_t; /**< boolean type */ typedef int bool_t; /**< boolean type */
#ifndef TRUE #ifndef TRUE
#define TRUE 1 #define TRUE 1
#endif #endif
#ifndef FALSE #ifndef FALSE
#define FALSE 0 #define FALSE 0
#endif #endif
#ifndef NULL #ifndef NULL
#define NULL 0 #define NULL 0
#endif #endif
#define success 0 #define success 0

@ -4,29 +4,29 @@
#include"rtconfig.h" #include"rtconfig.h"
#if RT_TICK_PER_SECOND == 1 #if RT_TICK_PER_SECOND == 1
#define DELAY_1S (RT_TICK_PER_SECOND) #define DELAY_1S (RT_TICK_PER_SECOND)
#define DELAY_S(X) (X*DELAY_1S) #define DELAY_S(X) (X*DELAY_1S)
#elif RT_TICK_PER_SECOND == 10 #elif RT_TICK_PER_SECOND == 10
#define DELAY_100MS(X) (X) #define DELAY_100MS(X) (X)
#define DELAY_S(X) (X*10) #define DELAY_S(X) (X*10)
#elif RT_TICK_PER_SECOND == 100 #elif RT_TICK_PER_SECOND == 100
#define DELAY_10MS(X) (X) #define DELAY_10MS(X) (X)
#define DELAY_100MS(X) (X*10) #define DELAY_100MS(X) (X*10)
#define DELAY_S(X) (X*100) #define DELAY_S(X) (X*100)
#elif (RT_TICK_PER_SECOND == 1000) #elif (RT_TICK_PER_SECOND == 1000)
#define DELAY_1MS (RT_TICK_PER_SECOND/1000) #define DELAY_1MS (RT_TICK_PER_SECOND/1000)
#define DELAY_MS(X) (X*DELAY_1MS) #define DELAY_MS(X) (X*DELAY_1MS)
#define DELAY_S(X) (X*1000*DELAY_1MS) #define DELAY_S(X) (X*1000*DELAY_1MS)
#elif (RT_TICK_PER_SECOND == 10000) #elif (RT_TICK_PER_SECOND == 10000)
#define DELAY_100US(X) (X*RT_TICK_PER_SECOND/10000) #define DELAY_100US(X) (X*RT_TICK_PER_SECOND/10000)
#define DELAY_1MS (RT_TICK_PER_SECOND/1000) #define DELAY_1MS (RT_TICK_PER_SECOND/1000)
#define DELAY_MS(X) (X*DELAY_1MS) #define DELAY_MS(X) (X*DELAY_1MS)
#define DELAY_S(X) (X*1000*DELAY_1MS) #define DELAY_S(X) (X*1000*DELAY_1MS)
#endif #endif

@ -3,16 +3,16 @@
#define __RTTHREAD_CFG_H__ #define __RTTHREAD_CFG_H__
/* RT_NAME_MAX*/ /* RT_NAME_MAX*/
#define RT_NAME_MAX 24 #define RT_NAME_MAX 24
/* RT_ALIGN_SIZE*/ /* RT_ALIGN_SIZE*/
#define RT_ALIGN_SIZE 8 #define RT_ALIGN_SIZE 8
/* PRIORITY_MAX */ /* PRIORITY_MAX */
#define RT_THREAD_PRIORITY_MAX 32 #define RT_THREAD_PRIORITY_MAX 32
/* Tick per Second */ /* Tick per Second */
#define RT_TICK_PER_SECOND 10000 //0.1ms #define RT_TICK_PER_SECOND 10000 //0.1ms
/* SECTION: RT_DEBUG */ /* SECTION: RT_DEBUG */
/* Thread Debug */ /* Thread Debug */
@ -26,9 +26,9 @@
/* Using Software Timer */ /* Using Software Timer */
/* #define RT_USING_TIMER_SOFT */ /* #define RT_USING_TIMER_SOFT */
#define RT_TIMER_THREAD_PRIO 4 #define RT_TIMER_THREAD_PRIO 4
#define RT_TIMER_THREAD_STACK_SIZE 512 #define RT_TIMER_THREAD_STACK_SIZE 512
#define RT_TIMER_TICK_PER_SECOND 1000 #define RT_TIMER_TICK_PER_SECOND 1000
/* SECTION: IPC */ /* SECTION: IPC */
/* Using Semaphore*/ /* Using Semaphore*/
@ -60,11 +60,11 @@
/* Using Device System */ /* Using Device System */
#define RT_USING_CONSOLE #define RT_USING_CONSOLE
// <string name="RT_CONSOLE_DEVICE_NAME" description="The device name for console" default="uart1" /> // <string name="RT_CONSOLE_DEVICE_NAME" description="The device name for console" default="uart1" />
#define RT_CONSOLE_DEVICE_NAME "uart1" #define RT_CONSOLE_DEVICE_NAME "uart1"
/* SECTION: Console options */ /* SECTION: Console options */
/* the buffer size of console*/ /* the buffer size of console*/
#define RT_CONSOLEBUF_SIZE 512 #define RT_CONSOLEBUF_SIZE 512
/* SECTION: finsh, a C-Express shell */ /* SECTION: finsh, a C-Express shell */
#define RT_USING_FINSH #define RT_USING_FINSH

@ -1,13 +1,13 @@
#include "app_task.h" #include "app_task.h"
int main(void){ int main(void){
/* disable interrupt first */ /* disable interrupt first */
rt_hw_interrupt_disable(); rt_hw_interrupt_disable();
/* startup RT-Thread RTOS */ /* startup RT-Thread RTOS */
rtthread_startup(); rtthread_startup();
return 0; return 0;
} }

@ -82,7 +82,7 @@ static void test_elog(void) {
* @param parameter parameter * @param parameter parameter
*/ */
void sys_init_thread(void* parameter){ void sys_init_thread(void* parameter){
set_system_status(SYSTEM_STATUS_INIT); set_system_status(SYSTEM_STATUS_INIT);
/* initialize EasyFlash and EasyLogger */ /* initialize EasyFlash and EasyLogger */
if ((easyflash_init() == EF_NO_ERR)&&(elog_init() == ELOG_NO_ERR)) { if ((easyflash_init() == EF_NO_ERR)&&(elog_init() == ELOG_NO_ERR)) {

@ -39,20 +39,20 @@ void rt_hw_board_init()
*/ */
static void RCC_Configuration(void) static void RCC_Configuration(void)
{ {
//下面是给各模块开启时钟 //下面是给各模块开启时钟
//启动GPIO //启动GPIO
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | \ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | \
RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | \ RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | \
RCC_APB2Periph_GPIOE | RCC_APB2Periph_GPIOG, RCC_APB2Periph_GPIOE | RCC_APB2Periph_GPIOG,
ENABLE); ENABLE);
//启动AFIO //启动AFIO
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
//启动USART1时钟 //启动USART1时钟
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
//启动USART2时钟 //启动USART2时钟
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
//启动DMA时钟 //启动DMA时钟
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
/* Enable ADC1 and GPIOC clock */ /* Enable ADC1 and GPIOC clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);

@ -29,23 +29,23 @@
*/ */
/* board configuration */ /* board configuration */
// <o> SDCard Driver <1=>SDIO sdcard <0=>SPI MMC card // <o> SDCard Driver <1=>SDIO sdcard <0=>SPI MMC card
// <i>Default: 1 // <i>Default: 1
#define STM32_USE_SDIO 0 #define STM32_USE_SDIO 0
/* whether use board external SRAM memory */ /* whether use board external SRAM memory */
// <e>Use external SRAM memory on the board // <e>Use external SRAM memory on the board
// <i>Enable External SRAM memory // <i>Enable External SRAM memory
#define STM32_EXT_SRAM 0 #define STM32_EXT_SRAM 0
// <o>Begin Address of External SRAM // <o>Begin Address of External SRAM
// <i>Default: 0x68000000 // <i>Default: 0x68000000
#define STM32_EXT_SRAM_BEGIN 0x68000000 /* the begining address of external SRAM */ #define STM32_EXT_SRAM_BEGIN 0x68000000 /* the begining address of external SRAM */
// <o>End Address of External SRAM // <o>End Address of External SRAM
// <i>Default: 0x68080000 // <i>Default: 0x68080000
#define STM32_EXT_SRAM_END 0x68080000 /* the end address of external SRAM */ #define STM32_EXT_SRAM_END 0x68080000 /* the end address of external SRAM */
// </e> // </e>
// <o> Internal SRAM memory size[Kbytes] <8-64> // <o> Internal SRAM memory size[Kbytes] <8-64>
// <i>Default: 64 // <i>Default: 64
#define STM32_SRAM_SIZE 64 #define STM32_SRAM_SIZE 64
#define STM32_SRAM_END (SRAM_BASE + STM32_SRAM_SIZE * 1024) #define STM32_SRAM_END (SRAM_BASE + STM32_SRAM_SIZE * 1024)
@ -53,18 +53,18 @@
/* RT_USING_UART */ /* RT_USING_UART */
#define RT_USING_UART1 #define RT_USING_UART1
#define RT_UART_RX_BUFFER_SIZE 64 #define RT_UART_RX_BUFFER_SIZE 64
#define LED_RUN_ON GPIO_SetBits (GPIOA,GPIO_Pin_10) //RUN #define LED_RUN_ON GPIO_SetBits (GPIOA,GPIO_Pin_10) //RUN
#define LED_RUN_OFF GPIO_ResetBits(GPIOA,GPIO_Pin_10) //RUN #define LED_RUN_OFF GPIO_ResetBits(GPIOA,GPIO_Pin_10) //RUN
/*********************************************************************************************************/ /*********************************************************************************************************/
/** MACRO'S */ /** MACRO'S */
/***********************************************************************************************************/ /***********************************************************************************************************/
/***********************************************************************************************************/ /***********************************************************************************************************/
/* DATA TYPES */ /* DATA TYPES */
/***********************************************************************************************************/ /***********************************************************************************************************/

@ -7,15 +7,15 @@
typedef int bool_t; /**< boolean type */ typedef int bool_t; /**< boolean type */
#ifndef TRUE #ifndef TRUE
#define TRUE 1 #define TRUE 1
#endif #endif
#ifndef FALSE #ifndef FALSE
#define FALSE 0 #define FALSE 0
#endif #endif
#ifndef NULL #ifndef NULL
#define NULL 0 #define NULL 0
#endif #endif
#define success 0 #define success 0

@ -1,7 +1,7 @@
/* /*
* File : usart.c * File : usart.c
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006-2013, RT-Thread Development Team * COPYRIGHT (C) 2006-2021, RT-Thread Development Team
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@ -155,18 +155,18 @@ static rt_err_t stm32_control(struct rt_serial_device *serial, int cmd, void *ar
if (irq_type == RT_DEVICE_FLAG_INT_RX) if (irq_type == RT_DEVICE_FLAG_INT_RX)
{ {
/* return rx irq flag */ /* return rx irq flag */
return USART_GetFlagStatus(uart->uart_device, USART_FLAG_RXNE); return USART_GetFlagStatus(uart->uart_device, USART_FLAG_RXNE);
} }
else if (irq_type == RT_DEVICE_FLAG_INT_TX) else if (irq_type == RT_DEVICE_FLAG_INT_TX)
{ {
/* return tx flag */ /* return tx flag */
if (uart->tx_irq_type == USART_IT_TC) if (uart->tx_irq_type == USART_IT_TC)
{ {
return USART_GetFlagStatus(uart->uart_device, USART_FLAG_TC); return USART_GetFlagStatus(uart->uart_device, USART_FLAG_TC);
} }
else if (uart->tx_irq_type == USART_IT_TXE) else if (uart->tx_irq_type == USART_IT_TXE)
{ {
return USART_GetFlagStatus(uart->uart_device, USART_FLAG_TXE); return USART_GetFlagStatus(uart->uart_device, USART_FLAG_TXE);
} }
} }
break; break;

Loading…
Cancel
Save