Enabling Half-Duplex mode in USART1

I am looking to create a code patch to allow the enabling of half duplex mode in USART1. It just requires calling the following function in the chip drivers (this will work for both the Photon and the Core):

USART_HalfDuplexCmd(USART_TypeDef* USARTx, FunctionalState NewState);

Adding this to the 0.3.4 firmware was easy. I am just struggling with where to put this in the 0.4.x firmware. It looks like I might have to put it into both hal/src/core/usart_hal.c and hal/src/stm32f2xx/usart_hal.c, as I don’t know if I can get at the USART_TypeDef* that I need in wiring/src/spark_wiring_usartserial.cpp.

I am definitely going to have to put something into wiring/src/spark_wiring_usartserial.cpp so that it can be enabled from user space, I think I may have to call something in the HAL.

Since the code will be identical between the Core and the Photon is there a single place I could put it, or am I going to have to put it in both?

Or am I totally off base and is there a better place to put it?

Thanks!

Scott =)

I have done it the hard way, putting in multiple copes of the same function into the different HAL usart_hal.c files. I am ready to do a pull request if this is the best way to do it.

The code works on my Core. I haven’t gotten my Photons in the mail yet to test it on those.

@prices, can you put the PR together so we can review the proposed changes? If there is a better, the PR can be removed later.

@peekay123 The pull request has been created.

Thanks.

1 Like

@prices, which branch did you do the PR on?

@peekay123, The develop branch.

@prices, if possible, can you rename your PR since it is called “develop” and dosen’t describe the request :smile:

It is now called “Patch to enable half duplex mode in Serial1”. Sorry. I am still recovering from my weekend. :wink:

2 Likes

Haha! best excuse ever! :slight_smile:

@prices, there are a couple of other PRs for configuring the serial ports. I will defer to @mdma to decide how to integrate the functionality into the new firmware. Being able to configure the SerialX settings is very important IMO. :smiley:

Worked this out mostly yesterday and the day before. The changes have been accepted, I am just waiting on the docs being accepted.

You guys sure are nice to work with. :smile:

2 Likes