]> Pileus Git - ~andy/csm213a-hw/commitdiff
Fix input events
authorAndy Spencer <andy753421@gmail.com>
Tue, 11 Mar 2014 03:04:45 +0000 (03:04 +0000)
committerAndy Spencer <andy753421@gmail.com>
Tue, 11 Mar 2014 03:04:45 +0000 (03:04 +0000)
hw2/main.cpp

index 9292124da454b95e442519ba975843df35c051d1..f7b76715e07e170726d7106c2c59eb44f90bf122 100644 (file)
@@ -101,7 +101,7 @@ void time_ext_sync(uint64_t local, uint64_t world)
        world = time_last_world;
 
 //#ifdef VERBOSE
-#if 1
+#if 0
        uint64_t error = world > guess ? world - guess :
                         guess > world ? guess - world : 0;
        int      ahead = guess > world;
@@ -334,21 +334,19 @@ void serial_send_sync(sirq_t *port, uint64_t now)
  */
 void serial_send_event(uint16_t event, uint64_t local)
 {
-//     uint64_t world = time_to_world(local);
+       time_printf("event received", local);
 
-       // Message data
 #if 0
+       // Message data
        header_t    head;
        event_msg_t body;
 
+       uint64_t world = time_to_world(local);
+
        ntime_t time = {};
        time.seconds = (uint32_t)(world / NSEC_PER_SEC);
        time.nanosec = (uint32_t)(world % NSEC_PER_SEC);
 
-       sirq_printf("event received - %08x:%08x - %u.%09u\r\n",
-               (uint32_t)(local >> 32), (uint32_t)local,
-               time.seconds, time.nanosec);
-
        // Transmit sync message
        head.header = MSG_HEADER;
        head.msgid  = MSG_ID_SYNC;
@@ -623,7 +621,7 @@ static struct {
        uint64_t due;
 } tasks[] = {
        { task_serial, 0          }, // always
-       { task_events, 1000000000 }, // always -- testing
+       { task_events, 0          }, // always -- testing
        { task_sync,   0          }, // always
        { task_emit,   0          }, // always
        { task_leds,   100000000  }, // 10hz
@@ -656,7 +654,7 @@ int main(int argc, char **argv)
        sirq_mbed  = sirq_open(SIRQ_UART2, PTD3,  PTD2,  115200); // to mbed
 
        // Setup timers
-       tdma_evt   = tdma_open(TDMA_CHAN0, 3, PTC9,  PullUp); // async event
+       tdma_evt   = tdma_open(TDMA_CHAN0, 3, PTC9,  PullDown); // async event
 
        // mbed time sync
        tdma_rcv   = tdma_open(TDMA_CHAN2, 3, PTD2,  PullUp);   // time sync rcv