23
23
24
24
static void gpio_setup (void )
25
25
{
26
- /* Enable GPIOD clock. */
27
- /* Manually: */
28
- // RCC_AHB1ENR |= RCC_AHB1ENR_IOPDEN;
29
- /* Using API functions: */
30
26
rcc_periph_clock_enable (RCC_GPIOI );
31
27
32
- /* Set GPIO12 (in GPIO port D) to 'output push-pull'. */
33
- /* Manually: */
34
- // GPIOD_CRH = (GPIO_CNF_OUTPUT_PUSHPULL << (((8 - 8) * 4) + 2));
35
- // GPIOD_CRH |= (GPIO_MODE_OUTPUT_2_MHZ << ((8 - 8) * 4));
36
- /* Using API functions: */
37
28
gpio_mode_setup (GPIOI , GPIO_MODE_OUTPUT , GPIO_PUPD_NONE , GPIO1 );
38
29
}
39
30
@@ -43,25 +34,8 @@ int main(void)
43
34
44
35
gpio_setup ();
45
36
46
- /* Blink the LED (PC8 ) on the board. */
37
+ /* Blink the LED (PI1 ) on the board. */
47
38
while (1 ) {
48
- /* Manually: */
49
- // GPIOD_BSRR = GPIO12; /* LED off */
50
- // for (i = 0; i < 1000000; i++) /* Wait a bit. */
51
- // __asm__("nop");
52
- // GPIOD_BRR = GPIO12; /* LED on */
53
- // for (i = 0; i < 1000000; i++) /* Wait a bit. */
54
- // __asm__("nop");
55
-
56
- /* Using API functions gpio_set()/gpio_clear(): */
57
- // gpio_set(GPIOD, GPIO12); /* LED off */
58
- // for (i = 0; i < 1000000; i++) /* Wait a bit. */
59
- // __asm__("nop");
60
- // gpio_clear(GPIOD, GPIO12); /* LED on */
61
- // for (i = 0; i < 1000000; i++) /* Wait a bit. */
62
- // __asm__("nop");
63
-
64
- /* Using API function gpio_toggle(): */
65
39
gpio_toggle (GPIOI , GPIO1 ); /* LED on/off */
66
40
for (i = 0 ; i < 1000000 ; i ++ ) { /* Wait a bit. */
67
41
__asm__("nop" );
0 commit comments