Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_46254178
rt-thread
提交
f0805a79
R
rt-thread
项目概览
weixin_46254178
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
f0805a79
编写于
2月 11, 2021
作者:
mysterywolf
提交者:
GitHub
2月 11, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #16 from RT-Thread/master
pr
上级
852d7d75
a4dd106d
变更
26
展开全部
隐藏空白更改
内联
并排
Showing
26 changed file
with
920 addition
and
343 deletion
+920
-343
bsp/gd32103c-eval/Kconfig
bsp/gd32103c-eval/Kconfig
+30
-0
bsp/gd32103c-eval/Libraries/CMSIS/GD/GD32F1xx/Include/gd32f10x.h
...2103c-eval/Libraries/CMSIS/GD/GD32F1xx/Include/gd32f10x.h
+100
-100
bsp/gd32103c-eval/Libraries/GD32F1xx_standard_peripheral/Include/gd32f10x_rcc.h
...aries/GD32F1xx_standard_peripheral/Include/gd32f10x_rcc.h
+11
-11
bsp/gd32103c-eval/Libraries/GD32F1xx_standard_peripheral/Source/gd32f10x_timer.c
...ries/GD32F1xx_standard_peripheral/Source/gd32f10x_timer.c
+37
-37
bsp/gd32103c-eval/README.md
bsp/gd32103c-eval/README.md
+1
-0
bsp/gd32103c-eval/drivers/SConscript
bsp/gd32103c-eval/drivers/SConscript
+3
-0
bsp/gd32103c-eval/drivers/drv_adc.c
bsp/gd32103c-eval/drivers/drv_adc.c
+5
-7
bsp/gd32103c-eval/drivers/drv_comm.h
bsp/gd32103c-eval/drivers/drv_comm.h
+27
-0
bsp/gd32103c-eval/drivers/drv_hwtimer.c
bsp/gd32103c-eval/drivers/drv_hwtimer.c
+540
-0
bsp/gd32103c-eval/drivers/drv_hwtimer.h
bsp/gd32103c-eval/drivers/drv_hwtimer.h
+38
-0
bsp/gd32103c-eval/rtconfig.h
bsp/gd32103c-eval/rtconfig.h
+0
-3
bsp/raspberry-pi/raspi4-32/driver/touch/drv_xpt2046.c
bsp/raspberry-pi/raspi4-32/driver/touch/drv_xpt2046.c
+3
-3
bsp/stm32/libraries/HAL_Drivers/drv_hwtimer.c
bsp/stm32/libraries/HAL_Drivers/drv_hwtimer.c
+1
-1
bsp/stm32/libraries/HAL_Drivers/drv_pwm.c
bsp/stm32/libraries/HAL_Drivers/drv_pwm.c
+1
-1
bsp/stm32/stm32f103-blue-pill/README.pdf
bsp/stm32/stm32f103-blue-pill/README.pdf
+0
-0
bsp/stm32/stm32f103-blue-pill/documents/Beginning STM32 (excerpt).pdf
...m32f103-blue-pill/documents/Beginning STM32 (excerpt).pdf
+0
-0
components/drivers/include/drivers/hwtimer.h
components/drivers/include/drivers/hwtimer.h
+1
-1
components/drivers/misc/pin.c
components/drivers/misc/pin.c
+4
-3
components/libc/compilers/common/sys/time.h
components/libc/compilers/common/sys/time.h
+3
-1
components/libc/compilers/common/time.c
components/libc/compilers/common/time.c
+86
-39
components/libc/compilers/newlib/libc.h
components/libc/compilers/newlib/libc.h
+1
-18
components/libc/compilers/newlib/syscalls.c
components/libc/compilers/newlib/syscalls.c
+8
-113
documentation/coding_style_cn.md
documentation/coding_style_cn.md
+1
-1
include/libc/libc_ioctl.h
include/libc/libc_ioctl.h
+1
-1
include/rtdef.h
include/rtdef.h
+12
-0
src/components.c
src/components.c
+6
-3
未找到文件。
bsp/gd32103c-eval/Kconfig
浏览文件 @
f0805a79
...
...
@@ -66,5 +66,35 @@ menu "On-chip Peripheral Drivers"
bool "using adc1"
default n
endif
menuconfig BSP_USING_HWTIMER
bool "Enable hwtimer"
default n
select RT_USING_HWTIMER
if BSP_USING_HWTIMER
config BSP_USING_HWTIMER0
bool "using hwtimer0"
default n
config BSP_USING_HWTIMER1
bool "using hwtimer1"
default n
config BSP_USING_HWTIMER2
bool "using hwtimer2"
default n
config BSP_USING_HWTIMER3
bool "using hwtimer3"
default n
config BSP_USING_HWTIMER4
bool "using hwtimer4"
default n
config BSP_USING_HWTIMER5
bool "using hwtimer5"
default n
config BSP_USING_HWTIMER6
bool "using hwtimer6"
default n
config BSP_USING_HWTIMER7
bool "using hwtimer7"
default n
endif
endmenu
bsp/gd32103c-eval/Libraries/CMSIS/GD/GD32F1xx/Include/gd32f10x.h
浏览文件 @
f0805a79
此差异已折叠。
点击以展开。
bsp/gd32103c-eval/Libraries/GD32F1xx_standard_peripheral/Include/gd32f10x_rcc.h
浏览文件 @
f0805a79
...
...
@@ -455,14 +455,14 @@ typedef struct {
#define RCC_APB2PERIPH_GPIOG RCC_APB2CCR_PGEN
#define RCC_APB2PERIPH_ADC0 RCC_APB2CCR_ADC0EN
#define RCC_APB2PERIPH_ADC1 RCC_APB2CCR_ADC1EN
#define RCC_APB2PERIPH_TIMER
1 RCC_APB2CCR_TIMER1
EN
#define RCC_APB2PERIPH_TIMER
0 RCC_APB2CCR_TIMER0
EN
#define RCC_APB2PERIPH_SPI1 RCC_APB2CCR_SPI1EN
#define RCC_APB2PERIPH_TIMER
8 RCC_APB2CCR_TIMER8
EN
#define RCC_APB2PERIPH_TIMER
7 RCC_APB2CCR_TIMER7
EN
#define RCC_APB2PERIPH_USART1 RCC_APB2CCR_USART1EN
#define RCC_APB2PERIPH_ADC2 RCC_APB2CCR_ADC2EN
#define RCC_APB2PERIPH_TIMER9 RCC_APB2CCR_TIMER9EN
#define RCC_APB2PERIPH_TIMER8 RCC_APB2CCR_TIMER8EN
#define RCC_APB2PERIPH_TIMER9 RCC_APB2CCR_TIMER9EN
#define RCC_APB2PERIPH_TIMER10 RCC_APB2CCR_TIMER10EN
#define RCC_APB2PERIPH_TIMER11 RCC_APB2CCR_TIMER11EN
/**
* @}
...
...
@@ -481,14 +481,14 @@ typedef struct {
#define RCC_APB2PERIPH_GPIOGRST RCC_APB2RCR_PGRST
#define RCC_APB2PERIPH_ADC0RST RCC_APB2RCR_ADC0RST
#define RCC_APB2PERIPH_ADC1RST RCC_APB2RCR_ADC1RST
#define RCC_APB2PERIPH_TIMER
1RST RCC_APB2RCR_TIMER1
RST
#define RCC_APB2PERIPH_TIMER
0RST RCC_APB2RCR_TIMER0
RST
#define RCC_APB2PERIPH_SPI1RST RCC_APB2RCR_SPI1RST
#define RCC_APB2PERIPH_TIMER
8RST RCC_APB2RCR_TIMER8
RST
#define RCC_APB2PERIPH_TIMER
7RST RCC_APB2RCR_TIMER7
RST
#define RCC_APB2PERIPH_USART0RST RCC_APB2RCR_USART0RST
#define RCC_APB2PERIPH_ADC2RST RCC_APB2RCR_ADC2RST
#define RCC_APB2PERIPH_TIMER8RST RCC_APB2RCR_TIMER8RST
#define RCC_APB2PERIPH_TIMER9RST RCC_APB2RCR_TIMER9RST
#define RCC_APB2PERIPH_TIMER10RST RCC_APB2RCR_TIMER10RST
#define RCC_APB2PERIPH_TIMER11RST RCC_APB2RCR_TIMER11RST
/**
* @}
...
...
@@ -497,15 +497,15 @@ typedef struct {
/** @defgroup RCC_APB1_peripheral
* @{
*/
#define RCC_APB1PERIPH_TIMER1 RCC_APB1CCR_TIMER1EN
#define RCC_APB1PERIPH_TIMER2 RCC_APB1CCR_TIMER2EN
#define RCC_APB1PERIPH_TIMER3 RCC_APB1CCR_TIMER3EN
#define RCC_APB1PERIPH_TIMER4 RCC_APB1CCR_TIMER4EN
#define RCC_APB1PERIPH_TIMER5 RCC_APB1CCR_TIMER5EN
#define RCC_APB1PERIPH_TIMER6 RCC_APB1CCR_TIMER6EN
#define RCC_APB1PERIPH_TIMER
7 RCC_APB1CCR_TIMER7
EN
#define RCC_APB1PERIPH_TIMER
11 RCC_APB1CCR_TIMER11
EN
#define RCC_APB1PERIPH_TIMER12 RCC_APB1CCR_TIMER12EN
#define RCC_APB1PERIPH_TIMER13 RCC_APB1CCR_TIMER13EN
#define RCC_APB1PERIPH_TIMER14 RCC_APB1CCR_TIMER14EN
#define RCC_APB1PERIPH_WWDG RCC_APB1CCR_WWDGEN
#define RCC_APB1PERIPH_SPI2 RCC_APB1CCR_SPI2EN
#define RCC_APB1PERIPH_SPI3 RCC_APB1CCR_SPI3EN
...
...
@@ -529,15 +529,15 @@ typedef struct {
/** @defgroup RCC_APB1_Peripherals_RST
* @{
*/
#define RCC_APB1PERIPH_TIMER1RST RCC_APB1RCR_TIMER1RST
#define RCC_APB1PERIPH_TIMER2RST RCC_APB1RCR_TIMER2RST
#define RCC_APB1PERIPH_TIMER3RST RCC_APB1RCR_TIMER3RST
#define RCC_APB1PERIPH_TIMER4RST RCC_APB1RCR_TIMER4RST
#define RCC_APB1PERIPH_TIMER5RST RCC_APB1RCR_TIMER5RST
#define RCC_APB1PERIPH_TIMER6RST RCC_APB1RCR_TIMER6RST
#define RCC_APB1PERIPH_TIMER
7RST RCC_APB1RCR_TIMER7
RST
#define RCC_APB1PERIPH_TIMER
11RST RCC_APB1RCR_TIMER11
RST
#define RCC_APB1PERIPH_TIMER12RST RCC_APB1RCR_TIMER12RST
#define RCC_APB1PERIPH_TIMER13RST RCC_APB1RCR_TIMER13RST
#define RCC_APB1PERIPH_TIMER14RST RCC_APB1RCR_TIMER14RST
#define RCC_APB1PERIPH_WWDGRST RCC_APB1RCR_WWDGRST
#define RCC_APB1PERIPH_SPI2RST RCC_APB1RCR_SPI2RST
#define RCC_APB1PERIPH_SPI3RST RCC_APB1RCR_SPI3RST
...
...
bsp/gd32103c-eval/Libraries/GD32F1xx_standard_peripheral/Source/gd32f10x_timer.c
浏览文件 @
f0805a79
...
...
@@ -45,14 +45,17 @@ static void TI4_Config(TIMER_TypeDef *TIMERx, uint16_t TIMER_ICPolarity, uint16_
/**
* @brief Deinitialize the TIMER .
* @param TIMERx: x ={
1-14
} .
* @param TIMERx: x ={
0-13
} .
* @retval None
*/
void
TIMER_DeInit
(
TIMER_TypeDef
*
TIMERx
)
{
if
(
TIMERx
==
TIMER1
)
{
RCC
->
APB2RCR
|=
RCC_APB2PERIPH_TIMER1RST
;
RCC
->
APB2RCR
&=
~
RCC_APB2PERIPH_TIMER1
;
if
(
TIMERx
==
TIMER0
)
{
RCC
->
APB2RCR
|=
RCC_APB2PERIPH_TIMER0RST
;
RCC
->
APB2RCR
&=
~
RCC_APB2PERIPH_TIMER0
;
}
else
if
(
TIMERx
==
TIMER1
)
{
RCC
->
APB1RCR
|=
RCC_APB1PERIPH_TIMER1RST
;
RCC
->
APB1RCR
&=
~
RCC_APB1PERIPH_TIMER1
;
}
else
if
(
TIMERx
==
TIMER2
)
{
RCC
->
APB1RCR
|=
RCC_APB1PERIPH_TIMER2RST
;
RCC
->
APB1RCR
&=
~
RCC_APB1PERIPH_TIMER2
;
...
...
@@ -69,8 +72,8 @@ void TIMER_DeInit(TIMER_TypeDef *TIMERx)
RCC
->
APB1RCR
|=
RCC_APB1PERIPH_TIMER6RST
;
RCC
->
APB1RCR
&=
~
RCC_APB1PERIPH_TIMER6
;
}
else
if
(
TIMERx
==
TIMER7
)
{
RCC
->
APB
1RCR
|=
RCC_APB1
PERIPH_TIMER7RST
;
RCC
->
APB
1RCR
&=
~
RCC_APB1
PERIPH_TIMER7
;
RCC
->
APB
2RCR
|=
RCC_APB2
PERIPH_TIMER7RST
;
RCC
->
APB
2RCR
&=
~
RCC_APB2
PERIPH_TIMER7
;
}
else
if
(
TIMERx
==
TIMER8
)
{
RCC
->
APB2RCR
|=
RCC_APB2PERIPH_TIMER8RST
;
RCC
->
APB2RCR
&=
~
RCC_APB2PERIPH_TIMER8
;
...
...
@@ -81,23 +84,20 @@ void TIMER_DeInit(TIMER_TypeDef *TIMERx)
RCC
->
APB2RCR
|=
RCC_APB2PERIPH_TIMER10RST
;
RCC
->
APB2RCR
&=
~
RCC_APB2PERIPH_TIMER10
;
}
else
if
(
TIMERx
==
TIMER11
)
{
RCC
->
APB
2RCR
|=
RCC_APB2
PERIPH_TIMER11RST
;
RCC
->
APB
2RCR
&=
~
RCC_APB2
PERIPH_TIMER11
;
RCC
->
APB
1RCR
|=
RCC_APB1
PERIPH_TIMER11RST
;
RCC
->
APB
1RCR
&=
~
RCC_APB1
PERIPH_TIMER11
;
}
else
if
(
TIMERx
==
TIMER12
)
{
RCC
->
APB1RCR
|=
RCC_APB1PERIPH_TIMER12RST
;
RCC
->
APB1RCR
&=
~
RCC_APB1PERIPH_TIMER12
;
}
else
if
(
TIMERx
==
TIMER13
)
{
RCC
->
APB1RCR
|=
RCC_APB1PERIPH_TIMER13RST
;
RCC
->
APB1RCR
&=
~
RCC_APB1PERIPH_TIMER13
;
}
else
if
(
TIMERx
==
TIMER14
)
{
RCC
->
APB1RCR
|=
RCC_APB1PERIPH_TIMER14RST
;
RCC
->
APB1RCR
&=
~
RCC_APB1PERIPH_TIMER14
;
}
}
/**
* @brief Initialize the specified Timer
* @param TIMERx: x ={
1 -14
} .
* @param TIMERx: x ={
0 -13
} .
* @param TIMER_Init: pointer to a TIMER_BaseInitPara structure.
* @retval None
*/
...
...
@@ -107,15 +107,15 @@ void TIMER_BaseInit(TIMER_TypeDef *TIMERx, TIMER_BaseInitPara *TIMER_Init)
tmpctlr1
=
TIMERx
->
CTLR1
;
if
((
TIMERx
==
TIMER
1
)
||
(
TIMERx
==
TIMER8
)
||
(
TIMERx
==
TIMER2
)
||
(
TIMERx
==
TIMER3
)
||
(
TIMERx
==
TIMER
4
)
||
(
TIMERx
==
TIMER5
)
||
(
TIMERx
==
TIMER9
)
||
(
TIMERx
==
TIMER10
)
||
(
TIMERx
==
TIMER1
1
)
||
(
TIMERx
==
TIMER12
)
||
(
TIMERx
==
TIMER13
)
||
(
TIMERx
==
TIMER14
))
{
if
((
TIMERx
==
TIMER
0
)
||
(
TIMERx
==
TIMER7
)
||
(
TIMERx
==
TIMER1
)
||
(
TIMERx
==
TIMER2
)
||
(
TIMERx
==
TIMER
3
)
||
(
TIMERx
==
TIMER4
)
||
(
TIMERx
==
TIMER8
)
||
(
TIMERx
==
TIMER9
)
||
(
TIMERx
==
TIMER1
0
)
||
(
TIMERx
==
TIMER11
)
||
(
TIMERx
==
TIMER12
)
||
(
TIMERx
==
TIMER13
))
{
/* Configure the Counter Mode */
tmpctlr1
&=
(
uint16_t
)(
~
((
uint16_t
)(
TIMER_CTLR1_DIR
|
TIMER_CTLR1_CAM
)));
tmpctlr1
|=
(
uint32_t
)
TIMER_Init
->
TIMER_CounterMode
;
}
if
((
TIMERx
!=
TIMER
6
)
&&
(
TIMERx
!=
TIMER7
))
{
if
((
TIMERx
!=
TIMER
5
)
&&
(
TIMERx
!=
TIMER6
))
{
/* Configure the clock division */
tmpctlr1
&=
(
uint16_t
)(
~
((
uint16_t
)
TIMER_CTLR1_CDIV
));
tmpctlr1
|=
(
uint32_t
)
TIMER_Init
->
TIMER_ClockDivision
;
...
...
@@ -129,8 +129,8 @@ void TIMER_BaseInit(TIMER_TypeDef *TIMERx, TIMER_BaseInitPara *TIMER_Init)
/* Configure the Prescaler value */
TIMERx
->
PSC
=
TIMER_Init
->
TIMER_Prescaler
;
if
((
TIMERx
==
TIMER
1
)
||
(
TIMERx
==
TIMER
8
))
{
if
((
TIMERx
==
TIMER
0
)
||
(
TIMERx
==
TIMER
7
))
{
/* Configure the Repetition Counter value */
TIMERx
->
CREP
=
TIMER_Init
->
TIMER_RepetitionCounter
;
}
...
...
@@ -156,7 +156,7 @@ void TIMER_BaseStructInit(TIMER_BaseInitPara *TIMER_Init)
/**
* @brief Configure the TIMER Prescaler.
* @param TIMERx: x ={
1-14
}
* @param TIMERx: x ={
0-13
}
* @param Prescaler: Prescaler value
* @param TIMER_PSCReloadMode: Prescaler Reload mode
* This value will be :
...
...
@@ -203,7 +203,7 @@ void TIMER_CounterMode(TIMER_TypeDef *TIMERx, uint16_t TIMER_CounterMode)
/**
* @brief Configure the TIMER Counter Register value
* @param TIMERx: x ={
1-14
} .
* @param TIMERx: x ={
0-13
} .
* @param Counter: the Counter register new value.
* @retval None
*/
...
...
@@ -214,7 +214,7 @@ void TIMER_SetCounter(TIMER_TypeDef *TIMERx, uint32_t Counter)
/**
* @brief Configure the Autoreload value
* @param TIMERx: x ={
1-14
} .
* @param TIMERx: x ={
0-13
} .
* @param AutoReloadValue:
* @retval None
*/
...
...
@@ -225,7 +225,7 @@ void TIMER_SetAutoreload(TIMER_TypeDef *TIMERx, uint32_t AutoReloadValue)
/**
* @brief Get the Counter value.
* @param TIMERx: x ={
1-14
} .
* @param TIMERx: x ={
0-13
} .
* @retval Counter Register value.
*/
uint32_t
TIMER_GetCounter
(
TIMER_TypeDef
*
TIMERx
)
...
...
@@ -235,7 +235,7 @@ uint32_t TIMER_GetCounter(TIMER_TypeDef *TIMERx)
/**
* @brief Get the Prescaler value.
* @param TIMERx: x ={
1-14
} .
* @param TIMERx: x ={
0-13
} .
* @retval Prescaler Register value
*/
uint16_t
TIMER_GetPrescaler
(
TIMER_TypeDef
*
TIMERx
)
...
...
@@ -245,7 +245,7 @@ uint16_t TIMER_GetPrescaler(TIMER_TypeDef *TIMERx)
/**
* @brief Configure the TIMERx Update event.
* @param TIMERx: x ={
1-14
} .
* @param TIMERx: x ={
0-13
} .
* @param NewValue: new value of the TIMERx UPDIS bit
* This value will be :
* @arg ENABLE : Update Enbale
...
...
@@ -263,7 +263,7 @@ void TIMER_UpdateDisableConfig(TIMER_TypeDef *TIMERx, TypeState NewValue)
/**
* @brief Configure the TIMER Update Request source.
* @param TIMERx: x ={
1-14
} .
* @param TIMERx: x ={
0-13
} .
* @param TIMER_UpdateSrc: Configures the Update source.
* This value will be :
* @arg TIMER_UPDATE_SRC_GLOBAL : Update generate by setting of UPG bit or the counter
...
...
@@ -282,7 +282,7 @@ void TIMER_UpdateRequestConfig(TIMER_TypeDef *TIMERx, uint16_t TIMER_UpdateSrc)
/**
* @brief Configure the CARL Preload function
* @param TIMERx: x ={
1-14
} .
* @param TIMERx: x ={
0-13
} .
* @param NewValue: the state of the Preload function on CARL.
* This value will be :
* @arg ENABLE
...
...
@@ -339,7 +339,7 @@ void TIMER_SetClockDivision(TIMER_TypeDef *TIMERx, uint16_t TIMER_CDIV)
/**
* @brief ENABLE or DISABLE the TIMER.
* @param TIMERx: x ={
1-14
} .
* @param TIMERx: x ={
0-13
} .
* @param NewValue: ENABLE or DISABLE.
* @retval None
*/
...
...
@@ -443,7 +443,7 @@ void TIMER_OC1_Init(TIMER_TypeDef *TIMERx, TIMER_OCInitPara *TIMER_OCInit)
/* Set the Output State */
tmpche
|=
TIMER_OCInit
->
TIMER_OutputState
;
if
((
TIMERx
==
TIMER
1
)
||
(
TIMERx
==
TIMER8
))
{
if
((
TIMERx
==
TIMER
0
)
||
(
TIMERx
==
TIMER7
))
{
/* Reset the Output complementary Polarity */
tmpche
&=
(
uint16_t
)(
~
((
uint16_t
)
TIMER_CHE_CH1NP
));
...
...
@@ -518,7 +518,7 @@ void TIMER_OC2_Init(TIMER_TypeDef *TIMERx, TIMER_OCInitPara *TIMER_OCInit)
/* Set the Output State */
tmpche
|=
(
uint16_t
)(
TIMER_OCInit
->
TIMER_OutputState
<<
4
);
if
((
TIMERx
==
TIMER
1
)
||
(
TIMERx
==
TIMER8
))
{
if
((
TIMERx
==
TIMER
0
)
||
(
TIMERx
==
TIMER7
))
{
/* Reset the Output complementary Polarity */
tmpche
&=
(
uint16_t
)(
~
((
uint16_t
)
TIMER_CHE_CH2NP
));
...
...
@@ -593,7 +593,7 @@ void TIMER_OC3_Init(TIMER_TypeDef *TIMERx, TIMER_OCInitPara *TIMER_OCInit)
/* Set the Output State */
tmpche
|=
(
uint16_t
)(
TIMER_OCInit
->
TIMER_OutputState
<<
8
);
if
((
TIMERx
==
TIMER
1
)
||
(
TIMERx
==
TIMER8
))
{
if
((
TIMERx
==
TIMER
0
)
||
(
TIMERx
==
TIMER7
))
{
/* Reset the Output complementary Polarity */
tmpche
&=
(
uint16_t
)(
~
((
uint16_t
)
TIMER_CHE_CH3NP
));
...
...
@@ -667,7 +667,7 @@ void TIMER_OC4_Init(TIMER_TypeDef *TIMERx, TIMER_OCInitPara *TIMER_OCInit)
/* Set the Output State */
tmpche
|=
(
uint16_t
)(
TIMER_OCInit
->
TIMER_OutputState
<<
12
);
if
((
TIMERx
==
TIMER
1
)
||
(
TIMERx
==
TIMER8
))
{
if
((
TIMERx
==
TIMER
0
)
||
(
TIMERx
==
TIMER7
))
{
/* Reset the Ouput Compare IDLE State */
tmpctlr2
&=
(
uint16_t
)(
~
((
uint16_t
)
TIMER_CTLR2_ISO4
));
...
...
@@ -1646,7 +1646,7 @@ void TIMER_Set_IC4_Prescaler(TIMER_TypeDef *TIMERx, uint16_t TIMER_ICPSC)
/**
* @brief Configure interrupts Enables
* @param TIMERx: x ={
1-14
} .
* @param TIMERx: x ={
0-13
} .
* @param TIMER_INT: the interrupts sources to Configure.
* This value will be :
* @arg TIMER_INT_UPDATE : update Interrupt
...
...
@@ -1671,7 +1671,7 @@ void TIMER_INTConfig(TIMER_TypeDef *TIMERx, uint16_t TIMER_INT, TypeState NewVal
/**
* @brief Generate the software event
* @param TIMERx: x ={
1-14
} .
* @param TIMERx: x ={
0-13
} .
* @param TIMER_EventSrc:
* This value will be :
* @arg TIMER_EVENT_SRC_UPDATE : update Event
...
...
@@ -1691,7 +1691,7 @@ void TIMER_GenerateEvent(TIMER_TypeDef *TIMERx, uint16_t TIMER_EventSrc)
/**
* @brief Get current flag status
* @param TIMERx: x ={
1-14
} .
* @param TIMERx: x ={
0-13
} .
* @param TIMER_FLAG:
* This value will be :
* @arg TIMER_FLAG_UPDATE : update Flag
...
...
@@ -1719,7 +1719,7 @@ TypeState TIMER_GetBitState(TIMER_TypeDef *TIMERx, uint16_t TIMER_FLAG)
/**
* @brief Clear the flags
* @param TIMERx: x ={
1-14
} .
* @param TIMERx: x ={
0-13
} .
* @param TIMER_FLAG: the flag bit to clear.
* This value will be :
* @arg TIMER_FLAG_UPDATE : update Flag
...
...
@@ -1743,7 +1743,7 @@ void TIMER_ClearBitState(TIMER_TypeDef *TIMERx, uint16_t TIMER_FLAG)
/**
* @brief Get interrupt state
* @param TIMERx: x ={
1-14
} .
* @param TIMERx: x ={
0-13
} .
* @param TIMER_INT:
* This value will be :
* @arg TIMER_INT_UPDATE: update Interrupt
...
...
@@ -1772,7 +1772,7 @@ TypeState TIMER_GetIntBitState(TIMER_TypeDef *TIMERx, uint16_t TIMER_INT)
/**
* @brief Clear the interrupt pending bits
* @param TIMERx: x ={
1-14
} .
* @param TIMERx: x ={
0-13
} .
* @param TIMER_INT:
* This value will be :
* @arg TIMER_INT_UPDATE: update Interrupt
...
...
bsp/gd32103c-eval/README.md
浏览文件 @
f0805a79
...
...
@@ -47,6 +47,7 @@ msh />
| UART | 支持 | UART0~4 |
| GPIO | 支持 | GPIOA~G |
| ADC | 支持 | ADC0~1 |
| HWTIMER | 支持 | TIMER0~7 |
| IIC | 未支持 | I2C0~1 |
| SPI | 未支持 | SPI0~2 |
| ETH | 未支持 | |
...
...
bsp/gd32103c-eval/drivers/SConscript
浏览文件 @
f0805a79
...
...
@@ -21,6 +21,9 @@ if GetDepend('RT_USING_PIN'):
if
GetDepend
(
'RT_USING_ADC'
):
src
+=
[
'drv_adc.c'
]
if
GetDepend
(
'RT_USING_HWTIMER'
):
src
+=
[
'drv_hwtimer.c'
]
group
=
DefineGroup
(
'Drivers'
,
src
,
depend
=
[
''
],
CPPPATH
=
CPPPATH
)
Return
(
'group'
)
bsp/gd32103c-eval/drivers/drv_adc.c
浏览文件 @
f0805a79
...
...
@@ -9,17 +9,15 @@
*/
#include <board.h>
#include <drivers/drv_comm.h>
#include <drivers/adc.h>
#include <rtdbg.h>
#ifdef RT_USING_ADC
#define DBG_TAG "drv.adc"
#define DBG_LVL DBG_INFO
//#define DRV_DEBUG
#define LOG_TAG "drv.adc"
#include <rtdbg.h>
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#endif
#ifdef RT_USING_ADC
#define MAX_EXTERN_ADC_CHANNEL 16
...
...
bsp/gd32103c-eval/drivers/drv_comm.h
0 → 100644
浏览文件 @
f0805a79
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-01-28 iysheng first version
*/
#ifndef __DRV_COMM_H__
#define __DRV_COMM_H__
#ifdef __cplusplus
extern
"C"
{
#endif
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#endif
#ifdef __cplusplus
}
#endif
#endif
/* __DRV_HWTIMER_H__ */
bsp/gd32103c-eval/drivers/drv_hwtimer.c
0 → 100644
浏览文件 @
f0805a79
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-01-28 iysheng first version
*/
#include <board.h>
#include <drivers/drv_comm.h>
#include <drivers/drv_hwtimer.h>
#ifdef BSP_USING_HWTIMER
enum
timer_index_E
{
#ifdef BSP_USING_HWTIMER0
TIM0_INDEX
,
#endif
#ifdef BSP_USING_HWTIMER1
TIM1_INDEX
,
#endif
#ifdef BSP_USING_HWTIMER2
TIM2_INDEX
,
#endif
#ifdef BSP_USING_HWTIMER3
TIM3_INDEX
,
#endif
#ifdef BSP_USING_HWTIMER4
TIM4_INDEX
,
#endif
#ifdef BSP_USING_HWTIMER5
TIM5_INDEX
,
#endif
#ifdef BSP_USING_HWTIMER6
TIM6_INDEX
,
#endif
#ifdef BSP_USING_HWTIMER7
TIM7_INDEX
,
#endif
#ifdef BSP_USING_HWTIMER8
TIM8_INDEX
,
#endif
#ifdef BSP_USING_HWTIMER9
TIM9_INDEX
,
#endif
#ifdef BSP_USING_HWTIMER10
TIM10_INDEX
,
#endif
#ifdef BSP_USING_HWTIMER11
TIM11_INDEX
,
#endif
#ifdef BSP_USING_HWTIMER12
TIM12_INDEX
,
#endif
#ifdef BSP_USING_HWTIMER13
TIM13_INDEX
,
#endif
};
/*
* static void __set_timerx_freq
* Set freq with timerx
*
* @param timerx the pointer of TIMER_TypeDef
* @param freq of the timer clock
* @retval None
*/
static
void
__set_timerx_freq
(
TIMER_TypeDef
*
timerx
,
uint32_t
freq
)
{
RCC_ClocksPara
RCC_Clocks
=
{
0
};
uint16_t
prescaler
;
uint32_t
temp
;
RCC_GetClocksFreq
(
&
RCC_Clocks
);
if
(
timerx
==
TIMER0
||
timerx
==
TIMER7
||
timerx
==
TIMER8
\
||
timerx
==
TIMER9
||
timerx
==
TIMER10
)
{
temp
=
RCC
->
GCFGR
&
RCC_GCFGR_APB2PS
;
temp
>>=
11
;
/* whether should frequency doubling */
temp
=
(
temp
<
4
)
?
0
:
1
;
prescaler
=
(
RCC_Clocks
.
APB2_Frequency
<<
temp
)
/
freq
-
1
;
}
else
{
temp
=
RCC
->
GCFGR
&
RCC_GCFGR_APB1PS
;
temp
>>=
8
;
/* whether should frequency doubling */
temp
=
(
temp
<
4
)
?
0
:
1
;
prescaler
=
(
RCC_Clocks
.
APB1_Frequency
<<
temp
)
/
freq
-
1
;
}
TIMER_PrescalerConfig
(
timerx
,
prescaler
,
TIMER_PSC_RELOAD_NOW
);
}
static
void
gd32_hwtimer_init
(
struct
rt_hwtimer_device
*
timer
,
rt_uint32_t
state
)
{
TIMER_TypeDef
*
timer_base
=
timer
->
parent
.
user_data
;
TIMER_BaseInitPara
TIMER_Init
;
RT_ASSERT
(
timer_base
);
if
(
state
)
{
TIMER_InternalClockConfig
(
timer_base
);
TIMER_BaseStructInit
(
&
TIMER_Init
);
TIMER_Init
.
TIMER_Period
=
timer
->
info
->
maxcnt
;
TIMER_BaseInit
(
timer_base
,
&
TIMER_Init
);
__set_timerx_freq
(
timer_base
,
timer
->
info
->
maxfreq
);
}
}
static
rt_err_t
gd32_hwtimer_start
(
struct
rt_hwtimer_device
*
timer
,
\
rt_uint32_t
cnt
,
rt_hwtimer_mode_t
mode
)
{
TIMER_TypeDef
*
timer_base
=
timer
->
parent
.
user_data
;
if
(
mode
==
HWTIMER_MODE_ONESHOT
)
{
TIMER_SinglePulseMode
(
timer_base
,
TIMER_SP_MODE_SINGLE
);
}
else
if
(
mode
==
HWTIMER_MODE_PERIOD
)
{
TIMER_SinglePulseMode
(
timer_base
,
TIMER_SP_MODE_REPETITIVE
);
}
TIMER_SetCounter
(
timer_base
,
0
);
TIMER_SetAutoreload
(
timer_base
,
cnt
-
1
);
TIMER_Enable
(
timer_base
,
ENABLE
);
return
0
;
}
static
void
gd32_hwtimer_stop
(
struct
rt_hwtimer_device
*
timer
)
{
TIMER_TypeDef
*
timer_base
=
timer
->
parent
.
user_data
;
TIMER_Enable
(
timer_base
,
DISABLE
);
}
static
rt_uint32_t
gd32_hwtimer_count_get
(
struct
rt_hwtimer_device
*
timer
)
{
TIMER_TypeDef
*
timer_base
=
timer
->
parent
.
user_data
;
rt_uint32_t
count
;
count
=
TIMER_GetCounter
(
timer_base
);
return
count
;
}
static
rt_err_t
gd32_hwtimer_control
(
struct
rt_hwtimer_device
*
timer
,
rt_uint32_t
cmd
,
\
void
*
args
)
{
int
ret
=
RT_EOK
;
rt_int32_t
freq
;
rt_hwtimer_mode_t
mode
;
switch
(
cmd
)
{
case
HWTIMER_CTRL_FREQ_SET
:
freq
=
*
(
rt_uint32_t
*
)
args
;
__set_timerx_freq
(
timer
->
parent
.
user_data
,
freq
);
break
;
default:
rt_kprintf
(
"invalid cmd:%x
\n
"
,
cmd
);
ret
=
-
EINVAL
;
break
;
}
return
ret
;
}
static
const
struct
rt_hwtimer_ops
g_gd32_hwtimer_ops
=
{
gd32_hwtimer_init
,
gd32_hwtimer_start
,
gd32_hwtimer_stop
,
gd32_hwtimer_count_get
,
gd32_hwtimer_control
,
};
static
gd32_hwtimer_device
g_gd32_hwtimer
[]
=
{
#ifdef BSP_USING_HWTIMER0
{
"timer0"
,
{
TIMER0
,
TIMER0_UP_IRQn
,
RCU_TIMER0
,
},
{
0
},
{
1000000
,
1000
,
0xffff
,
0
,
/* count up mode */
}
},
#endif
#ifdef BSP_USING_HWTIMER1
{
"timer1"
,
{
TIMER1
,
TIMER1_IRQn
,
RCU_TIMER1
,
},
{
0
},
{
1000000
,
1000
,
0xffff
,
0
,
/* count up mode */
}
},
#endif
#ifdef BSP_USING_HWTIMER2
{
"timer2"
,
{
TIMER2
,
TIMER2_IRQn
,
RCU_TIMER2
,
},
{
0
},
{
1000000
,
1000
,
0xffff
,
0
,
/* count up mode */
}
},
#endif
#ifdef BSP_USING_HWTIMER3
{
"timer3"
,
{
TIMER3
,
TIMER3_IRQn
,
RCU_TIMER3
,
},
{
0
},
{
1000000
,
1000
,
0xffff
,
0
,
/* count up mode */
}
},
#endif
#ifdef BSP_USING_HWTIMER4
{
"timer4"
,
{
TIMER4
,
TIMER4_IRQn
,
RCU_TIMER4
,
},
{
0
},
{
1000000
,
1000
,
0xffff
,
0
,
/* count up mode */
}
},
#endif
#ifdef BSP_USING_HWTIMER5
{
"timer5"
,
{
TIMER5
,
TIMER5_IRQn
,
RCU_TIMER5
,
},
{
0
},
{
1000000
,
1000
,
0xffff
,
0
,
/* count up mode */
}
},
#endif
#ifdef BSP_USING_HWTIMER6
{
"timer6"
,
{
TIMER6
,
TIMER6_IRQn
,
RCU_TIMER6
,
},
{
0
},
{
1000000
,
1000
,
0xffff
,
0
,
/* count up mode */
}
},
#endif
#ifdef BSP_USING_HWTIMER7
{
"timer7"
,
{
TIMER7
,
TIMER7_UP_IRQn
,
RCU_TIMER7
,
},
{
0
},
{
1000000
,
1000
,
0xffff
,
0
,
/* count up mode */
}
},
#endif
#ifdef BSP_USING_HWTIMER8
{
"timer8"
,
{
TIMER8
,
TIMER8_IRQn
,
RCU_TIMER8
,
},
{
0
},
{
1000000
,
1000
,
0xffff
,
0
,
/* count up mode */
}
},
#endif
#ifdef BSP_USING_HWTIMER9
{
"timer9"
,
{
TIMER9
,
TIMER9_IRQn
,
RCU_TIMER9
,
},
{
0
},
{
1000000
,
1000
,
0xffff
,
0
,
/* count up mode */
}
},
#endif
#ifdef BSP_USING_HWTIMER10
{
"timer10"
,
{
TIMER10
,
TIMER10_IRQn
,
RCU_TIMER10
,
},
{
0
},
{
1000000
,
1000
,
0xffff
,
0
,
/* count up mode */
}
},
#endif
#ifdef BSP_USING_HWTIMER11
{
"timer11"
,
{
TIMER11
,
TIMER11_IRQn
,
RCU_TIMER11
,
},
{
0
},
{
1000000
,
1000
,
0xffff
,
0
,
/* count up mode */
}
},
#endif
#ifdef BSP_USING_HWTIMER12
{
"timer12"
,
{
TIMER12
,
TIMER12_IRQn
,
RCU_TIMER12
,
},
{
0
},
{
1000000
,
1000
,
0xffff
,
0
,
/* count up mode */
}
},
#endif
#ifdef BSP_USING_HWTIMER13
{
"timer13"
,
{
TIMER13
,
TIMER13_IRQn
,
RCU_TIMER13
,
},
{
0
},
{
1000000
,
1000
,
0xffff
,
0
,
/* count up mode */
}
},
#endif
};
#ifdef BSP_USING_HWTIMER0
void
TIMER0_UP_IRQHandler
(
void
)
{
rt_interrupt_enter
();
rt_device_hwtimer_isr
(
&
g_gd32_hwtimer
[
TIM0_INDEX
].
hwtimer_dev
);
TIMER_ClearIntBitState
(
g_gd32_hwtimer
[
TIM0_INDEX
].
hwtimer_dev
.
parent
.
user_data
,
\
TIMER_INT_UPDATE
);
rt_interrupt_leave
();
}
#endif
#ifdef BSP_USING_HWTIMER1
void
TIMER1_IRQHandler
(
void
)
{
rt_interrupt_enter
();
rt_device_hwtimer_isr
(
&
g_gd32_hwtimer
[
TIM1_INDEX
].
hwtimer_dev
);
TIMER_ClearIntBitState
(
g_gd32_hwtimer
[
TIM1_INDEX
].
hwtimer_dev
.
parent
.
user_data
,
\
TIMER_INT_UPDATE
);
rt_interrupt_leave
();
}
#endif
#ifdef BSP_USING_HWTIMER2
void
TIMER2_IRQHandler
(
void
)
{
rt_interrupt_enter
();
rt_device_hwtimer_isr
(
&
g_gd32_hwtimer
[
TIM2_INDEX
].
hwtimer_dev
);
TIMER_ClearIntBitState
(
g_gd32_hwtimer
[
TIM2_INDEX
].
hwtimer_dev
.
parent
.
user_data
,
\
TIMER_INT_UPDATE
);
rt_interrupt_leave
();
}
#endif
#ifdef BSP_USING_HWTIMER3
void
TIMER3_IRQHandler
(
void
)
{
rt_interrupt_enter
();
rt_device_hwtimer_isr
(
&
g_gd32_hwtimer
[
TIM3_INDEX
].
hwtimer_dev
);
TIMER_ClearIntBitState
(
g_gd32_hwtimer
[
TIM3_INDEX
].
hwtimer_dev
.
parent
.
user_data
,
\
TIMER_INT_UPDATE
);
rt_interrupt_leave
();
}
#endif
#ifdef BSP_USING_HWTIMER4
void
TIMER4_IRQHandler
(
void
)
{
rt_interrupt_enter
();
rt_device_hwtimer_isr
(
&
g_gd32_hwtimer
[
TIM4_INDEX
].
hwtimer_dev
);
TIMER_ClearIntBitState
(
g_gd32_hwtimer
[
TIM4_INDEX
].
hwtimer_dev
.
parent
.
user_data
,
\
TIMER_INT_UPDATE
);
rt_interrupt_leave
();
}
#endif
#ifdef BSP_USING_HWTIMER5
void
TIMER5_IRQHandler
(
void
)
{
rt_interrupt_enter
();
rt_device_hwtimer_isr
(
&
g_gd32_hwtimer
[
TIM5_INDEX
].
hwtimer_dev
);
TIMER_ClearIntBitState
(
g_gd32_hwtimer
[
TIM5_INDEX
].
hwtimer_dev
.
parent
.
user_data
,
\
TIMER_INT_UPDATE
);
rt_interrupt_leave
();
}
#endif
#ifdef BSP_USING_HWTIMER6
void
TIMER6_IRQHandler
(
void
)
{
rt_interrupt_enter
();
rt_device_hwtimer_isr
(
&
g_gd32_hwtimer
[
TIM6_INDEX
].
hwtimer_dev
);
TIMER_ClearIntBitState
(
g_gd32_hwtimer
[
TIM6_INDEX
].
hwtimer_dev
.
parent
.
user_data
,
\
TIMER_INT_UPDATE
);
rt_interrupt_leave
();
}
#endif
#ifdef BSP_USING_HWTIMER7
void
TIMER7_UP_IRQHandler
(
void
)
{
rt_interrupt_enter
();
rt_device_hwtimer_isr
(
&
g_gd32_hwtimer
[
TIM7_INDEX
].
hwtimer_dev
);
TIMER_ClearIntBitState
(
g_gd32_hwtimer
[
TIM7_INDEX
].
hwtimer_dev
.
parent
.
user_data
,
\
TIMER_INT_UPDATE
);
rt_interrupt_leave
();
}
#endif
static
int
rt_hwtimer_init
(
void
)
{
int
ret
=
0
,
i
=
0
;
for
(;
i
<
ARRAY_SIZE
(
g_gd32_hwtimer
);
i
++
)
{
g_gd32_hwtimer
[
i
].
hwtimer_dev
.
ops
=
&
g_gd32_hwtimer_ops
;
g_gd32_hwtimer
[
i
].
hwtimer_dev
.
info
=
&
g_gd32_hwtimer
[
i
].
hwtimer_info
;
rcu_periph_clock_enable
(
g_gd32_hwtimer
[
i
].
hw_data
.
rcu
);
NVIC_SetPriority
(
g_gd32_hwtimer
[
i
].
hw_data
.
irqn
,
0
);
NVIC_EnableIRQ
(
g_gd32_hwtimer
[
i
].
hw_data
.
irqn
);
TIMER_INTConfig
(
g_gd32_hwtimer
[
i
].
hw_data
.
reg_base
,
TIMER_INT_UPDATE
,
ENABLE
);
ret
=
rt_device_hwtimer_register
(
&
g_gd32_hwtimer
[
i
].
hwtimer_dev
,
\
g_gd32_hwtimer
[
i
].
dev_name
,
g_gd32_hwtimer
[
i
].
hw_data
.
reg_base
);
if
(
RT_EOK
!=
ret
)
{
rt_kprintf
(
"failed register %s, err=%d
\n
"
,
g_gd32_hwtimer
[
i
].
dev_name
,
\
ret
);
break
;
}
}
return
ret
;
}
INIT_BOARD_EXPORT
(
rt_hwtimer_init
);
#endif
bsp/gd32103c-eval/drivers/drv_hwtimer.h
0 → 100644
浏览文件 @
f0805a79
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-01-15 iysheng first release
*/
#ifndef __DRV_HWTIMER_H__
#define __DRV_HWTIMER_H__
#ifdef __cplusplus
extern
"C"
{
#endif
#include <drivers/hwtimer.h>
typedef
struct
{
TIMER_TypeDef
*
reg_base
;
IRQn_Type
irqn
;
rcu_periph_enum
rcu
;
}
gd32_hwtimer_data
;
typedef
struct
{
char
dev_name
[
RT_NAME_MAX
];
const
gd32_hwtimer_data
hw_data
;
rt_hwtimer_t
hwtimer_dev
;
const
struct
rt_hwtimer_info
hwtimer_info
;
}
gd32_hwtimer_device
;
#ifdef __cplusplus
}
#endif
#endif
/* __DRV_HWTIMER_H__ */
bsp/gd32103c-eval/rtconfig.h
浏览文件 @
f0805a79
...
...
@@ -85,7 +85,6 @@
#define RT_SERIAL_USING_DMA
#define RT_SERIAL_RB_BUFSZ 64
#define RT_USING_PIN
#define RT_USING_ADC
/* Using USB */
...
...
@@ -161,7 +160,5 @@
#define BSP_USING_UART
#define BSP_USING_UART0
#define BSP_USING_ADC
#define BSP_USING_ADC0
#endif
bsp/raspberry-pi/raspi4-32/driver/touch/drv_xpt2046.c
浏览文件 @
f0805a79
...
...
@@ -19,7 +19,7 @@
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
//XPT204
9
//XPT204
6
#define READ_X (0xD0)
#define READ_Y (0x90)
...
...
@@ -218,7 +218,7 @@ static struct rt_touch_ops touch_ops =
.
touch_control
=
xpt2046_control
,
};
static
int
hw_xpt204
9
_touch_init
(
void
)
static
int
hw_xpt204
6
_touch_init
(
void
)
{
//touch sem
rt_sem_init
(
&
touch_ack
,
"touch_ack"
,
0
,
RT_IPC_FLAG_FIFO
);
...
...
@@ -249,4 +249,4 @@ static int hw_xpt2049_touch_init(void)
return
0
;
}
INIT_DEVICE_EXPORT
(
hw_xpt204
9
_touch_init
);
INIT_DEVICE_EXPORT
(
hw_xpt204
6
_touch_init
);
bsp/stm32/libraries/HAL_Drivers/drv_hwtimer.c
浏览文件 @
f0805a79
...
...
@@ -343,7 +343,7 @@ static rt_err_t timer_ctrl(rt_hwtimer_t *timer, rt_uint32_t cmd, void *arg)
if
(
tim
->
Instance
==
TIM15
||
tim
->
Instance
==
TIM16
||
tim
->
Instance
==
TIM17
)
#elif defined(SOC_SERIES_STM32WB)
if
(
tim
->
Instance
==
TIM16
||
tim
->
Instance
==
TIM17
)
#elif defined(SOC_SERIES_STM32MP1)
#elif defined(SOC_SERIES_STM32MP1)
if
(
tim
->
Instance
==
TIM14
||
tim
->
Instance
==
TIM16
||
tim
->
Instance
==
TIM17
)
#elif defined(SOC_SERIES_STM32F1) || defined(SOC_SERIES_STM32F0) || defined(SOC_SERIES_STM32G0)
if
(
0
)
...
...
bsp/stm32/libraries/HAL_Drivers/drv_pwm.c
浏览文件 @
f0805a79
...
...
@@ -350,7 +350,7 @@ static rt_err_t drv_pwm_control(struct rt_device_pwm *device, int cmd, void *arg
case
PWM_CMD_ENABLE
:
return
drv_pwm_enable
(
htim
,
configuration
,
RT_TRUE
);
case
PWMN_CMD_DISABLE
:
configuration
->
complementary
=
RT_
TRU
E
;
configuration
->
complementary
=
RT_
FALS
E
;
case
PWM_CMD_DISABLE
:
return
drv_pwm_enable
(
htim
,
configuration
,
RT_FALSE
);
case
PWM_CMD_SET
:
...
...
bsp/stm32/stm32f103-blue-pill/README.pdf
已删除
100644 → 0
浏览文件 @
852d7d75
文件已删除
bsp/stm32/stm32f103-blue-pill/documents/Beginning STM32 (excerpt).pdf
0 → 100644
浏览文件 @
f0805a79
文件已添加
components/drivers/include/drivers/hwtimer.h
浏览文件 @
f0805a79
...
...
@@ -70,7 +70,7 @@ typedef struct rt_hwtimer_device
rt_int32_t
freq
;
/* counting frequency set by the user */
rt_int32_t
overflow
;
/* timer overflows */
float
period_sec
;
float
period_sec
;
rt_int32_t
cycles
;
/* how many times will generate a timeout event after overflow */
rt_int32_t
reload
;
/* reload cycles(using in period mode) */
rt_hwtimer_mode_t
mode
;
/* timing mode(oneshot/period) */
...
...
components/drivers/misc/pin.c
浏览文件 @
f0805a79
...
...
@@ -6,6 +6,7 @@
* Change Logs:
* Date Author Notes
* 2015-01-20 Bernard the first version
* 2021-02-06 Meco Man fix RT_ENOSYS code in negative
*/
#include <drivers/pin.h>
...
...
@@ -108,7 +109,7 @@ rt_err_t rt_pin_attach_irq(rt_int32_t pin, rt_uint32_t mode,
{
return
_hw_pin
.
ops
->
pin_attach_irq
(
&
_hw_pin
.
parent
,
pin
,
mode
,
hdr
,
args
);
}
return
RT_ENOSYS
;
return
-
RT_ENOSYS
;
}
rt_err_t
rt_pin_detach_irq
(
rt_int32_t
pin
)
{
...
...
@@ -117,7 +118,7 @@ rt_err_t rt_pin_detach_irq(rt_int32_t pin)
{
return
_hw_pin
.
ops
->
pin_detach_irq
(
&
_hw_pin
.
parent
,
pin
);
}
return
RT_ENOSYS
;
return
-
RT_ENOSYS
;
}
rt_err_t
rt_pin_irq_enable
(
rt_base_t
pin
,
rt_uint32_t
enabled
)
...
...
@@ -127,7 +128,7 @@ rt_err_t rt_pin_irq_enable(rt_base_t pin, rt_uint32_t enabled)
{
return
_hw_pin
.
ops
->
pin_irq_enable
(
&
_hw_pin
.
parent
,
pin
,
enabled
);
}
return
RT_ENOSYS
;
return
-
RT_ENOSYS
;
}
/* RT-Thread Hardware PIN APIs */
...
...
components/libc/compilers/common/sys/time.h
浏览文件 @
f0805a79
...
...
@@ -48,8 +48,10 @@ struct timezone {
int
tz_dsttime
;
/* type of dst correction */
};
int
gettimeofday
(
struct
timeval
*
tp
,
struct
timezone
*
tz
);
int
stime
(
const
time_t
*
t
);
time_t
timegm
(
struct
tm
*
const
t
);
int
gettimeofday
(
struct
timeval
*
tv
,
struct
timezone
*
tz
);
int
settimeofday
(
const
struct
timeval
*
tv
,
const
struct
timezone
*
tz
);
#ifdef __cplusplus
}
...
...
components/libc/compilers/common/time.c
浏览文件 @
f0805a79
...
...
@@ -8,6 +8,12 @@
* 2019-08-21 zhangjun copy from minilibc
* 2020-09-07 Meco Man combine gcc armcc iccarm
* 2021-02-05 Meco Man add timegm()
* 2021-02-07 Meco Man fixed gettimeofday()
* 2021-02-08 Meco Man add settimeofday() stime()
* 2021-02-10 Meco Man add ctime_r() and re-implement ctime()
* 2021-02-11 Meco Man fix bug #3183 - align days[] and months[] to 4 bytes
* add difftime()
* 2021-02-12 Meco Man add errno
*/
#include <sys/time.h>
...
...
@@ -16,9 +22,6 @@
#include <rtdevice.h>
#endif
#if !defined (__IAR_SYSTEMS_ICC__)
/* seconds per day */
#define SPD 24*60*60
...
...
@@ -39,8 +42,9 @@ const short __spm[13] =
(
31
+
28
+
31
+
30
+
31
+
30
+
31
+
31
+
30
+
31
+
30
),
(
31
+
28
+
31
+
30
+
31
+
30
+
31
+
31
+
30
+
31
+
30
+
31
),
};
static
const
char
days
[]
=
"Sun Mon Tue Wed Thu Fri Sat "
;
static
const
char
months
[]
=
"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec "
;
ALIGN
(
4
)
static
const
char
days
[]
=
"Sun Mon Tue Wed Thu Fri Sat "
;
ALIGN
(
4
)
static
const
char
months
[]
=
"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec "
;
static
int
__isleap
(
int
year
)
{
...
...
@@ -89,6 +93,8 @@ struct tm *gmtime_r(const time_t *timep, struct tm *r)
;
r
->
tm_mon
=
i
;
r
->
tm_mday
+=
work
-
__spm
[
i
];
r
->
tm_isdst
=
0
;
return
r
;
}
...
...
@@ -102,10 +108,10 @@ struct tm* gmtime(const time_t* t)
struct
tm
*
localtime_r
(
const
time_t
*
t
,
struct
tm
*
r
)
{
time_t
local_tz
;
int
timezone
;
int
utc_plus
;
timezone
=
0
*
3600
*
8
;
/* GTM: UTC+0 */
local_tz
=
*
t
+
timezone
;
utc_plus
=
0
;
/* GTM: UTC+0 */
local_tz
=
*
t
+
utc_plus
*
3600
;
return
gmtime_r
(
&
local_tz
,
r
);
}
...
...
@@ -148,44 +154,45 @@ char* asctime(const struct tm *timeptr)
return
asctime_r
(
timeptr
,
buf
);
}
char
*
ctime
(
const
time_t
*
timep
)
char
*
ctime_r
(
const
time_t
*
tim_p
,
char
*
result
)
{
return
asctime
(
localtime
(
timep
));
struct
tm
tm
;
return
asctime_r
(
localtime_r
(
tim_p
,
&
tm
),
result
);
}
#endif
/* __IAR_SYSTEMS_ICC__ */
char
*
ctime
(
const
time_t
*
tim_p
)
{
return
asctime
(
localtime
(
tim_p
));
}
double
difftime
(
time_t
tim1
,
time_t
tim2
)
{
return
(
double
)(
tim1
-
tim2
);
}
/**
* Returns the current time.
*
* @param time_t * t the timestamp pointer, if not used, keep NULL.
*
* @return time_t return timestamp current.
* @return The value ((time_t)-1) is returned if the calendar time is not available.
* If timer is not a NULL pointer, the return value is also stored in timer.
*
*/
#if defined (__IAR_SYSTEMS_ICC__) && (__VER__) >= 6020000
/* for IAR 6.2 later Compiler */
#pragma module_name = "?time"
#if _DLIB_TIME_USES_64
time_t
__time64
(
time_t
*
t
)
#else
time_t
__time32
(
time_t
*
t
)
#endif
#else
/* Keil & GCC */
time_t
time
(
time_t
*
t
)
#endif
RT_WEAK
time_t
time
(
time_t
*
t
)
{
time_t
time_now
=
0
;
time_t
time_now
=
((
time_t
)
-
1
);
/* default is not available */
#ifdef RT_USING_RTC
static
rt_device_t
device
=
RT_NULL
;
/* optimization: find rtc device only first
.
*/
/* optimization: find rtc device only first */
if
(
device
==
RT_NULL
)
{
device
=
rt_device_find
(
"rtc"
);
}
/* read timestamp from RTC device
.
*/
/* read timestamp from RTC device */
if
(
device
!=
RT_NULL
)
{
if
(
rt_device_open
(
device
,
0
)
==
RT_EOK
)
...
...
@@ -202,6 +209,11 @@ time_t time(time_t *t)
*
t
=
time_now
;
}
if
(
time_now
==
(
time_t
)
-
1
)
{
errno
=
ENOSYS
;
}
return
time_now
;
}
...
...
@@ -210,26 +222,29 @@ RT_WEAK clock_t clock(void)
return
rt_tick_get
();
}
/* TODO: timezone */
int
gettimeofday
(
struct
timeval
*
tp
,
struct
timezone
*
tz
)
int
stime
(
const
time_t
*
t
)
{
time_t
time
=
0
;
#ifdef RT_USING_DEVICE
#ifdef RT_USING_RTC
rt_device_t
device
;
/* read timestamp from RTC device. */
device
=
rt_device_find
(
"rtc"
);
RT_ASSERT
(
device
!=
RT_NULL
);
rt_device_control
(
device
,
RT_DEVICE_CTRL_RTC_GET_TIME
,
&
time
);
if
(
tp
!=
RT_NULL
)
if
(
rt_device_open
(
device
,
0
)
==
RT_EOK
)
{
tp
->
tv_sec
=
time
;
tp
->
tv_usec
=
0
;
rt_device_control
(
device
,
RT_DEVICE_CTRL_RTC_SET_TIME
,
(
void
*
)
t
)
;
rt_device_close
(
device
)
;
}
#else
tv
->
tv_sec
=
0
;
tv
->
tv_usec
=
0
;
#endif
else
{
errno
=
ENOSYS
;
return
-
1
;
}
return
0
;
return
time
;
#else
errno
=
ENOSYS
;
return
-
1
;
#endif
/* RT_USING_RTC */
}
time_t
timegm
(
struct
tm
*
const
t
)
...
...
@@ -305,3 +320,35 @@ time_t timegm(struct tm * const t)
i
=
60
;
return
((
day
+
t
->
tm_hour
)
*
i
+
t
->
tm_min
)
*
i
+
t
->
tm_sec
;
}
/* TODO: timezone */
int
gettimeofday
(
struct
timeval
*
tv
,
struct
timezone
*
tz
)
{
time_t
t
=
time
(
RT_NULL
);
if
(
tv
!=
RT_NULL
&&
t
!=
(
time_t
)
-
1
)
{
tv
->
tv_sec
=
t
;
tv
->
tv_usec
=
0
;
return
0
;
}
else
{
errno
=
ENOSYS
;
return
-
1
;
}
}
/* TODO: timezone */
int
settimeofday
(
const
struct
timeval
*
tv
,
const
struct
timezone
*
tz
)
{
if
(
tv
!=
RT_NULL
)
{
return
stime
((
const
time_t
*
)
&
tv
->
tv_sec
);
}
else
{
errno
=
ENOSYS
;
return
-
1
;
}
}
components/libc/compilers/newlib/libc.h
浏览文件 @
f0805a79
...
...
@@ -10,23 +10,10 @@
#ifndef __RTT_LIBC_H__
#define __RTT_LIBC_H__
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <sys/time.h>
#ifndef _EXFUN
#define _EXFUN(name, proto)
name proto
#define _EXFUN(name, proto)
name proto
#endif
#define MILLISECOND_PER_SECOND 1000UL
#define MICROSECOND_PER_SECOND 1000000UL
#define NANOSECOND_PER_SECOND 1000000000UL
#define MILLISECOND_PER_TICK (MILLISECOND_PER_SECOND / RT_TICK_PER_SECOND)
#define MICROSECOND_PER_TICK (MICROSECOND_PER_SECOND / RT_TICK_PER_SECOND)
#define NANOSECOND_PER_TICK (NANOSECOND_PER_SECOND / RT_TICK_PER_SECOND)
#ifdef __cplusplus
extern
"C"
{
#endif
...
...
@@ -34,10 +21,6 @@ int libc_system_init(void);
int
libc_stdio_set_console
(
const
char
*
device_name
,
int
mode
);
int
libc_stdio_get_console
(
void
);
/* some time related function */
int
libc_set_time
(
const
struct
timespec
*
time
);
int
libc_get_time
(
struct
timespec
*
time
);
int
libc_time_to_tick
(
const
struct
timespec
*
time
);
#ifdef __cplusplus
}
#endif
...
...
components/libc/compilers/newlib/syscalls.c
浏览文件 @
f0805a79
...
...
@@ -5,7 +5,9 @@
*
* Change Logs:
* Date Author Notes
* 2021-02-11 Meco Man remove _gettimeofday_r() and _times_r()
*/
#include <reent.h>
#include <sys/errno.h>
#include <sys/time.h>
...
...
@@ -190,14 +192,6 @@ _stat_r(struct _reent *ptr, const char *file, struct stat *pstat)
#endif
}
_CLOCK_T_
_times_r
(
struct
_reent
*
ptr
,
struct
tms
*
ptms
)
{
/* return "not supported" */
ptr
->
_errno
=
ENOTSUP
;
return
-
1
;
}
int
_unlink_r
(
struct
_reent
*
ptr
,
const
char
*
file
)
{
...
...
@@ -243,111 +237,6 @@ _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes)
}
#endif
#ifdef RT_USING_PTHREADS
#include <clock_time.h>
/* POSIX timer provides clock_gettime function */
#include <time.h>
int
_gettimeofday_r
(
struct
_reent
*
ptr
,
struct
timeval
*
__tp
,
void
*
__tzp
)
{
struct
timespec
tp
;
if
(
clock_gettime
(
CLOCK_REALTIME
,
&
tp
)
==
0
)
{
if
(
__tp
!=
RT_NULL
)
{
__tp
->
tv_sec
=
tp
.
tv_sec
;
__tp
->
tv_usec
=
tp
.
tv_nsec
/
1000UL
;
}
return
tp
.
tv_sec
;
}
/* return "not supported" */
ptr
->
_errno
=
ENOTSUP
;
return
-
1
;
}
#else
#define MILLISECOND_PER_SECOND 1000UL
#define MICROSECOND_PER_SECOND 1000000UL
#define NANOSECOND_PER_SECOND 1000000000UL
#define MILLISECOND_PER_TICK (MILLISECOND_PER_SECOND / RT_TICK_PER_SECOND)
#define MICROSECOND_PER_TICK (MICROSECOND_PER_SECOND / RT_TICK_PER_SECOND)
#define NANOSECOND_PER_TICK (NANOSECOND_PER_SECOND / RT_TICK_PER_SECOND)
struct
timeval
_timevalue
=
{
0
};
#ifdef RT_USING_DEVICE
static
void
libc_system_time_init
(
void
)
{
time_t
time
;
rt_tick_t
tick
;
rt_device_t
device
;
time
=
0
;
device
=
rt_device_find
(
"rtc"
);
if
(
device
!=
RT_NULL
)
{
/* get realtime seconds */
rt_device_control
(
device
,
RT_DEVICE_CTRL_RTC_GET_TIME
,
&
time
);
}
/* get tick */
tick
=
rt_tick_get
();
_timevalue
.
tv_usec
=
MICROSECOND_PER_SECOND
-
(
tick
%
RT_TICK_PER_SECOND
)
*
MICROSECOND_PER_TICK
;
_timevalue
.
tv_sec
=
time
-
tick
/
RT_TICK_PER_SECOND
-
1
;
}
#endif
int
libc_get_time
(
struct
timespec
*
time
)
{
rt_tick_t
tick
;
static
rt_bool_t
inited
=
0
;
RT_ASSERT
(
time
!=
RT_NULL
);
/* initialize system time */
if
(
inited
==
0
)
{
libc_system_time_init
();
inited
=
1
;
}
/* get tick */
tick
=
rt_tick_get
();
time
->
tv_sec
=
_timevalue
.
tv_sec
+
tick
/
RT_TICK_PER_SECOND
;
time
->
tv_nsec
=
(
_timevalue
.
tv_usec
+
(
tick
%
RT_TICK_PER_SECOND
)
*
MICROSECOND_PER_TICK
)
*
1000
;
return
0
;
}
int
_gettimeofday_r
(
struct
_reent
*
ptr
,
struct
timeval
*
__tp
,
void
*
__tzp
)
{
struct
timespec
tp
;
if
(
libc_get_time
(
&
tp
)
==
0
)
{
if
(
__tp
!=
RT_NULL
)
{
__tp
->
tv_sec
=
tp
.
tv_sec
;
__tp
->
tv_usec
=
tp
.
tv_nsec
/
1000UL
;
}
return
tp
.
tv_sec
;
}
/* return "not supported" */
ptr
->
_errno
=
ENOTSUP
;
return
-
1
;
}
#endif
/* Memory routine */
void
*
_malloc_r
(
struct
_reent
*
ptr
,
size_t
size
)
...
...
@@ -453,3 +342,9 @@ int flock(int fd, int operation)
{
return
0
;
}
/*
These functions will be implemented and replaced by the 'common/time.c' file
int _gettimeofday_r(struct _reent *ptr, struct timeval *__tp, void *__tzp);
_CLOCK_T_ _times_r(struct _reent *ptr, struct tms *ptms);
*/
documentation/coding_style_cn.md
浏览文件 @
f0805a79
...
...
@@ -7,7 +7,7 @@
## 1.目录名称
目录名称如果无特殊的需求,请使用全小写的形式;目录名称应能够反
应
部分的意思,例
目录名称如果无特殊的需求,请使用全小写的形式;目录名称应能够反
映
部分的意思,例
如各芯片移植由其芯片名称构成或芯片类别构成;components 目录下能够反映组件的意义。
## 2.文件名称
...
...
include/libc/libc_ioctl.h
浏览文件 @
f0805a79
...
...
@@ -16,7 +16,7 @@
#define _IOC_WRITE 1U
#define _IOC_READ 2U
#if
ndef _WIN32
#if
!defined (_WIN32) && !defined (__TASKING__)
#define _IO(a,b) _IOC(_IOC_NONE,(a),(b),0)
#define _IOW(a,b,c) _IOC(_IOC_WRITE,(a),(b),sizeof(c))
#define _IOR(a,b,c) _IOC(_IOC_READ,(a),(b),sizeof(c))
...
...
include/rtdef.h
浏览文件 @
f0805a79
...
...
@@ -192,6 +192,18 @@ typedef rt_base_t rt_off_t; /**< Type for offset */
#define RT_WEAK
#define rt_inline static inline
#define RTT_API
#elif defined (__TASKING__)
#include <stdarg.h>
#define SECTION(x)
#define RT_UNUSED
#define RT_USED
#define PRAGMA(x) _Pragma(#x)
#define ALIGN(n)
#define RT_WEAK
#define rt_inline static inline
#define RTT_API
#else
#error not supported tool chain
#endif
...
...
src/components.c
浏览文件 @
f0805a79
...
...
@@ -173,19 +173,22 @@ struct rt_thread main_thread;
void
main_thread_entry
(
void
*
parameter
)
{
extern
int
main
(
void
);
extern
int
$
Super
$$
main
(
void
);
#ifdef RT_USING_COMPONENTS_INIT
/* RT-Thread components initialization */
rt_components_init
();
#endif
#ifdef RT_USING_SMP
rt_hw_secondary_cpu_up
();
#endif
/* invoke system main function */
#if defined(__CC_ARM) || defined(__CLANG_ARM)
$
Super
$$
main
();
/* for ARMCC. */
#elif defined(__ICCARM__) || defined(__GNUC__)
{
extern
int
$
Super
$$
main
(
void
);
$
Super
$$
main
();
/* for ARMCC. */
}
#elif defined(__ICCARM__) || defined(__GNUC__) || defined(__TASKING__)
main
();
#endif
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录