| 1234567891011121314151617181920212223242526272829303132 |
- #include "app/app.h"
- #include "foc/foc_stm.h"
- #include "foc/gas_sensor.h"
- #include "foc/foc_api.h"
- #include "libs/task.h"
- static u32 app_task(void);
- static void gas_sample_handler(timer_t *t);
- static timer_t _gas_sample_timer = {.handler = gas_sample_handler};
- void app_init(void){
- task_start(app_task, 5);
- timer_post(&_gas_sample_timer, 50);
- }
- void start_stop_handler(void) {
- if (!foc_is_ready()) {
- foc_set_ready(true);
- }else {
- foc_set_ready(false);
- }
- }
- static u32 app_task(void) {
- gas_sample_voltage();
- return 1;//隔5ms执行一次
- }
- static void gas_sample_handler(timer_t *t) {
- float v = gas_get_value();
- foc_set_ref_speed(v * MAX_SPEED_RPM);
- timer_post(&_gas_sample_timer, 200);
- }
|