Skip to content

Commit 7d76d60

Browse files
Fix HyperX DRAM ordering
1 parent 7e5546c commit 7d76d60

2 files changed

Lines changed: 17 additions & 19 deletions

File tree

Controllers/HyperXDRAMController/HyperXDRAMController.cpp

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@ void HyperXDRAMController::SetAllColors(unsigned char red, unsigned char green,
9797
| Loop through all slots and only set those which are |
9898
| active. |
9999
\*-----------------------------------------------------*/
100-
for(int slot = 0; slot < 4; slot++)
100+
for(unsigned int slot_idx = 0; slot_idx < 4; slot_idx++)
101101
{
102+
unsigned char slot = slot_map[slot_idx];
103+
102104
if((slots_valid & (1 << slot)) != 0)
103105
{
104106
unsigned char base = slot_base[slot];
@@ -136,16 +138,18 @@ void HyperXDRAMController::SetLEDColor(unsigned int led, unsigned char red, unsi
136138
\*-----------------------------------------------------*/
137139
int led_slot = led / 5;
138140
int slot_id = -1;
139-
int slot;
141+
unsigned char slot;
140142

141143
led -= (led_slot * 5);
142144

143145
/*-----------------------------------------------------*\
144146
| Loop through all possible slots and only count those |
145147
| which are active. |
146148
\*-----------------------------------------------------*/
147-
for(slot = 0; slot < 4; slot++)
149+
for(unsigned int slot_idx = 0; slot_idx < 4; slot_idx++)
148150
{
151+
slot = slot_map[slot_idx];
152+
149153
if((slots_valid & ( 1 << slot)) != 0)
150154
{
151155
slot_id++;
@@ -157,21 +161,7 @@ void HyperXDRAMController::SetLEDColor(unsigned int led, unsigned char red, unsi
157161
}
158162
}
159163

160-
unsigned char base = slot_base[slot];
161-
unsigned char red_base = base + 0x00;
162-
unsigned char green_base = base + 0x01;
163-
unsigned char blue_base = base + 0x02;
164-
unsigned char bright_base = base + 0x10;
165-
166-
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x01);
167-
168-
bus->i2c_smbus_write_byte_data(dev, red_base + (3 * led), red );
169-
bus->i2c_smbus_write_byte_data(dev, green_base + (3 * led), green);
170-
bus->i2c_smbus_write_byte_data(dev, blue_base + (3 * led), blue );
171-
bus->i2c_smbus_write_byte_data(dev, bright_base + (3 * led), 0x64 );
172-
173-
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x02);
174-
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x03);
164+
SetLEDColor(slot, led, red, green, blue);
175165
}
176166

177167

Controllers/HyperXDRAMController/HyperXDRAMController.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,19 @@ enum
188188
static const unsigned char slot_base[4] =
189189
{
190190
HYPERX_REG_SLOT0_LED0_RED, /* SPD 0x50 maps to slot 0 */
191-
HYPERX_REG_SLOT2_LED0_RED, /* SPD 0x51 maps to slot 2 */
192191
HYPERX_REG_SLOT1_LED0_RED, /* SPD 0x52 maps to slot 1 */
192+
HYPERX_REG_SLOT2_LED0_RED, /* SPD 0x51 maps to slot 2 */
193193
HYPERX_REG_SLOT3_LED0_RED /* SPD 0x53 maps to slot 3 */
194194
};
195195

196+
static const unsigned char slot_map[4] =
197+
{
198+
0,
199+
2,
200+
1,
201+
3
202+
};
203+
196204
class HyperXDRAMController
197205
{
198206
public:

0 commit comments

Comments
 (0)