|
@@ -34,7 +34,20 @@
|
34
|
34
|
|
35
|
35
|
#include "ch.h"
|
36
|
36
|
#include "hal.h"
|
37
|
|
-#include "ch_test.h"
|
|
37
|
+
|
|
38
|
+static PWMConfig pwmcfg = {
|
|
39
|
+ 380000, /* 1MHz PWM clock frequency. */
|
|
40
|
+ 10, /* Initial PWM period 1ms. */
|
|
41
|
+ NULL,
|
|
42
|
+ {
|
|
43
|
+ {PWM_OUTPUT_ACTIVE_HIGH, NULL},
|
|
44
|
+ {PWM_OUTPUT_DISABLED, NULL},
|
|
45
|
+ {PWM_OUTPUT_DISABLED, NULL},
|
|
46
|
+ {PWM_OUTPUT_DISABLED, NULL}
|
|
47
|
+ },
|
|
48
|
+ 0,
|
|
49
|
+ 0
|
|
50
|
+};
|
38
|
51
|
|
39
|
52
|
/*
|
40
|
53
|
* Green LED blinker thread, times are in milliseconds.
|
|
@@ -43,7 +56,6 @@ static THD_WORKING_AREA(waThread1, 128);
|
43
|
56
|
static THD_FUNCTION(Thread1, arg) {
|
44
|
57
|
|
45
|
58
|
(void)arg;
|
46
|
|
- chRegSetThreadName("blinker");
|
47
|
59
|
while (true) {
|
48
|
60
|
palClearPad(GPIOC, GPIOC_LED);
|
49
|
61
|
chThdSleepMilliseconds(500);
|
|
@@ -67,23 +79,19 @@ int main(void) {
|
67
|
79
|
halInit();
|
68
|
80
|
chSysInit();
|
69
|
81
|
|
70
|
|
- /*
|
71
|
|
- * Activates the serial driver 2 using the driver default configuration.
|
72
|
|
- */
|
73
|
|
- sdStart(&SD2, NULL);
|
74
|
|
-
|
75
|
82
|
/*
|
76
|
83
|
* Creates the blinker thread.
|
77
|
84
|
*/
|
78
|
85
|
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
|
79
|
86
|
|
|
87
|
+ pwmStart(&PWMD1, &pwmcfg);
|
|
88
|
+ palSetPadMode(GPIOA, 8, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
|
|
89
|
+ pwmEnableChannel(&PWMD1, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 5000));
|
80
|
90
|
/*
|
81
|
91
|
* Normal main() thread activity, in this demo it does nothing except
|
82
|
92
|
* sleeping in a loop and check the button state.
|
83
|
93
|
*/
|
84
|
94
|
while (true) {
|
85
|
|
- //if (!palReadPad(GPIOC, GPIOC_BUTTON))
|
86
|
|
- // test_execute((BaseSequentialStream *)&SD2);
|
87
|
95
|
chThdSleepMilliseconds(500);
|
88
|
96
|
}
|
89
|
97
|
}
|