generated from hulk/gd32e23x_template
Organize files
This commit is contained in:
50
src/main.c
50
src/main.c
@@ -9,37 +9,12 @@
|
||||
#include "gd32e23x.h"
|
||||
#include "systick.h"
|
||||
#include "gd32e23x_libopt.h"
|
||||
#include "RS485.h"
|
||||
#include "LDC1612.h"
|
||||
#include "rs485.h"
|
||||
#include "ldc1612.h"
|
||||
#include "led.h"
|
||||
|
||||
uint32_t g_temperature_uint32;
|
||||
|
||||
void led_config(void) {
|
||||
rcu_periph_clock_enable(LED_RCU);
|
||||
|
||||
gpio_mode_set(LED_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LED_PIN);
|
||||
gpio_output_options_set(LED_PORT, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, LED_PIN);
|
||||
gpio_bit_write(LED_PORT, LED_PIN, SET);
|
||||
|
||||
rcu_periph_clock_enable(LED_TIMER_RCU);
|
||||
timer_deinit(LED_TIMER);
|
||||
|
||||
timer_parameter_struct timer_initpara;
|
||||
timer_struct_para_init(&timer_initpara);
|
||||
timer_initpara.prescaler = 799;
|
||||
timer_initpara.alignedmode = TIMER_COUNTER_EDGE;
|
||||
timer_initpara.counterdirection = TIMER_COUNTER_UP;
|
||||
timer_initpara.period = 999;
|
||||
timer_initpara.clockdivision = TIMER_CKDIV_DIV1;
|
||||
timer_init(LED_TIMER, &timer_initpara);
|
||||
|
||||
timer_auto_reload_shadow_enable(LED_TIMER);
|
||||
timer_interrupt_enable(LED_TIMER, TIMER_INT_UP);
|
||||
|
||||
timer_enable(LED_TIMER);
|
||||
|
||||
nvic_irq_enable(LED_IRQ, 2);
|
||||
}
|
||||
uint32_t g_eddy_current_value_uint32;
|
||||
|
||||
/*!
|
||||
\brief main function
|
||||
@@ -50,23 +25,24 @@ void led_config(void) {
|
||||
int main(void) {
|
||||
/* configure systick */
|
||||
systick_config();
|
||||
RS485_config();
|
||||
/* configure USART */
|
||||
rs485_config();
|
||||
/* configure LED */
|
||||
led_config();
|
||||
/* configure I2C */
|
||||
i2c_gpio_config();
|
||||
i2c_config();
|
||||
|
||||
uint32_t raw_value = 0;
|
||||
|
||||
delay_ms(500);
|
||||
ldc1612_iic_get_sensor_infomation();
|
||||
|
||||
/* configure LDC1612 */
|
||||
ldc1612_single_ch0_config();
|
||||
|
||||
while (1) {
|
||||
delay_ms(500);
|
||||
raw_value = ldc1612_get_raw_channel_result(CHANNEL_0);
|
||||
printf("data:%ld\r\n",raw_value);
|
||||
g_temperature_uint32 = TMP112A_ReadTemperature();
|
||||
g_eddy_current_value_uint32 = 0;
|
||||
g_temperature_uint32 = 0;
|
||||
g_eddy_current_value_uint32 = ldc1612_get_raw_channel_result(CHANNEL_0);
|
||||
g_temperature_uint32 = tmp112a_get_raw_channel_result();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user