Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: target/dartuinoP0/init.c

Issue 1515283002: [target][dartuino P0] Configure switches GPIO (Closed) Base URL: https://github.com/travisg/lk.git@master
Patch Set: rebase Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 Travis Geiselbrecht 2 * Copyright (c) 2015 Travis Geiselbrecht
3 * 3 *
4 * Permission is hereby granted, free of charge, to any person obtaining 4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files 5 * a copy of this software and associated documentation files
6 * (the "Software"), to deal in the Software without restriction, 6 * (the "Software"), to deal in the Software without restriction,
7 * including without limitation the rights to use, copy, modify, merge, 7 * including without limitation the rights to use, copy, modify, merge,
8 * publish, distribute, sublicense, and/or sell copies of the Software, 8 * publish, distribute, sublicense, and/or sell copies of the Software,
9 * and to permit persons to whom the Software is furnished to do so, 9 * and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions: 10 * subject to the following conditions:
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 const sdram_config_t target_sdram_config = { 48 const sdram_config_t target_sdram_config = {
49 .bus_width = SDRAM_BUS_WIDTH_16, 49 .bus_width = SDRAM_BUS_WIDTH_16,
50 .cas_latency = SDRAM_CAS_LATENCY_2, 50 .cas_latency = SDRAM_CAS_LATENCY_2,
51 .col_bits_num = SDRAM_COLUMN_BITS_8 51 .col_bits_num = SDRAM_COLUMN_BITS_8
52 }; 52 };
53 53
54 54
55 55
56 void target_early_init(void) 56 void target_early_init(void)
57 { 57 {
58 58 GPIO_InitTypeDef gpio_init;
59 GPIO_InitTypeDef gpio_init_structure;
60 59
61 __HAL_RCC_GPIOE_CLK_ENABLE(); 60 __HAL_RCC_GPIOE_CLK_ENABLE();
62 __HAL_RCC_GPIOD_CLK_ENABLE(); 61 __HAL_RCC_GPIOD_CLK_ENABLE();
63 __HAL_RCC_GPIOJ_CLK_ENABLE(); 62 __HAL_RCC_GPIOJ_CLK_ENABLE();
64 63
65
66 #if DEBUG_UART == 3 64 #if DEBUG_UART == 3
67 /* configure usart 3 pins */ 65 // configure usart 3 pins.
68 gpio_config(GPIO_USART3_TX, GPIO_STM32_AF | GPIO_STM32_AFn(GPIO_AF7_USART3) | GPIO_PULLUP); 66 gpio_config(GPIO_USART3_TX, GPIO_STM32_AF | GPIO_STM32_AFn(GPIO_AF7_USART3) | GPIO_PULLUP);
69 gpio_config(GPIO_USART3_RX, GPIO_STM32_AF | GPIO_STM32_AFn(GPIO_AF7_USART3) | GPIO_PULLUP); 67 gpio_config(GPIO_USART3_RX, GPIO_STM32_AF | GPIO_STM32_AFn(GPIO_AF7_USART3) | GPIO_PULLUP);
70 #else 68 #else
71 #error need to configure gpio pins for debug uart 69 #error need to configure gpio pins for debug uart
72 #endif 70 #endif
73 71
74 gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP; 72 gpio_init.Mode = GPIO_MODE_OUTPUT_PP;
75 gpio_init_structure.Pull = GPIO_NOPULL; 73 gpio_init.Pull = GPIO_NOPULL;
76 gpio_init_structure.Speed = GPIO_SPEED_LOW; 74 gpio_init.Speed = GPIO_SPEED_LOW;
77 75
78 gpio_init_structure.Pin = GPIO_TO_PIN_MASK(GPIO_LED108) | GPIO_TO_PIN_MA SK(GPIO_LED109) |\ 76 gpio_init.Pin = GPIO_TO_PIN_MASK(GPIO_LED108) | GPIO_TO_PIN_MASK(GPIO_LED10 9) |
79 GPIO_TO_PIN_MASK(GPIO_LED110) | GPIO_TO_PIN_MA SK(GPIO_LED111); 77 GPIO_TO_PIN_MASK(GPIO_LED110) | GPIO_TO_PIN_MASK(GPIO_LED11 1);
80 HAL_GPIO_Init(GPIOE, &gpio_init_structure); 78 HAL_GPIO_Init(GPIOE, &gpio_init);
81 79
82 gpio_init_structure.Pin = GPIO_TO_PIN_MASK(GPIO_LED112) | GPIO_TO_PIN_MA SK(GPIO_LED113); 80 gpio_init.Pin = GPIO_TO_PIN_MASK(GPIO_LED112) | GPIO_TO_PIN_MASK(GPIO_LED11 3);
83 HAL_GPIO_Init(GPIOD, &gpio_init_structure); 81 HAL_GPIO_Init(GPIOD, &gpio_init);
84 82
85 gpio_init_structure.Pin = GPIO_TO_PIN_MASK(GPIO_LED114) | GPIO_TO_PIN_MA SK(GPIO_LED115); 83 gpio_init.Pin = GPIO_TO_PIN_MASK(GPIO_LED114) | GPIO_TO_PIN_MASK(GPIO_LED11 5);
86 HAL_GPIO_Init(GPIOJ, &gpio_init_structure); 84 HAL_GPIO_Init(GPIOJ, &gpio_init);
87 // Initialize to a pattern just so we know we have something 85
86 // Initialize to a pattern just so we know we have something.
88 gpio_set(GPIO_LED108, GPIO_LED_ON); 87 gpio_set(GPIO_LED108, GPIO_LED_ON);
89 gpio_set(GPIO_LED109, GPIO_LED_ON); 88 gpio_set(GPIO_LED109, GPIO_LED_ON);
90 gpio_set(GPIO_LED110, GPIO_LED_ON); 89 gpio_set(GPIO_LED110, GPIO_LED_ON);
91 gpio_set(GPIO_LED111, GPIO_LED_ON); 90 gpio_set(GPIO_LED111, GPIO_LED_ON);
92 gpio_set(GPIO_LED112, GPIO_LED_ON); 91 gpio_set(GPIO_LED112, GPIO_LED_ON);
93 gpio_set(GPIO_LED113, GPIO_LED_ON); 92 gpio_set(GPIO_LED113, GPIO_LED_ON);
94 gpio_set(GPIO_LED114, GPIO_LED_ON); 93 gpio_set(GPIO_LED114, GPIO_LED_ON);
95 gpio_set(GPIO_LED115, GPIO_LED_ON); 94 gpio_set(GPIO_LED115, GPIO_LED_ON);
96 95
97 /* now that the uart gpios are configured, enable the debug uart */ 96 // Initialize the switches GPIOs for interrupt on raising edge. In order
97 // to use stm32_EXTI15_10_IRQ() handler needs to be provided and EXTI15_10_I RQn
98 // needs to be enabled.
99 gpio_init.Mode = GPIO_MODE_INPUT;
100 gpio_init.Pull = GPIO_NOPULL;
101 gpio_init.Speed = GPIO_SPEED_FAST;
102 gpio_init.Mode = GPIO_MODE_IT_RISING;
103
104 gpio_init.Pin = GPIO_TO_PIN_MASK(GPIO_SW100) | GPIO_TO_PIN_MASK(GPIO_SW101 ) |
105 GPIO_TO_PIN_MASK(GPIO_SW102) | GPIO_TO_PIN_MASK(GPIO_SW103 );
106 HAL_GPIO_Init(GPIOJ, &gpio_init);
107
108 // now that the uart gpios are configured, enable the debug uart.
98 stm32_debug_early_init(); 109 stm32_debug_early_init();
99
100 /* The lcd framebuffer starts at the base of SDRAM */
101 } 110 }
102 111
103 static uint8_t* gen_mac_address(void) 112 static uint8_t* gen_mac_address(void)
104 { 113 {
105 static uint8_t mac_addr[6]; 114 static uint8_t mac_addr[6];
106 115
107 for (size_t i = 0; i < sizeof(mac_addr); i++) { 116 for (size_t i = 0; i < sizeof(mac_addr); i++) {
108 mac_addr[i] = rand() & 0xff; 117 mac_addr[i] = rand() & 0xff;
109 } 118 }
110 mac_addr[5] += 1; 119 mac_addr[5] += 1;
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 /* Enable USB HS Clocks */ 460 /* Enable USB HS Clocks */
452 __HAL_RCC_USB_OTG_HS_CLK_ENABLE(); 461 __HAL_RCC_USB_OTG_HS_CLK_ENABLE();
453 462
454 /* Set USBHS Interrupt to the lowest priority */ 463 /* Set USBHS Interrupt to the lowest priority */
455 HAL_NVIC_SetPriority(OTG_HS_IRQn, 5, 0); 464 HAL_NVIC_SetPriority(OTG_HS_IRQn, 5, 0);
456 465
457 /* Enable USBHS Interrupt */ 466 /* Enable USBHS Interrupt */
458 HAL_NVIC_EnableIRQ(OTG_HS_IRQn); 467 HAL_NVIC_EnableIRQ(OTG_HS_IRQn);
459 } 468 }
460 } 469 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698