]> Pileus Git - ~andy/csm213a-hw/blobdiff - hw2/main_comm.c
Add serial transmit call
[~andy/csm213a-hw] / hw2 / main_comm.c
index 6afe80d27c1550dfffa208b78ea51355ee127161..380fc87f0535830935b5c5ae79a72d61179a90a2 100644 (file)
@@ -101,7 +101,6 @@ void comm_init(sirq_t *dbg, sirq_t *bbb, sirq_t *mbed,
        comm_tdma_xmt  = xmt;
 }
 
-
 /**
  * Output time sync message
  */
@@ -120,10 +119,13 @@ void comm_send_sync(uint64_t local)
        head.length = sizeof(body);
        head.cksum  = 0; // todo
 
+       sirq_write(comm_sirq_mbed, &head, sizeof(head));
+
+       // Capture transmit time
        tdma_stop(comm_tdma_rcv, 0);
        tdma_start(comm_tdma_xmt);
 
-       sirq_write(comm_sirq_mbed, &head, sizeof(head));
+       sirq_transmit(comm_sirq_mbed);
 
        tdma_stop(comm_tdma_xmt, 100);
        tdma_start(comm_tdma_rcv);
@@ -143,6 +145,8 @@ void comm_send_sync(uint64_t local)
 
        sirq_write(comm_sirq_mbed, &body, sizeof(body));
 
+       sirq_transmit(comm_sirq_mbed);
+
        // Queue next transmit time
        comm_sync_due  = 0;
 }
@@ -180,9 +184,11 @@ void comm_send_event(uint16_t event, uint64_t local)
        if (comm_device_id == 1) {
                sirq_write(comm_sirq_bbb,  &head, sizeof(head));
                sirq_write(comm_sirq_bbb,  &body, sizeof(body));
-       } else {
+       } else if (comm_device_id > 1) {
                sirq_write(comm_sirq_mbed, &head, sizeof(head));
                sirq_write(comm_sirq_mbed, &body, sizeof(body));
+       } else {
+               sirq_printf("no device id, skipping event\r\n");
        }
 }