void sub9(void) ;
#define u8 unsigned char
u8 Rxdata[10] ;
String inputString = ""; // a string to hold incoming data
boolean stringComplete = false; // whether the string is complete
boolean bfbase4ms = false; ;
boolean bfdatasend = false ;
int inByte; // Byte read from Serial1
unsigned int wcad ;
union{
struct{
unsigned bfbase : 1 ;
unsigned syi893 : 1 ;
unsigned bfpoweroff : 1 ;
unsigned shu164 :1;
unsigned bfrf_isrread : 1 ;
}onebit ;
unsigned char allbits ;
}wflag ;
// Depending on the board, you can select STM32 Hardware Timer from TIM1-TIM22
// For example, F767ZI can select Timer from TIM1-TIM14
// If you select a Timer not correctly, you'll get a message from ci[ompiler
// 'TIMxx' was not declared in this scope; did you mean 'TIMyy'?
// Init STM32 timer TIM1
STM32Timer ITimer(TIM1);
// Init STM32_ISR_Timer
// Each STM32_ISR_Timer can service 16 different ISR-based timers
STM32_ISR_Timer ISR_Timer;
// In STM32, avoid doing something fancy in ISR, for example complex Serial.print with String() argument
// The pure simple Serial.prints here are just for demonstration and testing. Must be eliminate in working environment
// Or you can get this run-time error / crash
void doingSomething1()
{
// digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}
Serial.print(F("\nStarting TimerInterruptLEDDemo on ")); Serial.println(BOARD_NAME);
Serial.println(STM32_TIMER_INTERRUPT_VERSION);
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));
// Instantiate HardwareTimer object. Thanks to 'new' instanciation, HardwareTimer is not destructed when setup() function is finished.
//HardwareTimer *MyTim = new HardwareTimer(Instance);
// configure pin in output mode
pinMode(LED_BLUE, OUTPUT);
// Interval in microsecs
if (ITimer.attachInterruptInterval(HW_TIMER_INTERVAL_MS * 1000, TimerHandler))
{
Serial.print(F("Starting ITimer OK, millis() = ")); Serial.println(millis());
}
else
Serial.println(F("Can't set ITimer. Select another freq. or timer"));
// Just to demonstrate, don't use too many ISR Timers if not absolutely necessary
// You can use up to 16 timer for each ISR_Timer
// ISR_Timer.setInterval(TIMER_INTERVAL_0_5S, doingSomething1);
void serialEvent() {
while (Serial.available()) {
// get the new byte:
char inChar = (char)Serial.read();
// add it to the inputString:
inputString += inChar;
// if the incoming character is a newline, set a flag so the main loop can
// do something about it:
stringComplete = true;
}
}
void loop()
{
/* Nothing to do all is done by hardware. Even no interrupt required. */
if(wflag.onebit.bfbase)
{
wflag.onebit.bfbase = 0 ;
subled();
wcad = analogRead(PA3); // read the input pin
if(wcad>30)
{
digitalWrite(LED_RED , LOW);
digitalWrite(LED_BLUE, HIGH );
}
else
{
digitalWrite(LED_RED , HIGH);
digitalWrite(LED_BLUE, LOW);
}
}