Skip to content

Commit f056753

Browse files
committed
add board yehuo-f103-znz
1 parent df68980 commit f056753

File tree

5 files changed

+58
-9
lines changed

5 files changed

+58
-9
lines changed

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ generic-pe5: begin clean gccversion build_generic-pe5 sizeafter finished copy_g
130130
generic-pe5-button-pa0: begin clean gccversion build_generic-pe5-button-pa0 sizeafter finished copy_generic-pe5-button-pa0 end
131131
generic-pb7: begin clean gccversion build_generic-pb7 sizeafter finished copy_generic-pb7 end
132132
generic-pb0: begin clean gccversion build_generic-pb0 sizeafter finished copy_generic-pb0 end
133+
yehuo-znz: begin clean gccversion build_yehuo-znz sizeafter finished copy_yehuo-znz end
133134
stbee : begin clean gccversion build_stbee sizeafter finished copy_stbee end
134135
naze32: begin clean gccversion build_naze32 sizeafter finished copy_naze32 end
135136
generic-pb12: begin clean gccversion build_generic-pb12 sizeafter finished copy_generic-pb12 end
@@ -329,6 +330,17 @@ copy_generic-pb7:
329330
cp $(TARGET).bin bootloader_only_binaries/generic_boot20_pb7.bin
330331
@echo
331332

333+
build_yehuo-znz: TARGETFLAGS= -DTARGET_YEHUO_F103_ZNZ $(DEFINES)
334+
# Set the linker script
335+
build_yehuo-znz: LDFLAGS +=-T$(ST_LIB)/c_only_md_high_density.ld
336+
build_yehuo-znz: elf bin lss sym
337+
copy_yehuo-znz:
338+
@echo
339+
@echo "Copying to binaries folder"
340+
@echo
341+
cp $(TARGET).bin bootloader_only_binaries/yehuo_boot20_znz.bin
342+
@echo
343+
332344
build_generic-pb0: TARGETFLAGS= -DTARGET_GENERIC_F103_PB0 $(DEFINES)
333345
# Set the linker script
334346
build_generic-pb0: LDFLAGS +=-T$(ST_LIB)/c_only_md_high_density.ld
7.04 KB
Binary file not shown.

config.h

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#define __CONFIG_H
3535

3636
#include "common.h"
37+
#include <stdint.h>
3738

3839

3940

@@ -97,7 +98,7 @@
9798
#define HAS_MAPLE_HARDWARE 1
9899

99100
#define LED_BANK GPIOB
100-
#define LED_PIN 1
101+
#define LED_PIN 0
101102
#define LED_ON_STATE 1
102103

103104
/* On the Mini, BUT is PB8 */
@@ -159,7 +160,7 @@
159160
#define BUTTON_BANK GPIOB
160161
#define BUTTON_PIN 2
161162
#define BUTTON_PRESSED_STATE 1
162-
163+
163164
#elif defined TARGET_GENERIC_F103_PC13_FASTBOOT
164165

165166

@@ -284,11 +285,21 @@
284285

285286
#elif defined TARGET_GENERIC_F103_PB0
286287

287-
#define LED_BANK GPIOB
288-
#define LED_PIN 0
289-
#define LED_ON_STATE 1
288+
#define LED_BANK GPIOB
289+
#define LED_PIN 0
290+
#define LED_ON_STATE 1
290291
#define BOOTLOADER_WAIT 30
291292

293+
#elif defined TARGET_YEHUO_F103_ZNZ
294+
295+
#define LED_BANK GPIOB
296+
#define LED_PIN 0
297+
#define LED_ON_STATE 0
298+
#define BOOTLOADER_WAIT 3
299+
#define USB_EN_BANK GPIOD
300+
#define USB_EN_PIN 6
301+
#define USB_EN_ON_STATE 0
302+
292303
#elif defined TARGET_STBEE
293304

294305
#define HAS_MAPLE_HARDWARE 1
@@ -411,7 +422,7 @@
411422
#error "No config for this target"
412423
#endif
413424

414-
// Check if button pulldown should be enabled
425+
// Check if button pulldown should be enabled
415426
// Default to True as this was the default prior to needing to disable it
416427
// in order to use the boot1 pin on the Blue Pill which has a very week pullup
417428
#ifndef BUTTON_INPUT_MODE

usb.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,34 @@
3131
*/
3232

3333
#include "usb.h"
34+
3435
#include "dfu.h"
36+
#include "hardware.h"
37+
38+
u16 wTransferSize;
3539

3640

3741
extern u8 u8_usbConfigDescriptorDFU[];
3842
extern u8 u8_usbFunctionalDescriptor[];
3943

44+
void setupUSBEnable(void) {
45+
# ifdef USB_EN_PIN
46+
47+
//for znz
48+
SET_REG(
49+
GPIO_CR(USB_EN_BANK, USB_EN_PIN),
50+
(GET_REG(GPIO_CR(USB_EN_BANK,USB_EN_PIN)) & crMask(USB_EN_PIN)) | CR_OUTPUT_PP << CR_SHITF(USB_EN_PIN)
51+
);
52+
53+
gpio_write_bit(USB_EN_BANK, USB_EN_PIN, USB_EN_ON_STATE);
54+
# endif
55+
}
56+
57+
4058
void setupUSB (void) {
4159

60+
setupUSBEnable();
61+
4262
#ifdef HAS_MAPLE_HARDWARE
4363
/* Setup USB DISC pin as output open drain */
4464
SET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC_PIN),(GET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC_PIN)) & crMask(USB_DISC_PIN)) | CR_OUTPUT_OD << CR_SHITF(USB_DISC_PIN));
@@ -56,6 +76,7 @@ void setupUSB (void) {
5676

5777
SET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC_PIN),(GET_REG(GPIO_CR(USB_DISC_BANK,USB_DISC_PIN)) & crMask(USB_DISC_PIN)) | CR_OUTPUT_PP << CR_SHITF(USB_DISC_PIN));
5878

79+
5980
gpio_write_bit(USB_DISC_BANK,USB_DISC_PIN,0); /* present ourselves to the host */
6081

6182
volatile unsigned int delay;

usb.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@
3939
#define ENDP3_RXADDR 0x110
4040

4141
#define bMaxPacketSize 0x40 /* 64B, maximum for usb FS devices */
42-
//#define wTransferSize FLASH_PAGE_SIZE /* This is important, because transfers have to match with the flash page size, otherwise it erases a page before its finished copying to that page */
42+
43+
//#define wTransferSize ((uint16_t)0x800)
44+
/* This is important, because transfers have to match with the flash page size, otherwise it erases a page before its finished copying to that page */
4345
#define dummyTransferSize 0x800
44-
int wTransferSize;
46+
extern u16 wTransferSize;
4547

4648
#define NUM_ENDPTS 0x01
4749

@@ -79,6 +81,9 @@ typedef enum _DEVICE_STATE {
7981
} DEVICE_STATE;
8082

8183
void setupUSB(void);
84+
85+
void setupUSBEnable(void);
86+
8287
void usbDsbBus(void);
8388
void usbAppInit(void); /* singleton usb initializer */
8489

@@ -134,4 +139,4 @@ void USB_LP_CAN1_RX0_IRQHandler(void);
134139

135140
void nothingProc(void);
136141

137-
#endif
142+
#endif //USB_H

0 commit comments

Comments
 (0)