1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-11-22 14:10:37 +02:00

Next part of board bringup: reset and power cycling.

- atusd/ERRATA: one more problem: the transistor footprint is wrong
- atusd/tools/lib/atusd.c (atusd_cycle, atusd_reset): added power cycling and
  hardware reset
- atusd/tools/lib/atusd.h: be nice and make a header file
- atusd/tools/try.c: be nice and use header files (caught a bug as well)
This commit is contained in:
Werner Almesberger 2010-09-05 14:07:01 -03:00
parent 86e556ce92
commit a18d5969bd
4 changed files with 69 additions and 3 deletions

View File

@ -3,3 +3,6 @@
- added wire connecting uSD-side ground plane to ground plane at outer edge,
to improve CLK signal return. (Probably unnecessary, too.)
- the footprint of the transistor (Q1) is reversed :-( It works after
converting the chip from SOT to PLCC.

View File

@ -1,6 +1,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
@ -102,7 +103,7 @@ struct atusd_dsc *atusd_open(void)
void atusd_close(struct atusd_dsc *dsc)
{
/* stop the MMC clock */
/* stop the MMC bus clock */
MSC_STRPCL = 1;
/* cut the power */
@ -111,3 +112,52 @@ void atusd_close(struct atusd_dsc *dsc)
/* make all MMC pins inputs */
PDDIRC = MxSx | CLK | SCLK | SLP_TR | IRQ | nSEL;
}
void atusd_cycle(struct atusd_dsc *dsc)
{
/* stop the MMC bus clock */
MSC_STRPCL = 1;
/* drive all outputs low (including the MMC bus clock) */
PDDATC = MxSx | CLK | SCLK | SLP_TR | nSEL;
/* make the MMC bus clock a regular output */
PDFUNC = CLK;
/* cut the power */
PDDATS = VDD_OFF;
/* Power drains within about 20 ms. Wait 100 ms to be sure. */
usleep(100*1000);
/* drive nSS high */
PDDATS = nSEL;
/* supply power */
PDDATS = VDD_OFF;
/* return the bus clock output to the MMC controller */
PDFUNS = CLK;
/* start MMC clock output */
MSC_STRPCL = 2;
}
void atusd_reset(struct atusd_dsc *dsc)
{
/* activate reset */
PDDATS = SLP_TR;
PDDATC = nSEL;
/*
* Data sheet says 625 ns, programmer's guide says 6 us. Whom do we
* trust ?
*/
usleep(6);
/* release reset */
PDDATS = nSEL;
PDDATC = SLP_TR;
}

7
atusd/tools/lib/atusd.h Normal file
View File

@ -0,0 +1,7 @@
struct atusd_dsc;
struct atusd_dsc *atusd_open(void);
void atusd_close(struct atusd_dsc *dsc);
void atusd_cycle(struct atusd_dsc *dsc);
void atusd_reset(struct atusd_dsc *dsc);

View File

@ -1,4 +1,7 @@
struct atusd_dsc;
#include <stdio.h>
#include <unistd.h>
#include "lib/atusd.h"
int main(void)
@ -7,7 +10,10 @@ int main(void)
char tmp;
dsc = atusd_open();
read(1, tmp, 1);
read(1, &tmp, 1);
fprintf(stderr, "cycling\n");
atusd_cycle(dsc);
read(1, &tmp, 1);
atusd_close(dsc);
return 0;