[bsp][raspberry-pico]add gpio drivers
This commit is contained in:
parent
e3604553c7
commit
76331797cd
|
@ -123,7 +123,7 @@ CONFIG_RT_SERIAL_RB_BUFSZ=64
|
|||
# CONFIG_RT_USING_CPUTIME is not set
|
||||
# CONFIG_RT_USING_I2C is not set
|
||||
# CONFIG_RT_USING_PHY is not set
|
||||
# CONFIG_RT_USING_PIN is not set
|
||||
CONFIG_RT_USING_PIN=y
|
||||
# CONFIG_RT_USING_ADC is not set
|
||||
# CONFIG_RT_USING_DAC is not set
|
||||
# CONFIG_RT_USING_PWM is not set
|
||||
|
@ -274,7 +274,6 @@ CONFIG_RT_LIBC_USING_TIME=y
|
|||
# CONFIG_PKG_USING_PDULIB is not set
|
||||
# CONFIG_PKG_USING_BTSTACK is not set
|
||||
# CONFIG_PKG_USING_LORAWAN_ED_STACK is not set
|
||||
# CONFIG_PKG_USING_WAYZ_IOTKIT is not set
|
||||
|
||||
#
|
||||
# security packages
|
||||
|
@ -314,8 +313,6 @@ CONFIG_RT_LIBC_USING_TIME=y
|
|||
# CONFIG_PKG_USING_RDB is not set
|
||||
# CONFIG_PKG_USING_QRCODE is not set
|
||||
# CONFIG_PKG_USING_ULOG_EASYFLASH is not set
|
||||
# CONFIG_PKG_USING_ULOG_FILE is not set
|
||||
# CONFIG_PKG_USING_LOGMGR is not set
|
||||
# CONFIG_PKG_USING_ADBD is not set
|
||||
# CONFIG_PKG_USING_COREMARK is not set
|
||||
# CONFIG_PKG_USING_DHRYSTONE is not set
|
||||
|
@ -328,11 +325,6 @@ CONFIG_RT_LIBC_USING_TIME=y
|
|||
# CONFIG_PKG_USING_URLENCODE is not set
|
||||
# CONFIG_PKG_USING_UMCN is not set
|
||||
# CONFIG_PKG_USING_LWRB2RTT is not set
|
||||
# CONFIG_PKG_USING_CPU_USAGE is not set
|
||||
# CONFIG_PKG_USING_GBK2UTF8 is not set
|
||||
# CONFIG_PKG_USING_VCONSOLE is not set
|
||||
# CONFIG_PKG_USING_KDB is not set
|
||||
# CONFIG_PKG_USING_WAMR is not set
|
||||
|
||||
#
|
||||
# system packages
|
||||
|
@ -370,12 +362,6 @@ CONFIG_RT_LIBC_USING_TIME=y
|
|||
# CONFIG_PKG_USING_UC_COMMON is not set
|
||||
# CONFIG_PKG_USING_UC_MODBUS is not set
|
||||
# CONFIG_PKG_USING_PPOOL is not set
|
||||
# CONFIG_PKG_USING_OPENAMP is not set
|
||||
# CONFIG_PKG_USING_RT_PRINTF is not set
|
||||
# CONFIG_PKG_USING_RT_MEMCPY_CM is not set
|
||||
# CONFIG_PKG_USING_QFPLIB_M0_FULL is not set
|
||||
# CONFIG_PKG_USING_QFPLIB_M0_TINY is not set
|
||||
# CONFIG_PKG_USING_QFPLIB_M3 is not set
|
||||
|
||||
#
|
||||
# peripheral libraries and drivers
|
||||
|
@ -384,7 +370,6 @@ CONFIG_RT_LIBC_USING_TIME=y
|
|||
# CONFIG_PKG_USING_REALTEK_AMEBA is not set
|
||||
# CONFIG_PKG_USING_SHT2X is not set
|
||||
# CONFIG_PKG_USING_SHT3X is not set
|
||||
# CONFIG_PKG_USING_AS7341 is not set
|
||||
# CONFIG_PKG_USING_STM32_SDIO is not set
|
||||
# CONFIG_PKG_USING_ICM20608 is not set
|
||||
# CONFIG_PKG_USING_U8G2 is not set
|
||||
|
@ -434,10 +419,6 @@ CONFIG_RT_LIBC_USING_TIME=y
|
|||
# CONFIG_PKG_USING_SSD1306 is not set
|
||||
# CONFIG_PKG_USING_QKEY is not set
|
||||
# CONFIG_PKG_USING_RS485 is not set
|
||||
# CONFIG_PKG_USING_NES is not set
|
||||
# CONFIG_PKG_USING_VIRTUAL_SENSOR is not set
|
||||
# CONFIG_PKG_USING_VDEVICE is not set
|
||||
# CONFIG_PKG_USING_SGM706 is not set
|
||||
|
||||
#
|
||||
# miscellaneous packages
|
||||
|
@ -447,7 +428,6 @@ CONFIG_RT_LIBC_USING_TIME=y
|
|||
# CONFIG_PKG_USING_FASTLZ is not set
|
||||
# CONFIG_PKG_USING_MINILZO is not set
|
||||
# CONFIG_PKG_USING_QUICKLZ is not set
|
||||
# CONFIG_PKG_USING_LZMA is not set
|
||||
# CONFIG_PKG_USING_MULTIBUTTON is not set
|
||||
# CONFIG_PKG_USING_FLEXIBLE_BUTTON is not set
|
||||
# CONFIG_PKG_USING_CANFESTIVAL is not set
|
||||
|
@ -483,11 +463,9 @@ CONFIG_RT_LIBC_USING_TIME=y
|
|||
#
|
||||
# CONFIG_PKG_USING_THREES is not set
|
||||
# CONFIG_PKG_USING_2048 is not set
|
||||
# CONFIG_PKG_USING_SNAKE is not set
|
||||
# CONFIG_PKG_USING_TETRIS is not set
|
||||
# CONFIG_PKG_USING_LWGPS is not set
|
||||
# CONFIG_PKG_USING_TENSORFLOWLITEMICRO is not set
|
||||
# CONFIG_PKG_USING_STATE_MACHINE is not set
|
||||
|
||||
#
|
||||
# Privated Packages of RealThread
|
||||
|
@ -525,10 +503,6 @@ CONFIG_RT_LIBC_USING_TIME=y
|
|||
# CONFIG_PKG_USING_EMQ is not set
|
||||
# CONFIG_PKG_USING_CFGM is not set
|
||||
# CONFIG_PKG_USING_RT_CMSIS_DAP is not set
|
||||
# CONFIG_PKG_USING_VIRTUAL_DEVICE is not set
|
||||
# CONFIG_PKG_USING_SMODULE is not set
|
||||
# CONFIG_PKG_USING_SNFD is not set
|
||||
# CONFIG_PKG_USING_UDBD is not set
|
||||
# CONFIG_PKG_USING_BENCHMARK is not set
|
||||
# CONFIG_PKG_USING_UBJSON is not set
|
||||
# CONFIG_PKG_USING_DATATYPE is not set
|
||||
CONFIG_SOC_RP2040=y
|
||||
|
|
|
@ -1,6 +1,37 @@
|
|||
# Raspberry PICO
|
||||
|
||||
## Build
|
||||
## Introduction
|
||||
|
||||
**Raspberry Pi Pico is a low-cost, high-performance microcontroller board with flexible digital interfaces.**
|
||||
|
||||
**Key features include:**
|
||||
|
||||
- RP2040 microcontroller chip designed by Raspberry Pi in the United Kingdom
|
||||
- Dual-core Arm Cortex M0+ processor, flexible clock running up to 133 MHz
|
||||
- 264KB of SRAM, and 2MB of on-board Flash memory
|
||||
- Castellated module allows soldering direct to carrier boards
|
||||
- USB 1.1 with device and host support
|
||||
- Low-power sleep and dormant modes
|
||||
|
||||
- Drag-and-drop programming using mass storage over USB
|
||||
- 26 × multi-function GPIO pins
|
||||
- 2 × SPI, 2 × I2C, 2 × UART, 3 × 12-bit ADC, 16 × controllable PWM channels
|
||||
- Accurate clock and timer on-chip
|
||||
- Temperature sensor
|
||||
- Accelerated floating-point libraries on-chip
|
||||
- 8 × Programmable I/O (PIO) state machines for custom peripheral support
|
||||
|
||||
|
||||
|
||||
![Pico-R3-Pinout](figures/Pico-R3-Pinout.svg)
|
||||
|
||||
## Supported compiler
|
||||
|
||||
Support GCC 6 and above compilers.
|
||||
|
||||
## Program firmware
|
||||
|
||||
### Step 1: build
|
||||
|
||||
```
|
||||
scons -c
|
||||
|
@ -9,16 +40,20 @@ scons
|
|||
|
||||
**gcc version >= 6.x.x**
|
||||
|
||||
## Flash
|
||||
### Step 2: flash
|
||||
|
||||
Run the following command in the linux environment.
|
||||
|
||||
```
|
||||
./Libraries/generated/elf2uf2 rtthread-pico.elf rtthread-pico.uf2
|
||||
./libraries/generated/elf2uf2 rtthread-pico.elf rtthread-pico.uf2
|
||||
```
|
||||
|
||||
- Copy the rtthread-pico.uf2 file to the "RPI-RP2" disk
|
||||
- Then led blink.
|
||||
|
||||
## Run
|
||||
## Running Result
|
||||
|
||||
The output information on serial port should be like this:
|
||||
|
||||
```
|
||||
\ | /
|
||||
|
@ -29,3 +64,16 @@ Hello, RT-Thread!
|
|||
msh >
|
||||
```
|
||||
|
||||
## Peripheral Condition
|
||||
|
||||
| Drive | Support | Remark |
|
||||
| ----- | ------- | ------ |
|
||||
| UART | Support | UART0 |
|
||||
| GPIO | Support | 0-29 |
|
||||
| I2C | - | - |
|
||||
| RTC | - | - |
|
||||
| SDIO | - | - |
|
||||
| SPI | - | - |
|
||||
| TIMER | - | - |
|
||||
| WDT | - | - |
|
||||
|
||||
|
|
|
@ -27,11 +27,5 @@ Export('rtconfig')
|
|||
# prepare building environment
|
||||
objs = PrepareBuilding(env, RTT_ROOT)
|
||||
|
||||
#if GetDepend('RT_USING_RTGUI'):
|
||||
# objs = objs + SConscript(RTT_ROOT + '/examples/gui/SConscript', variant_dir='build/examples/gui', duplicate=0)
|
||||
|
||||
# libc testsuite
|
||||
# objs = objs + SConscript(RTT_ROOT + '/examples/libc/SConscript', variant_dir='build/examples/libc', duplicate=0)
|
||||
|
||||
# make a building
|
||||
DoBuilding(TARGET, objs)
|
||||
|
|
|
@ -5,20 +5,21 @@
|
|||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
|
||||
#include "board.h"
|
||||
|
||||
int main() {
|
||||
const uint LED_PIN = 25;
|
||||
#define LED_PIN 25
|
||||
|
||||
int main(void)
|
||||
{
|
||||
rt_kprintf("Hello, RT-Thread!\n");
|
||||
|
||||
gpio_init(LED_PIN);
|
||||
gpio_set_dir(LED_PIN, GPIO_OUT);
|
||||
while (true) {
|
||||
gpio_put(LED_PIN, 1);
|
||||
rt_pin_mode(LED_PIN, PIN_MODE_OUTPUT);
|
||||
|
||||
while (1)
|
||||
{
|
||||
rt_pin_write(LED_PIN, 1);
|
||||
rt_thread_mdelay(1000);
|
||||
gpio_put(LED_PIN, 0);
|
||||
rt_pin_write(LED_PIN, 0);
|
||||
rt_thread_mdelay(1000);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Copyright (c) 2006-2019, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2019-07-29 zdzn first version
|
||||
*/
|
||||
|
||||
#include "drv_gpio.h"
|
||||
|
||||
static void pico_pin_mode(struct rt_device *dev, rt_base_t pin, rt_base_t mode)
|
||||
{
|
||||
RT_ASSERT((0 <= pin) && (pin < N_GPIOS));
|
||||
|
||||
gpio_init(pin);
|
||||
switch (mode)
|
||||
{
|
||||
case PIN_MODE_OUTPUT:
|
||||
gpio_set_dir(pin, GPIO_OUT);
|
||||
break;
|
||||
case PIN_MODE_INPUT:
|
||||
gpio_set_dir(pin, GPIO_IN);
|
||||
break;
|
||||
case PIN_MODE_INPUT_PULLUP:
|
||||
gpio_pull_up(pin);
|
||||
break;
|
||||
case PIN_MODE_INPUT_PULLDOWN:
|
||||
gpio_pull_down(pin);
|
||||
break;
|
||||
case PIN_MODE_OUTPUT_OD:
|
||||
gpio_disable_pulls(pin);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void pico_pin_write(struct rt_device *dev, rt_base_t pin, rt_base_t value)
|
||||
{
|
||||
RT_ASSERT((0 <= pin) && (pin < N_GPIOS));
|
||||
gpio_put(pin, value);
|
||||
}
|
||||
|
||||
static int pico_pin_read(struct rt_device *device, rt_base_t pin)
|
||||
{
|
||||
RT_ASSERT((0 <= pin) && (pin < N_GPIOS));
|
||||
return (gpio_get(pin)? PIN_HIGH : PIN_LOW);
|
||||
}
|
||||
|
||||
static const struct rt_pin_ops ops =
|
||||
{
|
||||
pico_pin_mode,
|
||||
pico_pin_write,
|
||||
pico_pin_read,
|
||||
RT_NULL,
|
||||
RT_NULL,
|
||||
RT_NULL,
|
||||
RT_NULL,
|
||||
};
|
||||
|
||||
int rt_hw_gpio_init(void)
|
||||
{
|
||||
rt_device_pin_register("gpio", &ops, RT_NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
INIT_DEVICE_EXPORT(rt_hw_gpio_init);
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright (c) 2006-2019, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2019-07-29 zdzn first version
|
||||
*/
|
||||
|
||||
#ifndef __DRV_GPIO_H__
|
||||
#define __DRV_GPIO_H__
|
||||
|
||||
#include <rtdevice.h>
|
||||
#include <rtthread.h>
|
||||
|
||||
#include "board.h"
|
||||
|
||||
int rt_hw_gpio_init(void);
|
||||
|
||||
#endif /* __DRV_GPIO_H__ */
|
File diff suppressed because it is too large
Load Diff
After Width: | Height: | Size: 412 KiB |
|
@ -55,19 +55,6 @@ pico-sdk/src/rp2_common/pico_standard_link/crt0.S
|
|||
generated/bs2_default_padded_checksummed.S
|
||||
""")
|
||||
|
||||
# # starupt scripts for STM32F2xx
|
||||
# startup_scripts = 'startup_stm32f2xx.s'
|
||||
|
||||
# # add for startup script
|
||||
# if rtconfig.CROSS_TOOL == 'gcc':
|
||||
# src = src + ['CMSIS/CM3/DeviceSupport/ST/STM32F2xx/startup/gcc_ride7/' + startup_scripts]
|
||||
# elif rtconfig.CROSS_TOOL == 'keil':
|
||||
# src = src + ['CMSIS/CM3/DeviceSupport/ST/STM32F2xx/startup/arm/' + startup_scripts]
|
||||
# elif rtconfig.CROSS_TOOL == 'iar':
|
||||
# src = src + ['CMSIS/CM3/DeviceSupport/ST/STM32F2xx/startup/iar/' + startup_scripts]
|
||||
|
||||
# /home/henson/Documents/rasp-pico/pico/pico-examples/build/generated/pico_base
|
||||
|
||||
path = [
|
||||
cwd + '/pico-sdk/src/common/pico_stdlib/include',
|
||||
cwd + '/pico-sdk/src/rp2_common/hardware_gpio/include',
|
||||
|
@ -106,14 +93,6 @@ path = [
|
|||
cwd + '/generated/pico_base'
|
||||
]
|
||||
|
||||
# path += [cwd + '/CMSIS/CM3/CoreSupport',
|
||||
# cwd + '/CMSIS/Include']
|
||||
|
||||
# if GetDepend('RT_USING_LWIP') == True:
|
||||
# src = src + ['STM32F2x7_ETH_Driver/src/stm32f2x7_eth.c']
|
||||
# path = path + [cwd + '/STM32F2x7_ETH_Driver/inc']
|
||||
|
||||
|
||||
CPPDEFINES = [
|
||||
'PICO_NO_BINARY_INFO',
|
||||
'PICO_NO_PROGRAM_INFO',
|
||||
|
|
|
@ -80,6 +80,7 @@
|
|||
#define RT_USING_SERIAL
|
||||
#define RT_SERIAL_USING_DMA
|
||||
#define RT_SERIAL_RB_BUFSZ 64
|
||||
#define RT_USING_PIN
|
||||
|
||||
/* Using USB */
|
||||
|
||||
|
|
Loading…
Reference in New Issue