Added delay "adapter" class to keep simm_electrical_test.c completely platform-independent.

Updated the electrical class to wait after setting up pins before reading them.
This commit is contained in:
Doug Brown 2011-12-04 16:30:26 -08:00
parent fc44d70c4f
commit 65c6654660
3 changed files with 29 additions and 2 deletions

8
delay.c Normal file
View File

@ -0,0 +1,8 @@
/*
* delay.c
*
* Created on: Dec 4, 2011
* Author: Doug
*/
#include "delay.h"

15
delay.h Normal file
View File

@ -0,0 +1,15 @@
/*
* delay.h
*
* Created on: Dec 4, 2011
* Author: Doug
*/
#ifndef DELAY_H_
#define DELAY_H_
#include <util/delay.h>
#define DelayMS(ms) _delay_ms(ms)
#endif /* DELAY_H_ */

View File

@ -7,6 +7,7 @@
#include "simm_electrical_test.h"
#include "../ports.h"
#include "../delay.h"
#define SIMM_HIGHEST_ADDRESS_LINE 18
#define SIMM_ADDRESS_PINS_MASK ((1UL << (SIMM_HIGHEST_ADDRESS_LINE + 1)) - 1)
@ -14,6 +15,8 @@
#define SIMM_HIGHEST_DATA_LINE 31
#define SIMM_DATA_PINS_MASK (0xFFFFFFFFUL)
#define DELAY_SETTLE_TIME_MS 5
typedef enum ElectricalTestStage
{
TestingAddressLines,
@ -38,7 +41,7 @@ int SIMMElectricalTest_Run(void)
Ports_AddressPullups_RMW(SIMM_ADDRESS_PINS_MASK, SIMM_ADDRESS_PINS_MASK);
Ports_DataPullups_RMW(SIMM_DATA_PINS_MASK, SIMM_DATA_PINS_MASK);
// TODO: Wait a sec?
DelayMS(DELAY_SETTLE_TIME_MS);
if (Ports_ReadAddress() != SIMM_ADDRESS_PINS_MASK)
{
@ -127,7 +130,8 @@ int SIMMElectricalTest_Run(void)
// OK, so now we have set up all lines as needed. Exactly one pin is outputting a 0, and all other pins
// are inputs with pull-ups enabled. Read back all the lines, and if any pin reads back as 0,
// it means that pin is shorted to the pin we are testing (overpowering its pullup)
// TODO: Wait a bit here for things to settle?
DelayMS(DELAY_SETTLE_TIME_MS);
uint32_t readback = Ports_ReadAddress();
if (curStage == TestingAddressLines)