ok , thanks , working code :
Code: Select all
#include <Arduino.h>
#include "hal_conf_extra.h" // adhoc creation
COMP_HandleTypeDef hcomp1;
void setup() {
Serial.begin(115200);
hcomp1.Instance = COMP1; // comes from cube IDE
hcomp1.Init.InputPlus = COMP_INPUT_PLUS_IO1;
hcomp1.Init.InputMinus = COMP_INPUT_MINUS_1_2VREFINT;
hcomp1.Init.OutputPol = COMP_OUTPUTPOL_NONINVERTED;
hcomp1.Init.Hysteresis = COMP_HYSTERESIS_NONE;
hcomp1.Init.BlankingSrce = COMP_BLANKINGSRC_NONE;
hcomp1.Init.TriggerMode = COMP_TRIGGERMODE_NONE;
HAL_COMP_Init(&hcomp1);
HAL_COMP_Start(&hcomp1);
delay(4000) ; // monitor
Serial.print(COMP1->CSR) ; // debug : verify
}
void loop() {
}
Extra HAL configuration can be enabled/disabled in variant.h (if required)
or in a file named (at sketch level):
hal_conf_extra.h
Code: Select all
//For information on installing libraries, see: ttp://www.arduino.cc/en/Guide/Libraries
#define HAL_COMP_MODULE_ENABLED