|
LevelMeter-Display
2.0
An ultrasonic Level Meter for Stormwater Cisterns
|
Contains Factory Test Routines. More...

Functions | |
| static const char * | Byte2bin (uint8_t byte, char str[9]) |
| Converts a Byte into a binary String. More... | |
| bool | FTest (void) |
| Performs a simple Factory Test. More... | |
| void | FTest485 (void) |
| Performs a Factory Test of the RS485-Lines. More... | |
| uint8_t | FTest485GetConnects (void) |
| Returns Connections between the two RS485 Interfaces. More... | |
| static bool | FTestSupply (void) |
| Test Supply Voltages. More... | |
| static bool | FTestSWUnreg () |
| Tests the Switched Unreg Node. More... | |
| static void | FTestToggleSignal () |
| Toggles the Optocoupler Outputs. More... | |
| static bool | FTestWalkingOne (void) |
| Short Circuit Test #2. More... | |
| static bool | FTestWalkingZero () |
| Short Circuit Test #1. More... | |
| bool | GetRxD0 (void) |
| Get RxD0-Pin Value. More... | |
| bool | GetRxD1 (void) |
| Get RxD1-Pin Value. More... | |
| static void | PrintError () |
| Prints an Error Message for conflicting Pins. More... | |
| static void | PrintPass (bool pass) |
| Prints PASS or FAIL. More... | |
| void | SetTxD0 (bool level) |
| Sets the state of TxD0. More... | |
| void | SetTxD1 (bool level) |
| Sets the state of TxD1. More... | |
| static void | WaitKeyBlinking (void) |
| Waits for the Key to be pressed and released. More... | |
Variables | |
| static uint8_t | bit |
| The Pin of port currently under test. This is a bit mask. More... | |
| static uint8_t | port |
| The Port currently under test. More... | |
| static const ftestPortsStruct | ports [] |
| Ports to test. More... | |
| static uint8_t | testPort |
| The Port tested against current port. More... | |
| static uint8_t | tppin |
| The Read-Value of testPort PIN value. More... | |
| static uint8_t | tpport |
| The Read-Value of testPort PORT value. More... | |
| static uint8_t | tptestMask |
| The Test Mask of testPort. More... | |
Contains Factory Test Routines.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
|
static |
Converts a Byte into a binary String.
| byte | The byte |
| str | A String capable of holding at least the 9 characters representing the binary value |
Referenced by PrintError().

| bool FTest | ( | void | ) |
Performs a simple Factory Test.
This routine tries to test everything that can be tested without user intervention. It cannot detect all possible error conditions but will detect a lot of possible short circuits and other errors and can give valuable hints to the test personal.
All special function pins must be set to normal port I/O. The testMask basically is a copy of the DDR since only output pins can be tested. Take care of pins that must keep their special function during the test (e.g. TxD of the USART that receives the result). This has also to be masked out, as well as pins that would cause disastrous consequences if switched uncontrolled.
First the user is asked to press the pushbutton key. This is to test the key itself. After that, the signal outputs are toggled a few times each. LEDs connected on the test adapter will show the user if that works. The following tests require no user attention. The device will measure its supply voltages and test all output pins against all others so short circuits between output pins or output pin and VCC/GND will most likely be detected.
Since interrupts are disabled in the progress of this function and DDRs are modified, the calling routine should perform a watchdog reset to restore proper operation of the device.
Do not try to restore DDRs and interrupts, you will most likely forget some and there is nothing bad in willingly performing a reset...
References delay1s(), FTestSupply(), FTestSWUnreg(), FTestToggleSignal(), FTestWalkingOne(), FTestWalkingZero(), hprintf_P(), LEDBlueOff(), LEDBlueOn(), LEDGreenOff(), LEDGreenOn(), LEDRedOff(), LEDRedOn(), LEDYellowOff(), LEDYellowOn(), SensorPowerOff(), and WaitKeyBlinking().
Referenced by CmdFTest().


| void FTest485 | ( | void | ) |
Performs a Factory Test of the RS485-Lines.
For this test to succeed, all jumpers on X3 have to be in position "485" and a switch has to be in the test adapter that connects sensor RS485 with host RS485.
References delay10ms(), FTest485GetConnects(), LCDPrintLine_P(), and secCnt.

| uint8_t FTest485GetConnects | ( | void | ) |
Returns Connections between the two RS485 Interfaces.
References delay50us(), GetRxD0(), GetRxD1(), SetTxD0(), SetTxD1(), Uart0DisableLineDriver(), Uart0EnableLineDriver(), Uart1DisableLineDriver(), and Uart1EnableLineDriver().
Referenced by FTest485().


