Definition in file libedt_timing.c.
#include <time.h>
#include "edtinc.h"
Go to the source code of this file.
Functions | |
u_char | edt_crc16_highbyte (u_char *buf, int len) |
u_char | edt_crc16_lowbyte (u_char *buf, int len) |
void | edt_disable_timecode_programmable_year (EdtDev *edt_p) |
Disable the msp430 IRIG-B firmware programmable year mode. | |
void | edt_enable_timecode_programmable_year (EdtDev *edt_p, u_short year) |
Enable the msp430 IRIG-B firmware programmable year mode and set the year. | |
int | edt_get_timecode_version (EdtDev *edt_p) |
Get the msp430 IRIG-B firmware version. | |
void | edt_set_msp430_clock (EdtDev *edt_p, int clock_sel, int clock_hz) |
Select an internal or external clock source for the MSP430 and state the clock rate. | |
int | edt_set_timecode_enable (EdtDev *edt_p, int enable) |
Enable or disable timecode production from the MSP430. | |
void | edt_set_timecode_raw (EdtDev *edt_p, int enable) |
Enable or disable raw BCD timecode production from the MSP430. | |
void | edt_set_timecode_seconds_offset (EdtDev *edt_p, u_int seconds) |
Set a seconds offset for timecode production. | |
int | edt_spi_close (EdtDev *edt_p) |
Closes the SPI master EDT device handle. | |
void | edt_spi_display_time (EdtDev *edt_p, int loops) |
Prints the timecode in ascii once per second for N loops. | |
int | edt_spi_fifo_empty (EdtDev *edt_p) |
Returns true if the SPI fifo is empty. | |
void | edt_spi_flush_fifo (EdtDev *edt_p) |
Flushes the EDT SPI input and output fifos, discarding all data. | |
int | edt_spi_get_binary (EdtDev *edt_p, unsigned char *byte) |
Inputs a single binary byte from the EDT SPI interface. | |
u_char | edt_spi_get_byte (EdtDev *edt_p) |
Polls the EDT SPI master for a single byte. | |
u_char | edt_spi_get_byte_nointr (EdtDev *edt_p) |
int | edt_spi_get_pkt (EdtDev *edt_p, u_char *pkt) |
After a packet-start byte is received, call this routine to input the packet and check the CRC. | |
u_char | edt_spi_get_stat (EdtDev *edt_p) |
Returns the value of the EDT SPI status register. | |
uint64_t | edt_spi_get_time_pkt (EdtDev *edt_p) |
Obtains a timestamp packet from the timing msp430 via SPI. | |
int | edt_spi_invoke_flash_loader (EdtDev *edt_p) |
Puts the EDT SPI msp430 into flash-loader mode. | |
EdtDev * | edt_spi_open (char *edt_interface, int unit, u_int spi_reg_base) |
Opens the EDT SPI master. | |
u_char | edt_spi_put_byte (EdtDev *edt_p, u_char ch) |
Sends one byte to the EDT SPI master. | |
char * | edt_spi_putstr (EdtDev *edt_p, char *str) |
Send a single line of ascii string to the msp430 over the SPI. | |
u_int | edt_spi_reg_read (EdtDev *edt_p, u_int desc) |
Read an SPI access register using the correct register base address. | |
void | edt_spi_reg_write (EdtDev *edt_p, u_int desc, u_int val) |
Write an SPI access register using the correct register base address. | |
void | edt_spi_send_binary (EdtDev *edt_p, u_char val) |
void | edt_spi_send_packet (EdtDev *edt_p, u_char *cmdbuf) |
Send a command packet to the msp430 via the SPI; wait for output fifo full but not ACK/NAK reply. |
void edt_disable_timecode_programmable_year | ( | EdtDev * | edt_p | ) |
Disable the msp430 IRIG-B firmware programmable year mode.
edt_p | The EDT open device handle. |
See the included example program timing_test.c.
Definition at line 1007 of file libedt_timing.c.
void edt_enable_timecode_programmable_year | ( | EdtDev * | edt_p, | |
u_short | year | |||
) |
Enable the msp430 IRIG-B firmware programmable year mode and set the year.
edt_p | The EDT open device handle. | |
year | The year >= 2000. |
By default, the CONTROL FIELD of the IRIG-B signal is assumed to provide the current year since 2000. When this is not the case this function enables the programmed year mode and sets the year to the second argument.
The year argument must be >= 2000. This value is stored in a firmware variable in the MSP430 and included in the timestamps produced by the IRIG-B signal. When the "days" field of the IRIG-B signal rolls over to 1, the year is incremented by 1.
See the included example program timing_test.c.
Definition at line 976 of file libedt_timing.c.
int edt_get_timecode_version | ( | EdtDev * | edt_p | ) |
Get the msp430 IRIG-B firmware version.
edt_p | The EDT open device handle. |
See the included example program timing_test.c.
Definition at line 758 of file libedt_timing.c.
void edt_set_msp430_clock | ( | EdtDev * | edt_p, | |
int | clock_sel, | |||
int | clock_hz | |||
) |
Select an internal or external clock source for the MSP430 and state the clock rate.
edt_p | The EDT open device handle. | |
clock_sel | An integer containing 0 for internal clock and 1 for external clock select. | |
clock_hz | An integer stating the number of Hertz for the selected clock. |
When an external clock is selected and no clock signal is available on XIN (P26), a clock fault condition is triggered which resets the system clock back to the default internal 16 Mhz clock.
See the included example program timing_test.c.
Definition at line 906 of file libedt_timing.c.
int edt_set_timecode_enable | ( | EdtDev * | edt_p, | |
int | enable | |||
) |
Enable or disable timecode production from the MSP430.
edt_p | The EDT open device handle. | |
enable | An integer containing 1 to enable timestamp production, 0 to disable it. |
See the included example program timing_test.c.
Definition at line 789 of file libedt_timing.c.
void edt_set_timecode_raw | ( | EdtDev * | edt_p, | |
int | enable | |||
) |
Enable or disable raw BCD timecode production from the MSP430.
edt_p | The EDT open device handle. | |
enable | An integer containing 1 to enable BCD timestamp production, 0 to disable it. |
See the included example program timing_test.c.
Definition at line 834 of file libedt_timing.c.
void edt_set_timecode_seconds_offset | ( | EdtDev * | edt_p, | |
u_int | seconds | |||
) |
Set a seconds offset for timecode production.
edt_p | The EDT open device handle. | |
seconds | An integer containing the number of seconds to add to the timecode. |
See the included example program timing_test.c.
Definition at line 870 of file libedt_timing.c.
int edt_spi_close | ( | EdtDev * | edt_p | ) |
Closes the SPI master EDT device handle.
edt_p | The EDT open device handle. |
Definition at line 151 of file libedt_timing.c.
void edt_spi_display_time | ( | EdtDev * | edt_p, | |
int | loops | |||
) |
Prints the timecode in ascii once per second for N loops.
edt_p | The EDT open device handle. | |
loops | The number of seconds to print. |
See the included example program timing_test.c.
Definition at line 429 of file libedt_timing.c.
int edt_spi_fifo_empty | ( | EdtDev * | edt_p | ) |
Returns true if the SPI fifo is empty.
edt_p | The EDT open device handle. |
Definition at line 241 of file libedt_timing.c.
void edt_spi_flush_fifo | ( | EdtDev * | edt_p | ) |
Flushes the EDT SPI input and output fifos, discarding all data.
edt_p | The EDT open device handle. |
Definition at line 289 of file libedt_timing.c.
int edt_spi_get_binary | ( | EdtDev * | edt_p, | |
unsigned char * | byte | |||
) |
Inputs a single binary byte from the EDT SPI interface.
edt_p | The EDT open device handle. | |
byte | Pointer to an unsigned char. |
Definition at line 202 of file libedt_timing.c.
u_char edt_spi_get_byte | ( | EdtDev * | edt_p | ) |
Polls the EDT SPI master for a single byte.
edt_p | The EDT open device handle. |
Definition at line 165 of file libedt_timing.c.
int edt_spi_get_pkt | ( | EdtDev * | edt_p, | |
u_char * | pkt | |||
) |
After a packet-start byte is received, call this routine to input the packet and check the CRC.
edt_p | The EDT open device handle. | |
byte | Pointer to an unsigned char array of 64-bytes which will contain the packet on success. |
Definition at line 328 of file libedt_timing.c.
u_char edt_spi_get_stat | ( | EdtDev * | edt_p | ) |
Returns the value of the EDT SPI status register.
edt_p | The EDT open device handle. |
Definition at line 275 of file libedt_timing.c.
uint64_t edt_spi_get_time_pkt | ( | EdtDev * | edt_p | ) |
Obtains a timestamp packet from the timing msp430 via SPI.
edt_p | The EDT open device handle. |
Definition at line 385 of file libedt_timing.c.
int edt_spi_invoke_flash_loader | ( | EdtDev * | edt_p | ) |
Puts the EDT SPI msp430 into flash-loader mode.
edt_p | The EDT open device handle. |
See the included utility program msp430_load.c.
Definition at line 546 of file libedt_timing.c.
EdtDev* edt_spi_open | ( | char * | edt_interface, | |
int | unit, | |||
u_int | spi_reg_base | |||
) |
Opens the EDT SPI master.
edt_interface | string containing the type of board; "pcd", "pdv", "pe53b", etc. | |
unit | Board unit number | |
spi_reg_base | Selects an alternative spi register base address (0 selects default 0x60) |
See the included example program timing_test.c.
Definition at line 121 of file libedt_timing.c.
u_char edt_spi_put_byte | ( | EdtDev * | edt_p, | |
u_char | ch | |||
) |
Sends one byte to the EDT SPI master.
edt_p | The EDT open device handle. | |
ch | The byte to send to the SPI master. |
Definition at line 260 of file libedt_timing.c.
char* edt_spi_putstr | ( | EdtDev * | edt_p, | |
char * | str | |||
) |
Send a single line of ascii string to the msp430 over the SPI.
edt_p | The EDT open device handle. | |
str | The string to send to the EDT SPI interface. |
Definition at line 614 of file libedt_timing.c.
u_int edt_spi_reg_read | ( | EdtDev * | edt_p, | |
u_int | desc | |||
) |
Read an SPI access register using the correct register base address.
edt_p | The EDT open device handle. | |
desc | One of the SPI_ access macros from libedt_timing.h |
Definition at line 70 of file libedt_timing.c.
void edt_spi_reg_write | ( | EdtDev * | edt_p, | |
u_int | desc, | |||
u_int | val | |||
) |
Write an SPI access register using the correct register base address.
edt_p | The EDT open device handle. | |
desc | One of the SPI_ access macros from libedt_timing.h | |
val | Value to write to the SPI register. |
Definition at line 93 of file libedt_timing.c.
void edt_spi_send_packet | ( | EdtDev * | edt_p, | |
u_char * | cmdbuf | |||
) |
Send a command packet to the msp430 via the SPI; wait for output fifo full but not ACK/NAK reply.
edt_p | The EDT open device handle. | |
str | The formatted command buffer to send as a packet. |
define SPI_PKT_START 0x82 Start of packet byte.
followed by a command buffer, followed by a two-byte command buffer CRC check.
The command buffer consists of the following:
byte 0: Command byte byte 1: Number of data bytes 0 - 60 bytes 2 - 62: Command specific data bytes
Currently supported commands are:
define SPI_PACKET_LOOP 0 Loop back packet; send back the packet. Data size 0-60 bytes; no ACK/NAK response.
define SPI_TIMECODE_EN 1 Enable (1) or disable (0) the 1 Hz ascii-hex timestamp. Data size 1 byte. ACK/NAK response.
define SPI_CLK_SELECT 2 Select msp430 clock source as internal DCO (0) or external XIN (1) plus clock rate. ACK/NAK response. Data size 5 bytes; first byte selects internal/external, last 4 bytes is an integer specifying the clock rate in Hz; LS byte first; MS byte last. Currently supported clock rates for DCO (0) are 1, 8, 12 and 16 Mhz. Currently supported clock rate for XIN (1) is 10 Mhz.
define SPI_TIMECODE_PKT 3 Sent from msp430 to FPGA. Data consists of 4-8 bytes of timecode LSByte first, extended UNIX seconds time format.
The CRC check bytes apply to the command buffer (command, length and data bytes), and is computed as follows where CKL is the low CRC byte, CKH is the high CRC byte, B1 is the Command byte and Bn is the last data byte (derived from Texas Instruments Application Report SLAA089D "Features of the MSP430 Bootstrap Loader"):
CKL = INV [ B1 XOR B3 XOR ... XOR Bn–1 ] CKH = INV [ B2 XOR B4 XOR ... XOR Bn ]
Definition at line 728 of file libedt_timing.c.