KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
shell_ipmux.c
1 /*
2  * KM3NeT CLB v2 Firmware
3  * ----------------------
4  *
5  * Copyright 2013 KM3NeT Collaboration
6  *
7  * All Rights Reserved.
8  *
9  *
10  * File : shell_tests.c
11  * Created : 14 mrt. 2013
12  * Author : Vincent van Beveren
13  */
14 
15 #include <stdbool.h>
16 #include <stdio.h>
17 
18 #include <stdlib.h>
19 
20 #include "lm32soc/lm32.h"
21 #include "drv/wb/ipmux.h"
22 #include "kernel/scheduler.h"
23 #include "kernel/err.h"
24 #include "lm32soc/dev_soc.h"
25 
26 
27 const char cmd_ipmux_help[] = "IPMux Info - type 'ipmux help' for more info";
28 
29 void pkGenHelp() {
30  puts(" [q] - to quit [h] - show help [r] - Reset to defaults");
31  puts(" -1 -16 / +1 +16 (use [shift] to step by 16)");
32  puts(" [z] [Z] [x] [X] - Division ratio");
33  puts(" [c] [C] [v] [V] - Number words");
34  puts(" [b] [B] [n] [N] - Number packets\n");
35 }
36 
37 void pkGenPrint() {
38  printf("div-ratio: %dns, num word: %d, num packets %d\n",
39  IPMPKGEN->DIV_RATIO * 16,
40  IPMPKGEN->NUM_WORDS,
41  IPMPKGEN->NUM_PACKETS);
42 }
43 
44 #define DECR(REG, VALUE) \
45  if (REG >= VALUE) REG -= VALUE; \
46  update = true; break
47 
48 #define INCR(REG, VALUE) \
49  if (REG <= (0xFFFFFFFF - VALUE)) REG += VALUE; \
50  update = true; break
51 
52 
53 void pkGen() {
54  puts("pkgen mode");
55 
56 
57 
58  pkGenHelp();
59  pkGenPrint();
60  bool quit = false;
61  bool update = false;
62  while (!quit)
63  {
64  int c = getchar();
65  switch (c) {
66  case 'q': case 'Q':
67  quit = true;
68  break;
69  case 'h': case 'H':
70  pkGenHelp();
71  break;
72  case 'r': case 'R':
73  IPMPKGEN->DIV_RATIO = 0x000008f0;
74  IPMPKGEN->NUM_WORDS = 0x00000009;
75  IPMPKGEN->NUM_PACKETS = 0x00000010;
76  update = true;
77  break;
78  case 'z': DECR(IPMPKGEN->DIV_RATIO, 1);
79  case 'Z': DECR(IPMPKGEN->DIV_RATIO, 16);
80  case 'x': INCR(IPMPKGEN->DIV_RATIO, 1);
81  case 'X': INCR(IPMPKGEN->DIV_RATIO, 16);
82  case 'c': DECR(IPMPKGEN->NUM_WORDS, 1);
83  case 'C': DECR(IPMPKGEN->NUM_WORDS, 16);
84  case 'v': INCR(IPMPKGEN->NUM_WORDS, 1);
85  case 'V': INCR(IPMPKGEN->NUM_WORDS, 16);
86  case 'b': DECR(IPMPKGEN->NUM_PACKETS, 1);
87  case 'B': DECR(IPMPKGEN->NUM_PACKETS, 16);
88  case 'n': INCR(IPMPKGEN->NUM_PACKETS, 1);
89  case 'N': INCR(IPMPKGEN->NUM_PACKETS, 16);
90  default:
91  break;
92  }
93  if (update) {
94  pkGenPrint();
95  update = false;
96  }
97  }
98 }
99 
100 bool cmd_ipmux_exec(int argc, const char *args[])
101 {
102  if (argc == 1) {
103  if (strcmp(args[0],"help") == 0) {
104  puts("ipmux [option]");
105  puts("Option:");
106  puts(" dump - IPMUX dump registers");
107  puts(" pkgen - Enter packet gen mode");
108  } else if (strcmp(args[0], "dump") == 0) {
109  ipMuxDumpRegs();
110  } else if (strcmp(args[0], "pkgen") == 0) {
111  pkGen();
112  } else return false;
113  } else return false;
114 
115  return true;
116 }
Low level routines for LM32, including interrupt handling.
IPMUX Driver for CLBv2.
Simple task scheduler for tasks.
#define IPMPKGEN
IPMux Control.
Definition: dev_soc.h:71
void ipMuxDumpRegs()
Debug function to see whats inside.
Definition: ipmux.c:205
Manages the global system error.
This file assigns all device structures to memory mapped structures.