Skip to content

Commit fbe2f89

Browse files
committed
MPAE-19439 renames variables for easier understanding
1 parent ec4913b commit fbe2f89

File tree

5 files changed

+24
-24
lines changed

5 files changed

+24
-24
lines changed

avr128db48-i2c-io-expander2-leds-and-buttons-polled-printf.X/avr128db48-i2c-io-expander2-leds-and-buttons-polled-printf.mc3

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
</entry>
147147
<entry>
148148
<file>mcc_generated_files\examples\I2C-Host-Example\i2c_host_example.c</file>
149-
<hash>8a4c8fb9c5a95d53dbb71834a048b46c9eb433a60e8674ad03b548bd222c7244</hash>
149+
<hash>faa91b838c4a01ae78e77355725923b6f69d3be3b70d6846d74184c602b8d2d1</hash>
150150
</entry>
151151
<entry>
152152
<file>mcc_generated_files\i2c_host\i2c_host_event_types.h</file>

avr128db48-i2c-io-expander2-leds-and-buttons-polled-printf.X/main.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ void printButtonPressed(int pressedButton) {
123123

124124
void button_led_control(void)
125125
{
126-
uint8_t ioexInputs = 0;
127-
uint8_t defaultInputs = 0;
128-
uint8_t activeLEDs = 0;
126+
uint8_t mcp23008_1_activeLEDs = 0;
127+
uint8_t mcp23008_2_previousInputs = 0;
128+
uint8_t mcp23008_2_currentInputs = 0;
129129

130130
(uint8_t) MCP23008_Write(MCP23008_1_I2C_ADDRESS, MCP23008_IODIR, 0x00);
131131
(uint8_t) MCP23008_Write(MCP23008_1_I2C_ADDRESS, MCP23008_GPIO, 0x00); // After this line of code, the LEDs should be on.
@@ -135,25 +135,25 @@ void button_led_control(void)
135135
(uint8_t) MCP23008_Write(MCP23008_2_I2C_ADDRESS, MCP23008_IOCON, 0x20); // Set SEQOP bit to 1 for Byte mode
136136

137137
// Read the default state of the inputs
138-
(uint8_t) MCP23008_Read(MCP23008_2_I2C_ADDRESS, MCP23008_GPIO, &defaultInputs);
139-
(int) printf("Default inputs: 0x%02X\n", defaultInputs);
138+
(uint8_t) MCP23008_Read(MCP23008_2_I2C_ADDRESS, MCP23008_GPIO, &mcp23008_2_previousInputs);
139+
(int) printf("Default inputs: 0x%02X\n", mcp23008_2_previousInputs);
140140

141141
while ((IO_Reset_GetValue() != 0) && !resetFlag) // Run until Reset SW is pressed
142142
{
143-
(uint8_t) MCP23008_Read(MCP23008_2_I2C_ADDRESS, MCP23008_GPIO, &ioexInputs); // Read GPIO register to get the state of the inputs
143+
(uint8_t) MCP23008_Read(MCP23008_2_I2C_ADDRESS, MCP23008_GPIO, &mcp23008_2_currentInputs); // Read GPIO register to get the state of the inputs
144144

145-
uint8_t changed_inputs = defaultInputs ^ ioexInputs; // XOR to find changed bits
145+
uint8_t changed_inputs = mcp23008_2_previousInputs ^ mcp23008_2_currentInputs; // XOR to find changed bits
146146
if (!(changed_inputs == 0U)) // Check if there is any change from the default state
147147
{
148148
for (uint8_t i = 0U; i < 8U; i++) // Check each bit to see if a button is pressed
149149
{
150150
if (!(changed_inputs == 0U)) // Check if there is any change from the default state
151151
{
152-
if ((ioexInputs & (1U << i)) == 0U) // Button pressed (active low)
152+
if ((mcp23008_2_currentInputs & (1U << i)) == 0U) // Button pressed (active low)
153153
{
154154
uint8_t pressedButton = i;
155-
activeLEDs = (activeLEDs | (1U << pressedButton));
156-
(uint8_t) MCP23008_Write(MCP23008_1_I2C_ADDRESS, MCP23008_GPIO, activeLEDs); // Set IO-expander 1 pins low
155+
mcp23008_1_activeLEDs = (mcp23008_1_activeLEDs | (1U << pressedButton));
156+
(uint8_t) MCP23008_Write(MCP23008_1_I2C_ADDRESS, MCP23008_GPIO, mcp23008_1_activeLEDs); // Set IO-expander 1 pins low
157157
printButtonPressed(pressedButton);
158158
}
159159
}
@@ -185,4 +185,4 @@ int main(void)
185185
}
186186
}
187187
return 0; // Shouldn't get here!!
188-
}
188+
}

avr128db48-i2c-io-expander2-leds-and-buttons-polled-printf.X/mcc-manifest-autosave.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
manifest_file_version: 1.0.0
44
project: avr128db48-i2c-io-expander2-leds-and-buttons-polled-printf
5-
creation_date: 2025-04-11T15:38:29.432+02:00[Europe/Berlin]
5+
creation_date: 2025-04-12T14:12:26.527+02:00[Europe/Berlin]
66
operating_system: Windows 11
77
mcc_mode: IDE
88
mcc_mode_version: v6.25

avr128db48-i2c-io-expander2-leds-and-buttons-polled-printf.X/mcc-manifest-generated-success.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
manifest_file_version: 1.0.0
44
project: avr128db48-i2c-io-expander2-leds-and-buttons-polled-printf
5-
creation_date: 2025-04-11T15:38:29.397+02:00[Europe/Berlin]
5+
creation_date: 2025-04-12T14:12:26.473+02:00[Europe/Berlin]
66
operating_system: Windows 11
77
mcc_mode: IDE
88
mcc_mode_version: v6.25

avr128db48-i2c-io-expander2-leds-and-buttons-polled-printf.X/mcc_generated_files/examples/I2C-Host-Example/i2c_host_example.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ void printButtonPressed(int pressedButton) {
124124
125125
void button_led_control(void)
126126
{
127-
uint8_t ioexInputs = 0;
128-
uint8_t defaultInputs = 0;
129-
uint8_t activeLEDs = 0;
127+
uint8_t mcp23008_1_activeLEDs = 0;
128+
uint8_t mcp23008_2_previousInputs = 0;
129+
uint8_t mcp23008_2_currentInputs = 0;
130130
131131
(uint8_t) MCP23008_Write(MCP23008_1_I2C_ADDRESS, MCP23008_IODIR, 0x00);
132132
(uint8_t) MCP23008_Write(MCP23008_1_I2C_ADDRESS, MCP23008_GPIO, 0x00); // After this line of code, the LEDs should be on.
@@ -136,25 +136,25 @@ void button_led_control(void)
136136
(uint8_t) MCP23008_Write(MCP23008_2_I2C_ADDRESS, MCP23008_IOCON, 0x20); // Set SEQOP bit to 1 for Byte mode
137137
138138
// Read the default state of the inputs
139-
(uint8_t) MCP23008_Read(MCP23008_2_I2C_ADDRESS, MCP23008_GPIO, &defaultInputs);
140-
(int) printf("Default inputs: 0x%02X\n", defaultInputs);
139+
(uint8_t) MCP23008_Read(MCP23008_2_I2C_ADDRESS, MCP23008_GPIO, &mcp23008_2_previousInputs);
140+
(int) printf("Default inputs: 0x%02X\n", mcp23008_2_previousInputs);
141141
142142
while ((IO_Reset_GetValue() != 0) && !resetFlag) // Run until Reset SW is pressed
143143
{
144-
(uint8_t) MCP23008_Read(MCP23008_2_I2C_ADDRESS, MCP23008_GPIO, &ioexInputs); // Read GPIO register to get the state of the inputs
144+
(uint8_t) MCP23008_Read(MCP23008_2_I2C_ADDRESS, MCP23008_GPIO, &mcp23008_2_currentInputs); // Read GPIO register to get the state of the inputs
145145
146-
uint8_t changed_inputs = defaultInputs ^ ioexInputs; // XOR to find changed bits
146+
uint8_t changed_inputs = mcp23008_2_previousInputs ^ mcp23008_2_currentInputs; // XOR to find changed bits
147147
if (!(changed_inputs == 0U)) // Check if there is any change from the default state
148148
{
149149
for (uint8_t i = 0U; i < 8U; i++) // Check each bit to see if a button is pressed
150150
{
151151
if (!(changed_inputs == 0U)) // Check if there is any change from the default state
152152
{
153-
if ((ioexInputs & (1U << i)) == 0U) // Button pressed (active low)
153+
if ((mcp23008_2_currentInputs & (1U << i)) == 0U) // Button pressed (active low)
154154
{
155155
uint8_t pressedButton = i;
156-
activeLEDs = (activeLEDs | (1U << pressedButton));
157-
(uint8_t) MCP23008_Write(MCP23008_1_I2C_ADDRESS, MCP23008_GPIO, activeLEDs); // Set IO-expander 1 pins low
156+
mcp23008_1_activeLEDs = (mcp23008_1_activeLEDs | (1U << pressedButton));
157+
(uint8_t) MCP23008_Write(MCP23008_1_I2C_ADDRESS, MCP23008_GPIO, mcp23008_1_activeLEDs); // Set IO-expander 1 pins low
158158
printButtonPressed(pressedButton);
159159
}
160160
}

0 commit comments

Comments
 (0)