Skip to content

Commit 376c880

Browse files
committed
Add support for OPTA
1 parent ade74f4 commit 376c880

File tree

3 files changed

+101
-7
lines changed

3 files changed

+101
-7
lines changed

app/board.h

+62-1
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,69 @@
204204
#define BOARD_USB_OTG_HS_DIR_ALTERNATE (GPIO_AF10_OTG2_HS)
205205
#define BOARD_USB_OTG_HS_DIR_GPIO (GPIOC)
206206

207-
#else
207+
#elif defined TARGET_OPTA
208+
#define BOARD_GREEN_LED PH_12
209+
#define BOARD_RED_LED PH_11
210+
#define BOARD_BLUE_LED PE_5
211+
212+
#define BOARD_ETH_RESET PJ_15
213+
214+
#define BOARD_USBD_VID 0x2341
215+
#define BOARD_USBD_PID 0x0364
216+
217+
#define BOARD_USBD_STRING "Opta"
218+
219+
#define BOARD_QSPI_SO0 PD_11
220+
#define BOARD_QSPI_SO1 PD_12
221+
#define BOARD_QSPI_SO2 PE_2
222+
#define BOARD_QSPI_SO3 PD_13
223+
#define BOARD_QSPI_SCK PB_2
224+
#define BOARD_QSPI_CS PG_6
225+
226+
#define BOARD_USB_OTG_FS_DM_DP_PIN (GPIO_PIN_11 | GPIO_PIN_12)
227+
#define BOARD_USB_OTG_FS_DM_DP_MODE (GPIO_MODE_AF_PP)
228+
#define BOARD_USB_OTG_FS_DM_DP_PULL (GPIO_PULLUP)
229+
#define BOARD_USB_OTG_FS_DM_DP_SPEED (GPIO_SPEED_FREQ_VERY_HIGH)
230+
#define BOARD_USB_OTG_FS_DM_DP_ALTERNATE (GPIO_AF10_OTG1_FS)
231+
#define BOARD_USB_OTG_FS_DM_DP_GPIO (GPIOA)
232+
233+
#define BOARD_USB_OTG_HS_CLK_PIN (GPIO_PIN_5)
234+
#define BOARD_USB_OTG_HS_CLK_MODE (GPIO_MODE_AF_PP)
235+
#define BOARD_USB_OTG_HS_CLK_PULL (GPIO_NOPULL)
236+
#define BOARD_USB_OTG_HS_CLK_SPEED (GPIO_SPEED_FREQ_VERY_HIGH)
237+
#define BOARD_USB_OTG_HS_CLK_ALTERNATE (GPIO_AF10_OTG2_HS)
238+
#define BOARD_USB_OTG_HS_CLK_GPIO (GPIOA)
239+
240+
#define BOARD_USB_OTG_HS_D0_PIN (GPIO_PIN_3)
241+
#define BOARD_USB_OTG_HS_D0_MODE (GPIO_MODE_AF_PP)
242+
#define BOARD_USB_OTG_HS_D0_PULL (GPIO_NOPULL)
243+
#define BOARD_USB_OTG_HS_D0_SPEED (GPIO_SPEED_FREQ_VERY_HIGH)
244+
#define BOARD_USB_OTG_HS_D0_ALTERNATE (GPIO_AF10_OTG2_HS)
245+
#define BOARD_USB_OTG_HS_D0_GPIO (GPIOA)
246+
247+
#define BOARD_USB_OTG_HS_D1_D7_PIN (GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_5 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13)
248+
#define BOARD_USB_OTG_HS_D1_D7_MODE (GPIO_MODE_AF_PP)
249+
#define BOARD_USB_OTG_HS_D1_D7_PULL (GPIO_NOPULL)
250+
#define BOARD_USB_OTG_HS_D1_D7_ALTERNATE (GPIO_AF10_OTG2_HS)
251+
#define BOARD_USB_OTG_HS_D1_D7_GPIO (GPIOB)
252+
253+
#define BOARD_USB_OTG_HS_STP_PIN (GPIO_PIN_0)
254+
#define BOARD_USB_OTG_HS_STP_MODE (GPIO_MODE_AF_PP)
255+
#define BOARD_USB_OTG_HS_STP_PULL (GPIO_NOPULL)
256+
#define BOARD_USB_OTG_HS_STP_ALTERNATE (GPIO_AF10_OTG2_HS)
257+
#define BOARD_USB_OTG_HS_STP_GPIO (GPIOC)
258+
259+
#define BOARD_USB_OTG_HS_NXT_PIN (GPIO_PIN_3)
260+
#define BOARD_USB_OTG_HS_NXT_MODE (GPIO_MODE_AF_PP)
261+
#define BOARD_USB_OTG_HS_NXT_PULL (GPIO_NOPULL)
262+
#define BOARD_USB_OTG_HS_NXT_ALTERNATE (GPIO_AF10_OTG2_HS)
263+
#define BOARD_USB_OTG_HS_NXT_GPIO (GPIOC)
208264

