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

Enable OLED support for Teensy 3.2/LC #7591

Merged
merged 6 commits into from
Jul 25, 2020
Merged

Conversation

zvecr
Copy link
Member

@zvecr zvecr commented Dec 9, 2019

Description

Another situation where the ChibiOS hal does a poor job of abstraction, where I2Cv1 has a different config structure.

Note: Teensy LC do not have enough memory to run a 128x32 OLED in the codebases current state.

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation

Issues Fixed or Closed by This PR

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

@drashna drashna requested a review from a team December 10, 2019 06:04
@zvecr zvecr force-pushed the feature/teensy_oled branch 2 times, most recently from 0854a00 to bac6647 Compare December 21, 2019 18:31
@zvecr zvecr marked this pull request as ready for review December 21, 2019 18:34
@stale
Copy link

stale bot commented Feb 4, 2020

Thank you for your contribution!
This pull request has been automatically marked as stale because it has not had activity in the last 45 days. It will be closed in 30 days if no further activity occurs. Please feel free to give a status update now, or re-open when it's ready.
For maintainers: Please label with awaiting review, breaking_change, in progress, or on hold to prevent the issue from being re-flagged.

@drashna drashna requested a review from a team February 5, 2020 03:53
@laughingrice
Copy link

laughingrice commented Apr 4, 2020

Not sure if it helps, I merged the changes into master and managed to compile both my code and handwired/onekey on the teensy 3.2 with the i2c_scanner keymap, but no i2c device is found (error -1).

I will be happy for any pointers/examples/missing patches. Not sure if the problem is the I2C code or if it's using non-standard I2C pins

@zvecr zvecr force-pushed the feature/teensy_oled branch from bac6647 to e8cc7ae Compare April 4, 2020 21:50
@zvecr
Copy link
Member Author

zvecr commented Apr 4, 2020

Just rebased and retested.

Default pins are configured to be 16 and 17 on this image,
image
With those, i2c scanner works fine.

@laughingrice
Copy link

I must be doing something wrong then.
I ran this sanity check / test using arduino and got "I2C device found at address 0x69"

#include <Wire.h>

void ScanI2C()
{
    int nDevices = 0;

    for(byte address = 1 ; address < 127 ; address++)
    {
        Wire.beginTransmission(address);
        byte error = Wire.endTransmission();

        if (!error)
        {
            Serial.print("I2C device found at address 0x");
            Serial.println(address,HEX);
            nDevices++;
        }
    }

    if (nDevices == 0)
        Serial.println("No I2C devices found\n");
}

void setup()
{
    Serial.begin(38400); // USB is always 12 Mbit/sec
    while (!Serial);

    Wire.begin();
    Wire.setSDA(17);
    Wire.setSCL(16);

    ScanI2C();
}

void loop() {}

I then tested the said branch:

git clone https://github.com/zvecr/qmk_firmware.git
cd qmk_firmware
git checkout feature/teensy_oled
make git-submodule

In keyboards/handwired/onekey/rules.mk changed the following

DEFAULT_FOLDER = handwired/onekey/teensy_32
LAYOUTS = i2c_scanner

ran qmk compile -kb handwired/onekey -km i2c_scanner, flashed .build/handwired_onekey_teensy_32_i2c_scanner.hex and got

Scanning...
No I2C devices found

@zvecr
Copy link
Member Author

zvecr commented Apr 4, 2020

As a FYI, you don't need to modify the rules.mk, just run qmk compile -kb handwired/onekey/teensy_32 -km i2c_scanner.

I assume there must be a difference in the I2C arduino implementation, and the device i'm using for testing responds differently.

i2c_start(address);
// except on ChibiOS where the only way is do do "something"
uint8_t data = 0;
return i2c_readReg(address, 0, &data, sizeof(data), TIMEOUT);

thus the "best effort" build warning.

@drashna drashna requested a review from a team April 5, 2020 05:27
@St0RM53
Copy link

