Defines | |
#define | NOE 0 |
#define | RISEE 1 |
#define | FALLE 2 |
#define | ANYE 3 |
#define | ICSTART 0 |
#define | ICSTOP 1 |
#define | ICNOTIFYON 2 |
#define | ICNOTIFYOFF 3 |
#define | NULLCOMMAND 4 |
#define | ANOTE 1 |
#define | AUTOLOAD 2 |
#define | AUTOSTOP 4 |
#define | NOTIFYRESPONSE BITMASK(ICNOTIFY) |
#define | COUNTRESPONSE BITMASK(COUNTER) |
Typedefs | |
typedef void(* | CountHander )(int, void *) |
Functions | |
int | E12_CountConfig (int fd, int counter, int trigger, int threshold, int flags, Cop_Data *Cop) |
int | E12_CounterCalcFreq (int counter, Cop_Data *Cop) |
int | E12_CounterLoad (int fd, int counter, int data, Cop_Data *Cop) |
int | E12_CounterReadRQ (int fd, int counter) |
int | E12_CountCommand (int fd, int counter, int command) |
int | E12_CountCfg_Req (int fd, int counter) |
int | UpdatetHardwareCounterInfo (int fd, Cop_Data *Cop) |
The 37e12 provides 8 general purpose digital lines on port 0 that can be configured as counters. These counters are all 16 bit down counters that can be configured to trigger on any edge. They can be set to do any of the following things when they hit zero:
|
enable zero cross notification this will stick a packet into the 37e12's output FIFO whenever a zero cross occurs If the 37e12 goes for long periods without being read and isn't in autostop mode you may want to leave this off so you don't read a huge amount of notifications when you return to reading it. If you are reading periodically however it is recommended that you turn it on, as the parser will use it's notifications to store timestamp information about zero crossings |
|
any edge |
|
automatically reload from the threshold element when roll-over from zero occurs |
|
stop counter when zero is reached, notification will still work in this case as it notifys at zero and not at the roll-over- |
|
falling edge |
|
turn off zero cross notification |
|
turn on zero cross notification |
|
start the addressed counter |
|
stop the addressed counter |
|
no input capture |
|
do nothing, legacy command |
|
rising edge |
|
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. |
|
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. |