Data Structures | |
struct | Cop_Data |
struct | Cop_DataBlock |
struct | countconfig |
struct | countdata |
struct | PWMconfig |
struct | RG_ParseMask |
struct | VersionInfo |
Defines | |
#define | NEW 1 |
#define | OLD 0 |
#define | TRUE 1 |
#define | FALSE 0 |
#define | RS232BUFSIZE 1000 |
#define | RS422BUFSIZE 1000 |
#define | LCD_QSZ 10 |
#define | COPCODE |
#define | BITMASK(data) (1<<data) |
#define | INTERNAL_ATOD_NUM 16 |
#define | EXTERNAL_ATOD_NUM 8 |
#define | PWMNUM 16 |
#define | COUNTNUM 8 |
#define | ATOD0RESPONSE (BITMASK(ADBLK0)) |
#define | ATOD1RESPONSE (BITMASK(ADBLK1)) |
Typedefs | |
typedef Cop_DataBlock | Cop_DataBlock |
typedef VersionInfo | VersionInfo |
typedef RG_ParseMask | RG_ParseMask |
typedef PWMconfig | PWMconfig |
typedef countconfig | countconfig |
typedef countdata | countdata |
typedef Cop_Data | Cop_Data |
Functions | |
int | CopParsePacket (Cop_Data *data) |
int | CopGetPacket (Cop_Data *data, Cop_DataBlock *block) |
int | CopPacketMask (Cop_Data *data, Cop_DataBlock *block) |
int | CopPacketStart (Cop_Data *data, Cop_DataBlock *block) |
void | CopPackBreak (Cop_Data *data) |
Cop_Data * | CopDeviceCreate (int flags) |
int | CopDeviceDestroy (Cop_Data *Cop) |
__u32 | E12_Packet_Route (Cop_Data *Cop, unsigned char *data, int datasize) |
__u32 | E12_Parse_Until (int fd, Cop_Data *Cop, __u32 bitmask) |
int | UpdatetHardwareCounterInfo (int fd, Cop_Data *Cop) |
int | UpdatetHardwarePWMInfo (int fd, Cop_Data *Cop) |
int | e12packetout (int fd, __u8 device, __u8 maskcnt, void *data) |
int | E12_PWMControl (int fd, int pwm, int frequency, int duty, Cop_Data *Cop) |
int | E12_PWMCfg_Req (int fd, int pwm) |
int | E12_CountConfig (int fd, int counter, int trigger, int threshold, int flags, Cop_Data *Cop) |
int | E12_CountCfg_Req (int fd, int counter) |
int | E12_CounterReadRQ (int fd, int counter) |
int | E12_CounterLoad (int fd, int counter, int data, Cop_Data *Cop) |
int | E12_CounterCalcFreq (int counter, Cop_Data *Cop) |
int | E12_CountCommand (int fd, int counter, int command) |
int | E12_Digitalout (int fd, __u8 data, int port) |
int | E12_Digital_Req (int fd) |
int | E12_Digital_Cfg (int fd, __u8 mask, int port) |
int | E12_Internal_AtoD_Req (int fd, int channel) |
int | E12_External_AtoD_Req (int fd, int channel) |
int | E12_AtoD_Req (int fd, int channel) |
int | E12_DtoA_Write (int fd, int channel, int data) |
int | E12_Serial_Write (int fd, int port, int numchars, char *buffer) |
int | E12_Serial_Config (int fd, int port, int baud, int mode) |
int | E12_VersionReq (int fd) |
This raw data is then interpreted by passing it into the E12_Packet_Route function, which breaks it down and puts received data into the fields of a Cop_Data structure. User programs know what data has been returned by reading the return value from the packet routing function(E12_Packet_Route).This returned value is a bitmask, because more than one packet may be contained in any given chunk of raw data. Different types of data will set different bits, as detailed in the function descriptions below. Cop_Data structures are created and initialized with the CopDeviceCreate function, and destroyed with the CopDeviceDestroy function.
|
The Cop_Data typedef This is a type of structure created and initialized by CopDeviceCreate. It is used for the stored of packet data currently being parsed, as well as to store data that has already been parsed and is being passed back to the user.
|
|
This countconfig structure is used to configure an port 0 digital line to be a counter. E12_CountConfig fills out this structure based on parameters passed to it and passes it the e12packetout
|
|
Counter data structure. This type of structure contains data collected from a running counter |
|
This PWMconfig structure is used to configure an internal digital port to be a PWM. E12_PWMControl fills out this structure based on parameters passed to it and passes it the e12packetout
|
|
Request/grant RG_ParseMask parse mask for devices with multiple channels. This substructure within the Cop_Data structure is a collection of bitmasks indicating that new data has arrived It is updated by a call to E12_Packet_Route. For example, after calling E12_Packet_Route on a particular block of data, External_AD might have a value of 6. This would indicate that channels 0 and 2 have received new data which is now stored in the Cop->External_AD[0] and Cop->External_AD[1]. |
|
version info structure VersionInfo This is how data received from the E12_VersionReq function is stored. |
|
Create a Coprocessor structure This function creates a Cop_Data structure which can be passed to E12_Packet_Route to be filled with with incoming data from the coprocessor device
Definition at line 418 of file Coprocessor.c. |
|
Destroys a Coprocessor structure This function destroys a previously allocated Cop_Data structure
Definition at line 425 of file Coprocessor.c. |
|
Pull data from an input block and check if it completes a packet based on parameters discoved by CopPacketMask and CopPacketStart. If it does, pass the data on through the Cop_Data structure into CopParsePacket
Definition at line 173 of file Coprocessor.c. References Cop_Data::packet, Cop_Data::psize, and Cop_Data::ptogo. |
|
called when a packet is marked as invalid to reset a Cop_Data structures packet counts
Definition at line 161 of file Coprocessor.c. References Cop_Data::packet, and Cop_Data::psize. |
|
Pull a chunk of data from a block and interprete its parameters to find data length, and masking. This is used by the lower level packet functions and could have unpredicatable results if by the applications developer.
Definition at line 127 of file Coprocessor.c. References Cop_Data::packet, Cop_Data::packetdata, Cop_Data::psize, and Cop_Data::ptogo. |
|
Pull a chunk of data from a block and interprete its parameters to find the type and masking. This is used by the lower level packet functions and could have unpredicatable results if by the applications developer.
Definition at line 95 of file Coprocessor.c. References Cop_Data::packet, Cop_Data::packetdata, and Cop_Data::psize. |
|
|
Request AtoD reading calls Internal or External AtoD req based on the number if the number is greater than the number of internal AtoD channels it call external at channel-internal Atod channels. Return packets will set the appropriate bits in E12_Packet_Route's return value and in the Cop_Data structure's parsemask.
Definition at line 695 of file Coprocessor.c. |
|
Request a counters configuration information from the hardware This function requests a counters configuration information from the hardware. Typically it's wrapped by UpdatetHardwareCounterInfo to update all the counters at once and handle the reading/parsing as well.
Definition at line 592 of file Coprocessor.c. References countconfig::counter. |
|
Send a command to a configured counter. Once a counter has been configured with E12_CountConfig it can be used toxz
Definition at line 628 of file Coprocessor.c. |
|
This is the first step in using a counter. Before any of the other function will work this must be called. This function is used to configure a general purpose digital line on port 0 as a counter. Configuring a line as a counter will destroy any other configuration currently held on that pin, this will be reflected in the Cop_Data's configuration structures. This command does not start the counter, only configures it. To start a counter E12_CountCommand must be used with the ICSTART command.
Definition at line 578 of file Coprocessor.c. References Cop_Data::counter_config, PWMconfig::duty, countconfig::flags, PWMconfig::frequency, Cop_Data::PWM_config, countconfig::threshold, and countconfig::trigger. |
|
Compute an average frequency for a running counter from the timestamps. The frequency is calculated by dividing the starting count by the difference between the zero cross timestamp and the starting timestamp. It is therefore only accurate under the following conditions 1. The notify flag must be set. If it isn't then the 37e12 will not notify the board when zero crossings occur so accurate timestamps will not be available. 2. The counter value most not be modified while it's running. The 37e12 only sends a timer start timestamp when the board first receives the timer start signal, therefore if the counter value is modified during a count the timestamp will be wrong. 3. The frequency must be constant, if not the function can only compute an average frequency, not the current frequency. The greater the count relative to the frequency the more accurate the calculation. Definition at line 616 of file Coprocessor.c. References Cop_Data::counter_data, countdata::laststamp, countdata::laststart, and countdata::timestamp. |
|
Change the value of a counter. This function can be used to change the current count. It can be used at any time, including while the counter is running. Changing the value of a running counter will not send a new countstart timestamp, only the start counter command does this. Therefore if a counter is changed while it's running E12_CounterCalcFreq will return an invalid value until the next count cycle.
Definition at line 608 of file Coprocessor.c. |
|
Request an update of a Cop counter element. This sends a request to the 37e12 to return the current status of a counter. This will result in a packet of type COUNTER being returned, or a bitmask of COUNTRESPONSE. The appropriate parsemask will be set for the counter returned.
Definition at line 601 of file Coprocessor.c. |
|
Write a byte of configuration data to a digital port. This is used to configure the lines of a digital port to be 1(outputs) or 0(inputs) This function applies to the internal ports 0 and 1 of the 37e12. The isolated external ports are not configurable. the byte is a bitmask of the lines. ex: 0x03 is binary for 00000011 which would activate lines 0 and 1 of the port being addressed, and deactivate the other lines.
Definition at line 666 of file Coprocessor.c. |
|
Request Internal Digital port reading. This requests a packet from the 37e12 containing the readings from both the digital ports. When E12_Packet_Route parses raw data containing a return packet from this function it sets BITMASK(PRTIN0) to 1 in it's return value . See e12digitalGP.c for an example of this.
Definition at line 658 of file Coprocessor.c. |
|
Write a byte of data to a digital port. This is used to set the lines of a digital port to 1(logic on) or 0(logic off) This function applies to the internal ports 0 and 1 of the 37e12. The isolated ports are controlled externally from the processor and are accessed directly by the driver. see e12digitalGP.c for an example of how to write to the internal ports, and ISO_out.c/ISO_in.c for examples of how to write to the external isolated ports. the byte is a bitmask of the lines. ex: 0x03 is binary for 00000011 which would activate lines 0 and 1 of the port being addressed, and deactivate the other lines.
Definition at line 642 of file Coprocessor.c. |
|
Write to DtoA Writes the value data to external DtoA channel channel This is a 12 bit DtoA, bits above that in the data field are ignored.
Definition at line 708 of file Coprocessor.c. |
|
Request External AtoD reading Raw data containing a packet returned from this function will set BITMASK(ADBLK1) in E12_Packet_Route's return value. It will also set a bit in the Cop_Data structure's parsemask.External_AD element, indicating the number of the channel returned.
Definition at line 688 of file Coprocessor.c. |
|
Request Internal AtoD reading Raw data containing a packet returned from this function will set BITMASK(ADBLK0) in E12_Packet_Route's return value. It will also set a bit in the Cop_Data structure's parsemask.Internal_AD element, indicating the number of the channel returned.
Definition at line 682 of file Coprocessor.c. |
|
Interpret raw data read from the 37e12 This is the main packet parsing function, it takes a chunk of raw data "data" of size "datasize" interprets it and updates the fields in "Cop" appropriately. Typically this would be called right after a read as in: rxnum = read(fd,buffer,sizeof(buffer)); typemask = E12_Packet_Route(CopRouter,buffer, rxnum); where fd would be a pointer to a /dev/37e12 device, buffer would be a user allocated buffer and CopRouter would be a previously allocated Cop_Data structure.
Definition at line 438 of file Coprocessor.c. References Cop_Data::parsemask, and Cop_Data::psize. |
|
Read and Interpret raw data read from the 37e12 until the desired packet is returned This is a secondary packet parsing function, it reads data from fd and parses it until it receives a typemask containing one of the bits in bitmask. This function calls read so whether or not it blocks is dependent on the driver and the flags that were passed to it when the fd was opened. If the function is used in non-blocking mode it does 1000 iterations before timing out and returning if no data is available.
Definition at line 468 of file Coprocessor.c. References Cop_Data::parsemask, and Cop_Data::psize. |
|
Configure an internal Digital port to be a pwm. This function sets up a one of the digital port lines to be a PWM. The 2 ports, 0 and 1 behave differently with respect to this function. It requires a the Cop data structure to be passed to it so that it can shadow the configuration. This also updates the other configuration parameters to reflect the effect of the PWM configuration, ie, if a the port was previously configured as a counter it changes the counters shadow status to show that it is no longer on. Configuring a Port 0 line to be a PWM uses the DG128's IOC counter functionality to emulate PWM's . This does not allow as high a frequency as the hardware PWM's, but has the advantage of having independent channels(the frequency of one has no bearing on the frequency of the others). Since the PWM cycle is software based, maximum frequency and duty cycle are a function of the system load. The software PWM's can reliably handle pulse widths between 60us and 2.7ms, which would limit the frequency's to 186-8334Hz at 50% duty cycle. Port 1 PWMS use the hardware PWM's of the DG128 processor. This allows for much higher PWM rates, but suffers in that it doesn't allow for many different frequencies. This is because the hardware PWM's share internal clocks so if one gets bumped up too high, the others will change frequency as well. There are 2 clocks(ClockA and ClockB) shared among the eight lines as follows:
setting pin 7 of port 1 to 1Khz would cause clock B to be set at a prescale of 6. If pin 6 (which shares the same clock) was then set to 2Khz clock B's prescale would change to 5 and which would double the frequency of pin 7 to 200)KHz as well. Setting pin 6 to 1KHz would have had no effect because it would be within the same prescale range, also setting pin 5 to any value would have no effect on pin 7 because it uses a different clock.
Definition at line 549 of file Coprocessor.c. References Cop_Data::counter_config, PWMconfig::delay, PWMconfig::duty, countconfig::flags, PWMconfig::frequency, PWMconfig::pwm, Cop_Data::PWM_config, countconfig::threshold, and countconfig::trigger. |
|
Configure a 37e12's mode and baud rate
Definition at line 749 of file Coprocessor.c. |
|
Write data to a serial port
Definition at line 717 of file Coprocessor.c. |
|
Request version info Sends a request to the 37e12 for firmware version information, the version number and the __DATE__ it was compiled.
|
|
Create and send a packet to the device described by fd This function is a low level function used by the other transmit functions to send packets to the 37e12 It's direct use is not recommended as it requires some knowledge of the internal packet structure. Use the wrapper functions instead.
Definition at line 539 of file Coprocessor.c. |
|
Update the Cop structures count_config structures with data from the hardware.
Definition at line 504 of file Coprocessor.c. References RG_ParseMask::counter, and Cop_Data::parsemask. |
|
Update the Cop structures PWM_config structures with data from the hardware.
Definition at line 521 of file Coprocessor.c. References Cop_Data::parsemask, and RG_ParseMask::pwm. |