OpenGround – Part 7 – Using the FT6236 touch controller / I2C on the STM32F0

Disclosure: This post may contain affiliate links, meaning I get a commission if you decide to make a purchase through my links, at no cost to you.

By | September 22, 2016

This is the seventh post of my series documenting the development of a custom firmware for the FS-i6s transmitter. In my previous post we used the internal DMA engine to read out all ADC channels. Now it’s time to activate the FT6236 touchscreen.

Touch! How?

The Flysky FS-i6S uses an FT6236 controller. There is some documentation on this controller available. First of all there is the FT6236 datasheet with some basic information. Additionally, Adafruit published an application note for the FT6x06 controller series and there is a basic driver for this touch controller inside the linux source tree (code).

Driver

The touch controller is connected to the I2C1 interface of the STM32 and uses an additional reset control line and an interrupt request line. See my first post for the pinout.

The implementation can be found in the file touch.c on my github repository. The first initialization routines are some basic I2C set up stuff for an stm32f0. something special/uncommon is the touch_init_i2c_free_bus() function. It is used to send out a SCK pulsetrain to reset/free any I2C devices stuck in between a transfer. This should not be necessary here as we can hard-reset the touch controller by using the RST line, however it does not harm to have it. This routine was originally written when i faced issues with the I2C eeprom on the D4R-ii receiver while porting OpenSky to it.

Once the basic I2C setup is done, the touch controller can be used immediately. Right now there is only some register reading for debugging purposes. There is no proper initialization, the controller runs with its’ default values.

Gestures?

The datasheet of the touch controller states that the chip is capable to detect different swipe and zoom gestures. However, I was not able to detect them. The gesture_id register always returns zero. Maybe the gesture recognition needs a special initialization sequence. In case you found out how to enable the gesture recognition please send me an email!

Try it out

You can compile an test the code on your own, check out the tag part7_touchscreen and build the code (this requires the arm gcc toolchain to be installed):

git clone https://github.com/fishpepper/OpenGround.git
git checkout part7_touchscreen
make

After the code was compiled we can now flash the code to our transmitter. We will use the ST-Link interface to flash the chip. The makefile has a nice macro for that, you can flash the target by executing:

make flash

The screen should now be initialized and you should see a print of the coordinates when you tap the screen. Please note that this code will shut down the transmitter after 10 seconds. You will have to re-enable the transmitter by pressing both power on buttons again. You canĀ not flash the tx when it is in the off state!

 

Leave a Reply

Your email address will not be published. Required fields are marked *