//#define SUSCEPT1 #ifdef SUSCEPT1 int device=1; #else int device=2; #endif #define INSTRUCTIONS #include #include "pico/stdlib.h" #include "pico/multicore.h" #include "hardware/spi.h" #include "hardware/watchdog.h" #include "program_defines.h" #include // Counter spinlocks int spinlock_num_count ; spin_lock_t *spinlock_count ; int spinlock_num_count_b ; spin_lock_t *spinlock_count_b ; String ids="Suscept"; int manual=1; int started=0; int outpointer=0; int zeroscreen=0; int calibration_manual=0; int calibration_phase=0; int calibration_b; int calibrated; double offset_zero_0=0; double offset_auto; boolean testb=false; boolean runloop2=false; struct program_t{ double paramdata; int param; }; struct program_t lastp={1e30,SHOLD}; #include "ad_da.h" LiquidCrystal lcd(A0,A1,A2,A3,A4,A5); //LiquidCrystal(rs, enable, d4, d5, d6, d7). #include "read_save.h" #include "utils.h" #include "serial.h" #include "period.h" #include "interpret.h" #include "calibration.h" void error_send(String s) { if (manual) Serial.println(s); } int started_loop0=0; boolean measureon=false; void setup1() { while (!started_loop0) delay(10); printf("Loop 1 started\n"); initdevice(); da_gain[0]=1; da_zero[0]=0; da_gain[1]=1; da_zero[1]=0; measureon=true; r_da(0,1); //set I r_da(1,3); // set OFFSET r_da(2,5); // set HALL I setchannel(12); runloop2=true; } void setup() { gpio_init (LED_PIN); gpio_set_dir (LED_PIN, GPIO_OUT); gpio_put (LED_PIN, 1); Serials_init(); delay(1000); Serial.setTimeout(100); printf("Starting %s\n","Suscept"); start_littlefs(); spinlock_num_count = spin_lock_claim_unused(true) ; spinlock_count = spin_lock_init(spinlock_num_count) ; spinlock_num_count_b = spin_lock_claim_unused(true) ; spinlock_count_b = spin_lock_init(spinlock_num_count_b) ; delay(1000); read_params(); read_name(); lcd.begin(20,4); lcd.setCursor(0, 0); lcd.print("Starting"); lcd.setCursor(0, 1); lcd.print(" "); started_loop0=1; measureon=false; started=0; } void loop1() { if (!runloop2) { delay(1); return; } if (calibration_b==1) calibration_process(); else { sleep_us(10); do_newcommand(); dataget(1); dasout(1); } } void loop() { sleep_ms(1); time_onestep(); if (measureon) onestep(); if (do_serials()>0) interpretlast(); }