ATY_LIB V2_102_230218
ATY_LIB for general devices or ALGO
 
Loading...
Searching...
No Matches
main.c
Go to the documentation of this file.
1// Copyright 2021 IOsetting <iosetting(at)outlook.com>
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15/***
16 * Demo: 28BYJ-48 Stepper Motor with ULN2003 Driver
17 *
18 * Pin connection:
19 * MCU ULN2003 External Power Supply
20 * P10 => IN1
21 * P11 => IN2
22 * P12 => IN3
23 * P13 => IN4
24 * VCC => 5V ~ 12V
25 * GND => GND
26 *
27 * test-board: Minimum System; test-MCU: STC8H1K08,STC8H3K64S2
28 */
29
30#include "fw_hal.h"
31
32// Clockwise, 8 steps
34 0B00001001,
35 0B00000001,
36 0B00000011,
37 0B00000010,
38 0B00000110,
39 0B00000100,
40 0B00001100,
41 0B00001000
42};
43
44void GPIO_Init(void)
45{
46 // P10, P11, P12, P13
48}
49
50int main(void)
51{
52 uint8_t step;
55 GPIO_Init();
56
57 while(1)
58 {
59 for (pos = 0; pos < 640; pos++)
60 {
61 step = 8;
62 while (step--)
63 {
64 P1 = P1 & 0xF0 | cw[7 - step];
65 SYS_Delay(5);
66 }
67 }
68 SYS_Delay(500);
69 for (pos = 0; pos < 640; pos++)
70 {
71 step = 8;
72 while (step--)
73 {
74 P1 = P1 & 0xF0 | cw[step];
75 SYS_Delay(5);
76 }
77 }
78 SYS_Delay(500);
79 }
80}
uint8_t pos
@ GPIO_Pin_2
Definition: fw_gpio.h:47
@ GPIO_Pin_0
Definition: fw_gpio.h:45
@ GPIO_Pin_3
Definition: fw_gpio.h:48
@ GPIO_Pin_1
Definition: fw_gpio.h:46
#define GPIO_P1_SetMode(__PINS__, __MODE__)
Definition: fw_gpio.h:79
@ GPIO_Mode_Output_PP
Definition: fw_gpio.h:24
void SYS_SetClock(void)
Definition: fw_sys.c:40
void SYS_Delay(uint16_t t)
Definition: fw_sys.c:65
unsigned short uint16_t
Definition: fw_types.h:19
unsigned char uint8_t
Definition: fw_types.h:18
int main(void)
Definition: main.c:45
void GPIO_Init(void)
Definition: main.c:39
uint8_t cw[8]
Definition: main.c:33