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

Add SOFTSERIAL support on RX4/TX4 for MATEKF405 target #2842

Merged
merged 1 commit into from
Apr 4, 2018
Merged
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
4 changes: 2 additions & 2 deletions src/main/target/MATEKF405/target.c
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = {

{ TIM5, IO_TAG(PA2), TIM_Channel_3, 1, IOCFG_AF_PP_PD, GPIO_AF_TIM5, TIM_USE_PWM }, //TX2

//{ TIM5, IO_TAG(PA0), TIM_Channel_1, 1, IOCFG_AF_PP_PD, GPIO_AF_TIM5, TIM_USE_ANY }, //TX4 softserial1_tx
//{ TIM5, IO_TAG(PA1), TIM_Channel_2, 1, IOCFG_AF_PP_PD, GPIO_AF_TIM5, TIM_USE_ANY }, //RX4 softserial1_rx
{ TIM5, IO_TAG(PA0), TIM_Channel_1, 1, IOCFG_AF_PP_PD, GPIO_AF_TIM5, TIM_USE_PWM }, //TX4 softserial1_tx
{ TIM5, IO_TAG(PA1), TIM_Channel_2, 1, IOCFG_AF_PP_PD, GPIO_AF_TIM5, TIM_USE_PWM }, //RX4 softserial1_rx

};
12 changes: 6 additions & 6 deletions src/main/target/MATEKF405/target.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@
#define UART5_RX_PIN PD2
#define UART5_TX_PIN PC12

//#define USE_SOFTSERIAL1
//#define SOFTSERIAL_1_RX_PIN PA1 //RX4
//#define SOFTSERIAL_1_TX_PIN PA0 //TX4
#define USE_SOFTSERIAL1
#define SOFTSERIAL_1_RX_PIN PA1 //RX4
#define SOFTSERIAL_1_TX_PIN PA0 //TX4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a clash between USE_SOFTSERIAL1 and USE_UART4 - they use the same pins. If softserial is enabled UART4 should be removed from the list of UARTs on this target.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the goal was to keep the possibility to use one or the other. Can't the two coexist meaning if nothing is configured on UART4 enabling SS1 and using it instead would work ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm worried about the scenario when user will configure both. This needs to be prevented.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A solution could be to add targets replacing UART4 with softserial. MATEKF405_1SS and MATEKF405OSD_1SS.

Copy link
Contributor

@MATEKSYS MATEKSYS Feb 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Use one or the other. UART4 can work as normal UART if users don't choose "Enable CPU based serial ports" in configurator. Tested it already.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shellixyz I think no need to add more targets. Now it is a good solution. . 5xUarts are still available for non-Frsky users. 4xUarts+1xSoftserial for Frsky users after enable softserial. We will add this guide in our FC page. in BF there are some targets use this type of hack on UART pins also.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, F4 telemetry_inversion = OFF by default. F722 telemetry_inversion = OFF default also. Need to set them = ON to get Frsky telemetry working. can telemetry_inversion be defined as ON by default in firmware.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,
I have tried getting telemetry to work on UART4 (TX4) to no avail.
I have tried D4R-II and X8R.
Attached is the dump.
Can someone help me figure out what I didnt do right?
INAV.txt

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ogocology Since you want to use soft serial for smartport I guess you connected your receiver without the uninversion hack so your issue is probably that you need telemetry_inverted = OFF. It means normal expected inversion. So for smartport it means inverted.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its working now with telemetry_inverted = OFF.
I also got servo working on s6 pad for camera tilt servo.

I remain grateful to all who consistently strive to make this level of support available (and FREE).

Cheers!


#define SERIAL_PORT_COUNT 6
#define SERIAL_PORT_COUNT 7

#define DEFAULT_RX_TYPE RX_TYPE_SERIAL
#define SERIALRX_PROVIDER SERIALRX_SBUS
Expand Down Expand Up @@ -182,7 +182,7 @@
#define CURRENT_METER_ADC_CHANNEL ADC_CHN_2
#define RSSI_ADC_CHANNEL ADC_CHN_3

#define DEFAULT_FEATURES (FEATURE_TX_PROF_SEL | FEATURE_OSD | FEATURE_CURRENT_METER | FEATURE_VBAT | FEATURE_TELEMETRY )
#define DEFAULT_FEATURES (FEATURE_OSD | FEATURE_CURRENT_METER | FEATURE_VBAT | FEATURE_TELEMETRY )
#define CURRENT_METER_SCALE 179

#define USE_LED_STRIP
Expand All @@ -201,6 +201,6 @@
#define TARGET_IO_PORTC 0xffff
#define TARGET_IO_PORTD (BIT(2))

#define USABLE_TIMER_CHANNEL_COUNT 9
#define USABLE_TIMER_CHANNEL_COUNT 11
#define MAX_PWM_OUTPUT_PORTS 6
#define USED_TIMERS (TIM_N(1)|TIM_N(2)|TIM_N(3)|TIM_N(4)|TIM_N(5)|TIM_N(8)|TIM_N(9))