Skip to content

Commit dce2c7c

Browse files
author
board707
committed
First update to hal-v0.6.0
1 parent 701a260 commit dce2c7c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+8311
-5425
lines changed

cores/w806/include/driver/wm_adc.h

Lines changed: 57 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -3,57 +3,50 @@
33

44
#include "wm_hal.h"
55

6-
#ifdef __cplusplus
7-
extern "C" {
8-
#endif
9-
106
typedef struct
117
{
12-
uint32_t channel; /* ADC_CHANNEL_0 : channel 0
13-
* ADC_CHANNEL_1 : channel 1
14-
* ADC_CHANNEL_2 : channel 2
15-
* ADC_CHANNEL_3 : channel 3
16-
* ADC_CHANNEL_0_1 : channel 0 and channel 1 differential input
17-
* ADC_CHANNEL_2_3 : channel 2 and channel 3 differential input */
18-
19-
uint32_t freq; /* 307hz ~ 2khz */
20-
21-
uint32_t cmp_val; /* compare value */
22-
23-
uint32_t cmp_pol; /* CMP_POL_0 : when adc_result >= cmp_val interrupt
24-
* CMP_POL_1 : whrn adc_result < cmp_val interrtup */
25-
8+
uint32_t channel; /* ADC_CHANNEL_0 ~ channel 0
9+
* ADC_CHANNEL_1 ~ channel 1
10+
* ADC_CHANNEL_2 ~ channel 2
11+
* ADC_CHANNEL_3 ~ channel 3
12+
* ADC_CHANNEL_0_1 : channel 0 and channel 1 differential input
13+
* ADC_CHANNEL_2_3 : channel 2 and channel 3 differential input */
14+
15+
uint32_t freq; /* 307hz ~ 2khz */
16+
17+
uint32_t cmp_val; /* compare value */
18+
19+
uint32_t cmp_pol; /* CMP_POL_0 : when adc_result >= cmp_val interrupt
20+
* CMP_POL_1 : whrn adc_result < cmp_val interrtup */
21+
2622
}ADC_InitTypeDef;
2723

2824
typedef struct __ADC_HandleTypeDef
2925
{
30-
ADC_TypeDef *Instance;
31-
32-
ADC_InitTypeDef Init;
33-
34-
HAL_LockTypeDef Lock;
35-
36-
int offset;
37-
26+
ADC_TypeDef *Instance;
27+
ADC_InitTypeDef Init;
28+
HAL_LockTypeDef Lock;
29+
int offset;
30+
3831
}ADC_HandleTypeDef;
3932

4033

4134
#define ADC ((ADC_TypeDef *)ADC_BASE)
4235

43-
#define ADC_CHANNEL_0 ADC_ANA_CR_CH_0
44-
#define ADC_CHANNEL_1 ADC_ANA_CR_CH_1
45-
#define ADC_CHANNEL_2 ADC_ANA_CR_CH_2
46-
#define ADC_CHANNEL_3 ADC_ANA_CR_CH_3
47-
#define ADC_CHANNEL_0_1 ADC_ANA_CR_CH_8
48-
#define ADC_CHANNEL_2_3 ADC_ANA_CR_CH_9
49-
#define ADC_CHANNEL_TEMP ADC_ANA_CR_CH_TEMP
50-
#define ADC_CHANNEL_OFFSET ADC_ANA_CR_CH_OFFSET
36+
#define ADC_CHANNEL_0 ADC_ANA_CR_CH_0
37+
#define ADC_CHANNEL_1 ADC_ANA_CR_CH_1
38+
#define ADC_CHANNEL_2 ADC_ANA_CR_CH_2
39+
#define ADC_CHANNEL_3 ADC_ANA_CR_CH_3
40+
#define ADC_CHANNEL_0_1 ADC_ANA_CR_CH_8
41+
#define ADC_CHANNEL_2_3 ADC_ANA_CR_CH_9
42+
#define ADC_CHANNEL_TEMP ADC_ANA_CR_CH_TEMP
43+
#define ADC_CHANNEL_OFFSET ADC_ANA_CR_CH_OFFSET
5144

52-
#define ADC_FREQ_MIN 307
53-
#define ADC_FREQ_MAX 2000
45+
#define ADC_FREQ_MIN 307
46+
#define ADC_FREQ_MAX 2000
5447

55-
#define CMP_POL_0 0x0UL
56-
#define CMP_POL_1 ADC_ADC_CR_CMPPOL
48+
#define CMP_POL_0 0x0UL
49+
#define CMP_POL_1 ADC_ADC_CR_CMPPOL
5750

5851
#define HAL_ADC_STATE_RESET 0x00000000U
5952
#define HAL_ADC_STATE_READY 0x00000001U
@@ -67,26 +60,26 @@ typedef struct __ADC_HandleTypeDef
6760
((CHANNEL) == ADC_CHANNEL_1) || \
6861
((CHANNEL) == ADC_CHANNEL_2) || \
6962
((CHANNEL) == ADC_CHANNEL_3) || \
70-
((CHANNEL) == ADC_CHANNEL_0_1) || \
63+
((CHANNEL) == ADC_CHANNEL_0_1) || \
7164
((CHANNEL) == ADC_CHANNEL_2_3) )
72-
73-
#define IS_ADC_CMP_POL(POL) (((POL) == CMP_POL_0) || \
74-
((POL) == CMP_POL_1))
75-
65+
66+
#define IS_ADC_CMP_POL(POL) (((POL) == CMP_POL_0) || \
67+
((POL) == CMP_POL_1))
68+
7669
#define IS_ADC_FREQUENCY(FREQ) (((FREQ) >= ADC_FREQ_MIN) && ((FREQ) <= ADC_FREQ_MAX))
7770

