Ver Fonte

use co-task

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui há 4 anos atrás
pai
commit
325e196056
45 ficheiros alterados com 1110 adições e 359 exclusões
  1. 3 3
      Applications/app/app.c
  2. 4 3
      Applications/bsp/adc.c
  3. 1 1
      Applications/bsp/adc.h
  4. 5 14
      Applications/bsp/bsp.c
  5. 3 2
      Applications/bsp/can.c
  6. 1 1
      Applications/bsp/can.h
  7. 1 1
      Applications/bsp/dma.h
  8. 1 1
      Applications/bsp/gd32_bkp.h
  9. 0 1
      Applications/bsp/gpio.c
  10. 1 1
      Applications/bsp/i2c.c
  11. 0 4
      Applications/bsp/mc_irqs.c
  12. 1 1
      Applications/bsp/pwm.c
  13. 1 1
      Applications/bsp/pwm.h
  14. 12 21
      Applications/bsp/uart.c
  15. 1 1
      Applications/bsp/uart.h
  16. 4 3
      Applications/foc/foc_api.c
  17. 11 9
      Applications/foc/foc_core.c
  18. 1 1
      Applications/foc/foc_type.h
  19. 1 1
      Applications/foc/gas_sensor.h
  20. 13 8
      Applications/foc/hall_sensor.c
  21. 1 1
      Applications/foc/hall_sensor.h
  22. 1 0
      Applications/foc/phase_current.c
  23. 1 2
      Applications/foc/ramp_ctrl.h
  24. 1 1
      Applications/foc/vbus_sensor.c
  25. 0 1
      Applications/libs/backtrace.c
  26. 1 1
      Applications/libs/byte_queue.h
  27. 2 1
      Applications/libs/circle_buffer.h
  28. 1 1
      Applications/libs/crc16.h
  29. 3 41
      Applications/libs/gtime.c
  30. 23 0
      Applications/libs/gtime.h
  31. 0 92
      Applications/libs/os.h
  32. 0 0
      Applications/libs/task_.c
  33. 0 0
      Applications/libs/task_.h
  34. 30 0
      Applications/libs/utils.h
  35. 9 19
      Applications/os/co_task.c
  36. 5 1
      Applications/os/co_task.h
  37. 37 0
      Applications/os/cpu.c
  38. 1 1
      Applications/os/heap_4.c
  39. 37 0
      Applications/os/os_type.h
  40. 16 1
      Applications/os/port/cortex-m4.c
  41. 72 0
      Applications/os/timer.c
  42. 17 0
      Applications/os/timer.h
  43. 9 7
      Applications/prot/can_message.c
  44. 550 88
      Project/MC100_OS.uvoptx
  45. 228 23
      Project/MC100_OS.uvprojx

+ 3 - 3
Applications/app/app.c

@@ -1,9 +1,9 @@
 #include "app/app.h"
 #include "bsp/bsp.h"
-#include "libs/os.h"
+#include "os/timer.h"
+#include "os/co_task.h"
 #include "libs/logger.h"
 #include "prot/can_message.h"
-#include "libs/task.h"
 #include "foc/foc_api.h"
 
 static void _test_timer_handler(timer_t *t);
