generated from hulk/gd32e23x_template
	Compare commits
	
		
			3 Commits
		
	
	
		
			7a7ed3e369
			...
			a64b1427de
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| a64b1427de | |||
| f130674630 | |||
| d356658079 | 
@@ -13,7 +13,6 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#include "tmp112.h"
 | 
			
		||||
 | 
			
		||||
/******************************************************************************/
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										29
									
								
								src/main.c
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								src/main.c
									
									
									
									
									
								
							@@ -18,28 +18,6 @@
 | 
			
		||||
uint32_t g_temperature_uint32;
 | 
			
		||||
uint32_t g_eddy_current_value_uint32;
 | 
			
		||||
 | 
			
		||||
void watchdog_init(void) {
 | 
			
		||||
    /* Enable the LSI clock */
 | 
			
		||||
    rcu_osci_on(RCU_IRC40K);
 | 
			
		||||
    rcu_osci_stab_wait(RCU_IRC40K);
 | 
			
		||||
 | 
			
		||||
    /* Enable the FWDGT clock */
 | 
			
		||||
    // rcu_periph_clock_enable(RCU_FWDGT);
 | 
			
		||||
 | 
			
		||||
    /* Configure FWDGT counter clock: 40KHz(IRC40K) / 64 = 0.625 KHz */
 | 
			
		||||
    fwdgt_config(625, FWDGT_PSC_DIV64); // Set timeout to 1 seconds (625 / 0.625 KHz)
 | 
			
		||||
 | 
			
		||||
    /* Enable FWDGT */
 | 
			
		||||
    fwdgt_enable();
 | 
			
		||||
 | 
			
		||||
    if(RESET != rcu_flag_get(RCU_FLAG_FWDGTRST)){
 | 
			
		||||
        // gd_eval_led_on(LED2);
 | 
			
		||||
        rcu_all_reset_flag_clear();
 | 
			
		||||
 | 
			
		||||
        // while(1);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*!
 | 
			
		||||
    \brief      main function
 | 
			
		||||
    \param[in]  none
 | 
			
		||||
@@ -62,16 +40,13 @@ int main(void) {
 | 
			
		||||
    /* configure LDC1612 */
 | 
			
		||||
    ldc1612_single_ch0_config();
 | 
			
		||||
 | 
			
		||||
    watchdog_init();
 | 
			
		||||
 | 
			
		||||
    while (1) {
 | 
			
		||||
        delay_ms(99);
 | 
			
		||||
        delay_ms(100);
 | 
			
		||||
        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();
 | 
			
		||||
        g_temperature_uint32 = tmp112a_get_raw_channel_result();
 | 
			
		||||
        // printf("1");
 | 
			
		||||
        fwdgt_counter_reload();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										10
									
								
								src/rs485.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/rs485.c
									
									
									
									
									
								
							@@ -135,12 +135,10 @@ void eddy_current_value_report(void) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void tempture_value_report(void) {
 | 
			
		||||
    uint32_t temperature_uint32 = tmp112a_get_raw_channel_result();
 | 
			
		||||
 | 
			
		||||
    package_data[0] = (temperature_uint32 >> 24) & 0xFF;
 | 
			
		||||
    package_data[1] = (temperature_uint32 >> 16) & 0xFF;
 | 
			
		||||
    package_data[2] = (temperature_uint32 >> 8) & 0xFF;
 | 
			
		||||
    package_data[3] = temperature_uint32 & 0xFF;
 | 
			
		||||
    package_data[0] = (g_temperature_uint32 >> 24) & 0xFF;
 | 
			
		||||
    package_data[1] = (g_temperature_uint32 >> 16) & 0xFF;
 | 
			
		||||
    package_data[2] = (g_temperature_uint32 >> 8) & 0xFF;
 | 
			
		||||
    package_data[3] = g_temperature_uint32 & 0xFF;
 | 
			
		||||
 | 
			
		||||
    uint8_t combined_data[7];
 | 
			
		||||
    memcpy(combined_data, package_header, 3);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user