Skip to content

Commit

Permalink
backup dac
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxCrazy1101 committed Mar 31, 2023
1 parent 5863799 commit bfd53c6
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion App/Source/app_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ static void task_adc0(void *pvParameters)
vref_value = (adc0_data[2] * 3.3f / 4096);

// printf("The temperature origin data is %d \r ,Battery Voltage origin data: %d \n", adc0_data[0], adc0_data[1]);
thread_safe_printf("Battery: %5.2f V, Temperature: %2.0f degrees Celsius, Vref: %5.2fV.\r\n", battery_value, temperature, vref_value);
thread_safe_printf("Battery: %5.2f V, Temperature: %2.0f degrees Celsius, Vref: %5.2fV.\r\n", adc0_data[0] * 3.3f * 2 / 4096, temperature, vref_value);
if (battery_value < 0) {
battery_value = 0;
} else if (battery_value > 100) {
Expand Down
6 changes: 1 addition & 5 deletions Hardware/Source/dac.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
//
// Created by Captain.L on 2023/3/17.
//

#include "dac.h"

void dac_config(void)
Expand All @@ -14,7 +10,7 @@ void dac_config(void)
dac_trigger_source_config(DAC0, DAC_TRIGGER_T5_TRGO); // 配置触发源Timer5_TRGO
dac_trigger_enable(DAC0); // 使能外部触发
dac_wave_mode_config(DAC0, DAC_WAVE_DISABLE); // 不使用波形发生器
dac_output_buffer_enable(DAC0); // 使能输出缓冲区
dac_output_buffer_disable(DAC0); // 使能输出缓冲区

/* 开启DAC */
dac_enable(DAC0); // DAC0使能
Expand Down
1 change: 1 addition & 0 deletions Hardware/Source/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ void dma_config()
// dma_channel_enable(DMA0, DMA_CH4);//暂不开启

/* 配置 DMA0 channel 5 */
dma_deinit(DMA0, DMA_CH5);
dma_flag_clear(DMA0, DMA_CH5, DMA_INTF_FEEIF);
dma_flag_clear(DMA0, DMA_CH5, DMA_INTF_SDEIF);
dma_flag_clear(DMA0, DMA_CH5, DMA_INTF_TAEIF);
Expand Down
5 changes: 5 additions & 0 deletions Hardware/Source/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,9 @@ void gpio_config()
// exti_interrupt_enable(EXTI_0);
// /* 清除中断标志位 */
// exti_interrupt_flag_clear(EXTI_0);

/* 锂电池输出控制 PF9 */
// PWR_OFF;
// gpio_mode_set(GPIOF, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO_PIN_9);
// gpio_output_options_set(GPIOF, GPIO_OTYPE_PP, GPIO_OSPEED_2MHZ, GPIO_PIN_9);
}
6 changes: 3 additions & 3 deletions Hardware/Source/tim.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,14 @@ void tim5_config(uint16_t prescaler, uint16_t period)

timer_init(TIMER5, &timere_initpara); // 初始化定时器

timer_autoreload_value_config(TIMER5, 0xFF);
timer_autoreload_value_config(TIMER5, 0x00);
timer_auto_reload_shadow_enable(TIMER5);
timer_master_output_trigger_source_select(TIMER5, TIMER_TRI_OUT_SRC_UPDATE); // 更新事件

/* 无需中断 */
/* 配置中断优先级 */
// nvic_irq_enable(BSP_TIMER_IRQ, 10, 0); // 设置中断优先级为 3,2
/* 使能中断 */
/* 使能中断 */
// timer_interrupt_enable(TIMER5, TIMER_INT_UP); // 使能更新事件中断

/* 使能定时器 */
Expand Down Expand Up @@ -250,7 +250,7 @@ void tim6_config(uint16_t prescaler, uint16_t period)

/* 无需中断 */
/* 配置中断优先级 */
nvic_irq_enable(TIMER6_IRQn, 10, 0); // 设置中断优先级为 3,2
nvic_irq_enable(TIMER6_IRQn, 10, 0); // 设置中断优先级为 3,2
/* 使能中断 */
timer_interrupt_enable(TIMER6, TIMER_INT_UP); // 使能更新事件中断

Expand Down
2 changes: 1 addition & 1 deletion User/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void bsp_Init(void)
timer_clk_config();
tim2_enable();
tim3_enable();
// tim5_config(240, 10);//10us ->10k
tim5_config(240, 10);//1M 1 100->10k 1M 10 100->1k
tim6_config(240, 100); // 100us
usart_gpio_config();
LCD_Init();
Expand Down
3 changes: 3 additions & 0 deletions User/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,7 @@ OF SUCH DAMAGE.
#define BSP_KEY_PIN GPIO_PIN_0
#define BSP_KEY_IN PAin(0)

#define PWR_ON PFout(9) = 1;
#define PWR_OFF PFout(9) = 0;

#endif /* __MAIN_H */
2 changes: 1 addition & 1 deletion dap_config.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ source [find interface/cmsis-dap.cfg]
transport select swd
source [find target/gd32f450.cfg]
# download speed = 10MHz
#adapter speed 10000
adapter speed 100000
# 不使用复位接口
#reset_config none

0 comments on commit bfd53c6

Please sign in to comment.