@@ -14,7 +14,7 @@ void app_start(void){
 	can_message_init();
 	foc_init();
 	timer_post(&test_timer, 2000);
-	task_run();
+	co_task_schedule();
 }
 
 static void _test_timer_handler(timer_t *t){

+ 4 - 3
Applications/bsp/adc.c

@@ -1,5 +1,6 @@
 #include "bsp/adc.h"
-#include "libs/task.h"
+#include "libs/utils.h"
+#include "os/co_task.h"
 static void _gpio_init(void);
 static void _adc0_init(void);
 static void _adc0_insert_chan_init(void);
@@ -169,10 +170,10 @@ s32 adc_sample_regular_channel(int channel, int times) {
 	adc_regular_channel_config(adc_device, 0, channel, ADC_SAMPLETIME_55POINT5);
 	while(count < times){
 restart:		
-		start_time = get_mseconds();
+		start_time = co_task_sys64_ticks();
 		adc_software_trigger_enable(adc_device, ADC_REGULAR_CHANNEL);
     	while(SET != adc_flag_get(adc_device, ADC_FLAG_EOC)){
-			if (get_mseconds() - start_time >= 2){
+			if (co_task_sys64_ticks() - start_time >= 2){
 				goto restart;
 			}
 		};

+ 1 - 1
Applications/bsp/adc.h

@@ -1,7 +1,7 @@
 #ifndef _ADC_H__
 #define _ADC_H__
 #include "bsp/bsp.h"
-#include "libs/os.h"
+#include "os/os_type.h"
 
 /*
 inserted ADC 由timer0 ch3触发,

+ 5 - 14
Applications/bsp/bsp.c

@@ -1,31 +1,22 @@
 #include "bsp/bsp.h"
 #include "libs/logger.h"
-#include "libs/task.h"
+#include "os/os_type.h"
 #include "bsp/uart.h"
 #include "version.h"
 
 static void wdog_enable(void);
-static void sys_tick_init(void);
-static void task_timer_init(void);
+static void normal_task_timer_init(void);
 
 void bsp_init(void){
 	wdog_enable();
-	sys_tick_init();
-	task_ticks_enable();
+	cpu_counts_enable();
 #if LOG_UART==1
 	shark_uart_init(SHARK_UART0);
 #endif
-	task_timer_init();
+	normal_task_timer_init();
 }
 
 
-static void sys_tick_init(void){
-	/* setup systick timer for 1000Hz interrupts */
-	SysTick_Config(SystemCoreClock / 1000);
-	/* configure the systick handler priority */
-	NVIC_SetPriority(SysTick_IRQn, 0x00U);
-}
-
 void system_reboot(void){
 	NVIC_SystemReset();
 }
@@ -83,7 +74,7 @@ int wdog_set_timeout(int wdog_time)
 }
 
 //10 ms
-static void task_timer_init(void) {
+static void normal_task_timer_init(void) {
     timer_parameter_struct timer_initpara;
     u32 timer = TIMER5;
     rcu_periph_clock_enable(RCU_TIMER5);

+ 3 - 2
Applications/bsp/can.c

@@ -1,6 +1,7 @@
 #include <stdio.h>
 #include "bsp.h"
 #include "can.h"
+#include "libs/utils.h"
 
 #define CAN_RX_MESSAGE_RX_ID 1
 #define CAN_SEND_QUEUE_SIZE 32
@@ -132,9 +133,9 @@ static int shark_send_can0_to_fifo(can_trasnmit_message_struct *P_message){
 int shark_can0_send_message(uint32_t can_id, const void*buff, int len){
 	can_trasnmit_message_struct trasnmit_msg;
 	can_id_t can_frame_id;
-	U32 total_frames = ((len + 7) >> 3);
+	u32 total_frames = ((len + 7) >> 3);
 	int send_len = len;
-	U32 frame_id = 1;
+	u32 frame_id = 1;
 	can_frame_id.id = can_id;
 	can_frame_id.total = total_frames;
 

+ 1 - 1
Applications/bsp/can.h

@@ -1,7 +1,7 @@
 #ifndef _Shark_Can0_h__
 #define _Shark_Can0_h__
 #include <stdio.h>
-#include "libs/os.h"
+#include "os/os_type.h"
 #include "config.h"
 //CAN DLC lenght
 #define   CAN_DLC_LENGTH     8

+ 1 - 1
Applications/bsp/dma.h

@@ -1,7 +1,7 @@
 #ifndef _DMA_H__
 #define _DMA_H__
 #include "bsp/bsp.h"
-#include "libs/os.h"
+#include "os/os_type.h"
 
 #define PWM_TIMER_CC3_DMA_DEV DMA0
 #define PWM_TIMER_CC3_DMA_CLK RCU_DMA0

+ 1 - 1
Applications/bsp/gd32_bkp.h

@@ -12,7 +12,7 @@
 #define bkp_read_data bkp_data_read
 #endif
 #include "config.h"
-#include "libs/os.h"
+#include "os/os_type.h"
 
 #define POWER_FIRSTFLAG_REG BKP_DATA_0
 #define POWER_FIRSTFLAG_VALUE 0x5AA5

+ 0 - 1
Applications/bsp/gpio.c

@@ -1,6 +1,5 @@
 
 #include "bsp/gpio.h"
-#include "libs/os.h"
 
 /*
 * gpio.c

+ 1 - 1
Applications/bsp/i2c.c

@@ -1,6 +1,6 @@
 #include "bsp.h"
 #include "i2c.h"
-
+#include "libs/utils.h"
 static int _shark_i2c_rw_bytes(uint32_t index, uint8_t address, uint8_t reg, uint8_t *buffer, int length, int write);
 
 #define iic_device(id) ((id == 0)?I2C0:I2C1)

+ 0 - 4
Applications/bsp/mc_irqs.c

@@ -75,15 +75,11 @@ void DebugMon_Handler(void)
 
 extern void mc_phase_current_irq(void);
 extern void mc_brake_irq(void);
-extern void system_tick_handler(void);
 extern void hall_sensor_handler(void);
 extern void foc_normal_task(void);
 extern void foc_brake_handler(bool brake);
 extern void foc_pwm_up_handler(void);
 
-void SysTick_Handler(void) {
-	system_tick_handler();
-}
 
 void ADC0_1_IRQHandler(void)
 {

+ 1 - 1
Applications/bsp/pwm.c

@@ -1,6 +1,6 @@
 #include "bsp/pwm.h"
 #include "bsp/adc.h"
-#include "libs/task.h"
+#include "os/timer.h"
 /*
 以下主要是在某一相电路无法采集的时候,需要对这相的pwm挖坑处理
 timer 分配:

+ 1 - 1
Applications/bsp/pwm.h

@@ -1,7 +1,7 @@
 #ifndef _PWM_H__
 #define _PWM_H__
 #include "bsp/bsp.h"
-#include "libs/os.h"
+#include "os/os_type.h"
 #include "bsp/dma.h"
 
 #define TIMxCCER_MASK_CH012        ((uint16_t)  (TIMER_CHCTL2_CH0EN|TIMER_CHCTL2_CH0NEN|\

+ 12 - 21
Applications/bsp/uart.c

@@ -1,8 +1,8 @@
 #include "uart.h"
-#include "libs/os.h"
-#include "libs/task.h"
+#include "os/co_task.h"
 #include "libs/crc16.h"
 #include "libs/logger.h"
+#include "libs/utils.h"
 
 #define SHARK_UART_BAUDRATE				38400
 
@@ -37,7 +37,6 @@ static u8 shark_uart1_rx_cache[SHARK_UART_RX_MEM_SIZE];
 #endif
 
 static shark_uart_t _shark_uart[1];
-static task_t _uart_task;
 ///static bool uart_no_data = false;
 #if ENABLE_RX_DMA==1
 #define update_dma_w_pos(uart) circle_update_write_position(&uart->rx_queue, SHARK_UART_RX_MEM_SIZE - DMA_CHCNT(SHARK_UART0_rx_dma, uart->rx_dma_ch))
@@ -245,21 +244,16 @@ static void shark_uart_device_init(shark_uart_t *uart){
 #endif
 }
 
-static u32 shark_uart_handler(void)
+static void shark_uart_task(void *args)
 {
-	shark_uart_t *uart = _shark_uart + SHARK_UART0;
-	if (uart->uart_com != 0) {
-		shark_uart_rx(uart);
-		shark_uart_dma_tx(uart);
-	}
-#if UART_NUM==2	
-	uart = _shark_uart + SHARK_UART1;
-	if (uart->uart_com != 0) {
-		shark_uart_rx(uart);
-		shark_uart_dma_tx(uart);
+	shark_uart_t *uart = (shark_uart_t *)args;
+	while(1) {
+		if(uart->uart_com != 0) {
+			shark_uart_rx(uart);
+			shark_uart_dma_tx(uart);
+		}
+		co_task_yield();
 	}
-#endif	
-	return 0;
 }
 
 
@@ -368,11 +362,8 @@ void shark_uart_init(uart_enum_t uart_no)
 #endif
 	shark_uart_tx_dma_init(uart);
 	usart_enable(uart->uart_com);
-	
-	if (_uart_task.handler == NULL) {
-		_uart_task.handler = shark_uart_handler;
-		task_add(&_uart_task);
-	}
+
+	co_task_create(shark_uart_task, uart, 256);
 	if (uart_no == SHARK_UART0) {
 #if ENABLE_RX_DMA==0
 		nvic_irq_enable(UART3_IRQn, 3, 0);

+ 1 - 1
Applications/bsp/uart.h

@@ -1,6 +1,6 @@
 #pragma once
 #include "bsp/bsp.h"
-#include "libs/os.h"
+#include "os/co_task.h"
 #include "libs/byte_queue.h"
 #include "libs/circle_buffer.h"
 

+ 4 - 3
Applications/foc/foc_api.c

@@ -1,5 +1,6 @@
 #include <string.h>
-#include "libs/task.h"
+#include "os/os_type.h"
+#include "libs/utils.h"
 #include "bsp/bsp.h"
 #include "bsp/adc.h"
 #include "bsp/pwm.h"
@@ -125,7 +126,7 @@ void foc_current_calibrate(void){
 	pwm_disable_channel();
 	foc_pwm_start(false);
 
-	task_udelay(10);
+	cpu_udelay(10);
 	
 	phase_current_init(&g_foc.current_samp);
 	g_foc.current_samp.is_calibrating_offset = true;
@@ -135,7 +136,7 @@ void foc_current_calibrate(void){
 	while(g_foc.current_samp.offset_sample_count != 0){};
 	
 	foc_pwm_start(false);
-	task_udelay(100);
+	cpu_udelay(100);
 	phase_current_init(&g_foc.current_samp);	
 	g_foc.current_samp.sector = SECTOR_1;
 	foc_pwm_start(true);

+ 11 - 9
Applications/foc/foc_core.c

@@ -1,4 +1,4 @@
-#include "libs/task.h"
+#include "os/co_task.h"
 #include "bsp/pwm.h"
 #include "bsp/adc.h"
 #include "foc_core.h"
@@ -43,12 +43,12 @@ motor_foc_t g_foc = {
 };
 
 
-static u32 foc_measure_task(void);
+static void foc_measure_task(void*);
 
 void foc_core_init(void) {
 	vbus_sensor_init();
 	ntc_sensor_init();
-	task_start(foc_measure_task, 0);
+	co_task_create(foc_measure_task, NULL, 256);
 }
 
 #if 1
@@ -249,12 +249,14 @@ void foc_normal_task(void) {
 	FOC_Normal_Task(&g_foc);
 }
 
-static u32 foc_measure_task(void){
-	vbus_sample_voltage();
-	ntc_sensor_sample();
-	LowPass_Filter(g_foc.vbus, vbus_get_voltage(), 0.1f);
-	wdog_reload();
-	return 1;
+static void foc_measure_task(void *args){
+	while(1) {
+		vbus_sample_voltage();
+		ntc_sensor_sample();
+		LowPass_Filter(g_foc.vbus, vbus_get_voltage(), 0.1f);
+		wdog_reload();
+		co_task_yield();
+	}
 }
 
 

+ 1 - 1
Applications/foc/foc_type.h

@@ -1,7 +1,7 @@
 #ifndef _FOC_TYPE_H__
 #define _FOC_TYPE_H__
 #include <math.h>
-#include "libs/os.h"
+#include "os/os_type.h"
 #include "math/fast_math.h"
 #include "pi_controller.h"
 #include "ramp_ctrl.h"

+ 1 - 1
Applications/foc/gas_sensor.h

@@ -1,6 +1,6 @@
 #ifndef _GAS_SENSOR_H__
 #define _GAS_SENSOR_H__
-#include "libs/os.h"
+#include "os/os_type.h"
 
 typedef struct {
 	float voltage;

+ 13 - 8
Applications/foc/hall_sensor.c

@@ -1,7 +1,8 @@
 #include <string.h>
 #include "bsp/bsp.h"
 #include "bsp/mc_hall_gpio.h"
-#include "libs/task.h"
+#include "os/co_task.h"
+#include "libs/utils.h"
 #include "math/fast_math.h"
 #include "hall_sensor.h"
 #include "foc/foc_api.h"
@@ -34,13 +35,17 @@ static hall_sample_t h_samples;
 #define tick_2_s(tick) ((float)tick / (float)SYSTEM_CLOCK)
 
 static u32 __inline delta_ticks(u32 prev) {
-	u32 now = task_ticks_abs();
+	u32 now = cpu_counts_abs();
 	if (now >= prev) {
 		return (now - prev);
 	}
 	return (0xFFFFFFFFU - prev + now) + 1;
 }
 
+static u32 __inline get_seconds(void) {
+	return co_task_sys64_ticks()/1000;
+}
+
 static void _hall_put_sample(float angle, u32 ticks) {
 	hall_sample_t *s = &h_samples;
 	s->index += 1;
@@ -133,7 +138,7 @@ int hall_sensor_calibrate(float voltage, u16 *hall_table){
 	foc_pwm_start(true);
 	for (int i = 0;i < 1000;i++) {
 		foc_set_dq_command((float)i * voltage / 1000.0f, 0.0f);
-		task_udelay(1000);
+		delay_ms(1000);
 	}
 	float sin_hall[8];
 	float cos_hall[8];
@@ -141,12 +146,12 @@ int hall_sensor_calibrate(float voltage, u16 *hall_table){
 	memset(sin_hall, 0, sizeof(sin_hall));
 	memset(cos_hall, 0, sizeof(cos_hall));
 	memset(hall_iterations, 0, sizeof(hall_iterations));
-	task_udelay(50 * 1000);
+	delay_ms(50 * 1000);
 	// Forwards
 	for (int i = 0;i < 3;i++) {
 		for (int j = 0;j < 360;j++) {
 			hall_sensor_set_theta(true, j);
-			task_udelay(10 * 1000);
+			delay_ms(10 * 1000);
 
 			int hall = get_hall_stat(7);
 			float s, c;
@@ -161,7 +166,7 @@ int hall_sensor_calibrate(float voltage, u16 *hall_table){
 	for (int i = 0;i < 3;i++) {
 		for (int j = 360;j >= 0;j--) {
 			hall_sensor_set_theta(true, j);
-			task_udelay(10 * 1000);
+			delay_ms(10 * 1000);
 
 			int hall = get_hall_stat(7);
 			float s, c;
@@ -199,7 +204,7 @@ void hall_sensor_handler(void) {
 			_hall.working = true;
 			_hall.state = state_now;
 			_hall.theta = theta_now;
-			_hall.ticks = task_ticks_abs();
+			_hall.ticks = cpu_counts_abs();
 		}
 		return;
 	}
@@ -276,7 +281,7 @@ void hall_sensor_handler(void) {
 		_hall.degree_per_s = _hall_avg_speed();
 		_hall.e_filted_rpm = _hall.degree_per_s / 360.0f * 60.0f; //电角速度
 	}
-	_hall.ticks = task_ticks_abs();
+	_hall.ticks = cpu_counts_abs();
 	_hall.second = get_seconds();
 	_hall.theta = theta_now;
 	_hall.state = state_now;

+ 1 - 1
Applications/foc/hall_sensor.h

@@ -1,6 +1,6 @@
 #ifndef _HALL_SENSOR_H__
 #define _HALL_SENSOR_H__
-#include "libs/os.h"
+#include "os/os_type.h"
 #include "bsp/bsp.h"
 
 #define NEGATIVE          (int8_t)-1

+ 1 - 0
Applications/foc/phase_current.c

@@ -1,5 +1,6 @@
 #include "bsp/adc.h"
 #include "foc_type.h"
+#include "libs/utils.h"
 
 #define MOS_Rds_Calibrate 1
 

+ 1 - 2
Applications/foc/ramp_ctrl.h

@@ -1,7 +1,6 @@
 #ifndef _RAMP_CTRL_H__
 #define _RAMP_CTRL_H__
-#include "libs/os.h"
-#include "libs/task.h"
+#include "os/timer.h"
 typedef struct {
 	timer_t timer;
 	float start_point;

+ 1 - 1
Applications/foc/vbus_sensor.c

@@ -11,7 +11,7 @@ void vbus_sensor_init(void){
 void vbus_sample_voltage(void){
 	u32 vadc = adc_sample_regular_channel(VBUS_V_CHAN, 16);
 
-	_vbus.voltage_avg = ((float)vadc)/(65536.0f) * ADC_REFERENCE_VOLTAGE / VBUS_PARTITIONING_FACTOR;
+	//_vbus.voltage_avg = ((float)vadc)/(65536.0f) * ADC_REFERENCE_VOLTAGE / VBUS_PARTITIONING_FACTOR;
 }
 
 

+ 0 - 1
Applications/libs/backtrace.c

@@ -1,7 +1,6 @@
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include "task.h"
 #include "libs/backtrace.h"
 #include "bsp/gd32_bkp.h"
 

+ 1 - 1
Applications/libs/byte_queue.h

@@ -1,6 +1,6 @@
 #pragma once
 
-#include "libs/os.h"
+#include "os/os_type.h"
 #include "bsp/bsp.h"
 
 typedef struct {

+ 2 - 1
Applications/libs/circle_buffer.h

@@ -2,7 +2,8 @@
 #define _Cirule_Buffer_h__
 
 #include <stdint.h>
-#include "libs/os.h"
+#include "os/os_type.h"
+#include "libs/utils.h"
 
 #define CBUFF_SUCCESS 0
 #define CBUFF_FULL -1

+ 1 - 1
Applications/libs/crc16.h

@@ -1,6 +1,6 @@
 #pragma once
 
-#include "libs/os.h"
+#include "os/os_type.h"
 
 u16 crc16_update_byte(u16 crc, u8 value);
 u16 crc16_update(u16 crc, const u8 *data, u16 size);

+ 3 - 41
Applications/libs/os.c → Applications/libs/gtime.c

@@ -1,6 +1,6 @@
-#include "os.h"
-#include "libs/task.h"
-#include "bsp/bsp.h"
+#include "gtime.h"
+#include <time.h>
+#include "os/co_task.h"
 //one while will use 4 ins
 
 /* below function is dumy here, will overide by xxx_rtc.c */
@@ -12,44 +12,6 @@ __weak uint32_t rtc_get_timestamp(void){
 }
 
 
-void task_delay(int ms) {
-	os_udelay(ms*1000);
-}
-
-void os_ticks_enable(void)
-{
-	CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
-	DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
-}
-
-u32 os_ticks_abs(void)
-{
-	return DWT->CYCCNT;
-}
-
-u32 os_ticks_rel(u32 start)
-{
-	u32 ticks = DWT->CYCCNT;
-
-	if (ticks >= start) {
-		return ticks - start;
-	}
-
-	return 0xFFFFFFFF - start + ticks + 1;
-}
-
-void os_ticks_delay(u32 ticks)
-{
-	volatile u32 start = os_ticks_abs();
-	while (os_ticks_rel(start) < ticks);
-}
-
-void os_udelay(u32 delay)
-{
-	os_ticks_delay(delay * (SystemCoreClock / 1000000));
-}
-
-
 /* set rtc time, used utc timestamp, can not include time zone*/
 uint32_t calendar_to_utc(time_val *time){
 

+ 23 - 0
Applications/libs/gtime.h

@@ -0,0 +1,23 @@
+#ifndef _G_Time_H__
+#define _G_Time_H__
+
+#include "os/os_type.h"
+
+typedef struct{
+	uint16_t year; 	/*YYYY*/
+	uint8_t month;
+	uint8_t day;
+	uint8_t hour;
+	uint8_t minute;
+	uint8_t second;
+}time_val;
+
+
+uint32_t calendar_to_utc(time_val *time);
+void set_utc_time(time_val *time);
+void get_local_time(time_val *out, int8_t tz);
+uint32_t get_timestamp(void);
+uint32_t get_timestamp_with_time_zone(int8_t tz);
+
+#endif /* _G_Time_H__ */
+

+ 0 - 92
Applications/libs/os.h

@@ -1,92 +0,0 @@
-#ifndef _Shark_OS_H__
-#define _Shark_OS_H__
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <time.h>
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-typedef uint8_t u8;
-typedef uint16_t u16;
-typedef uint32_t u24;
-typedef uint32_t u32;
-typedef uint64_t u64;
-
-typedef int8_t s8;
-typedef int16_t s16;
-typedef int32_t s24;
-typedef int32_t s32;
-typedef int64_t s64;
-
-/* These types must be 16-bit, 32-bit or larger integer */
-typedef signed int		S32;
-typedef unsigned int	U32;
-typedef unsigned long int U64;
-/* These types must be 8-bit integer */
-typedef signed char	S8;
-
-typedef unsigned char	U8;
-
-/* These types must be 16-bit integer */
-typedef signed short 	S16;
-typedef unsigned short	U16;
-
-typedef signed char	int8;
-typedef signed short 	int16;
-typedef signed int		int32;
-typedef unsigned char	uint8;
-typedef unsigned short	uint16;
-typedef unsigned int	uint32;
-
-typedef struct{
-	uint16_t year; 	/*YYYY*/
-	uint8_t month;
-	uint8_t day;
-	uint8_t hour;
-	uint8_t minute;
-	uint8_t second;
-}time_val;
-
-
-void task_delay(int ms);
-void os_udelay(u32 us);
-
-uint32_t calendar_to_utc(time_val *time);
-void set_utc_time(time_val *time);
-void get_local_time(time_val *out, int8_t tz);
-uint32_t get_timestamp(void);
-uint32_t get_timestamp_with_time_zone(int8_t tz);
-
-#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
-#define min(a,b) (a>b?b:a)
-#define MAX(x, y) ((x)>(y)?(x):(y))
-
-#define delay_us os_udelay
-
-static __inline__ void delay_ms(u32 ms) {
-	os_udelay(ms*1000);
-}
-
-static __inline__ u16 DECODE_U16(u8 *buff) {
-	return (((U16)(buff[1]) << 8) | buff[0]);
-}
-
-static __inline__ u32 DECODE_U24(u8 *buff) {
-	return ((U32)(buff[2]) << 16 | DECODE_U16(buff));
-}
-
-static __inline__ u16 DECODE_U32(u8 *buff) {
-	return ((U32)(buff[3]) << 24 | DECODE_U24(buff));
-}
-
-
-#endif /* _Shark_OS_H__ */
-

+ 0 - 0
Applications/libs/task.c → Applications/libs/task_.c


+ 0 - 0
Applications/libs/task.h → Applications/libs/task_.h


+ 30 - 0
Applications/libs/utils.h

@@ -0,0 +1,30 @@
+#ifndef _UTILS_H__
+#define _UTILS_H__
+
+#include "os/os_type.h"
+#include "os/co_task.h"
+
+#define delay_us cpu_udelay
+
+static __inline__ void delay_ms(u32 ms) {
+	cpu_udelay(ms*1000);
+}
+
+static __inline__ u16 DECODE_U16(u8 *buff) {
+	return (((u16)(buff[1]) << 8) | buff[0]);
+}
+
+static __inline__ u32 DECODE_U24(u8 *buff) {
+	return ((u32)(buff[2]) << 16 | DECODE_U16(buff));
+}
+
+static __inline__ u16 DECODE_U32(u8 *buff) {
+	return ((u32)(buff[3]) << 24 | DECODE_U24(buff));
+}
+
+#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
+#define min(a,b) (a>b?b:a)
+#define MAX(x, y) ((x)>(y)?(x):(y))
+
+
+#endif /* _UTILS_H__ */

+ 9 - 19
Applications/os/co_task.c

@@ -15,20 +15,22 @@ typedef struct _tcb{
 }tcb_t;
 
 volatile tcb_t *current_tcb;
+u64 g_task_ticks64;
+u32 g_task_ticks;
 
 static tcb_t *g_tcb_head;
 static volatile u32 _context_swap_cnt = 0;
-static u32 g_task_ticks;
 
 extern void arch_save_context(void);
 extern void arch_restore_context(void);
 extern void arch_start_first_task(void);
 extern u32 arch_stack_init(volatile u32 *stack_base, u16 stack_size, void *fptr, void *p_arg);
+extern void co_task_tick_init(void);
 
 static tcb_t *_next_task(void);
 static void _task_add(tcb_t *tcb);
 static void _task_context_swap(tcb_t *prev, tcb_t *next);
-static void sys_tick_init(void);
+
 
 void *co_task_create(task_func func, void *args, u16 stack_size){
 	tcb_t *p_tcb = co_malloc(sizeof(tcb_t));
@@ -42,7 +44,7 @@ void *co_task_create(task_func func, void *args, u16 stack_size){
 }
 
 void co_task_schedule(void){
-	sys_tick_init();
+	co_task_tick_init();
 	current_tcb = g_tcb_head;
 	arch_start_first_task();
 	while(1);
@@ -71,6 +73,10 @@ void co_task_delay(int ms){
 	}
 }
 
+u64 co_task_sys64_ticks(void) {
+	return g_task_ticks64;
+}
+
 /* peak next task to run */
 static tcb_t *_next_task(void) {
 	tcb_t *next = current_tcb->next;
@@ -110,22 +116,6 @@ static void _task_context_swap(tcb_t *prev, tcb_t *next) {
 	}
 }
 
-static void sys_tick_init(void){
-	/* setup systick timer for 1000Hz interrupts */
-	SysTick_Config(SystemCoreClock / 1000);
-	/* configure the systick handler priority */
-	NVIC_SetPriority(SysTick_IRQn, 0x00U);
-}
-
-
-static void task_ticks(void) {
-	g_task_ticks ++;
-}
-
-void SysTick_Handler(void) {
-	task_ticks();
-}
-
 extern void *pvPortMalloc(u32);
 extern void vPortFree(void *);
 void *co_malloc(u32 size) {

+ 5 - 1
Applications/os/co_task.h

@@ -1,12 +1,16 @@
 #ifndef _OS_TASK_H__
 #define _OS_TASK_H__
-#include "libs/os.h"
 #include "bsp/bsp.h"
+#include "os/os_type.h"
 /*
 Task如果没有调用task_yield/delay 永远执行下去
 */
 typedef void (*task_func)(void *);
 
+void cpu_counts_enable(void);
+u32 cpu_counts_abs(void);
+void cpu_udelay(u32 delay);
+u64 co_task_sys64_ticks(void);
 void *co_task_create(task_func func, void *param, u16 stack_size);
 void co_task_delay(int ms); //task 延时
 void co_task_yield(void); //task 让出cpu

+ 37 - 0
Applications/os/cpu.c

@@ -0,0 +1,37 @@
+#include "os/os_type.h"
+#include "bsp/bsp.h"
+
+void cpu_counts_enable(void)
+{
+	CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
+	DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
+}
+
+u32 cpu_counts_abs(void)
+{
+	return DWT->CYCCNT;
+}
+
+static u32 cpu_counts_rel(u32 start)
+{
+	u32 ticks = DWT->CYCCNT;
+
+	if (ticks >= start) {
+		return ticks - start;
+	}
+
+	return 0xFFFFFFFF - start + ticks + 1;
+}
+
+static void cpu_counts_delay(u32 ticks)
+{
+	volatile u32 start = cpu_counts_abs();
+	while (cpu_counts_rel(start) < ticks);
+}
+
+void cpu_udelay(u32 delay)
+{
+	cpu_counts_delay(delay * (SystemCoreClock / 1000000));
+}
+
+

+ 1 - 1
Applications/os/heap_4.c

@@ -38,7 +38,7 @@
 
 #define portBYTE_ALIGNMENT			8
 #define portBYTE_ALIGNMENT_MASK 	0x0007
-#define configTOTAL_HEAP_SIZE    (10*1024)
+#define configTOTAL_HEAP_SIZE    (32*1024)
 #define configASSERT(x)
 /* Block sizes must not get too small. */
 #define heapMINIMUM_BLOCK_SIZE	( ( size_t ) ( xHeapStructSize << 1 ) )

+ 37 - 0
Applications/os/os_type.h

@@ -0,0 +1,37 @@
+#ifndef _OS_Type_H__
+#define _OS_Type_H__
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+typedef uint8_t u8;
+typedef uint16_t u16;
+typedef uint32_t u24;
+typedef uint32_t u32;
+typedef uint64_t u64;
+
+typedef int8_t s8;
+typedef int16_t s16;
+typedef int32_t s24;
+typedef int32_t s32;
+typedef int64_t s64;
+
+typedef signed char	int8;
+typedef signed short 	int16;
+typedef signed int		int32;
+typedef unsigned char	uint8;
+typedef unsigned short	uint16;
+typedef unsigned int	uint32;
+
+#endif /* _OS_Type_H__ */
+

+ 16 - 1
Applications/os/port/cortex-m4.c

@@ -1,6 +1,13 @@
-#include "libs/os.h"
+#include "os/os_type.h"
 #include "bsp/bsp.h"
 
+void co_task_tick_init(void){
+	/* setup systick timer for 1000Hz interrupts */
+	SysTick_Config(SystemCoreClock / 1000);
+	/* configure the systick handler priority */
+	NVIC_SetPriority(SysTick_IRQn, 0x00U);
+}
+
 u32 arch_stack_init(u32 *stack_base, u16 stack_size, void *fptr, void *p_arg) {
 	u32 *p_stk = &stack_base[stack_size];
 	u32 u_stk = (u32) p_stk;
@@ -50,4 +57,12 @@ __asm void arch_restore_context(void){
 	LDMFD	sp!, {r0-r12, pc}
 }
 
+extern u64 g_task_ticks64;
+extern u32 g_task_ticks;
+
+void SysTick_Handler(void) {
+	g_task_ticks ++;
+	g_task_ticks64 ++;
+}
+
 

+ 72 - 0
Applications/os/timer.c

@@ -0,0 +1,72 @@
+#include "os/timer.h"
+#include "os/co_task.h"
+#include "bsp/bsp.h"
+
+extern u64 g_task_ticks64;
+
+static void timer_task_handler(void *);
+static timer_t timer_head = {
+	.prev = &timer_head,
+	.next = &timer_head
+};
+static bool _timer_start = false;
+
+void timer_post(timer_t *timer, u32 delay)
+{
+	timer_t *node;
+	u64 time = g_task_ticks64 + (delay > 0 ? delay : 1);
+	__disable_irq();
+	if (timer->prev != NULL) {
+		timer->prev->next = timer->next;
+	}
+
+	if (timer->next != NULL) {
+		timer->next->prev = timer->prev;
+	}
+
+	for (node = timer_head.next; node != &timer_head; node = node->next) {
+		if (node->time > time) {
+			break;
+		}
+	}
+
+	timer->prev = node->prev;
+	node->prev->next = timer;
+	node->prev = timer;
+	timer->next = node;
+	timer->time = time;
+	__enable_irq();
+	if (!_timer_start) {
+		co_task_create(timer_task_handler, NULL, 384);
+		_timer_start = true;
+	}
+}
+
+void timer_cancel(timer_t *timer)
+{
+	__disable_irq();
+	if (timer->prev != NULL && timer->next != NULL) {
+		timer->prev->next = timer->next;
+		timer->next->prev = timer->prev;
+	}
+	timer->next = timer->prev = timer;
+	__enable_irq();
+}
+
+static void timer_task_handler(void *args)
+{
+	while (1) {
+		timer_t *timer = timer_head.next;
+
+		if (timer->time > g_task_ticks64) {
+			co_task_delay((u32)(timer->time - g_task_ticks64));
+		}
+
+		if (timer != &timer_head) {
+			timer_cancel(timer);
+			timer->handler(timer);
+		}
+		co_task_yield();
+	}
+}
+

+ 17 - 0
Applications/os/timer.h

@@ -0,0 +1,17 @@
+#pragma once
+
+#include "os/os_type.h"
+
+typedef struct _timer {
+	void (*handler)(struct _timer *timer);
+	struct _timer *prev;
+	struct _timer *next;
+	u64 time;	
+} timer_t;
+
+#define TIMER_INIT(timer, handler) 	{ handler, &timer, &timer }
+
+void timer_post(timer_t *timer, u32 delay);
+void timer_cancel(timer_t *timer);
+void timer_task_start(void);
+

+ 9 - 7
Applications/prot/can_message.c

@@ -1,7 +1,7 @@
 #include "bsp/bsp.h"
-#include "libs/os.h"
+#include "os/co_task.h"
 #include "libs/logger.h"
-#include "libs/task.h"
+#include "libs/utils.h"
 #include "can_message.h"
 
 #define MAX_CAN_MESSAGE 4
@@ -13,7 +13,7 @@ static node_list_t _idle_list = LIST_HEAD_INIT(_idle_list);
 
 static void can_process_message(can_message_t *message);
 static void free_can_message(can_message_t *message);
-static u32 _can_poll_task(void);
+static void _can_poll_task(void*);
 static void handle_can_frame(void);
 
 void can_message_init(void){
@@ -22,7 +22,7 @@ void can_message_init(void){
 		list_add_tail(&_idle_list, &msg_list[i].list);
 	}
 	shark_can0_init();
-	task_start(_can_poll_task, 0);
+	co_task_create(_can_poll_task, NULL, 256);
 }
 
 void put_raw_message(can_id_t id, uint8_t *data, int len) {
@@ -49,9 +49,11 @@ static void free_raw_message(msg_list_t *raw) {
 	list_add_tail(&_idle_list, &raw->list);
 }
 
-static u32 _can_poll_task(void) {
-	handle_can_frame();
-	return 0;
+static void _can_poll_task(void *args) {
+	while(1) {
+		handle_can_frame();
+		co_task_yield();
+	}
 }
 
 

+ 550 - 88
Project/MC100_OS.uvoptx

@@ -73,11 +73,11 @@
         <LExpSel>0</LExpSel>
       </OPTXL>
       <OPTFL>
-        <tvExp>0</tvExp>
+        <tvExp>1</tvExp>
         <tvExpOptDlg>0</tvExpOptDlg>
         <IsCurrentTarget>1</IsCurrentTarget>
       </OPTFL>
-      <CpuCode>0</CpuCode>
+      <CpuCode>255</CpuCode>
       <DebugOpt>
         <uSim>0</uSim>
         <uTrg>1</uTrg>
@@ -148,24 +148,14 @@
           <Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0GD32F30x_HD -FS08000000 -FL010000 -FP0($$Device:GD32F303CC$Flash\GD32F30x_HD.FLM))</Name>
         </SetRegEntry>
       </TargetDriverDllRegistry>
-      <Breakpoint>
-        <Bp>
-          <Number>0</Number>
-          <Type>0</Type>
-          <LineNumber>17</LineNumber>
-          <EnabledFlag>1</EnabledFlag>
-          <Address>134218470</Address>
-          <ByteObject>0</ByteObject>
-          <HtxType>0</HtxType>
-          <ManyObjects>0</ManyObjects>
-          <SizeOfObject>0</SizeOfObject>
-          <BreakByAccess>0</BreakByAccess>
-          <BreakIfRCount>1</BreakIfRCount>
-          <Filename>..\Applications\main.c</Filename>
-          <ExecCommand></ExecCommand>
-          <Expression>\\MC100_OS\../Applications/main.c\17</Expression>
-        </Bp>
-      </Breakpoint>
+      <Breakpoint/>
+      <WatchWindow1>
+        <Ww>
+          <count>0</count>
+          <WinNumber>1</WinNumber>
+          <ItemText>g_tcb_head</ItemText>
+        </Ww>
+      </WatchWindow1>
       <Tracepoint>
         <THDelay>0</THDelay>
       </Tracepoint>
@@ -213,7 +203,7 @@
 
   <Group>
     <GroupName>Application</GroupName>
-    <tvExp>0</tvExp>
+    <tvExp>1</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
     <RteFlg>0</RteFlg>
@@ -229,26 +219,26 @@
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
-  </Group>
-
-  <Group>
-    <GroupName>GD32F30x_Drivers</GroupName>
-    <tvExp>0</tvExp>
-    <tvExpOptDlg>0</tvExpOptDlg>
-    <cbSel>0</cbSel>
-    <RteFlg>0</RteFlg>
     <File>
-      <GroupNumber>2</GroupNumber>
+      <GroupNumber>1</GroupNumber>
       <FileNumber>2</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_adc.c</PathWithFileName>
-      <FilenameWithoutPath>gd32f30x_adc.c</FilenameWithoutPath>
+      <PathWithFileName>..\Applications\app\app.c</PathWithFileName>
+      <FilenameWithoutPath>app.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
+  </Group>
+
+  <Group>
+    <GroupName>Foc</GroupName>
+    <tvExp>1</tvExp>
+    <tvExpOptDlg>0</tvExpOptDlg>
+    <cbSel>0</cbSel>
+    <RteFlg>0</RteFlg>
     <File>
       <GroupNumber>2</GroupNumber>
       <FileNumber>3</FileNumber>
@@ -256,8 +246,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_bkp.c</PathWithFileName>
-      <FilenameWithoutPath>gd32f30x_bkp.c</FilenameWithoutPath>
+      <PathWithFileName>..\Applications\foc\circle_limitation.c</PathWithFileName>
+      <FilenameWithoutPath>circle_limitation.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -268,8 +258,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_can.c</PathWithFileName>
-      <FilenameWithoutPath>gd32f30x_can.c</FilenameWithoutPath>
+      <PathWithFileName>..\Applications\foc\foc_api.c</PathWithFileName>
+      <FilenameWithoutPath>foc_api.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -280,8 +270,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_dma.c</PathWithFileName>
-      <FilenameWithoutPath>gd32f30x_dma.c</FilenameWithoutPath>
+      <PathWithFileName>..\Applications\foc\foc_core.c</PathWithFileName>
+      <FilenameWithoutPath>foc_core.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -292,8 +282,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_exti.c</PathWithFileName>
-      <FilenameWithoutPath>gd32f30x_exti.c</FilenameWithoutPath>
+      <PathWithFileName>..\Applications\foc\foc_stm.c</PathWithFileName>
+      <FilenameWithoutPath>foc_stm.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -304,8 +294,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_fmc.c</PathWithFileName>
-      <FilenameWithoutPath>gd32f30x_fmc.c</FilenameWithoutPath>
+      <PathWithFileName>..\Applications\foc\gas_sensor.c</PathWithFileName>
+      <FilenameWithoutPath>gas_sensor.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -316,8 +306,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_fwdgt.c</PathWithFileName>
-      <FilenameWithoutPath>gd32f30x_fwdgt.c</FilenameWithoutPath>
+      <PathWithFileName>..\Applications\foc\hall_sensor.c</PathWithFileName>
+      <FilenameWithoutPath>hall_sensor.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -328,8 +318,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_gpio.c</PathWithFileName>
-      <FilenameWithoutPath>gd32f30x_gpio.c</FilenameWithoutPath>
+      <PathWithFileName>..\Applications\foc\ntc_sensor.c</PathWithFileName>
+      <FilenameWithoutPath>ntc_sensor.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -340,8 +330,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_i2c.c</PathWithFileName>
-      <FilenameWithoutPath>gd32f30x_i2c.c</FilenameWithoutPath>
+      <PathWithFileName>..\Applications\foc\phase_current.c</PathWithFileName>
+      <FilenameWithoutPath>phase_current.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -352,8 +342,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_misc.c</PathWithFileName>
-      <FilenameWithoutPath>gd32f30x_misc.c</FilenameWithoutPath>
+      <PathWithFileName>..\Applications\foc\pi_controller.c</PathWithFileName>
+      <FilenameWithoutPath>pi_controller.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -364,8 +354,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_rcu.c</PathWithFileName>
-      <FilenameWithoutPath>gd32f30x_rcu.c</FilenameWithoutPath>
+      <PathWithFileName>..\Applications\foc\ramp_ctrl.c</PathWithFileName>
+      <FilenameWithoutPath>ramp_ctrl.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -376,8 +366,8 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_rtc.c</PathWithFileName>
-      <FilenameWithoutPath>gd32f30x_rtc.c</FilenameWithoutPath>
+      <PathWithFileName>..\Applications\foc\svpwm.c</PathWithFileName>
+      <FilenameWithoutPath>svpwm.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
@@ -388,120 +378,592 @@
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_timer.c</PathWithFileName>
-      <FilenameWithoutPath>gd32f30x_timer.c</FilenameWithoutPath>
+      <PathWithFileName>..\Applications\foc\vbus_sensor.c</PathWithFileName>
+      <FilenameWithoutPath>vbus_sensor.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
+  </Group>
+
+  <Group>
+    <GroupName>Math</GroupName>
+    <tvExp>0</tvExp>
+    <tvExpOptDlg>0</tvExpOptDlg>
+    <cbSel>0</cbSel>
+    <RteFlg>0</RteFlg>
     <File>
-      <GroupNumber>2</GroupNumber>
+      <GroupNumber>3</GroupNumber>
       <FileNumber>15</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_usart.c</PathWithFileName>
-      <FilenameWithoutPath>gd32f30x_usart.c</FilenameWithoutPath>
+      <PathWithFileName>..\Applications\math\fast_math.c</PathWithFileName>
+      <FilenameWithoutPath>fast_math.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
     <File>
-      <GroupNumber>2</GroupNumber>
+      <GroupNumber>3</GroupNumber>
       <FileNumber>16</FileNumber>
-      <FileType>1</FileType>
+      <FileType>4</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_pmu.c</PathWithFileName>
-      <FilenameWithoutPath>gd32f30x_pmu.c</FilenameWithoutPath>
+      <PathWithFileName>..\Applications\math\arm_cortexM4lf_math.lib</PathWithFileName>
+      <FilenameWithoutPath>arm_cortexM4lf_math.lib</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
+  </Group>
+
+  <Group>
+    <GroupName>Proto</GroupName>
+    <tvExp>1</tvExp>
+    <tvExpOptDlg>0</tvExpOptDlg>
+    <cbSel>0</cbSel>
+    <RteFlg>0</RteFlg>
     <File>
-      <GroupNumber>2</GroupNumber>
+      <GroupNumber>4</GroupNumber>
       <FileNumber>17</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_dbg.c</PathWithFileName>
-      <FilenameWithoutPath>gd32f30x_dbg.c</FilenameWithoutPath>
+      <PathWithFileName>..\Applications\prot\can_message.c</PathWithFileName>
+      <FilenameWithoutPath>can_message.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
   </Group>
 
   <Group>
-    <GroupName>StartUp</GroupName>
-    <tvExp>0</tvExp>
+    <GroupName>OS</GroupName>
+    <tvExp>1</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
     <RteFlg>0</RteFlg>
     <File>
-      <GroupNumber>3</GroupNumber>
+      <GroupNumber>5</GroupNumber>
       <FileNumber>18</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\Librarys\CMSIS\GD\GD32F30x\Source\system_gd32f30x.c</PathWithFileName>
-      <FilenameWithoutPath>system_gd32f30x.c</FilenameWithoutPath>
+      <PathWithFileName>..\Applications\os\port\cortex-m4.c</PathWithFileName>
+      <FilenameWithoutPath>cortex-m4.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
     <File>
-      <GroupNumber>3</GroupNumber>
+      <GroupNumber>5</GroupNumber>
       <FileNumber>19</FileNumber>
-      <FileType>2</FileType>
+      <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\Librarys\CMSIS\GD\GD32F30x\Source\ARM\startup_gd32f30x_hd.s</PathWithFileName>
-      <FilenameWithoutPath>startup_gd32f30x_hd.s</FilenameWithoutPath>
+      <PathWithFileName>..\Applications\os\co_task.c</PathWithFileName>
+      <FilenameWithoutPath>co_task.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>5</GroupNumber>
+      <FileNumber>20</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Applications\os\cpu.c</PathWithFileName>
+      <FilenameWithoutPath>cpu.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>5</GroupNumber>
+      <FileNumber>21</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Applications\os\heap_4.c</PathWithFileName>
+      <FilenameWithoutPath>heap_4.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>5</GroupNumber>
+      <FileNumber>22</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Applications\os\timer.c</PathWithFileName>
+      <FilenameWithoutPath>timer.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
   </Group>
 
   <Group>
-    <GroupName>OS</GroupName>
+    <GroupName>Libs</GroupName>
+    <tvExp>1</tvExp>
+    <tvExpOptDlg>0</tvExpOptDlg>
+    <cbSel>0</cbSel>
+    <RteFlg>0</RteFlg>
+    <File>
+      <GroupNumber>6</GroupNumber>
+      <FileNumber>23</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Applications\libs\backtrace.c</PathWithFileName>
+      <FilenameWithoutPath>backtrace.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>6</GroupNumber>
+      <FileNumber>24</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Applications\libs\circle_buffer.c</PathWithFileName>
+      <FilenameWithoutPath>circle_buffer.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>6</GroupNumber>
+      <FileNumber>25</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Applications\libs\logger.c</PathWithFileName>
+      <FilenameWithoutPath>logger.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>6</GroupNumber>
+      <FileNumber>26</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Applications\libs\crc16.c</PathWithFileName>
+      <FilenameWithoutPath>crc16.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>6</GroupNumber>
+      <FileNumber>27</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Applications\libs\byte_queue.c</PathWithFileName>
+      <FilenameWithoutPath>byte_queue.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>6</GroupNumber>
+      <FileNumber>28</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Applications\libs\gtime.c</PathWithFileName>
+      <FilenameWithoutPath>gtime.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+  </Group>
+
+  <Group>
+    <GroupName>BSP</GroupName>
+    <tvExp>1</tvExp>
+    <tvExpOptDlg>0</tvExpOptDlg>
+    <cbSel>0</cbSel>
+    <RteFlg>0</RteFlg>
+    <File>
+      <GroupNumber>7</GroupNumber>
+      <FileNumber>29</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Applications\bsp\bsp.c</PathWithFileName>
+      <FilenameWithoutPath>bsp.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>7</GroupNumber>
+      <FileNumber>30</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Applications\bsp\gd32_bkp.c</PathWithFileName>
+      <FilenameWithoutPath>gd32_bkp.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>7</GroupNumber>
+      <FileNumber>31</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Applications\bsp\gd32_rtc.c</PathWithFileName>
+      <FilenameWithoutPath>gd32_rtc.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>7</GroupNumber>
+      <FileNumber>32</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Applications\bsp\gpio.c</PathWithFileName>
+      <FilenameWithoutPath>gpio.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>7</GroupNumber>
+      <FileNumber>33</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Applications\bsp\i2c.c</PathWithFileName>
+      <FilenameWithoutPath>i2c.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>7</GroupNumber>
+      <FileNumber>34</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Applications\bsp\can.c</PathWithFileName>
+      <FilenameWithoutPath>can.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>7</GroupNumber>
+      <FileNumber>35</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Applications\bsp\fmc_flash.c</PathWithFileName>
+      <FilenameWithoutPath>fmc_flash.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>7</GroupNumber>
+      <FileNumber>36</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Applications\bsp\pwm.c</PathWithFileName>
+      <FilenameWithoutPath>pwm.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>7</GroupNumber>
+      <FileNumber>37</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Applications\bsp\mc_irqs.c</PathWithFileName>
+      <FilenameWithoutPath>mc_irqs.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>7</GroupNumber>
+      <FileNumber>38</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Applications\bsp\mc_hall_gpio.c</PathWithFileName>
+      <FilenameWithoutPath>mc_hall_gpio.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>7</GroupNumber>
+      <FileNumber>39</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Applications\bsp\adc.c</PathWithFileName>
+      <FilenameWithoutPath>adc.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>7</GroupNumber>
+      <FileNumber>40</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Applications\bsp\uart.c</PathWithFileName>
+      <FilenameWithoutPath>uart.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+  </Group>
+
+  <Group>
+    <GroupName>GD32F30x_Drivers</GroupName>
     <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
     <RteFlg>0</RteFlg>
     <File>
-      <GroupNumber>4</GroupNumber>
-      <FileNumber>20</FileNumber>
+      <GroupNumber>8</GroupNumber>
+      <FileNumber>41</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\Applications\os\heap_4.c</PathWithFileName>
-      <FilenameWithoutPath>heap_4.c</FilenameWithoutPath>
+      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_adc.c</PathWithFileName>
+      <FilenameWithoutPath>gd32f30x_adc.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
     <File>
-      <GroupNumber>4</GroupNumber>
-      <FileNumber>21</FileNumber>
+      <GroupNumber>8</GroupNumber>
+      <FileNumber>42</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\Applications\os\port\cortex-m4.c</PathWithFileName>
-      <FilenameWithoutPath>cortex-m4.c</FilenameWithoutPath>
+      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_bkp.c</PathWithFileName>
+      <FilenameWithoutPath>gd32f30x_bkp.c</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>
     <File>
-      <GroupNumber>4</GroupNumber>
-      <FileNumber>22</FileNumber>
+      <GroupNumber>8</GroupNumber>
+      <FileNumber>43</FileNumber>
       <FileType>1</FileType>
       <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
-      <PathWithFileName>..\Applications\os\co_task.c</PathWithFileName>
-      <FilenameWithoutPath>co_task.c</FilenameWithoutPath>
+      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_can.c</PathWithFileName>
+      <FilenameWithoutPath>gd32f30x_can.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>8</GroupNumber>
+      <FileNumber>44</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_dma.c</PathWithFileName>
+      <FilenameWithoutPath>gd32f30x_dma.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>8</GroupNumber>
+      <FileNumber>45</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_exti.c</PathWithFileName>
+      <FilenameWithoutPath>gd32f30x_exti.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>8</GroupNumber>
+      <FileNumber>46</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_fmc.c</PathWithFileName>
+      <FilenameWithoutPath>gd32f30x_fmc.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>8</GroupNumber>
+      <FileNumber>47</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_fwdgt.c</PathWithFileName>
+      <FilenameWithoutPath>gd32f30x_fwdgt.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>8</GroupNumber>
+      <FileNumber>48</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_gpio.c</PathWithFileName>
+      <FilenameWithoutPath>gd32f30x_gpio.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>8</GroupNumber>
+      <FileNumber>49</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_i2c.c</PathWithFileName>
+      <FilenameWithoutPath>gd32f30x_i2c.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>8</GroupNumber>
+      <FileNumber>50</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_misc.c</PathWithFileName>
+      <FilenameWithoutPath>gd32f30x_misc.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>8</GroupNumber>
+      <FileNumber>51</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_rcu.c</PathWithFileName>
+      <FilenameWithoutPath>gd32f30x_rcu.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>8</GroupNumber>
+      <FileNumber>52</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_rtc.c</PathWithFileName>
+      <FilenameWithoutPath>gd32f30x_rtc.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>8</GroupNumber>
+      <FileNumber>53</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_timer.c</PathWithFileName>
+      <FilenameWithoutPath>gd32f30x_timer.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>8</GroupNumber>
+      <FileNumber>54</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_usart.c</PathWithFileName>
+      <FilenameWithoutPath>gd32f30x_usart.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>8</GroupNumber>
+      <FileNumber>55</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_pmu.c</PathWithFileName>
+      <FilenameWithoutPath>gd32f30x_pmu.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>8</GroupNumber>
+      <FileNumber>56</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Librarys\GD32F30x_Drivers\source\gd32f30x_dbg.c</PathWithFileName>
+      <FilenameWithoutPath>gd32f30x_dbg.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+  </Group>
+
+  <Group>
+    <GroupName>StartUp</GroupName>
+    <tvExp>0</tvExp>
+    <tvExpOptDlg>0</tvExpOptDlg>
+    <cbSel>0</cbSel>
+    <RteFlg>0</RteFlg>
+    <File>
+      <GroupNumber>9</GroupNumber>
+      <FileNumber>57</FileNumber>
+      <FileType>1</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Librarys\CMSIS\GD\GD32F30x\Source\system_gd32f30x.c</PathWithFileName>
+      <FilenameWithoutPath>system_gd32f30x.c</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+    <File>
+      <GroupNumber>9</GroupNumber>
+      <FileNumber>58</FileNumber>
+      <FileType>2</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\Librarys\CMSIS\GD\GD32F30x\Source\ARM\startup_gd32f30x_hd.s</PathWithFileName>
+      <FilenameWithoutPath>startup_gd32f30x_hd.s</FilenameWithoutPath>
       <RteFlg>0</RteFlg>
       <bShared>0</bShared>
     </File>

+ 228 - 23
Project/MC100_OS.uvprojx

@@ -49,7 +49,7 @@
             <InvalidFlash>1</InvalidFlash>
           </TargetStatus>
           <OutputDirectory>.\Objects\</OutputDirectory>
-          <OutputName>MC100_OS</OutputName>
+          <OutputName>MC100</OutputName>
           <CreateExecutable>1</CreateExecutable>
           <CreateLib>0</CreateLib>
           <CreateHexFile>1</CreateHexFile>
@@ -82,8 +82,8 @@
           <AfterMake>
             <RunUserProg1>1</RunUserProg1>
             <RunUserProg2>1</RunUserProg2>
-            <UserProg1Name>fromelf --bin --output ./Output/MC100_OS.bin ./Objects/MC100_OS.axf</UserProg1Name>
-            <UserProg2Name>SharkFwVersion mv  ./Output/MC100_OS.bin</UserProg2Name>
+            <UserProg1Name>fromelf --bin --output ./Output/MC100.bin ./Objects/MC100.axf</UserProg1Name>
+            <UserProg2Name>SharkFwVersion mv  ./Output/MC100.bin</UserProg2Name>
             <UserProg1Dos16Mode>0</UserProg1Dos16Mode>
             <UserProg2Dos16Mode>0</UserProg2Dos16Mode>
             <nStopA1X>0</nStopA1X>
@@ -388,6 +388,231 @@
               <FileType>1</FileType>
               <FilePath>..\Applications\main.c</FilePath>
             </File>
+            <File>
+              <FileName>app.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\app\app.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>Foc</GroupName>
+          <Files>
+            <File>
+              <FileName>circle_limitation.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\foc\circle_limitation.c</FilePath>
+            </File>
+            <File>
+              <FileName>foc_api.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\foc\foc_api.c</FilePath>
+            </File>
+            <File>
+              <FileName>foc_core.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\foc\foc_core.c</FilePath>
+            </File>
+            <File>
+              <FileName>foc_stm.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\foc\foc_stm.c</FilePath>
+            </File>
+            <File>
+              <FileName>gas_sensor.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\foc\gas_sensor.c</FilePath>
+            </File>
+            <File>
+              <FileName>hall_sensor.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\foc\hall_sensor.c</FilePath>
+            </File>
+            <File>
+              <FileName>ntc_sensor.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\foc\ntc_sensor.c</FilePath>
+            </File>
+            <File>
+              <FileName>phase_current.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\foc\phase_current.c</FilePath>
+            </File>
+            <File>
+              <FileName>pi_controller.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\foc\pi_controller.c</FilePath>
+            </File>
+            <File>
+              <FileName>ramp_ctrl.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\foc\ramp_ctrl.c</FilePath>
+            </File>
+            <File>
+              <FileName>svpwm.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\foc\svpwm.c</FilePath>
+            </File>
+            <File>
+              <FileName>vbus_sensor.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\foc\vbus_sensor.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>Math</GroupName>
+          <Files>
+            <File>
+              <FileName>fast_math.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\math\fast_math.c</FilePath>
+            </File>
+            <File>
+              <FileName>arm_cortexM4lf_math.lib</FileName>
+              <FileType>4</FileType>
+              <FilePath>..\Applications\math\arm_cortexM4lf_math.lib</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>Proto</GroupName>
+          <Files>
+            <File>
+              <FileName>can_message.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\prot\can_message.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>OS</GroupName>
+          <Files>
+            <File>
+              <FileName>cortex-m4.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\os\port\cortex-m4.c</FilePath>
+            </File>
+            <File>
+              <FileName>co_task.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\os\co_task.c</FilePath>
+            </File>
+            <File>
+              <FileName>cpu.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\os\cpu.c</FilePath>
+            </File>
+            <File>
+              <FileName>heap_4.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\os\heap_4.c</FilePath>
+            </File>
+            <File>
+              <FileName>timer.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\os\timer.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>Libs</GroupName>
+          <Files>
+            <File>
+              <FileName>backtrace.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\libs\backtrace.c</FilePath>
+            </File>
+            <File>
+              <FileName>circle_buffer.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\libs\circle_buffer.c</FilePath>
+            </File>
+            <File>
+              <FileName>logger.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\libs\logger.c</FilePath>
+            </File>
+            <File>
+              <FileName>crc16.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\libs\crc16.c</FilePath>
+            </File>
+            <File>
+              <FileName>byte_queue.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\libs\byte_queue.c</FilePath>
+            </File>
+            <File>
+              <FileName>gtime.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\libs\gtime.c</FilePath>
+            </File>
+          </Files>
+        </Group>
+        <Group>
+          <GroupName>BSP</GroupName>
+          <Files>
+            <File>
+              <FileName>bsp.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\bsp\bsp.c</FilePath>
+            </File>
+            <File>
+              <FileName>gd32_bkp.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\bsp\gd32_bkp.c</FilePath>
+            </File>
+            <File>
+              <FileName>gd32_rtc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\bsp\gd32_rtc.c</FilePath>
+            </File>
+            <File>
+              <FileName>gpio.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\bsp\gpio.c</FilePath>
+            </File>
+            <File>
+              <FileName>i2c.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\bsp\i2c.c</FilePath>
+            </File>
+            <File>
+              <FileName>can.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\bsp\can.c</FilePath>
+            </File>
+            <File>
+              <FileName>fmc_flash.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\bsp\fmc_flash.c</FilePath>
+            </File>
+            <File>
+              <FileName>pwm.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\bsp\pwm.c</FilePath>
+            </File>
+            <File>
+              <FileName>mc_irqs.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\bsp\mc_irqs.c</FilePath>
+            </File>
+            <File>
+              <FileName>mc_hall_gpio.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\bsp\mc_hall_gpio.c</FilePath>
+            </File>
+            <File>
+              <FileName>adc.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\bsp\adc.c</FilePath>
+            </File>
+            <File>
+              <FileName>uart.c</FileName>
+              <FileType>1</FileType>
+              <FilePath>..\Applications\bsp\uart.c</FilePath>
+            </File>
           </Files>
         </Group>
         <Group>
@@ -490,26 +715,6 @@
             </File>
           </Files>
         </Group>
-        <Group>
-          <GroupName>OS</GroupName>
-          <Files>
-            <File>
-              <FileName>heap_4.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\Applications\os\heap_4.c</FilePath>
-            </File>
-            <File>
-              <FileName>cortex-m4.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\Applications\os\port\cortex-m4.c</FilePath>
-            </File>
-            <File>
-              <FileName>co_task.c</FileName>
-              <FileType>1</FileType>
-              <FilePath>..\Applications\os\co_task.c</FilePath>
-            </File>
-          </Files>
-        </Group>
       </Groups>
     </Target>
   </Targets>