Skip to content

Commit 65ee11f

Browse files
authored
Merge pull request hathach#1882 from koendv/pitaya_lite
add board: DshanMCU Pitaya Lite
2 parents bc57358 + b2568eb commit 65ee11f

File tree

8 files changed

+717
-1
lines changed

8 files changed

+717
-1
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CFLAGS += \
2+
-DHSE_VALUE=8000000
3+
4+
LD_FILE = $(BOARD_PATH)/flash.ld
5+
SRC_S += $(SDK_DIR)/mm32f327x/MM32F327x/Source/GCC_StartAsm/startup_mm32m3ux_u_gcc.S
6+
7+
# For flash-jlink target
8+
#JLINK_DEVICE = stm32f411ve
9+
10+
# flash target using on-board stlink
11+
#flash: flash-jlink
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2020 MM32 SE TEAM
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*
24+
* This file is part of the TinyUSB stack.
25+
*/
26+
27+
/* Entry Point */
28+
ENTRY(Reset_Handler)
29+
30+
/* Highest address of the user mode stack */
31+
_estack = 0x2001FFFF; /* end of RAM */
32+
33+
/* Generate a link error if heap and stack don't fit into RAM */
34+
_Min_Heap_Size = 0x200; /* required amount of heap */
35+
_Min_Stack_Size = 0x400; /* required amount of stack */
36+
37+
/* Specify the memory areas */
38+
MEMORY
39+
{
40+
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K
41+
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
42+
}
43+
44+
/* Define output sections */
45+
SECTIONS
46+
{
47+
/* The startup code goes first into FLASH */
48+
.isr_vector :
49+
{
50+
. = ALIGN(4);
51+
KEEP(*(.isr_vector)) /* Startup code */
52+
. = ALIGN(4);
53+
} >FLASH
54+
55+
/* The program code and other data goes into FLASH */
56+
.text :
57+
{
58+
. = ALIGN(4);
59+
*(.text) /* .text sections (code) */
60+
*(.text*) /* .text* sections (code) */
61+
*(.glue_7) /* glue arm to thumb code */
62+
*(.glue_7t) /* glue thumb to arm code */
63+
*(.eh_frame)
64+
65+
KEEP (*(.init))
66+
KEEP (*(.fini))
67+
68+
. = ALIGN(4);
69+
_etext = .; /* define a global symbols at end of code */
70+
} >FLASH
71+
72+
/* Constant data goes into FLASH */
73+
.rodata :
74+
{
75+
. = ALIGN(4);
76+
*(.rodata) /* .rodata sections (constants, strings, etc.) */
77+
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
78+
. = ALIGN(4);
79+
} >FLASH
80+
81+
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
82+
.ARM : {
83+
__exidx_start = .;
84+
*(.ARM.exidx*)
85+
__exidx_end = .;
86+
} >FLASH
87+
88+
.preinit_array :
89+
{
90+
PROVIDE_HIDDEN (__preinit_array_start = .);
91+
KEEP (*(.preinit_array*))
92+
PROVIDE_HIDDEN (__preinit_array_end = .);
93+
} >FLASH
94+
.init_array :
95+
{
96+
PROVIDE_HIDDEN (__init_array_start = .);
97+
KEEP (*(SORT(.init_array.*)))
98+
KEEP (*(.init_array*))
99+
PROVIDE_HIDDEN (__init_array_end = .);
100+
} >FLASH
101+
.fini_array :
102+
{
103+
PROVIDE_HIDDEN (__fini_array_start = .);
104+
KEEP (*(SORT(.fini_array.*)))
105+
KEEP (*(.fini_array*))
106+
PROVIDE_HIDDEN (__fini_array_end = .);
107+
} >FLASH
108+
109+
/* used by the startup to initialize data */
110+
_sidata = LOADADDR(.data);
111+
112+
/* Initialized data sections goes into RAM, load LMA copy after code */
113+
.data :
114+
{
115+
. = ALIGN(4);
116+
_sdata = .; /* create a global symbol at data start */
117+
*(.data) /* .data sections */
118+
*(.data*) /* .data* sections */
119+
120+
. = ALIGN(4);
121+
_edata = .; /* define a global symbol at data end */
122+
} >RAM AT> FLASH
123+
124+
125+
/* Uninitialized data section */
126+
. = ALIGN(4);
127+
.bss :
128+
{
129+
/* This is used by the startup in order to initialize the .bss section */
130+
_sbss = .; /* define a global symbol at bss start */
131+
__bss_start__ = _sbss;
132+
*(.bss)
133+
*(.bss*)
134+
*(COMMON)
135+
136+
. = ALIGN(4);
137+
_ebss = .; /* define a global symbol at bss end */
138+
__bss_end__ = _ebss;
139+
} >RAM
140+
141+
/* User_heap_stack section, used to check that there is enough RAM left */
142+
._user_heap_stack :
143+
{
144+
. = ALIGN(8);
145+
PROVIDE ( end = . );
146+
PROVIDE ( _end = . );
147+
. = . + _Min_Heap_Size;
148+
. = . + _Min_Stack_Size;
149+
. = ALIGN(8);
150+
} >RAM
151+
152+
153+
154+
/* Remove information from the standard libraries */
155+
/DISCARD/ :
156+
{
157+
libc.a ( * )
158+
libm.a ( * )
159+
libgcc.a ( * )
160+
}
161+
162+
.ARM.attributes 0 : { *(.ARM.attributes) }
163+
}
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2020 MM32 SE TEAM
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*
24+
* This file is part of the TinyUSB stack.
25+
*/
26+
27+
/* WeAct BluePillPlus with MM32F3273G6P */
28+
29+
#include "mm32_device.h"
30+
#include "hal_conf.h"
31+
#include "tusb.h"
32+
#include "../board.h"
33+
34+
//--------------------------------------------------------------------+
35+
// Forward USB interrupt events to TinyUSB IRQ Handler
36+
//--------------------------------------------------------------------+
37+
void OTG_FS_IRQHandler (void)
38+
{
39+
tud_int_handler(0);
40+
41+
}
42+
void USB_DeviceClockInit (void)
43+
{
44+
/* Select USBCLK source */
45+
// RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_Div1);
46+
RCC->CFGR &= ~(0x3 << 22);
47+
RCC->CFGR |= (0x1 << 22);
48+
49+
/* Enable USB clock */
50+
RCC->AHB2ENR |= 0x1 << 7;
51+
}
52+
//--------------------------------------------------------------------+
53+
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
54+
//--------------------------------------------------------------------+
55+
// LED
56+
57+
extern u32 SystemCoreClock;
58+
const int baudrate = 115200;
59+
60+
void board_init (void)
61+
{
62+
// usb clock
63+
USB_DeviceClockInit();
64+
65+
if ( SysTick_Config(SystemCoreClock / 1000) )
66+
{
67+
while ( 1 )
68+
;
69+
}
70+
NVIC_SetPriority(SysTick_IRQn, 0x0);
71+
72+
// LED on PB2
73+
GPIO_InitTypeDef GPIO_InitStruct;
74+
RCC_AHBPeriphClockCmd(RCC_AHBENR_GPIOB, ENABLE);
75+
GPIO_StructInit(&GPIO_InitStruct);
76+
77+
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_2;
78+
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
79+
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
80+
GPIO_Init(GPIOB, &GPIO_InitStruct);
81+
82+
board_led_write(true);
83+
84+
// KEY on PA0
85+
RCC_AHBPeriphClockCmd(RCC_AHBENR_GPIOA, ENABLE);
86+
GPIO_StructInit(&GPIO_InitStruct);
87+
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0;
88+
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_10MHz;
89+
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPD;
90+
GPIO_Init(GPIOA, &GPIO_InitStruct);
91+
92+
// UART
93+
UART_InitTypeDef UART_InitStruct;
94+
95+
RCC_APB2PeriphClockCmd(RCC_APB2ENR_UART1, ENABLE); //enableUART1,GPIOAclock
96+
RCC_AHBPeriphClockCmd(RCC_AHBENR_GPIOA, ENABLE); //
97+
//UART initialset
98+
99+
GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_7);
100+
GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_7);
101+
102+
UART_StructInit(&UART_InitStruct);
103+
UART_InitStruct.UART_BaudRate = baudrate;
104+
UART_InitStruct.UART_WordLength = UART_WordLength_8b;
105+
UART_InitStruct.UART_StopBits = UART_StopBits_1; //one stopbit
106+
UART_InitStruct.UART_Parity = UART_Parity_No; //none odd-even verify bit
107+
UART_InitStruct.UART_HardwareFlowControl = UART_HardwareFlowControl_None; //No hardware flow control
108+
UART_InitStruct.UART_Mode = UART_Mode_Rx | UART_Mode_Tx; // receive and sent mode
109+
110+
UART_Init(UART1, &UART_InitStruct); //initial uart 1
111+
UART_Cmd(UART1, ENABLE); //enable uart 1
112+
113+
//UART1_TX GPIOA.9
114+
GPIO_StructInit(&GPIO_InitStruct);
115+
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_9;
116+
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
117+
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
118+
GPIO_Init(GPIOA, &GPIO_InitStruct);
119+
120+
//UART1_RX GPIOA.10
121+
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_5;
122+
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPU;
123+
GPIO_Init(GPIOA, &GPIO_InitStruct);
124+
125+
}
126+
127+
128+
//--------------------------------------------------------------------+
129+
// Board porting API
130+
//--------------------------------------------------------------------+
131+
132+
void board_led_write (bool state)
133+
{
134+
state ? (GPIO_ResetBits(GPIOB, GPIO_Pin_2)) : (GPIO_SetBits(GPIOB, GPIO_Pin_2));
135+
}
136+
137+
uint32_t board_button_read (void)
138+
{
139+
uint32_t key = GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_0) == Bit_SET;
140+
return key;
141+
}
142+
143+
int board_uart_read (uint8_t *buf, int len)
144+
{
145+
(void) buf;
146+
(void) len;
147+
return 0;
148+
}
149+
150+
int board_uart_write (void const *buf, int len)
151+
{
152+
const char *buff = buf;
153+
while ( len )
154+
{
155+
while ( (UART1->CSR & UART_IT_TXIEN) == 0 )
156+
; //The loop is sent until it is finished
157+
UART1->TDR = (*buff & 0xFF);
158+
buff++;
159+
len--;
160+
}
161+
return len;
162+
}
163+
164+
#if CFG_TUSB_OS == OPT_OS_NONE
165+
volatile uint32_t system_ticks = 0;
166+
void SysTick_Handler (void)
167+
{
168+
system_ticks++;
169+
}
170+
171+
uint32_t board_millis (void)
172+
{
173+
return system_ticks;
174+
}
175+
#endif
176+
177+
// Required by __libc_init_array in startup code if we are compiling using
178+
// -nostdlib/-nostartfiles.
179+
void _init(void)
180+
{
181+
182+
}

hw/bsp/mm32/boards/mm32f327x_mb39/board.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
CFLAGS += \
2+
-DHSE_VALUE=8000000
3+
14
LD_FILE = $(BOARD_PATH)/flash.ld
25
SRC_S += $(SDK_DIR)/mm32f327x/MM32F327x/Source/GCC_StartAsm/startup_mm32m3ux_u_gcc.S
36

7+
48
# For flash-jlink target
59
#JLINK_DEVICE = stm32f411ve
610

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CFLAGS += \
2+
-DHSE_VALUE=12000000
3+
4+
LD_FILE = $(BOARD_PATH)/flash.ld
5+
SRC_S += $(SDK_DIR)/mm32f327x/MM32F327x/Source/GCC_StartAsm/startup_mm32m3ux_u_gcc.S
6+
7+
# For flash-jlink target
8+
#JLINK_DEVICE = MM32F3273G8P
9+
10+
# flash target using on-board stlink
11+
#flash: flash-jlink

0 commit comments

Comments
 (0)