Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is it possible to use your library with stm32? #14

Open
gonzzzales opened this issue Dec 4, 2024 · 9 comments
Open

is it possible to use your library with stm32? #14

gonzzzales opened this issue Dec 4, 2024 · 9 comments

Comments

@gonzzzales
Copy link

No description provided.

@gonzzzales
Copy link
Author

gonzzzales commented Dec 4, 2024

I tryed to change it for using with stm32, but unfortunetly it not work
I made this changes in DaliBus.cpp

void DaliBusClass::begin(byte tx_pin, byte rx_pin, bool active_low) {
  txPin = tx_pin;
  rxPin = rx_pin;
  activeLow = active_low;

  // init bus state
  busState = IDLE;

  // TX pin setup
  pinMode(txPin, OUTPUT);
  setBusLevel(HIGH);

  // RX pin setup
  pinMode(rxPin, INPUT);
  //---attachPinChangeInterrupt(digitalPinToPinChangeInterrupt(rxPin), DaliBus_wrapper_pinchangeISR, CHANGE);
  attachInterrupt(digitalPinToInterrupt(rxPin), DaliBus_wrapper_pinchangeISR, CHANGE);

  // Timer setup
  //---Timer1.initialize(DALI_TE); // set timer to time of one half-bit
  //---Timer1.attachInterrupt(DaliBus_wrapper_timerISR);
  Timer1.pause();                                             // останавливаем таймер перед настройкой
  Timer1.setPeriod(DALI_TE);                                       // время в микросекундах
  Timer1.attachInterrupt(TIMER_UPDATE_INTERRUPT, DaliBus_wrapper_timerISR);  // активируем прерывание
  Timer1.refresh();  
  Timer1.resume();
}

@hubsif
Copy link
Owner

hubsif commented Dec 4, 2024

Hi @gonzzzales!
I don't have a STM32 board or any experience with it.
I don't think either the TimerOne and PinChangeInterrupt libraries used in this library support STM32. But you can have a look at @thewhobox's pull request #13 (which I haven't found the time to review yet). It uses a generic timer library instead that also supports STM32. However, you'd still have to configure and test it for STM32 yourself.

@thewhobox
Copy link

Hey guys,

The Timerinterrupt_Generic Supports STM32.
Ist would need small changes to support it but thats easy.
I can add These changes to the pull Requests in the next days.

@kubukoz
Copy link

kubukoz commented Dec 5, 2024

Hi @hubsif, any chance you could share more about how this would be set up with an arduino, from scratch? The wiring in particular is a complete mystery to me.

@gonzzzales
Copy link
Author

@thewhobox i tryed to do it with rogerclarc core. In other projects Timer1 and pinchangeinterrupts work fine. My changes you can see above. Unfortunetly blink example didn't want to work))

@thewhobox
Copy link

I added support for stm32 in my pr #13 (or this branch).
Due to i dont own a stm board its not tested, but it compiles without errors.

@thewhobox
Copy link

@kubukoz you need a pcb to receive or send dali commands.
You can find circuits online (here for example) or buy a finished product (dali click, led-warrior or waveshare dali2).

Then its only conencting RX and TX from pcb to your microcontroller.

@Martsola
Copy link

Martsola commented Jan 11, 2025

I did some testing with STM32F103C8 (Bluepill) and Thewhobox fork of the library.
For me code compiles ok with latest Arduino IDE, but execution fails. Basicly nothing happens.
Even only setting the built in led ON fails.

If I comment "#include <Dali.h>" then rest of the non DALI related code starts working.

Any suggestions how to debug more?

@thewhobox
Copy link

You could add some println to see where it crashes.
I suggest its in the begin method of the DaliClass.
There is all the code to start timer and initiate the pin interrupt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants