]> rtime.felk.cvut.cz Git - fpga/lx-cpu1/lx-dad.git/blobdiff - sw/app/lx_dad/appl_tests.c
Test option to use cmdproc IO as POSIX FILE stream.
[fpga/lx-cpu1/lx-dad.git] / sw / app / lx_dad / appl_tests.c
index a6ccd3a4ea3ceaea9bda8d269079dba5f120bd9c..50ebfadb50adbfec97008c9fae4fbe51869ab025 100644 (file)
@@ -33,11 +33,21 @@ int cmd_do_test_memusage(cmd_io_t *cmd_io, const struct cmd_des *des, char *para
 
 int cmd_do_test_adc(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
 {
-  printf("ADC: %ld %ld %ld %ld %ld\n",(LPC_ADC->DR[0] & 0xFFF0)>>4,
-                                     (LPC_ADC->DR[1] & 0xFFF0)>>4,
-                                      (LPC_ADC->DR[2] & 0xFFF0)>>4,
-                                      (LPC_ADC->DR[3] & 0xFFF0)>>4,
-                                     (LPC_ADC->DR[7] & 0xFFF0)>>4);
+  FILE *F;
+
+  if (cmd_io->priv.ed_line.io_stack)
+    cmd_io = cmd_io->priv.ed_line.io_stack;
+
+  F = cmd_io_as_file(cmd_io, "r+");
+  if (F == NULL)
+    return CMDERR_EIO;
+
+  fprintf(F, "ADC: %ld %ld %ld %ld %ld\n", (LPC_ADC->DR[0] & 0xFFF0) >> 4,
+         (LPC_ADC->DR[1] & 0xFFF0) >> 4,
+         (LPC_ADC->DR[2] & 0xFFF0) >> 4,
+         (LPC_ADC->DR[3] & 0xFFF0) >> 4,
+         (LPC_ADC->DR[7] & 0xFFF0) >> 4);
+  fclose(F);
   return 0;
 }
 
@@ -300,7 +310,7 @@ int cmd_do_zmer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
        status_old = *testaddr;
        //while((status_old & (1<<2))==(status & (1<<2))) status=*testaddr;
        //while (*testaddr &(1<<6));
-       *testaddr = 0xa;
+       *testaddr = 0x12;
        while (!(*testaddr & (1<<6))) printf("\ncekam\n");
         status = *testaddr;
         testaddr =  (volatile uint32_t *)0x80008000;
@@ -352,7 +362,9 @@ int cmd_do_runnung_meas(cmd_io_t *cmd_io, const struct cmd_des *des, char *param
        for(i=0;i<1024;i++){
        //       values[i]=*testaddr++; 
                 val=*testaddr++;
-                val = (val>> 17) == 0 ? val : -1 ^ 0x7FFFF | val;
+                val+=(1<<17);
+                val&=(1<<18)-1;
+                val -= (1<<17);
                 values[i]=-1*val;
         }
        if (status&(1<<2)){