Permalink
Browse files

small cleanup

  • Loading branch information...
tz
tz committed Feb 7, 2010
1 parent 1d32f84 commit 519d0c9ced5b1fafee8d10fd602171e0053fb1f7
Showing with 91 additions and 108 deletions.
  1. +3 −2 fat32cli/main.c
  2. +3 −1 fat32lib/TODO
  3. +1 −1 fat32lib/creat.c
  4. +1 −0 fat32lib/mount.c
  5. +3 −8 fat32test/Makefile
  6. +10 −10 hyperlog/main.c
  7. +5 −4 i2cperiph/9dof.c
  8. +1 −1 i2cperiph/Makefile
  9. +4 −0 i2cperiph/hmc5843.c
  10. +60 −81 i2cperiph/nh100160.c
View
@@ -222,11 +222,12 @@ int main(int argc, char *argv[])
if (!i)
seekfile(0, 0);
#if 1 // show what is read
- else
- for (i = 0; i < 1; i++) {
+ else {
+ for (i = 0; i < 2; i++) {
readsec(i);
dumpsect();
}
+ }
#endif
}
if (i)
View
@@ -4,10 +4,12 @@ Double buffer for sector (fill one while pulling from other).
typedef int to something?
max file size - if using auto-create log, auto create next log
+Iterator pattern duplicated in opendir and creat.
+
if directory empty allow rmdir
check for empty, save . and .. cluster num, delete dir as file, cd .., find . cluster, 0xe5 ent.
-newlog naming template, 3 for extension, else max, [0-9A-Z], so FFFFFFFF would do hex, 99999999 would do decimal, ZZZZZZZZ would do all, "FFFF " would limit to 4 chars.
+newlog naming template, else max, [0-9A-Z], so FFFFFFFF would do hex, 99999999 would do decimal, ZZZZZZZZ would do all, "FFFF " would limit to 4 chars.
rename (and/or move in tree) (technically writing the directory, chk for dup name)
View
@@ -29,7 +29,7 @@ static void clearclus(u32 clus)
static void ungetclus(u32 clus)
{
readsec(fpm.fat0 + (clus >> 7));
- tzmemclr(&filesectbuf[(127 & clus) << 2], 0);
+ tzmemclr(&filesectbuf[(127 & clus) << 2], 4);
u8 i;
for (i = 0; i < fpm.nft; i++)
writesec(fpm.fat0 + (clus >> 7) + i * fpm.spf);
View
@@ -39,6 +39,7 @@ int rawmount(u32 addr, u32 partlen)
u16 rsv; // reserved sectors - first fat starts just after
u16 fsi; // sector of filesystem info (hints)
+ // OMITTED check for bytes per sector, assuming 512
c = &filesectbuf[0xd];
fpm.spc = *c++;
get2tow(rsv);
View
@@ -1,6 +1,6 @@
all: setforlinux testfat
-CFLAGS=-g -O2 -Wall $(DFLAGS)
+CFLAGS=-g -O2 -Wall $(DFLAGS) -I../fat32lib -I.
CC=gcc
.c.o:
@@ -16,12 +16,7 @@ setforlinux:
clean:
rm -f *.hex *.eep *.elf *.lss *.sym *.dsm *.o *.a *.d
-mount.o fat32data.o opendir.o creat.o deltrunc.o write.o read.o seek.o: fat32.h fat32private.h
-
linuxmain.o: fat32.h sdhc.h
-liblinfat32.a: mount.o fat32data.o opendir.o creat.o deltrunc.o write.o read.o seek.o
- ar r $@ $^
-
-testfat: main.o dosmunge.o sdhcemu.o liblinfat32.a
- $(CC) -o $@ dosmunge.o main.o sdhcemu.o -L. -llinfat32
+testfat: main.o dosmunge.o sdhcemu.o
+ $(CC) -o $@ dosmunge.o main.o sdhcemu.o -L../fat32lib/ -llinfat32
View
@@ -89,18 +89,18 @@ int main(void)
unsigned long cnt = 100000; // timeout to push buffer
for(;;) {
i = uartgetch();
+
+ if( UCSR0A & 0x10 ) { // break (FE), sync-trunc
+ UCSR0A &= ~0x10;
+ flushbuf();
+ syncdirent(1);
+ PORTD &= ~0x20;
+ return 0;
+ }
+
if( i < 0 ) {
- if( UCSR0A & 0x10 ) { // break (FE), sync-trunc
- UCSR0A &= ~0x10;
- flushbuf();
- syncdirent(1);
- return 0;
- PORTD &= ~0x20;
- continue;
- }
- else if( cnt-- ) // break (FE) pushes
+ if( cnt-- ) // break (FE) pushes
continue;
-
flushbuf();
syncdirent(0);
seekfile(0,2);
View
@@ -121,19 +121,20 @@ int main(void)
TWIinit();
printf("9DoF\n");
TWIdocmd(sendhmci); // Mag
- TWIdocmd(msgsetup); // Accel
- TWIdocmd(startacq); // Baro/Temp
+ // TWIdocmd(msgsetup); // Accel
+ // TWIdocmd(startacq); // Baro/Temp
_delay_ms(200);
TWIdocmd(sendhmci); // to insure init, need to do twice
+ TWIdocmd(sendhmci); // to insure init, need to do twice
cnt = 0;
adcnt = 0;
ADMUX = 0x12;
ADCSRA = 0xc6;
while (cnt++ < 200) {
-#if 1
+#if 0
TWIdocmd(ready);
if( 0xe == (0xe & ready[5])
&& (0x20 & ready[5]) ) // conversion ready
@@ -199,7 +200,7 @@ int main(void)
ADCSRA = 0xc6;
}
- for (;;) {
+ while(0) {
TWIdocmd(queryfifo);
unsigned char qlen = queryfifo[5];
if (!qlen)
View
@@ -35,7 +35,7 @@ MAP=-Wl,"-Map" -Wl,"$@.map" -Wl,"--cref"
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O ihex $^ $@
.hex.upload:
- avrdude -F -p $(CPU) -P $(PORT) -c stk500v1 -b 57600 -U $^
+ avrdude -F -p $(CPU) -P $(PORT) -c arduino -b 57600 -U $^
.eep.upload:
avrdude -V -F -p $(CPU) -P $(PORT) -c stk500v1 -b 57600 -U eeprom:w:$^
View
@@ -36,6 +36,10 @@ int main(void)
for (;;) {
TWIinit();
+ TWIdocmd(sendhmci);
+ _delay_ms(50);
+ TWIdocmd(sendhmci);
+ _delay_ms(50);
cnt = 0;
while (cnt++ < 200) {
TWIdocmd(sendhmcpr);
View
@@ -13,99 +13,78 @@
#define LCDADDR 0x7e
-unsigned char sendlcd0[] = {
- 91,
- LCDADDR,
- 0, // comsend
- 0x48, //partial display duty ratio
- 0x64, // 1/100 duty
- 0xA0, //ADC select
- 0xC8, //SHL select
- 0x44, //initial Com0 register
- 0x00, //scan from Com0
- 0xAB, //OSC on
- 0x26,
- 0x81, //set electronic volume
- 0x15, //vopcode=0x1C
- 0x56, //set 1/11 bias
- 0x64, //3x
-// delay(2,
- 0x2C,
- 0x66, //5x
-// delay(2,
- 0x2E,
- // delay2
- 0x2F, //power control
- 0xF3, //bias save circuit
- 0x00,
- 0x96, //frc and pwm
- 0x38, //external mode
- 0x75,
- 0x97, //3frc, 45 pwm
- //start 16‐level grayscale settings
-0x80,0x00,0x81,0x00,0x82,0x00,0x83,0x00,0x84,0x06,0x85,0x06,0x86,0x06,0x87,0x06,
-0x88,0x0B,0x89,0x0B,0x8A,0x0B,0x8B,0x0B,0x8C,0x10,0x8D,0x10,0x8E,0x10,0x8F,0x10,
-0x90,0x15,0x91,0x15,0x92,0x15,0x93,0x15,0x94,0x1A,0x95,0x1A,0x96,0x1A,0x97,0x1A,
-0x98,0x1E,0x99,0x1E,0x9A,0x1E,0x9B,0x1E,0x9C,0x23,0x9D,0x23,0x9E,0x23,0x9F,0x23,
-0xA0,0x27,0xA1,0x27,0xA2,0x27,0xA3,0x27,0xA4,0x2B,0xA5,0x2B,0xA6,0x2B,0xA7,0x2B,
-0xA8,0x2F,0xA9,0x2F,0xAA,0x2F,0xAB,0x2F,0xAC,0x32,0xAD,0x32,0xAE,0x32,0xAF,0x32,
-0xB0,0x35,0xB1,0x35,0xB2,0x35,0xB3,0x35,0xB4,0x38,0xB5,0x38,0xB6,0x38,0xB7,0x38,
-0xB8,0x3A,0xB9,0x3A,0xBA,0x3A,0xBB,0x3A,0xBC,0x3C,0xBD,0x3C,0xBE,0x3C,0xBF,0x3C,
- //end grayscale settings
-0x38,0x74,0xAF, //display on
-
- 0,0,0,0,0 };
-
+unsigned char lcdi0[] = {
+ 14, 0x7E,0x00,
+ 0x48,0x64,0xA0,0xC8, 0x44,0x00,0xAB,0x26, 0x81,0x1c,0x56,0x64,
+ 0};
+unsigned char lcdi1[] = {
+ 4,0x7E,0x00,
+ 0x2C,0x66,
+ 0};
+unsigned char lcdi2[] = {
+ 3,0x7E,0x00,
+ 0x2E,
+ 0};
+unsigned char lcdi3[] = {
+ 2+7,
+ 0x7E,0x00,
+ 0x2F,0xF3,0x00,0x96, 0x38,0x75,0x97,
+
+ 2+64,
+ 0x7E,0x00,
+ 0x80,0x00,0x81,0x00,0x82,0x00,0x83,0x00,0x84,0x06,0x85,0x06,0x86,0x06,0x87,0x06,
+ 0x88,0x0B,0x89,0x0B,0x8A,0x0B,0x8B,0x0B,0x8C,0x10,0x8D,0x10,0x8E,0x10,0x8F,0x10,
+ 0x90,0x15,0x91,0x15,0x92,0x15,0x93,0x15,0x94,0x1A,0x95,0x1A,0x96,0x1A,0x97,0x1A,
+ 0x98,0x1E,0x99,0x1E,0x9A,0x1E,0x9B,0x1E,0x9C,0x23,0x9D,0x23,0x9E,0x23,0x9F,0x23,
+ 2+64,
+ 0x7E,0x00,
+ 0xA0,0x27,0xA1,0x27,0xA2,0x27,0xA3,0x27,0xA4,0x2B,0xA5,0x2B,0xA6,0x2B,0xA7,0x2B,
+ 0xA8,0x2F,0xA9,0x2F,0xAA,0x2F,0xAB,0x2F,0xAC,0x32,0xAD,0x32,0xAE,0x32,0xAF,0x32,
+ 0xB0,0x35,0xB1,0x35,0xB2,0x35,0xB3,0x35,0xB4,0x38,0xB5,0x38,0xB6,0x38,0xB7,0x38,
+ 0xB8,0x3A,0xB9,0x3A,0xBA,0x3A,0xBB,0x3A,0xBC,0x3C,0xBD,0x3C,0xBE,0x3C,0xBF,0x3C,
+ 2+3,
+ 0x7E,0x00,
+ 0x38,0x74,0xAF,
+ 0};
unsigned char sendlcda0[] = {
- 24, LCDADDR,0x80,0x80,0x40, 'O', 'n', 'e', '=', '=','=','=','=', '+','+','+','+', '=','=','=','=', '=','O','n','e',
- 0,0,0,0,0,0,0,0
+ 5, LCDADDR,0,0xb0,0x10,1,
+ 0,0
};
unsigned char sendlcdb0[] = {
- 24, LCDADDR,0x80,0xc0,0x40, 'T', 'w', 'o', '=', '=','=','=','=', '+','+','+','+', '=','=','=','=', '=','T','w','o',
- 0, 0,0,0,0,0,0,0
-};
-
-#undef LCDADDR
-#define LCDADDR 0x7c
-unsigned char sendlcd1[] = {
- 13, LCDADDR,0x00,0x30,0x30,0x30,0x39,
- 0x14,0x7f,0x5f,0x6a,0x0f,0x06,0x01,
- 0
-};
-
-unsigned char sendlcda1[] = {
- 24, LCDADDR,0x80,0x80,0x40, 'O', 'n', 'e', '=', '=','=','=','=', '+','+','+','+', '=','=','=','=', '=','O','n','e',
- 0,0,0,0,0,0,0,0
+ 6, LCDADDR,0,0,0,0,0,
+ 0,0
};
-unsigned char sendlcdb1[] = {
- 24, LCDADDR,0x80,0xc0,0x40, 'T', 'w', 'o', '=', '=','=','=','=', '+','+','+','+', '=','=','=','=', '=','T','w','o',
- 0, 0,0,0,0,0,0,0
-};
int main(void)
{
- unsigned xo = 0;
-
- for (;;) {
- TWIinit();
-
- TWIdocmd(sendlcd0);
- TWIdocmd(sendlcd1);
- _delay_ms(20);
- TWIdocmd(sendlcda0);
- TWIdocmd(sendlcdb0);
- TWIdocmd(sendlcda1);
- TWIdocmd(sendlcdb1);
- while( 1 ) {
- sprintf( (char *) &sendlcda0[5], "%6d",xo );
- sprintf( (char *) &sendlcda1[5], "%6d",xo++ );
+ unsigned char text, page;
+
+ TWIinit();
+ _delay_ms(20);
+ TWIdocmd(lcdi0);
+ _delay_ms(200);
+ TWIdocmd(lcdi1);
+ _delay_ms(200);
+ TWIdocmd(lcdi2);
+ _delay_ms(10);
+ TWIdocmd(lcdi3);
+ for (;;)
+ for( page = 0xb0; page < 0xbd; page++) {
+ sendlcda0[3] = page;
TWIdocmd(sendlcda0);
- TWIdocmd(sendlcda1);
+ for( text = 0 ; text < 160; text++ ) {
+ sendlcdb0[3] = text;
+ sendlcdb0[4] = text;
+ sendlcdb0[5] = text;
+ sendlcdb0[6] = text;
+ TWIdocmd(sendlcdb0);
+ _delay_ms(10);
+ }
}
- }
}
+

0 comments on commit 519d0c9

Please sign in to comment.