Skip to content

Commit cbdb967

Browse files
committed
Issue #1747: Fix a bug whereby sserial port 1 and higher would have their
pins allocated as sserial even with no hardware connected. Also fix some errors spotted during the debugging.
1 parent b0ad713 commit cbdb967

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

src/hal/drivers/mesa-hostmot2/sserial.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -597,10 +597,6 @@ int hm2_sserial_parse_md(hostmot2_t *hm2, int md_index){
597597
return -EINVAL;
598598
}
599599

600-
if (hm2->config.num_sserials == 0) {
601-
return 0;
602-
}
603-
604600
//
605601
// looks good, start initializing
606602
//
@@ -638,7 +634,8 @@ int hm2_sserial_parse_md(hostmot2_t *hm2, int md_index){
638634
chan_counts[hm2->pin[pin].sec_unit] = (hm2->pin[pin].sec_pin & 0x0F);
639635
}
640636
// check if the channel is enabled
641-
HM2_DBG("sec unit = %i, sec pin = %i\n", hm2->pin[pin].sec_unit, hm2->pin[pin].sec_pin & 0x0F);
637+
HM2_DBG("port %i sec unit = %i, sec pin = %i mode=%c\n", port, hm2->pin[pin].sec_unit, hm2->pin[pin].sec_pin & 0x0F,
638+
hm2->config.sserial_modes[hm2->pin[pin].sec_unit][(hm2->pin[pin].sec_pin & 0x0F) - 1] );
642639
if (hm2->config.sserial_modes[hm2->pin[pin].sec_unit]
643640
[(hm2->pin[pin].sec_pin & 0x0F) - 1] != 'x') {
644641
src_reg |= (1 << port_pin);
@@ -655,8 +652,7 @@ int hm2_sserial_parse_md(hostmot2_t *hm2, int md_index){
655652
}
656653

657654
// Now iterate through the sserial instances, seeing what is on the enabled pins.
658-
for (i = 0 ; i < hm2->sserial.num_instances ; i++) {
659-
655+
for (i = 0 ; i < md->instances ; i++) {
660656
hm2_sserial_instance_t *inst = &hm2->sserial.instance[count];
661657
inst->index = i;
662658
inst->num_channels = chan_counts[i];
@@ -677,11 +673,11 @@ int hm2_sserial_parse_md(hostmot2_t *hm2, int md_index){
677673
HM2_PRINT("Smart Serial Firmware Version %i\n",buff);
678674
hm2->sserial.version = buff;
679675

680-
r = check_set_baudrate(hm2, inst) < 0;
676+
r = check_set_baudrate(hm2, inst);
681677
if (r < 0) goto fail0;
682678

683679
//start up in setup mode
684-
r = hm2_sserial_stopstart(hm2, md, inst, 0xF00) < 0;
680+
r = hm2_sserial_stopstart(hm2, md, inst, 0xF00);
685681
if(r < 0) {goto fail0;}
686682

687683
inst->num_remotes = 0;
@@ -693,17 +689,17 @@ int hm2_sserial_parse_md(hostmot2_t *hm2, int md_index){
693689
addr0 = md->base_address + 3 * md->register_stride
694690
+ i * md->instance_stride + c * sizeof(rtapi_u32);
695691
HM2READ(addr0, user0);
696-
HM2_DBG("Inst %i Chan %i User0 = %x\n", i, c, user0);
692+
HM2_DBG("Inst %i Chan %i Addr %x User0 = %x\n", i, c, addr0, user0);
697693

698694
addr1 = md->base_address + 4 * md->register_stride
699695
+ i * md->instance_stride + c * sizeof(rtapi_u32);
700696
HM2READ(addr1, user1);
701-
HM2_DBG("Inst %i Chan %i User1 = %x\n", i, c, user1);
697+
HM2_DBG("Inst %i Chan %i Addr %x User1 = %x\n", i, c, addr1, user1);
702698

703699
addr2 = md->base_address + 5 * md->register_stride
704700
+ i * md->instance_stride + c * sizeof(rtapi_u32);
705701
HM2READ(addr2, user2);
706-
HM2_DBG("Inst %i Chan %i User2 = %x\n", i, c, user2);
702+
HM2_DBG("Inst %i Chan %i Addr %x User2 = %x\n", i, c, addr2, user2);
707703

708704
if (hm2->sserial.baudrate == 115200
709705
&& hm2->config.sserial_modes[i][c] != 'x') { //setup mode

0 commit comments

Comments
 (0)