RT-AICHIP-sample
modeSelect.c
[詳解]
1 /* ------------------------------------------------------------ *
2 File modeSelect.c
3 
4 モード選択を実行する関数
5 * ------------------------------------------------------------ */
6 #include "modeSelect.h"
7 
8 #include "LPC13xx.h"
9 #include "core_cm3.h"
10 #include "type.h"
11 
12 #include "UserInterface.h"
13 #include "SystemTickTimer.h"
14 #include "debug.h"
15 #include "usbTransmission.h"
16 
17 //動作モード毎の処理
18 #include "mode_dutyMax.h"
19 #include "mode_selectDuty.h"
20 #include "mode_debug.h"
21 #include "mode_controlRun.h"
22 #include "mode_BluetoothSetting.h"
23 
24 
25 static void modeSelectInfo(void)
26 {
27 
28  myPrintfUART("############ mode select ################\n");
29  myPrintfUART("++++++++++++++++++++++++++++++++\n");
30  myPrintfUART(" Choose the mode .\n");
31  myPrintfUART(" Right SW: mode change \n");
32  myPrintfUART(" Left SW: enter \n");
33  myPrintfUART("++++++++++++++++++++++++++++++++\n");
34  myPrintfUART(" 0 output this info. :Green LED OFF \n");
35  myPrintfUART(" 1 duty max mode :Green LED ON \n");
36  myPrintfUART(" 2 select duty mode :flashing Green LED 1Hz \n");
37  myPrintfUART(" 3 control run mode :flashing Green LED 2Hz \n");
38  myPrintfUART(" 4 Bluetooth setting mode :flashing Green LED 4Hz \n");
39  myPrintfUART(" 5 debug mode :flashing Green LED 8Hz \n");
40  myPrintfUART("+++++++status of AICHIP++++++++++\n");
41  myPrintfUART(" Lipo Voltage : %f [V] \n", getLipoVoltage());
42  myPrintfUART(" Motor Voltage : %f [V] \n", getMotorVoltage());
43  myPrintfUART(" is USB Config : %d \n", isUSBConfig() );
44  myPrintfUART(" elapsed time : %d [msec] \n", getElapsedTime() );
45  myPrintfUART("++++++++++++++++++++++++++++++++\n");
46 }
47 
48 void modeSelect(void)
49 {
50  uint8_t md_select = 0;
51  modeSelectInfo();
52 
53  while(1)
54  {
55  wait1msec(1);
56  if( getRightSWcount() > 0 ) //右SWでモード選択
57  {
58  md_select++;
59  md_select = md_select % 6;
60  myPrintfUART("\t md_select = %d \n ",md_select);
61  if(md_select == 0)
62  {
63  modeSelectInfo();
64  }
65  while(getRightSWcount() != 0 );
66  }
67 
68  if( getLeftSWcount() > 0 ){
69  while(getRightSWcount() != 0 );
70  break; //左SWで決定
71  }
72 
73  switch(md_select){
74  case 0: turnGreenLED(0);
75  break;
76  case 1: turnGreenLED(1);
77  break;
78  case 2: flashGreenLED(500,500);
79  break;
80  case 3: flashGreenLED(250,250);
81  break;
82  case 4: flashGreenLED(125,125);
83  break;
84  case 5: flashGreenLED(62,63);
85  break;
86  }
87  }
88 
89  flashGreenLED(20,80);
90  wait1msec(1000);
91  turnGreenLED(0);
92  myPrintfUART("\t enter \n");
93 
94  switch(md_select){
95  case 0:
96  break;
97  case 1: mode_dutyMax();
98  break;
99  case 2: mode_selectDuty();
100  break;
101  case 3: mode_controlRun();
102  break;
103  case 4: mode_BluetoothSetting();
104  break;
105  case 5: mode_debug();
106  break;
107  }
108 
109  flashGreenLED(160,40);
110  wait1msec(1000);
111  turnGreenLED(0);
112 }
113 
114 
115 
116 
117 
118 
119 /******************************************************************************
120 ** End Of File
121 ******************************************************************************/
uint32_t getElapsedTime(void)
void mode_BluetoothSetting(void)
void mode_controlRun(void)
int myPrintfUART(const char *fmt,...)
Definition: debug.c:42
void mode_selectDuty(void)
CMSIS Cortex-M3 Core Peripheral Access Layer Header File.
unsigned char uint8_t
Definition: type.h:27
void modeSelect(void)
Definition: modeSelect.c:48
float getMotorVoltage(void)
float getLipoVoltage(void)
void mode_debug(void)
Definition: mode_debug.c:19
uint16_t getRightSWcount(void)
uint8_t isUSBConfig(void)
void flashGreenLED(uint16_t on_count, uint16_t off_count)
uint16_t getLeftSWcount(void)
Definition: UserInterface.c:98
void wait1msec(uint32_t wait_count)
void turnGreenLED(uint8_t state)
void mode_dutyMax(void)
Definition: mode_dutyMax.c:19