-
Notifications
You must be signed in to change notification settings - Fork 1
Unique I2C address for top/bottom variant #3
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
Conversation
Detection is based on LED pulling ADDR_SELECT (PA12) high / low
Instead of auto-detecting deck variant via PA12, the Crazyflie now pulls PC15 (I2C_ADDR) high to select address 0x11. Added 500ms boot delay to ensure the Crazyflie has set PC15 before the deck reads it. PA12 (ADDR_SELECT) remains available for future I2C commands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements dynamic I2C address configuration for the color-led firmware, allowing the device's I2C slave address to be selected at runtime based on GPIO pin states. The base I2C address is 0x10 (OwnAddress1 = 0x20 in 8-bit format), with the option to increment to 0x11 (OwnAddress1 = 0x22) based on pin PC15.
Key changes:
- Added runtime I2C address selection based on PC15 (I2C_ADDR) pin state
- Introduced PA12 as ADDR_SELECT input pin with pulldown (currently unused in code but configured)
- Modified GPIO initialization to support two new input pins for address configuration
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| color-led.ioc | Updated STM32CubeMX configuration to add PC15 and PA12 as GPIO input pins and changed PA12 from output to input mode |
| Core/Src/main.c | Implemented dynamic I2C address selection logic reading PC15 after 500ms delay, and updated GPIO initialization for new pin configurations |
| Core/Inc/main.h | Added pin definitions for I2C_ADDR (PC15) and ADDR_SELECT (PA12) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Extends I2C protocol (v1→v2) with two new commands: - CMD_GET_LED_POSITION: Reports top/bottom mounting via PA12 detection - CMD_GET_LED_CURRENT: Reports per-channel current readings (R,G,B,W) LED position is detected once at startup using pull-up/pull-down testing to distinguish between floating (no LED), driven-low (bottom), and driven-high (top) states. Current monitoring reads ADC channels 4-7 in round-robin fashion during main loop and converts to milliamps using appropriate sense resistor values (3.4Ω for red, 1.0Ω for others).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I2C address changing not working consistently |
b6d33aa to
5339d56
Compare
5339d56 to
1eb319c
Compare
…shing instructions in the development guide
Makes the flashing process more transparent
Refactor driver from single-deck to dual-deck architecture with context-based state management. Previously the driver only supported one deck at a time. Now both variants can operate simultaneously with separate state, parameters, and logging. Driver changes: - Context structure holds per-instance state (init, colors, thermal, current, position) - Two deck drivers: bcColorLEDBot (PID 0x13) and bcColorLEDTop (PID 0x14) - I2C addressing: bottom at 0x30, top at 0x31 (GPIO 11 controls address selection for top) - Separate bootloader reset functions for each deck (both use DFU address 0x64) - LED controller callback now forwards to all initialized instances Parameter and log group changes: - Renamed from colorled to colorLedBot and colorLedTop for separate control - brightnessCorr shortened to brightCorr (firmware name length limits) - Detection parameters: deck.bcColorLedBot and deck.bcColorLedTop - New log variables: ledPos, ledCurR, ledCurG, ledCurB, ledCurW Protocol enhancements (v1 → v2): - Add CMD_GET_LED_POSITION and CMD_GET_LED_CURRENT commands - Increase RXBUFFERSIZE to 9 bytes for current readings (4 channels × 2 bytes) - Task loop refactored with dedicated polling functions (thermal: 100ms, current: 1000ms) - LED position polled once during initialization (hardware-fixed value) Note: LED current readings are PWM-based and only provide stable values at full intensity (100% duty cycle). This feature and position detection are primarily for production testing. Luminance correction improvements: - Red LED value updated to 139 lumens (from 90) accounting for actual circuit current - Red's lower forward voltage (2.1V vs 2.9V) results in 1.54× higher current despite higher sense resistor, requiring luminance adjustment GPIO initialization now includes proper error handling with debug messages. Example app updated to auto-detect and select appropriate deck parameter group. Requires: - bitcraze/color-led-deck-firmware#3 - bitcraze/deck-ctrl-firmware#4
…loper note for STM32 option bytes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Refactor driver from single-deck to dual-deck architecture with context-based state management. Previously the driver only supported one deck at a time. Now both variants can operate simultaneously with separate state, parameters, and logging. Driver changes: - Context structure holds per-instance state (init, colors, thermal, current, position) - Two deck drivers: bcColorLEDBot (PID 0x13) and bcColorLEDTop (PID 0x14) - I2C addressing: bottom at 0x30, top at 0x31 (GPIO 11 controls address selection for top) - Separate bootloader reset functions for each deck (both use DFU address 0x64) - LED controller callback now forwards to all initialized instances Parameter and log group changes: - Renamed from colorled to colorLedBot and colorLedTop for separate control - brightnessCorr shortened to brightCorr (firmware name length limits) - Detection parameters: deck.bcColorLedBot and deck.bcColorLedTop - New log variables: ledPos, ledCurR, ledCurG, ledCurB, ledCurW Protocol enhancements (v1 → v2): - Add CMD_GET_LED_POSITION and CMD_GET_LED_CURRENT commands - Increase RXBUFFERSIZE to 9 bytes for current readings (4 channels × 2 bytes) - Task loop refactored with dedicated polling functions (thermal: 100ms, current: 1000ms) - LED position polled once during initialization (hardware-fixed value) Note: LED current readings are PWM-based and only provide stable values at full intensity (100% duty cycle). This feature and position detection are primarily for production testing. Luminance correction improvements: - Red LED value updated to 139 lumens (from 90) accounting for actual circuit current - Red's lower forward voltage (2.1V vs 2.9V) results in 1.54× higher current despite higher sense resistor, requiring luminance adjustment GPIO initialization now includes proper error handling with debug messages. Example app updated to auto-detect and select appropriate deck parameter group. Requires: - bitcraze/color-led-deck-firmware#3 - bitcraze/deck-ctrl-firmware#4
The deck's I2C address is selected by the Crazyflie via the I2C_ADDR pin (PC15). When PC15 is pulled high, the deck uses address 0x31; when low, it defaults to 0x30. It required a sizeable 100ms boot delay to ensure PC15 is stable before reading it.
PA12 (ADDR_SELECT) is used for LED position detection. The deck tests this pin at startup using pull-up/pull-down states to distinguish between floating (no LED), driven-low (bottom), and driven-high (top) states.
The I2C protocol was extended from v1 to v2 with two new commands:
Requires: