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

Added Renesas Support (Arduino R4) #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ sentence=Arduino library for the Flysky/Turnigy RC iBUS protocol - servo (receiv
paragraph=With this library you can interface to any RC receiver that supports the Flysky iBUS protocol (such as TGY-IA6B). Flysky iBUS uses a half-duplex asynchronous protocol format at 115200 baud. The library requires at least one free hardware UART (serial) port. The library can be used to receive data (typically servo data) and send data (telemetry or sensors).
category=Communication
url=https://github.com/bmellink/IBusBM
architectures=avr,esp32,stm32,mbed,STM32F1,megaavr
architectures=avr,esp32,stm32,mbed,STM32F1,megaavr,renesas_uno
includes=IBusBM.h
30 changes: 29 additions & 1 deletion src/IBusBM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ IBusBM* IBusBMfirst = NULL;
SIGNAL(TIMER0_COMPA_vect) {
if (IBusBMfirst) IBusBMfirst->loop(); // gets new servo values if available and process any sensor data
}
#elif defined _VARIANT_ARDUINO_STM32_
void onTimer(stimer_t *htim) {
if (IBusBMfirst) IBusBMfirst->loop(); // gets new servo values if available and process any sensor data
}
#elif defined _RENESAS_RA_
FspTimer _fspTimer;
void onTimerCallback(timer_callback_args_t __attribute((unused))* p_args)
{
if (IBusBMfirst) IBusBMfirst->loop();
}
#else
void onTimer() {
if (IBusBMfirst) IBusBMfirst->loop(); // gets new servo values if available and process any sensor data
Expand Down Expand Up @@ -144,9 +154,27 @@ void IBusBM::begin(HardwareSerial &serial, int8_t timerid, int8_t rxPin, int8_t
NVIC_EnableIRQ(TIMER4_IRQn);

NRF_TIMER4->TASKS_START = 1; // Start TIMER2

#elif defined(_RENESAS_RA_)
uint8_t timer_type = GPT_TIMER;
int timerIndex = FspTimer::get_available_timer(timer_type);
if (timerIndex < 0)
{
// Failed. Force it to get any timer even AGT_TIMER
int timerIndex = FspTimer::get_available_timer(timer_type, true);
}
if (timerIndex > -1)
{
// We have a valid timer. Proceed to set the timer
FspTimer::force_use_of_pwm_reserved_timer();
_fspTimer.begin(TIMER_MODE_PERIODIC, timer_type, timerIndex, 1000, 0.0f, onTimerCallback);
_fspTimer.setup_overflow_irq();
_fspTimer.open();
_fspTimer.start();
}
#else
// It should not be too difficult to support additional architectures as most have timer functions, but I only tested AVR and ESP32
#warning "Timing only supportted for AVR, ESP32 and STM32 architectures. Use timerid IBUSBM_NOTIMER"
#warning "Timing only supportted for AVR, ESP32, Renesas_Uno and STM32 architectures. Use timerid IBUSBM_NOTIMER"
#endif
#endif
}
Expand Down
11 changes: 7 additions & 4 deletions src/IBusBM.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@

#if defined(ARDUINO_ARCH_MBED)
#include "mbed.h"
#include "HardwareSerial.h"
#include "mbed.h"
#include "HardwareSerial.h"
#elif defined(_RENESAS_RA_)
#include "FspTimer.h"
#endif

// if you have an opentx transciever you can add additional sensor types here.
Expand All @@ -32,9 +35,9 @@
#if defined(ARDUINO_ARCH_MBED)
#define HardwareSerial arduino::HardwareSerial
#else
#if !defined(ARDUINO_ARCH_MEGAAVR)
class HardwareSerial;
#endif
#if !defined(ARDUINO_ARCH_MEGAAVR) && !defined(_RENESAS_RA_)
class HardwareSerial;
#endif
#endif
class Stream;

Expand Down