265+
#define BOARD_USB_OTG_HS_DIR_PIN (GPIO_PIN_2)
266+
#define BOARD_USB_OTG_HS_DIR_MODE (GPIO_MODE_AF_PP)
267+
#define BOARD_USB_OTG_HS_DIR_PULL (GPIO_NOPULL)
268+
#define BOARD_USB_OTG_HS_DIR_ALTERNATE (GPIO_AF10_OTG2_HS)
269+
#define BOARD_USB_OTG_HS_DIR_GPIO (GPIOC)
209270
#endif
210271

211272
#endif /* __BOARD_H */

app/main.cpp

+23-6
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@
4141
#define USE_PLL_HSE_XTAL 0x4 // Use external xtal (X3 on board - not provided by default)
4242
#define USE_PLL_HSI 0x2 // Use HSI internal clock
4343

44+
#if ((CLOCK_SOURCE) & USE_PLL_HSI)
45+
extern "C" uint8_t SetSysClock_PLL_HSI(void);
46+
#elif ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC)
4447
extern "C" uint8_t SetSysClock_PLL_HSE(uint8_t bypass, bool lowspeed);
48+
#else
49+
50+
#endif
4551

4652
volatile const uint8_t bootloader_data[] __attribute__ ((section (".bootloader_version"), used)) = {
4753
BOOTLOADER_CONFIG_MAGIC,
@@ -66,10 +72,11 @@ USBD_HandleTypeDef USBD_Device;
6672
DigitalOut red(BOARD_RED_LED, 1);
6773
DigitalOut green(BOARD_GREEN_LED, 1);
6874
DigitalOut blue(BOARD_BLUE_LED, 1);
69-
#if defined(TARGET_NICLA_VISION)
70-
bool boot_sel = false;
71-
#else
75+
76+
#if defined (BOARD_BOOT_SEL)
7277
DigitalIn boot_sel(BOARD_BOOT_SEL,PullDown);
78+
#else
79+
bool boot_sel = false;
7380
#endif
7481

7582
Ticker swap_ticker;
@@ -133,7 +140,14 @@ static int debug_init(void) {
133140
static int start_dfu(void) {
134141
RTCSetBKPRegister(RTC_BKP_DR0, 0);
135142

143+
#if ((CLOCK_SOURCE) & USE_PLL_HSI)
144+
SetSysClock_PLL_HSI();
145+
#elif ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC)
136146
SetSysClock_PLL_HSE(1, false);
147+
#else
148+
149+
#endif
150+
137151
SystemCoreClockUpdate();
138152

139153
led_swap_feedback_off();
@@ -235,8 +249,11 @@ int main(void) {
235249
HAL_Delay(500);
236250
}
237251

252+
#if defined (BOARD_USB_RESET)
238253
DigitalOut usb_reset(BOARD_USB_RESET, 0);
239-
#if BOARD_HAS_VIDEO
254+
#endif
255+
256+
#if defined (BOARD_HAS_VIDEO) && (BOARD_HAS_VIDEO)
240257
DigitalOut video_enable(BOARD_VIDEO_ENABLE, 0);
241258
DigitalOut video_reset(BOARD_VIDEO_RESET, 0);
242259
#endif
@@ -248,16 +265,16 @@ int main(void) {
248265
HAL_FLASH_Unlock();
249266

250267
power_init();
251-
252268
HAL_Delay(10);
253269

270+
#if defined (BOARD_USB_RESET)
254271
usb_reset = 1;
255272
HAL_Delay(10);
256273
usb_reset = 0;
257274
HAL_Delay(10);
258275
usb_reset = 1;
259-
260276
HAL_Delay(10);
277+
#endif
261278

262279
if (magic != 0xDF59) {
263280
if (boot_empty_keys()) {

mbed_app.json

+16
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,22 @@
111111
"SE050"
112112
],
113113
"mcuboot.application-sdcard": null
114+
},
115+
"OPTA": {
116+
"target.clock_source": "USE_PLL_HSE_EXTC",
117+
"target.use-mpu": false,
118+
"target.macros_add": [
119+
"USE_USB_FS",
120+
"LOWSPEED=1",
121+
"BOARD_HAS_VIDEO=0"
122+
],
123+
"target.usb_speed": "USE_USB_OTG_FS",
124+
"target.components_remove" : [
125+
"WHD",
126+
"4343W_FS",
127+
"CYW43XXX"
128+
],
129+
"mcuboot.application-sdcard": null
114130
}
115131
}
116132
}

0 commit comments

Comments
 (0)