mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
Add LED-pad mapping
This commit is contained in:
@@ -35,6 +35,9 @@ __code const struct machine machine = {
|
|||||||
LEDS_1G | LEDS_LINK,
|
LEDS_1G | LEDS_LINK,
|
||||||
0 },
|
0 },
|
||||||
},
|
},
|
||||||
|
.led_mux_custom = 1,
|
||||||
|
.led_mux = {0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x0f, 0x0c, 0x0d, 0x0e, 0x10, 0x11, 0x12, 0x14,
|
||||||
|
0x15, 0x16, 0x18, 0x19, 0x1a, 0x1c, 0x1d, 0x1e, 0x20, 0x21, 0x22, 0x23 },
|
||||||
};
|
};
|
||||||
#elif defined MACHINE_KP_9000_6XH_X
|
#elif defined MACHINE_KP_9000_6XH_X
|
||||||
__code const struct machine machine = {
|
__code const struct machine machine = {
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
/*
|
/*
|
||||||
* Select your machine type below
|
* Select your machine type below
|
||||||
*/
|
*/
|
||||||
// #define MACHINE_KP_9000_6XHML_X2
|
#define MACHINE_KP_9000_6XHML_X2
|
||||||
// #define MACHINE_KP_9000_6XH_X
|
// #define MACHINE_KP_9000_6XH_X
|
||||||
#define MACHINE_KP_9000_9XH_X_EU
|
// #define MACHINE_KP_9000_9XH_X_EU
|
||||||
// #define MACHINE_SWGT024_V2_0
|
// #define MACHINE_SWGT024_V2_0
|
||||||
// #define MACHINE_HORACO_ZX_SG4T2
|
// #define MACHINE_HORACO_ZX_SG4T2
|
||||||
// #define MACHINE_HG0402XG_V1_1
|
// #define MACHINE_HG0402XG_V1_1
|
||||||
@@ -58,6 +58,8 @@ typedef struct machine {
|
|||||||
struct high_leds high_leds;
|
struct high_leds high_leds;
|
||||||
uint8_t port_led_set[9];
|
uint8_t port_led_set[9];
|
||||||
uint32_t led_sets[4][4];
|
uint32_t led_sets[4][4];
|
||||||
|
uint8_t led_mux_custom;
|
||||||
|
uint8_t led_mux[28];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct machine_runtime
|
typedef struct machine_runtime
|
||||||
|
|||||||
+71
-1
@@ -38,7 +38,42 @@ void leds_dump(void) __banked
|
|||||||
print_string("RTL837X_REG_LED3_0_SET1: "); print_reg(RTL837X_REG_LED3_0_SET1); write_char('\n');
|
print_string("RTL837X_REG_LED3_0_SET1: "); print_reg(RTL837X_REG_LED3_0_SET1); write_char('\n');
|
||||||
print_string("RTL837X_REG_LED3_0_SET3: "); print_reg(RTL837X_REG_LED3_0_SET3); write_char('\n');
|
print_string("RTL837X_REG_LED3_0_SET3: "); print_reg(RTL837X_REG_LED3_0_SET3); write_char('\n');
|
||||||
print_string("RTL837X_LED_PORT_SET_SEL: "); print_reg(RTL837X_LED_PORT_SET_SEL); write_char('\n');
|
print_string("RTL837X_LED_PORT_SET_SEL: "); print_reg(RTL837X_LED_PORT_SET_SEL); write_char('\n');
|
||||||
print_string("LED Configuration:\n");
|
print_string("RTL837X_REG_LED_GLB_MUX_1: "); print_reg(RTL837X_REG_LED_GLB_MUX_1); write_char('\n');
|
||||||
|
print_string("RTL837X_REG_LED_GLB_MUX_2: "); print_reg(RTL837X_REG_LED_GLB_MUX_2); write_char('\n');
|
||||||
|
print_string("RTL837X_REG_LED_GLB_MUX_3: "); print_reg(RTL837X_REG_LED_GLB_MUX_3); write_char('\n');
|
||||||
|
print_string("RTL837X_REG_LED_GLB_MUX_4: "); print_reg(RTL837X_REG_LED_GLB_MUX_4); write_char('\n');
|
||||||
|
print_string("RTL837X_REG_LED_GLB_MUX_5: "); print_reg(RTL837X_REG_LED_GLB_MUX_5); write_char('\n');
|
||||||
|
print_string("RTL837X_REG_LED_GLB_MUX_6: "); print_reg(RTL837X_REG_LED_GLB_MUX_6); write_char('\n');
|
||||||
|
print_string("RTL837X_REG_LED_GLB_ACTIVE: "); print_reg(RTL837X_REG_LED_GLB_ACTIVE); write_char('\n');
|
||||||
|
print_string("LED pad Configuration:\n");
|
||||||
|
for (uint8_t i = 0; i < 28; i++) {
|
||||||
|
print_byte(i);
|
||||||
|
write_char(' ');
|
||||||
|
}
|
||||||
|
write_char('\n');
|
||||||
|
for (uint8_t i = 0; i < 28; i++) {
|
||||||
|
switch (i % 5) {
|
||||||
|
case 0: // 0
|
||||||
|
reg_read_m(RTL837X_REG_LED_GLB_MUX_1 + (i / 5) * 4);
|
||||||
|
print_byte(sfr_data[3] & 0x3f);
|
||||||
|
break;
|
||||||
|
case 1: // 6
|
||||||
|
print_byte(((sfr_data[3] >> 6) | (sfr_data[2] << 2)) & 0x3f);
|
||||||
|
break;
|
||||||
|
case 2: // 12
|
||||||
|
print_byte(((sfr_data[1] << 4) | (sfr_data[2] >> 4)) & 0x3f);
|
||||||
|
break;
|
||||||
|
case 3: // 18
|
||||||
|
print_byte((sfr_data[1] >> 2) & 0x3f);
|
||||||
|
break;
|
||||||
|
case 4: // 24
|
||||||
|
print_byte(sfr_data[0] & 0x3f);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
write_char(' ');
|
||||||
|
}
|
||||||
|
write_char('\n');
|
||||||
|
print_string("LED-set Configuration:\n");
|
||||||
print_string("LED-ID\t\t0\t\t1\t\t2\t\t3\n");
|
print_string("LED-ID\t\t0\t\t1\t\t2\t\t3\n");
|
||||||
for (__xdata uint8_t set = 0; set < 4; set++) {
|
for (__xdata uint8_t set = 0; set < 4; set++) {
|
||||||
print_string("SET "); write_char('0' + set); write_char(':');
|
print_string("SET "); write_char('0' + set); write_char(':');
|
||||||
@@ -180,6 +215,38 @@ void leds_setup(void) __banked
|
|||||||
else
|
else
|
||||||
reg_bit_clear(RTL837X_REG_LED_GLB_IO_EN, 29);
|
reg_bit_clear(RTL837X_REG_LED_GLB_IO_EN, 29);
|
||||||
|
|
||||||
|
// Configure the LED-mux
|
||||||
|
if (machine.led_mux_custom) {
|
||||||
|
print_string("Configuring custom LED-muxes: ");
|
||||||
|
for (uint8_t i = 0; i < 28; i++) {
|
||||||
|
switch (i % 5) {
|
||||||
|
case 0: // 0
|
||||||
|
sfr_data[3] = machine.led_mux[i];
|
||||||
|
break;
|
||||||
|
case 1: // 6
|
||||||
|
sfr_data[3] |= machine.led_mux[i] << 6;
|
||||||
|
sfr_data[2] = machine.led_mux[i] >> 2;
|
||||||
|
break;
|
||||||
|
case 2: // 12
|
||||||
|
sfr_data[2] |= machine.led_mux[i] << 4;
|
||||||
|
sfr_data[1] = machine.led_mux[i] >> 4;
|
||||||
|
break;
|
||||||
|
case 3: // 18
|
||||||
|
sfr_data[1] |= machine.led_mux[i] << 2;
|
||||||
|
break;
|
||||||
|
case 4: // 24
|
||||||
|
sfr_data[0] = machine.led_mux[i];
|
||||||
|
print_sfr_data(); write_char(' ');
|
||||||
|
reg_write_m(RTL837X_REG_LED_GLB_MUX_1 + (i / 5) * 4);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
write_char(' ');
|
||||||
|
}
|
||||||
|
sfr_data[0] = 0; sfr_data[1] &= 0xf;
|
||||||
|
print_sfr_data(); write_char('\n');
|
||||||
|
reg_write_m(RTL837X_REG_LED_GLB_MUX_6);
|
||||||
|
}
|
||||||
|
|
||||||
// Configure the LED-set of a port
|
// Configure the LED-set of a port
|
||||||
sfr_data[3] = sfr_data[2] = sfr_data[1] = sfr_data[0] = 0;
|
sfr_data[3] = sfr_data[2] = sfr_data[1] = sfr_data[0] = 0;
|
||||||
for (uint8_t i = machine.min_port; i <= machine.max_port; i++)
|
for (uint8_t i = machine.min_port; i <= machine.max_port; i++)
|
||||||
@@ -187,6 +254,9 @@ void leds_setup(void) __banked
|
|||||||
reg_write_m(RTL837X_LED_PORT_SET_SEL);
|
reg_write_m(RTL837X_LED_PORT_SET_SEL);
|
||||||
|
|
||||||
// Configure the LED-sets
|
// Configure the LED-sets
|
||||||
|
sfr_data[3] = sfr_data[2] = sfr_data[1] = sfr_data[0] = 0;
|
||||||
|
reg_write_m(RTL837X_REG_LED3_0_SET1);
|
||||||
|
reg_write_m(RTL837X_REG_LED3_0_SET3);
|
||||||
__code uint8_t * __xdata lptr = &machine.led_sets[0][0];
|
__code uint8_t * __xdata lptr = &machine.led_sets[0][0];
|
||||||
for (__xdata uint8_t set = 0; set < 4; set++) {
|
for (__xdata uint8_t set = 0; set < 4; set++) {
|
||||||
sfr_data[0] = *(lptr + 5);
|
sfr_data[0] = *(lptr + 5);
|
||||||
|
|||||||
@@ -20,6 +20,13 @@
|
|||||||
// BIT 17 set: LED solid on
|
// BIT 17 set: LED solid on
|
||||||
// Bytes 0/1 hold the LED mode, e.g. serial, RTL8231?
|
// Bytes 0/1 hold the LED mode, e.g. serial, RTL8231?
|
||||||
// Blink rate is defined by setAsicRegBits(0x6520,0xe00000,rate);
|
// Blink rate is defined by setAsicRegBits(0x6520,0xe00000,rate);
|
||||||
|
#define RTL837X_REG_LED_GLB_MUX_1 0x65E0
|
||||||
|
#define RTL837X_REG_LED_GLB_MUX_2 0x65E4
|
||||||
|
#define RTL837X_REG_LED_GLB_MUX_3 0x65E8
|
||||||
|
#define RTL837X_REG_LED_GLB_MUX_4 0x65EC
|
||||||
|
#define RTL837X_REG_LED_GLB_MUX_5 0x65F0
|
||||||
|
#define RTL837X_REG_LED_GLB_MUX_6 0x65F4
|
||||||
|
#define RTL837X_REG_LED_GLB_ACTIVE 0x65D8
|
||||||
#define RTL837X_REG_LED_GLB_IO_EN 0x65DC
|
#define RTL837X_REG_LED_GLB_IO_EN 0x65DC
|
||||||
#define RTL837X_REG_LED3_0_SET3 0x6524
|
#define RTL837X_REG_LED3_0_SET3 0x6524
|
||||||
#define RTL837X_REG_LED3_0_SET1 0x6528
|
#define RTL837X_REG_LED3_0_SET1 0x6528
|
||||||
|
|||||||
Reference in New Issue
Block a user