Skip to content

Commit aed8ea3

Browse files
committed
MPAE-19438 fixed MISRA compliance
1 parent 8898ea4 commit aed8ea3

33 files changed

+25
-25
lines changed

pic18f57q43-i2c-io-expander2-leds-and-buttons-polled-printf.X/main.c renamed to pic18f57q43-i2c-io-expander2-leds-buttons-polled-printf.X/main.c

Lines changed: 11 additions & 11 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

142-
while (IO_Reset_GetValue() && !resetFlag) // Run until Reset SW is pressed
142+
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
}
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: pic18f57q43-i2c-io-expander2-leds-and-buttons-polled-printf
5-
creation_date: 2025-04-11T13:57:12.268+02:00[Europe/Berlin]
5+
creation_date: 2025-04-14T11:20:52.416+02:00[Europe/Berlin]
66
operating_system: Windows 11
77
mcc_mode: IDE
88
mcc_mode_version: v6.25
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: pic18f57q43-i2c-io-expander2-leds-and-buttons-polled-printf
5-
creation_date: 2025-04-11T13:57:12.228+02:00[Europe/Berlin]
5+
creation_date: 2025-04-14T11:20:52.371+02:00[Europe/Berlin]
66
operating_system: Windows 11
77
mcc_mode: IDE
88
mcc_mode_version: v6.25
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ void printButtonPressed(int pressedButton) {
125125
126126
void button_led_control(void)
127127
{
128-
uint8_t ioexInputs = 0;
129-
uint8_t defaultInputs = 0;
130-
uint8_t activeLEDs = 0;
128+
uint8_t mcp23008_1_activeLEDs = 0;
129+
uint8_t mcp23008_2_previousInputs = 0;
130+
uint8_t mcp23008_2_currentInputs = 0;
131131
132132
(uint8_t) MCP23008_Write(MCP23008_1_I2C_ADDRESS, MCP23008_IODIR, 0x00);
133133
(uint8_t) MCP23008_Write(MCP23008_1_I2C_ADDRESS, MCP23008_GPIO, 0x00); // After this line of code, the LEDs should be on.
@@ -137,25 +137,25 @@ void button_led_control(void)
137137
(uint8_t) MCP23008_Write(MCP23008_2_I2C_ADDRESS, MCP23008_IOCON, 0x20); // Set SEQOP bit to 1 for Byte mode
138138
139139
// Read the default state of the inputs
140-
(uint8_t) MCP23008_Read(MCP23008_2_I2C_ADDRESS, MCP23008_GPIO, &defaultInputs);
141-
(int) printf("Default inputs: 0x%02X\n", defaultInputs);
140+
(uint8_t) MCP23008_Read(MCP23008_2_I2C_ADDRESS, MCP23008_GPIO, &mcp23008_2_previousInputs);
141+
(int) printf("Default inputs: 0x%02X\n", mcp23008_2_previousInputs);
142142
143-
while (IO_Reset_GetValue() && !resetFlag) // Run until Reset SW is pressed
143+
while ((IO_Reset_GetValue() != 0) && !resetFlag) // Run until Reset SW is pressed
144144
{
145-
(uint8_t) MCP23008_Read(MCP23008_2_I2C_ADDRESS, MCP23008_GPIO, &ioexInputs); // Read GPIO register to get the state of the inputs
145+
(uint8_t) MCP23008_Read(MCP23008_2_I2C_ADDRESS, MCP23008_GPIO, &mcp23008_2_currentInputs); // Read GPIO register to get the state of the inputs
146146
147-
uint8_t changed_inputs = defaultInputs ^ ioexInputs; // XOR to find changed bits
147+
uint8_t changed_inputs = mcp23008_2_previousInputs ^ mcp23008_2_currentInputs; // XOR to find changed bits
148148
if (!(changed_inputs == 0U)) // Check if there is any change from the default state
149149
{
150150
for (uint8_t i = 0U; i < 8U; i++) // Check each bit to see if a button is pressed
151151
{
152152
if (!(changed_inputs == 0U)) // Check if there is any change from the default state
153153
{
154-
if ((ioexInputs & (1U << i)) == 0U) // Button pressed (active low)
154+
if ((mcp23008_2_currentInputs & (1U << i)) == 0U) // Button pressed (active low)
155155
{
156156
uint8_t pressedButton = i;
157-
activeLEDs = (activeLEDs | (1U << pressedButton));
158-
(uint8_t) MCP23008_Write(MCP23008_1_I2C_ADDRESS, MCP23008_GPIO, activeLEDs); // Set IO-expander 1 pins low
157+
mcp23008_1_activeLEDs = (mcp23008_1_activeLEDs | (1U << pressedButton));
158+
(uint8_t) MCP23008_Write(MCP23008_1_I2C_ADDRESS, MCP23008_GPIO, mcp23008_1_activeLEDs); // Set IO-expander 1 pins low
159159
printButtonPressed(pressedButton);
160160
}
161161
}

0 commit comments

Comments
 (0)