|
inlinestatic |
Test Supply Voltages.
References ADCData_t::ADC_P3, ADCData_t::ADC_P5, ADCData_t::ADC_Unreg, ADCDataAvg, hprintf_P(), ADCData_t::named, P3FromADC(), P5FromADC(), PrintPass(), and UnregFromADC().
Referenced by FTest().


|
inlinestatic |
Tests the Switched Unreg Node.
References ADCData_t::ADC_SWUnreg, ADCData_t::ADC_Unreg, ADCData, ADCDataAvg, ADCFLAG_NEWRESULTS, adcFlags, delay1s(), hprintf_P(), ADCData_t::named, PrintPass(), SensorPowerOff(), SensorPowerOn(), SWUnregFromADC(), tickCnt, and UnregFromADC().
Referenced by FTest().


|
inlinestatic |
Toggles the Optocoupler Outputs.
This is not an automated test. The user has to verify that LEDs connected to the optocouplers will toggle.
References delay50ms(), hprintf_P(), Sig1OFF(), Sig1ON(), Sig2OFF(), and Sig2ON().
Referenced by FTest().


|
inlinestatic |
Short Circuit Test #2.
All pins included in the testMask[] are set to 0. A single "1" is shiftet through all pins, the pin-registers are read to verify its presence exactly on this position.
References bit, delay50us(), hprintf_P(), ftestPortsStruct::pin, ftestPortsStruct::port, port, ports, PrintError(), PrintPass(), ftestPortsStruct::testMask, testPort, tppin, tpport, and tptestMask.
Referenced by FTest().


|
inlinestatic |
Short Circuit Test #1.
All pins included in the testMask[] are set to 1. A single "0" is shiftet through all pins, the pin-registers are read to verify its presence exactly on this position.
References bit, delay50us(), hprintf_P(), ftestPortsStruct::pin, ftestPortsStruct::port, port, ports, PrintError(), PrintPass(), ftestPortsStruct::testMask, testPort, tppin, tpport, and tptestMask.
Referenced by FTest().


| bool GetRxD0 | ( | void | ) |
Get RxD0-Pin Value.
Referenced by FTest485GetConnects().

| bool GetRxD1 | ( | void | ) |
Get RxD1-Pin Value.
Referenced by FTest485GetConnects().

|
static |
Prints an Error Message for conflicting Pins.
References bit, Byte2bin(), hprintf_P(), port, testPort, tppin, tpport, and tptestMask.
Referenced by FTestWalkingOne(), and FTestWalkingZero().


|
static |
Prints PASS or FAIL.
| pass | True if passed |
References hprintf_P().
Referenced by FTestSupply(), FTestSWUnreg(), FTestWalkingOne(), and FTestWalkingZero().


| void SetTxD0 | ( | bool | level | ) |
Sets the state of TxD0.
| level | The desired Output Level |
Referenced by FTest485GetConnects().

| void SetTxD1 | ( | bool | level | ) |
Sets the state of TxD1.
| level | The desired Output Level |
Referenced by FTest485GetConnects().

|
static |
Waits for the Key to be pressed and released.
The LCD-backlight is blinking until the key is pressed.
References KFLAG_KEYRELEASED, kflags, LCDSetBrightness(), and tickCnt.
Referenced by FTest().


|
static |
The Pin of port currently under test. This is a bit mask.
Referenced by FTestWalkingOne(), FTestWalkingZero(), and PrintError().
|
static |
The Port currently under test.
Referenced by FTestWalkingOne(), FTestWalkingZero(), and PrintError().
|
static |
Ports to test.
You must specify every port in your system in ascending order (even if it has not to be tested) and every bit that is set will be included in the test.
Only pins configured as output can be tested!
Referenced by FTestWalkingOne(), and FTestWalkingZero().
|
static |
The Port tested against current port.
Referenced by FTestWalkingOne(), FTestWalkingZero(), and PrintError().
|
static |
The Read-Value of testPort PIN value.
Referenced by FTestWalkingOne(), FTestWalkingZero(), and PrintError().
|
static |
The Read-Value of testPort PORT value.
Referenced by FTestWalkingOne(), FTestWalkingZero(), and PrintError().
|
static |
The Test Mask of testPort.
Referenced by FTestWalkingOne(), FTestWalkingZero(), and PrintError().
1.8.15