From: Nicolas D. <Ba...@us...> - 2011-03-22 18:06:10
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via 7c145a8bcb0fa1400dbe1344b84efd887941a4ff (commit) from 4e7bbded87fc3ae7a0741dbc9abfda6e01c12f6a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 7c145a8bcb0fa1400dbe1344b84efd887941a4ff Author: Nicolas Dandrimont <Nic...@cr...> Date: Tue Mar 22 19:02:50 2011 +0100 [USB_CAN/Firmware] Allow a configurable timestamping function ----------------------------------------------------------------------- Changes: diff --git a/elec/boards/USB_CAN/Firmware/usb_can/usb_can.c b/elec/boards/USB_CAN/Firmware/usb_can/usb_can.c index ef58b89..75d3c4a 100644 --- a/elec/boards/USB_CAN/Firmware/usb_can/usb_can.c +++ b/elec/boards/USB_CAN/Firmware/usb_can/usb_can.c @@ -45,12 +45,19 @@ INLINE uint32_t nibble_to_uint32(char *nibbles, size_t length) { return ret; } +uint16_t get_timestamp(void) { + /* The timestamp should wrap around every minute (it works until + the 32 bits of timer_clock are exhausted) */ + return ticks_to_ms(timer_clock()) % 60000; +} + void usb_can_init(usb_can *usbcan, can_driver *can, struct Serial *ser) { usbcan->can = can; usbcan->ser = ser; usbcan->is_open = false; usbcan->timestamped = false; + usbcan->get_timestamp = get_timestamp; } @@ -195,9 +202,7 @@ int usb_can_emit(usb_can *usbcan, can_rx_frame *frame) { sprintf(&buffer[i], "%02x", frame->data8[j]); if (usbcan->timestamped) { - /* The timestamp should wrap around every minute (it works until - the 32 bits of timer_clock are exhausted) */ - timestamp = ticks_to_ms(timer_clock()) % 60000; + timestamp = usbcan->get_timestamp(); sprintf(&buffer[i], "%04x", timestamp); i+=4; diff --git a/elec/boards/USB_CAN/Firmware/usb_can/usb_can.h b/elec/boards/USB_CAN/Firmware/usb_can/usb_can.h index 960f819..800e4a5 100644 --- a/elec/boards/USB_CAN/Firmware/usb_can/usb_can.h +++ b/elec/boards/USB_CAN/Firmware/usb_can/usb_can.h @@ -31,13 +31,18 @@ #include <drv/timer.h> #include <io/kfile.h> +typedef uint16_t (usb_can_timestamp(void)); + typedef struct _usb_can { can_driver *can; // CAN Device struct Serial *ser; // Serial Device bool is_open; // Channel open? bool timestamped; // Emit timestamps? + usb_can_timestamp *get_timestamp; // Get Timestamp function } usb_can; +uint16_t get_timestamp(void); + void usb_can_init(usb_can *usbcan, can_driver *can, struct Serial *ser); void usb_can_open(usb_can *usbcan); hooks/post-receive -- krobot |