78-
#define __HAL_ADC_ENABLE(__HANDLE__) (MODIFY_REG((__HANDLE__)->Instance->ANA_CR, ADC_ANA_CR_CH | ADC_ANA_CR_PD | ADC_ANA_CR_RST | ADC_ANA_CR_LDOEN, \
79-
(__HANDLE__)->Init.channel | ADC_ANA_CR_RST | ADC_ANA_CR_LDOEN))
80-
81-
#define __HAL_ADC_DISABLE(__HANDLE__) (MODIFY_REG((__HANDLE__)->Instance->ANA_CR, ADC_ANA_CR_PD | ADC_ANA_CR_RST | ADC_ANA_CR_LDOEN, \
82-
ADC_ANA_CR_PD))
71+
#define __HAL_ADC_ENABLE(__HANDLE__) (MODIFY_REG((__HANDLE__)->Instance->ANA_CR, ADC_ANA_CR_CH | ADC_ANA_CR_PD | ADC_ANA_CR_RST | ADC_ANA_CR_LDOEN, \
72+
(__HANDLE__)->Init.channel | ADC_ANA_CR_RST | ADC_ANA_CR_LDOEN))
73+
74+
#define __HAL_ADC_DISABLE(__HANDLE__) (MODIFY_REG((__HANDLE__)->Instance->ANA_CR, ADC_ANA_CR_PD | ADC_ANA_CR_RST | ADC_ANA_CR_LDOEN, \
75+
ADC_ANA_CR_PD))
8376

84-
#define __HAL_ADC_CLEAR_FLAG(__HANDLE__, __FLAG__) \
85-
(WRITE_REG((__HANDLE__)->Instance->IF, (__FLAG__)))
86-
87-
#define __HAL_ADC_INT_ENABLE(__HANDLE__, __FLAG__) (SET_BIT((__HANDLE__)->Instance->ADC_CR, __FLAG__))
77+
#define __HAL_ADC_CLEAR_FLAG(__HANDLE__, __FLAG__) \
78+
(WRITE_REG((__HANDLE__)->Instance->IF, (__FLAG__)))
79+
80+
#define __HAL_ADC_INT_ENABLE(__HANDLE__, __FLAG__) (SET_BIT((__HANDLE__)->Instance->ADC_CR, __FLAG__))
8881

89-
#define __HAL_ADC_INT_DISABLE(__HANDLE__, __FLAG__) (CLEAR_BIT((__HANDLE__)->Instance->ADC_CR, __FLAG__))
82+
#define __HAL_ADC_INT_DISABLE(__HANDLE__, __FLAG__) (CLEAR_BIT((__HANDLE__)->Instance->ADC_CR, __FLAG__))
9083

9184
#define __HAL_ADC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) \
9285
(((__HANDLE__)->Instance->ADC_CR & (__INTERRUPT__)) == (__INTERRUPT__))
@@ -96,28 +89,31 @@ typedef struct __ADC_HandleTypeDef
9689

9790

9891

92+
#ifdef __cplusplus
93+
extern "C"{
94+
#endif
9995
HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef* hadc);
10096
HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef *hadc);
10197
void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc);
10298
void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc);
10399

104100

