FreeEMS
0.2.0-SNAPSHOT-282-g9efc524
|
Go to the source code of this file.
Macros | |
#define | EXTERN extern |
Functions | |
unsigned short | safeAdd (unsigned short, unsigned short) |
Add two unsigned shorts safely. | |
unsigned short | safeTrim (unsigned short, signed short) |
Add signed short to an unsigned short safely. | |
unsigned short | safeScale (unsigned short, unsigned short, unsigned short) |
Scale without overflow. | |
void | sleep (unsigned short) FPAGE_FE |
Sleep for X milli seconds. | |
void | sleepMicro (unsigned short) FPAGE_FE |
Sleep for X micro seconds. | |
void | adjustPWM (void) FPAGE_FE |
Demonstrate PWM. | |
void | setupPagedRAM (unsigned char) FPAGE_F8 |
Setup tune switching. | |
void | sampleEachADC (ADCBuffer *) FPAGE_F8 |
Read ADCs one at a time. | |
void | sampleLoopADC (ADCBuffer *) FPAGE_F8 |
Read ADCs in a loop. | |
unsigned char | checksum (unsigned char *, unsigned short) FPAGE_F8 |
Simple checksum. | |
unsigned short | stringCopy (unsigned char *, unsigned char *) FPAGE_F8 |
Homebrew strcpy() | |
unsigned short | compare (unsigned char *, unsigned char *, unsigned short) |
Definition in file utils.h.
unsigned short safeAdd | ( | unsigned short | addend1, |
unsigned short | addend2 | ||
) |
Add two unsigned shorts safely.
This will either return short max or the sum of the two arguments.
addend1 | |
addend2 |
Definition at line 51 of file utils.c.
References SHORTMAX.
Referenced by calculateFuelAndIgnition(), and main().
unsigned short safeTrim | ( | unsigned short | addend1, |
signed short | addend2 | ||
) |
Add signed short to an unsigned short safely.
This will either return short max, zero, or the sum of the two arguments.
addend1 | |
addend2 |
Definition at line 67 of file utils.c.
References SHORTMAX.
Referenced by calculateFuelAndIgnition().
unsigned short safeScale | ( | unsigned short | baseValue, |
unsigned short | dividend, | ||
unsigned short | divisor | ||
) |
Scale without overflow.
Takes a base value and a scaler where 0x8000/32768 means 100%, 0 means 0% and 0xFFFF/65535 means 200%, and returns the baseValue multiplied, in effect, by the resulting percentage figure.
baseValue | |
dividend | |
divisor |
Definition at line 97 of file utils.c.
References SHORTMAX.
Referenced by calculateFuelAndIgnition().
void sleep | ( | unsigned short | ms | ) |
void sleepMicro | ( | unsigned short | us | ) |
Sleep for X micro seconds.
Run in a nested loop repeatedly for X micro seconds.
us | the number of micro seconds to kill |
Definition at line 243 of file utils.c.
Referenced by main().
void adjustPWM | ( | void | ) |
Demonstrate PWM.
Demonstrate basic PWM module usage by setting duty to scaled ADC inputs.
Definition at line 138 of file utils.c.
References ATD0DR0, ATD0DR1, ATD0DR2, ATD0DR3, ATD0DR4, ATD0DR5, ATD0DR6, ATD0DR7, PWMDTY0, PWMDTY1, PWMDTY2, PWMDTY3, PWMDTY4, PWMDTY5, PWMDTY6, and PWMDTY7.
Referenced by main().
void setupPagedRAM | ( | unsigned char | bool | ) |
Setup tune switching.
Place the correct set of tables in RAM based on a boolean parameter
bool | which set of data to enable. |
Definition at line 119 of file utils.c.
References currentFuelRPage, currentTimeRPage, currentTuneRPage, RPAGE, RPAGE_FUEL_ONE, RPAGE_FUEL_TWO, RPAGE_TIME_ONE, RPAGE_TIME_TWO, RPAGE_TUNE_ONE, and RPAGE_TUNE_TWO.
Referenced by initAllPagedRAM().
void sampleEachADC | ( | ADCBuffer * | Arrays | ) |
Read ADCs one at a time.
Read ADCs into the correct bank one at a time by name.
Arrays | a pointer to an ADCBuffer struct to store ADC values in. |
Definition at line 156 of file utils.c.
References ADCBuffer::AAP, ATD0DR0, ATD0DR1, ATD0DR2, ATD0DR3, ATD0DR4, ATD0DR5, ATD0DR6, ATD0DR7, ATD1DR0, ATD1DR1, ATD1DR2, ATD1DR3, ATD1DR4, ATD1DR5, ATD1DR6, ATD1DR7, ADCBuffer::BRV, ADCBuffer::CHT, ADCBuffer::EGO, ADCBuffer::EGO2, ADCBuffer::IAP, ADCBuffer::IAT, ADCBuffer::MAF, ADCBuffer::MAP, ADCBuffer::MAT, ADCBuffer::SpareADC3, ADCBuffer::SpareADC4, ADCBuffer::SpareADC5, ADCBuffer::SpareADC6, ADCBuffer::SpareADC7, and ADCBuffer::TPS.
Referenced by main(), PrimaryRPMISR(), and SecondaryRPMISR().
void sampleLoopADC | ( | ADCBuffer * | Arrays | ) |
Read ADCs in a loop.
Read ADCs into the correct bank in a loop using pointers.
Arrays | a pointer to an ADCBuffer struct to store ADC values in. |
Definition at line 185 of file utils.c.
References ATD0_BASE, ATD1_BASE, and DVUSP.
unsigned char checksum | ( | unsigned char * | block, |
unsigned short | length | ||
) |
Simple checksum.
Generate a simple additive checksum for a block of data.
block | a pointer to a memory region to checksum. |
length | how large the memory region to checksum is. |
Definition at line 261 of file utils.c.
Referenced by decodePacketAndRespond(), and finaliseAndSend().
unsigned short stringCopy | ( | unsigned char * | dest, |
unsigned char * | source | ||
) |
Homebrew strcpy()
strcpy() wouldn't compile for me for some reason so I wrote my own.
dest | where to copy the null terminated string to. |
source | where to copy the null terminated string from. |
Definition at line 279 of file utils.c.
Referenced by decodePacketAndRespond().
unsigned short compare | ( | unsigned char * | original, |
unsigned char * | toCheck, | ||
unsigned short | length | ||
) |
Definition at line 293 of file utils.c.
Referenced by decodePacketAndRespond().