Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Mr_Pangza
rt-thread
提交
4bc85624
R
rt-thread
项目概览
Mr_Pangza
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
2
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
4bc85624
编写于
3月 26, 2021
作者:
B
Bernard Xiong
提交者:
GitHub
3月 26, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4512 from Guozhanxin/pico-startup
Optimize pico bsp
上级
a3b12cb7
2f671012
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
158 addition
and
76 deletion
+158
-76
bsp/raspberry-pico/README.md
bsp/raspberry-pico/README.md
+10
-10
bsp/raspberry-pico/drivers/board.c
bsp/raspberry-pico/drivers/board.c
+16
-4
bsp/raspberry-pico/drivers/board.h
bsp/raspberry-pico/drivers/board.h
+3
-3
bsp/raspberry-pico/drivers/drv_uart.c
bsp/raspberry-pico/drivers/drv_uart.c
+127
-0
bsp/raspberry-pico/libraries/pico-sdk/src/rp2_common/pico_runtime/runtime.c
.../libraries/pico-sdk/src/rp2_common/pico_runtime/runtime.c
+1
-51
bsp/raspberry-pico/link.ld
bsp/raspberry-pico/link.ld
+1
-8
未找到文件。
bsp/raspberry-pico/README.md
浏览文件 @
4bc85624
...
...
@@ -64,14 +64,14 @@ msh >
## Peripheral Condition
| Drive | Support | Remark |
| ----- | ------- | ------ |
| UART | Support | UART0
|
| GPIO | Support | 0-29 |
| I2C | - | - |
| RTC | - | - |
| SDIO | - | - |
| SPI | - | - |
| TIMER | - | - |
| WDT | - | - |
| Drive | Support | Remark
|
| ----- | ------- | ------
-
|
| UART | Support | UART0
/1
|
| GPIO | Support | 0-29
|
| I2C | - | -
|
| RTC | - | -
|
| SDIO | - | -
|
| SPI | - | -
|
| TIMER | - | -
|
| WDT | - | -
|
bsp/raspberry-pico/drivers/board.c
浏览文件 @
4bc85624
...
...
@@ -16,8 +16,6 @@
#include "board.h"
#include "hardware/structs/systick.h"
uint8_t
heap
[
1024
*
80
];
void
isr_systick
(
void
)
{
/* enter interrupt */
...
...
@@ -45,11 +43,25 @@ uint32_t systick_config(uint32_t ticks)
void
rt_hw_board_init
()
{
rt_system_heap_init
(
HEAP_BEGIN
,
HEAP_END
);
alarm_pool_init_default
();
// Start and end points of the constructor list,
// defined by the linker script.
extern
void
(
*
__init_array_start
)();
extern
void
(
*
__init_array_end
)();
// Call each function in the list.
// We have to take the address of the symbols, as __init_array_start *is*
// the first function pointer, not the address of it.
for
(
void
(
**
p
)()
=
&
__init_array_start
;
p
<
&
__init_array_end
;
++
p
)
{
(
*
p
)();
}
/* Configure the SysTick */
systick_config
(
frequency_count_khz
(
CLOCKS_FC0_SRC_VALUE_ROSC_CLKSRC
)
*
10000
/
RT_TICK_PER_SECOND
);
rt_system_heap_init
(
heap
,
(
uint8_t
*
)
heap
+
sizeof
(
heap
));
stdio_init_all
();
rt_hw_uart_init
();
...
...
bsp/raspberry-pico/drivers/board.h
浏览文件 @
4bc85624
...
...
@@ -20,9 +20,9 @@
#define PICO_SRAM_SIZE 256
#define PICO_SRAM_END (0x20000000 + PICO_SRAM_SIZE * 1024)
extern
int
__bss_end
;
#define HEAP_BEGIN (&__bss_end)
#define HEAP_END
PICO_SRAM_END
extern
int
__bss_end
__
;
#define HEAP_BEGIN (&__bss_end
__
)
#define HEAP_END
((void *)PICO_SRAM_END)
int
rt_hw_uart_init
(
void
);
...
...
bsp/raspberry-pico/drivers/drv_uart.c
浏览文件 @
4bc85624
...
...
@@ -153,3 +153,130 @@ int rt_hw_uart_init(void)
return
ret
;
}
// INIT_DEVICE_EXPORT(rt_hw_uart_init);
// We are using pins 0 and 1, but see the GPIO function select table in the
// datasheet for information on which other pins can be used.
#define UART1_TX_PIN 4
#define UART1_RX_PIN 5
static
struct
pico_uart1_dev
uart1_dev
;
struct
pico_uart1_dev
{
struct
rt_serial_device
parent
;
rt_uint32_t
uart_periph
;
rt_uint32_t
irqno
;
};
void
pico_uart1_isr
(
void
)
{
rt_interrupt_enter
();
/* read interrupt status and clear it */
if
(
uart_is_readable
(
uart1
))
/* rx ind */
{
rt_hw_serial_isr
(
&
uart1_dev
.
parent
,
RT_SERIAL_EVENT_RX_IND
);
}
rt_interrupt_leave
();
}
/*
* UART interface
*/
static
rt_err_t
pico_uart1_configure
(
struct
rt_serial_device
*
serial
,
struct
serial_configure
*
cfg
)
{
return
RT_EOK
;
}
static
rt_err_t
pico_uart1_control
(
struct
rt_serial_device
*
serial
,
int
cmd
,
void
*
arg
)
{
switch
(
cmd
)
{
/* enable interrupt */
case
RT_DEVICE_CTRL_SET_INT
:
// Set up a RX interrupt
// We need to set up the handler first
// And set up and enable the interrupt handlers
irq_set_exclusive_handler
(
UART1_IRQ
,
pico_uart1_isr
);
irq_set_enabled
(
UART1_IRQ
,
true
);
// Now enable the UART to send interrupts - RX only
uart_set_irq_enables
(
uart1
,
true
,
false
);
break
;
}
return
RT_EOK
;
}
static
int
pico_uart1_putc
(
struct
rt_serial_device
*
serial
,
char
c
)
{
uart_putc_raw
(
uart1
,
c
);
return
1
;
}
static
int
pico_uart1_getc
(
struct
rt_serial_device
*
serial
)
{
int
ch
;
if
(
uart_is_readable
(
uart1
))
{
ch
=
uart_get_hw
(
uart1
)
->
dr
;
}
else
{
ch
=-
1
;
}
return
ch
;
}
const
static
struct
rt_uart_ops
_uart1_ops
=
{
pico_uart1_configure
,
pico_uart1_control
,
pico_uart1_putc
,
pico_uart1_getc
,
RT_NULL
,
};
/*
* UART Initiation
*/
int
rt_hw_uart1_init
(
void
)
{
rt_err_t
ret
=
RT_EOK
;
struct
serial_configure
config
=
RT_SERIAL_CONFIG_DEFAULT
;
uart_init
(
uart1
,
115200
);
// Set the TX and RX pins by using the function select on the GPIO
// Set datasheet for more information on function select
gpio_set_function
(
UART1_TX_PIN
,
GPIO_FUNC_UART
);
gpio_set_function
(
UART1_RX_PIN
,
GPIO_FUNC_UART
);
// Actually, we want a different speed
// The call will return the actual baud rate selected, which will be as close as
// possible to that requested
uart_set_baudrate
(
uart1
,
BAUD_RATE
);
// Set UART flow control CTS/RTS, we don't want these, so turn them off
uart_set_hw_flow
(
uart1
,
false
,
false
);
// Set our data format
uart_set_format
(
uart1
,
DATA_BITS
,
STOP_BITS
,
PARITY
);
// Turn off FIFO's - we want to do this character by character
uart_set_fifo_enabled
(
uart1
,
false
);
uart1_dev
.
parent
.
ops
=
&
_uart1_ops
;
uart1_dev
.
parent
.
config
=
config
;
ret
=
rt_hw_serial_register
(
&
uart1_dev
.
parent
,
"uart1"
,
RT_DEVICE_FLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
,
&
uart1_dev
);
return
ret
;
}
INIT_DEVICE_EXPORT
(
rt_hw_uart1_init
);
bsp/raspberry-pico/libraries/pico-sdk/src/rp2_common/pico_runtime/runtime.c
浏览文件 @
4bc85624
...
...
@@ -27,6 +27,7 @@
#endif
extern
char
__StackLimit
;
/* Set by linker. */
extern
void
_exit
(
int
status
);
uint32_t
__attribute__
((
section
(
".ram_vector_table"
)))
ram_vector_table
[
48
];
...
...
@@ -136,57 +137,6 @@ void runtime_init(void) {
spin_locks_reset
();
irq_init_priorities
();
alarm_pool_init_default
();
// Start and end points of the constructor list,
// defined by the linker script.
extern
void
(
*
__init_array_start
)();
extern
void
(
*
__init_array_end
)();
// Call each function in the list.
// We have to take the address of the symbols, as __init_array_start *is*
// the first function pointer, not the address of it.
for
(
void
(
**
p
)()
=
&
__init_array_start
;
p
<
&
__init_array_end
;
++
p
)
{
(
*
p
)();
}
}
void
_exit
(
int
status
)
{
#if PICO_ENTER_USB_BOOT_ON_EXIT
reset_usb_boot
(
0
,
0
);
#else
while
(
1
)
{
__breakpoint
();
}
#endif
}
void
*
_sbrk
(
int
incr
)
{
extern
char
end
;
/* Set by linker. */
static
char
*
heap_end
;
char
*
prev_heap_end
;
if
(
heap_end
==
0
)
heap_end
=
&
end
;
prev_heap_end
=
heap_end
;
char
*
next_heap_end
=
heap_end
+
incr
;
if
(
__builtin_expect
(
next_heap_end
>=
(
&
__StackLimit
),
false
))
{
#if PICO_USE_OPTIMISTIC_SBRK
if
(
next_heap_end
==
&
__StackLimit
)
{
// errno = ENOMEM;
return
(
char
*
)
-
1
;
}
next_heap_end
=
&
__StackLimit
;
#else
return
(
char
*
)
-
1
;
#endif
}
heap_end
=
next_heap_end
;
return
(
void
*
)
prev_heap_end
;
}
// exit is not useful... no desire to pull in __call_exitprocs
...
...
bsp/raspberry-pico/link.ld
浏览文件 @
4bc85624
...
...
@@ -224,13 +224,6 @@ SECTIONS
__bss_end__ = .;
} > RAM
.heap (COPY):
{
__end__ = .;
end = __end__;
*(.heap*)
__HeapLimit = .;
} > RAM
/* .stack*_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of stack sections, and assign
...
...
@@ -263,7 +256,7 @@ SECTIONS
PROVIDE(__stack = __StackTop);
/* Check if data + heap + stack exceeds RAM limit */
ASSERT(__StackLimit >= __
HeapLimit
, "region RAM overflowed")
ASSERT(__StackLimit >= __
bss_end__
, "region RAM overflowed")
/* todo assert on extra code */
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录