St0RM53 commented Apr 5, 2020

@zvecr @drashna Anything i can test please let me know. My keyboard with teensy 3.2 has already oled connected to it via i2c that runs a demo if i flash it with an arduino based program, so hardware is functional. Just need you to point me to which code changes to re-compile and test.

@drashna
Copy link
Member

drashna commented Apr 5, 2020

From github itself, you should be able to run this:

git fetch origin refs/pull/7591/head
git checkout -b zvecr/feature/teensy_oled FETCH_HEAD

You may need to change the "origin" part to match whatever remove you have set for https://github.com/qmk/qmk_firmware.git, but aside from that .... the above command s should let you test out the code change in question.

The alternative, is to use something like hub, which is a wrapper for git for interfacing with github.

@St0RM53
Copy link

St0RM53 commented Apr 24, 2020

@drashna @zvecr
Updated keyboard to work on latest QMK 0.8.133
Test results after enabling OLED driver in rules.mk :

Before applying the fix: https://pastebin.com/GcddgNbj
After applying the fix: https://pastebin.com/SA8ve5X0

Less errors but still an issue.
Here is the keyboard since i have issues updating by branch properly in github: https://www.dropbox.com/s/wcw5xuxjabdpdoz/lilith101.zip?dl=0

Remember to enable oled driver for testing.

@zvecr zvecr force-pushed the feature/teensy_oled branch from 264618e to abac879 Compare April 24, 2020 22:29
@St0RM53
Copy link

St0RM53 commented Apr 25, 2020

After help from @zvecr compilation is successful for both I2CD1 and I2CD2; however only I2CD1 was functional in my testing.

@St0RM53
Copy link

St0RM53 commented Apr 26, 2020

update: All working fine for I2CD2 as well, the issue was missing definitions for the GPIO bank used for I2C1 pins as i2c_master.h uses by default Bank B where I2C0 pins are set.

@laughingrice
Copy link

Everything is working now. Not sure of the exact problem, for some reason this code was much more sensitive to running through a logic level converter than the teensy Arduino library version.

The scope showed that it's running at a much higher default frequency and probably uses a different logic level for 0/1 (logic level shifter was not shifting to the full range for some reason). I removed the logic level converter and am running the passive side (mpc23018) on 3.3 volts (cost a little on the maximum led level) and it's working now.

Looks like my PCB needs to go through another design iteration ...

@St0RM53
Copy link

St0RM53 commented May 22, 2020

@laughingrice Yes everything is working as expect now. Teensy 3.2 runs on 3.3V so i am assuming your logic shifter might not be designed for that frequency or it's input impedance is too low for the T3.2 output

@drashna I'm assuming this will be closed automatically as soon as it is merged?

@tzarc tzarc merged commit d91987a into qmk:master Jul 25, 2020
drashna pushed a commit to zsa/qmk_firmware that referenced this pull request Aug 9, 2020
* I2C_TIMEOUT is not defined on arm teensy

* Work round teensy having different ChibiOS config options

* Stash OLED conf files

* update comment

* update comment

* Remove stm32 alias to allow teensy alt mode

format code according to conventions [skip ci]
nicocesar pushed a commit to nicocesar/qmk_firmware that referenced this pull request Aug 12, 2020
* I2C_TIMEOUT is not defined on arm teensy

* Work round teensy having different ChibiOS config options

* Stash OLED conf files

* update comment

* update comment

* Remove stm32 alias to allow teensy alt mode
BorisTestov pushed a commit to BorisTestov/qmk_firmware that referenced this pull request May 23, 2024
* I2C_TIMEOUT is not defined on arm teensy

* Work round teensy having different ChibiOS config options

* Stash OLED conf files

* update comment

* update comment

* Remove stm32 alias to allow teensy alt mode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ARM I2C driver not implemented for KINETIS MCU's (i.e. Teensy 3.2/3.5/3.6/LC)
6 participants