105-
// AD转换功能以查询方式实现所对应的开始、停止、查询是否转换完成、获取转换结果
101+
// AD转换功能以查询方式实现所对应的开始、停止、查询是否转换完成、获取转换结果
106102
HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef* hadc);
107103
HAL_StatusTypeDef HAL_ADC_Stop(ADC_HandleTypeDef* hadc);
108-
HAL_StatusTypeDef HAL_ADC_PollForConversion(ADC_HandleTypeDef* hadc);
109-
int HAL_ADC_GetValue(ADC_HandleTypeDef* hadc);
104+
HAL_StatusTypeDef HAL_ADC_PollForConversion(ADC_HandleTypeDef* hadc);
105+
int HAL_ADC_GetValue(ADC_HandleTypeDef* hadc);
110106

111-
// 该接口调用了以上接口,实现了一个完整的查询转换过程,并返回结果,可以直接调用该接口获取转换结果,返回值单位mv
112-
int HAL_ADC_GET_INPUT_VOLTAGE(ADC_HandleTypeDef* hadc);
107+
// 该接口调用了以上接口,实现了一个完整的查询转换过程,并返回结果,可以直接调用该接口获取转换结果,返回值单位mv
108+
int HAL_ADC_GET_INPUT_VOLTAGE(ADC_HandleTypeDef* hadc);
113109

114-
// AD转换功能以中断方式实现所对应的开始、停止、中断回调函数
110+
// AD转换功能以中断方式实现所对应的开始、停止、中断回调函数
115111
HAL_StatusTypeDef HAL_ADC_Start_IT(ADC_HandleTypeDef* hadc);
116112
HAL_StatusTypeDef HAL_ADC_Stop_IT(ADC_HandleTypeDef* hadc);
117113
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc);
118114

119-
// AD比较功能以中断方式实现所对应的开始、停止、中断回调函数
120-
HAL_StatusTypeDef HAL_ADC_Start_Compare_IT(ADC_HandleTypeDef* hadc);
115+
// AD比较功能以中断方式实现所对应的开始、停止、中断回调函数
116+
HAL_StatusTypeDef HAL_ADC_Start_Compare_IT(ADC_HandleTypeDef* hadc);
121117
HAL_StatusTypeDef HAL_ADC_Stop_Compare_IT(ADC_HandleTypeDef* hadc);
122118
void HAL_ADC_CompareCallback(ADC_HandleTypeDef* hadc);
123119

cores/w806/include/driver/wm_cpu.h

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,8 @@
1212

1313
#include "wm_hal.h"
1414

15-
16-
#ifdef __cplusplus
17-
extern "C" {
18-
#endif
19-
2015
/**BASE PLL CLOCK*/
21-
#define W805_PLL_CLK_MHZ (480)
16+
#define W806_PLL_CLK_MHZ (480)
2217

2318
#define IS_NVIC_DEVICE_IRQ(IRQ) ((IRQ) >= (IRQn_Type)0x00U)
2419

@@ -27,7 +22,7 @@ enum CPU_CLK{
2722
CPU_CLK_160M = 3,
2823
CPU_CLK_80M = 6,
2924
CPU_CLK_40M = 12,
30-
CPU_CLK_2M = 240,
25+
CPU_CLK_2M = 240,
3126
};
3227

3328
typedef union {
@@ -42,30 +37,32 @@ typedef union {
4237
uint32_t w;
4338
} clk_div_reg;
4439

45-
#define UNIT_MHZ (1000000)
40+
#define UNIT_MHZ (1000000)
4641

4742

4843
typedef struct{
49-
uint32_t apbclk;
50-
uint32_t cpuclk;
51-
uint32_t wlanclk;
44+
uint32_t apbclk;
45+
uint32_t cpuclk;
46+
uint32_t wlanclk;
5247
}wm_sys_clk;
5348

5449
typedef enum
5550
{
56-
HAL_TICK_FREQ_10HZ = 10,
57-
HAL_TICK_FREQ_100HZ = 100,
58-
HAL_TICK_FREQ_1KHZ = 1000,
59-
HAL_TICK_FREQ_DEFAULT = HAL_TICK_FREQ_1KHZ
51+
HAL_TICK_FREQ_10HZ = 10,
52+
HAL_TICK_FREQ_100HZ = 100,
53+
HAL_TICK_FREQ_1KHZ = 1000,
54+
HAL_TICK_FREQ_DEFAULT = HAL_TICK_FREQ_1KHZ
6055
} HAL_TickFreqTypeDef;
6156

6257

58+
#ifdef __cplusplus
59+
extern "C"{
60+
#endif
6361
void SystemClock_Config(uint32_t clk);
6462
void SystemClock_Get(wm_sys_clk *sysclk);
6563

6664
HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority);
6765
void HAL_IncTick(void);
68-
uint32_t HAL_Get_Micros(void);
6966
uint32_t HAL_GetTick(void);
7067
void HAL_Delay(uint32_t Delay);
7168

0 commit comments

Comments
 (0)