]> rtime.felk.cvut.cz Git - fpga/lx-cpu1/lx-dad.git/blobdiff - sw/app/lx_dad/appl_tests.c
all files updated to latest versions
[fpga/lx-cpu1/lx-dad.git] / sw / app / lx_dad / appl_tests.c
index 253dc60062d8c8e8ff50d89046c698a22f015016..c51e4927a3bce779d0be3807625dd52f3701b24e 100644 (file)
@@ -266,6 +266,147 @@ int cmd_do_goaddr(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
   return 0;
 }
 
+int cmd_do_mujtest(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
+{
+       volatile uint32_t *testaddr  = (volatile uint32_t *)0x80004000;
+       int p;
+       p=*testaddr++;
+       printf("read %d\n", p);
+       p=*testaddr++;
+       printf("read %d\n", p);
+       p=*testaddr++;
+       printf("read %d\n", p);
+       p=*testaddr++;
+       printf("read %d\n", p);
+       p=*testaddr++;
+       printf("read %d\n", p);
+       p=*testaddr++;
+       printf("read %d\n", p);
+       p=*testaddr++;
+       printf("read %d\n", p);
+       p=*testaddr++;
+       printf("read %d\n", p);
+       p=*testaddr++;
+       printf("read %d\n", p);
+       
+}
+
+int cmd_do_zmer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
+{
+       volatile uint32_t *testaddr  = (volatile uint32_t *)0x80004000;
+       int32_t values[2048];
+       uint32_t status, status_old, bank,i;
+       int32_t val;
+       status_old = *testaddr;
+       //while((status_old & (1<<2))==(status & (1<<2))) status=*testaddr;
+       //while (*testaddr &(1<<6));
+       *testaddr = 0x12;
+       while (!(*testaddr & (1<<6))) printf("\ncekam\n");
+        status = *testaddr;
+        testaddr =  (volatile uint32_t *)0x80008000;
+        if (status&(1<<2)){
+               // printf("bank1\n");
+               testaddr =  (volatile uint32_t *)0x80009000;
+       } else {
+               //printf("bank0\n");
+       }
+        for(i=0;i<1024;i++){
+       //       values[i]=*testaddr++; 
+                val=*testaddr++;
+                val+=(1<<17);
+                val&=(1<<18)-1;
+                val -= (1<<17);
+                values[i]=val;
+        }
+        if (status&(1<<2)){
+                printf("bank1\n");
+               //testaddr =  (volatile uint32_t *)0x80008000;
+       } else {
+               printf("bank0\n");
+       }
+        for (i=0;i<1024;i++){
+                if (i==1024){
+                        printf("bank1\n");
+                }
+                printf("%d\n",values[i]);
+                
+        }
+        printf("konec\n");
+       
+        return 0;
+}
+
+int cmd_do_runnung_meas(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]){
+       volatile uint32_t *testaddr  = (volatile uint32_t *)0x80004000;
+       int32_t values[1024];
+       uint32_t status, status_old, bank,i;
+       int32_t val;
+       status_old = *testaddr;
+       status = *testaddr;
+       while((status_old & (1<<2))==(status & (1<<2))) {status=*testaddr; printf("dely %i %i",status_old & (1<<2),status & (1<<2));}
+       if (status&(1<<2)){
+               testaddr =  (volatile uint32_t *)0x80009000;
+       } else {
+               testaddr =  (volatile uint32_t *)0x80008000;
+       }
+       for(i=0;i<1024;i++){
+       //       values[i]=*testaddr++; 
+                val=*testaddr++;
+                val+=(1<<17);
+                val&=(1<<18)-1;
+                val -= (1<<17);
+                values[i]=-1*val;
+        }
+       if (status&(1<<2)){
+                printf("bank1\n");
+               //testaddr =  (volatile uint32_t *)0x80008000;
+       } else {
+               printf("bank0\n");
+       }
+       //printf("zacatek\n");
+        for (i=0;i<1024;i++){
+                printf("%d\n",values[i]);
+        }
+        printf("konec\n");
+        return 0;
+}
+
+
+int cmd_do_init(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
+{
+       printf("init!\n");
+       volatile uint32_t *testaddr  = (volatile uint32_t *)0x80004000;
+       *testaddr++ = 0x9;
+//     *testaddr++;
+       *testaddr++ = 9;
+       *testaddr++ = 399;
+       *testaddr++ = 409;
+       *testaddr++ = 399;
+       *testaddr++ = 9;
+       *testaddr++ = 599;
+       *testaddr++ = 609;
+       //*testaddr++ = 4879;
+       *testaddr++ = 5023999;
+       *testaddr=499;
+       
+       printf("OK!\n");
+       return 0;
+}
+
+int cmd_do_send(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
+{
+       char *end;
+       volatile uint32_t *testaddr  = (volatile uint32_t *)0x80004000;
+       int read;
+       int p=(int) strtol(param[1], &end, 10);
+       testaddr+=p;
+       p=(int) strtol(end, &end, 10);
+       *testaddr=p;
+       read=*testaddr;
+       printf("sent %d & read %d\n", p, read);
+       return 0;
+}
+
 cmd_des_t const cmd_des_test_memusage={0, 0,
                         "memusage","report memory usage",cmd_do_test_memusage,
                         {0,
@@ -311,6 +452,19 @@ cmd_des_t const cmd_des_testmpu={0, 0,
 cmd_des_t const cmd_des_goaddr={0, 0,
                        "goaddr","run from address",
                        cmd_do_goaddr,{(void*)0}};
+                       
+cmd_des_t const cmd_des_mujtest={0,0,"mujtest","run my simple test", cmd_do_mujtest,{(void*)0}};
+
+cmd_des_t const cmd_des_zmer={0,0,"zmer","read values from spectrometer (2 readouts)", cmd_do_zmer,{(void*)0x12}};
+
+cmd_des_t const cmd_des_scan={0,0,"scan","read values from spectrometer (2 readouts)", cmd_do_zmer,{(void*)0x10}};
+
+
+cmd_des_t const cmd_des_init={0,0,"init", "inicializacni vypis pro zacatek komunikace", cmd_do_init,{(void*)0}};
+
+cmd_des_t const cmd_des_sendvalue={0,0,"send", "send value to given address", cmd_do_send,{(void*)0}};
+
+cmd_des_t const cmd_des_runnung_meas = {0,0,"run","read values from spectrometer (running)", cmd_do_runnung_meas,{(void*)0x10}};
 
 cmd_des_t const *const cmd_appl_tests[]={
   &cmd_des_test_memusage,
@@ -325,5 +479,12 @@ cmd_des_t const *const cmd_appl_tests[]={
   &cmd_des_testsdram,
   &cmd_des_testmpu,
   &cmd_des_goaddr,
+  &cmd_des_mujtest,
+  &cmd_des_zmer,
+  &cmd_des_scan,
+  &cmd_des_init,
+  &cmd_des_sendvalue,
+  & cmd_des_runnung_meas,
   NULL
 };
+