RT-AICHIP-sample
mode_dutyMax.c
[詳解]
1 /* ------------------------------------------------------------ *
2 ** File mode_dutyMax.c
3 
4 duty maxで走らせるモード
5 
6 操作:
7  右SW: モータの状態を切り替え
8  左SW: 長押しでモード選択へ繊維
9 
10 * ------------------------------------------------------------ */
11 #include "mode_dutyMax.h"
12 #include "type.h"
13 #include "AICHIPFunction.h"
14 #include "UserInterface.h"
15 #include "SystemTickTimer.h"
16 #include "debug.h"
17 
18 
19 void mode_dutyMax(void)
20 {
21  uint8_t flag_motor_state = 0; //0:ストップ 1:回転
22 
23  myPrintfUART("############ duty max mode ################\n");
24  myPrintfUART("++++++++++++++++++++++++++++++++\n");
25  myPrintfUART(" Right SW: change motor state .\n");
26  myPrintfUART(" Left SW: mode select .\n");
27  myPrintfUART("++++++++++++++++++++++++++++++++\n");
28 
29  while(1)
30  {
31  wait1msec(1);
32 
33  //右SWでモータの状態を切り替え
34  if( getRightSWcount() == 3)
35  {
36  flag_motor_state = 1 - flag_motor_state;
37  myPrintfUART("\t motor state : %d \n",flag_motor_state);
38  }
39 
40  //モーターの状態を変える
41  if( flag_motor_state == 1)
42  {
43  turnGreenLED(1);
44  setDutyMotor(1.0);
45  }
46  else
47  {
48  turnGreenLED(0);
49  setDutyMotor(0.0);
50  }
51 
52  //モード選択へ遷移
53  if( getLeftSWcount() > 1000)
54  {
55  setDutyMotor(0.0);
56  myPrintfUART("\t return mode select \n");
57  break;
58  }
59 
60  }
61 
62 }
63 
64 /******************************************************************************
65 ** End Of File
66 ******************************************************************************/
int myPrintfUART(const char *fmt,...)
Definition: debug.c:42
void setDutyMotor(float pwm_duty)
unsigned char uint8_t
Definition: type.h:27
uint16_t getRightSWcount(void)
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