Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
github-classroom[bot] authored Nov 4, 2024
0 parents commit d996d41
Show file tree
Hide file tree
Showing 15 changed files with 386 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"image": "rafaelcorsi/embarcados",
"remoteEnv": {
"WOKWI_CLI_TOKEN": "${localEnv:WOKWI_CLI_TOKEN}"
},
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined",
"--privileged",
"-v", "/dev/bus/usb:/dev/bus/usb",
"--device=/dev/bus/usb",
"--device=/dev/ttyACM0"
],
"customizations": {
"vscode": {
"extensions": [
"marus25.cortex-debug",
"mcu-debug.debug-tracker-vscode",
"mcu-debug.memory-view",
"mcu-debug.peripheral-viewer",
"mcu-debug.rtos-views",
"ms-vscode.cmake-tools",
"ms-vscode.cpptools",
"ms-vscode.cpptools-extension-pack",
"ms-vscode.cpptools-themes",
"ms-vscode.vscode-serial-monitor",
"twxs.cmake",
"wokwi.wokwi-vscode",
"seunlanlege.action-buttons"
]
},
"settings":{
"cmake.statusbar.advanced": {
"cpack": {"statusBarVisibility": "hidden"},
"debug": {
"statusBarVisibility": "hidden",
"inheritDefault": "hidden"
},
"launch": {
"visibility": "visible"
},
"build": {
"visibility": "hidden"
},
"buildTarget": {
"statusBarVisibility": "hidden",
"visibility": "hidden"
}

}
}
}

}
11 changes: 11 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: build pico

on:
push:
jobs:

Testing:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: insper-embarcados/pico-build@v0
13 changes: 13 additions & 0 deletions .github/workflows/cppcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: cppcheck

on:
push:
jobs:

Testing:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: insper-embarcados/actions-cppcheck@v1
with:
c_file: main/main.c
13 changes: 13 additions & 0 deletions .github/workflows/embedded-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: embedded-check

on:
push:
jobs:

Testing:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: insper-embarcados/actions-embedded-check@v1
with:
c_file: main/main.c
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": ["ms-vscode.cpptools", "ms-vscode.cpptools-extension-pack", "ms-vscode.cpptools-themes",
"twxs.cmake", "ms-vscode.cmake-tools", "marus25.cortex-debug", "mcu-debug.debug-tracker-vscode",
"mcu-debug.memory-view", "mcu-debug.peripheral-viewer", "mcu-debug.rtos-views", "ms-vscode.vscode-serial-monitor",
"Wokwi.wokwi-vscode"]
}

28 changes: 28 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Pico Debug",
"cwd": "${workspaceRoot}",
"executable": "${command:cmake.launchTargetPath}",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
// This may need to be "arm-none-eabi-gdb" for some previous builds
"gdbPath" : "gdb-multiarch",
"device": "RP2040",
"configFiles": ["interface/cmsis-dap.cfg", "target/rp2040.cfg"],
"svdFile": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.svd",
"runToEntryPoint": "main",
"openOCDLaunchCommands": [
"adapter speed 5000"
],
// Work around for stopping at main on restart
"postRestartCommands": [
"break main",
"continue"
],

}
]
}
47 changes: 47 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
// These settings tweaks to the cmake plugin will ensure
// that you debug using cortex-debug instead of trying to launch
// a Pico binary on the host

"cmake.buildBeforeRun": true,
"cmake.configureOnOpen": true,
"cmake.ctest.allowParallelJobs": true,
"cmake.parallelJobs": 8,
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",


// actions task buttons
"actionButtons": {
"defaultColor": "#ff0034", // Can also use string color names.
"loadNpmCommands":false, // Disables automatic generation of actions for npm commands.
"reloadButton":"", // Custom reload button text or icon (default ↻). null value enables automatic reload on configuration change
"commands": [
{
"name": "$(rocket) ",
"color": "white",
"useVsCodeApi": true,
"command": "workbench.action.tasks.runTask",
"args": ["Flash"]
}
]
},

// CMake Tools Status Bar Configuration
"cmake.statusbar.advanced": {
"debug": {
"visibility": "hidden"
},
"launch": {
"visibility": "visible"
},
"build": {
"visibility": "hidden"
},
"buildTarget": {
"visibility": "hidden"
}
}


}

21 changes: 21 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Flash",
"type": "shell",
"command": "openocd",
"args": [
"-f",
"interface/cmsis-dap.cfg",
"-f",
"target/rp2040.cfg",
"-c",
"adapter speed 5000; program {${command:cmake.launchTargetPath}} verify reset exit"
],
"problemMatcher": []
}

]
}

33 changes: 33 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
cmake_minimum_required(VERSION 3.12)

# Pull in SDK (must be before project)
include(pico_sdk_import.cmake)

include(pico_extras_import_optional.cmake)

project(pico_emb C CXX ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

if(PICO_SDK_VERSION_STRING VERSION_LESS "1.3.0")
message(
FATAL_ERROR
"Raspberry Pi Pico SDK version 1.3.0 (or later) required. Your version is ${PICO_SDK_VERSION_STRING}"
)
endif()

# Initialize the SDK
pico_sdk_init()

add_compile_options(
-Wall -Wno-format # int != int32_t as far as the compiler is concerned because
# gcc has int32_t as long int
-Wno-unused-function # we have some for the docs that aren't called
)

if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
add_compile_options(-Wno-maybe-uninitialized)
endif()

# Codes subdir:
add_subdirectory(main)
7 changes: 7 additions & 0 deletions main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
add_executable(main main.c)

# pull in common dependencies
target_link_libraries(main pico_stdlib)

# create map/bin/hex/uf2 file etc.
pico_add_extra_outputs(main)
17 changes: 17 additions & 0 deletions main/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/

#include <stdio.h>
#include "pico/stdlib.h"
#include "hardware/gpio.h"

int main() {
stdio_init_all();
while (true) {
printf("Hello, world!\n");
sleep_ms(1000);
}
}
1 change: 1 addition & 0 deletions pico.code-profile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"pico","icon":"dashboard","settings":"{\"settings\":\"{\\n \\\"window.zoomLevel\\\": 1,\\n \\\"cmake.configureOnOpen\\\": true\\n}\"}","extensions":"[{\"identifier\":{\"id\":\"marus25.cortex-debug\",\"uuid\":\"2fd8abff-b3ce-46c9-a6a8-92d5ad69d8d0\"},\"displayName\":\"Cortex-Debug\"},{\"identifier\":{\"id\":\"mcu-debug.debug-tracker-vscode\",\"uuid\":\"bd8507f9-4b21-4877-b045-1f20471fe96e\"},\"displayName\":\"debug-tracker-vscode\"},{\"identifier\":{\"id\":\"mcu-debug.memory-view\",\"uuid\":\"f319e29a-19e8-43fb-8e3e-e264b6144083\"},\"displayName\":\"MemoryView\"},{\"identifier\":{\"id\":\"mcu-debug.peripheral-viewer\",\"uuid\":\"e6f326b2-3602-4e64-9cd1-ebe454be1992\"},\"displayName\":\"Peripheral Viewer\"},{\"identifier\":{\"id\":\"mcu-debug.rtos-views\",\"uuid\":\"0b85f1d6-1d95-4f57-bacd-ca639159f71d\"},\"displayName\":\"RTOS Views\"},{\"identifier\":{\"id\":\"ms-vscode.cmake-tools\",\"uuid\":\"7c889349-8749-43d4-8b5e-08939936d7f4\"},\"displayName\":\"CMake Tools\"},{\"identifier\":{\"id\":\"ms-vscode.cpptools\",\"uuid\":\"690b692e-e8a9-493f-b802-8089d50ac1b2\"},\"displayName\":\"C/C++\"},{\"identifier\":{\"id\":\"ms-vscode.cpptools-extension-pack\",\"uuid\":\"3957b2f6-f086-49b5-a7b4-5da772123130\"},\"displayName\":\"C/C++ Extension Pack\"},{\"identifier\":{\"id\":\"ms-vscode.cpptools-themes\",\"uuid\":\"99b17261-8f6e-45f0-9ad5-a69c6f509a4f\"},\"displayName\":\"C/C++ Themes\"},{\"identifier\":{\"id\":\"ms-vscode.vscode-serial-monitor\",\"uuid\":\"17dcad22-0c4b-428f-8a04-5d2629f1480e\"},\"displayName\":\"Serial Monitor\"},{\"identifier\":{\"id\":\"twxs.cmake\",\"uuid\":\"2be7cf14-2603-402e-9771-fd79df83cdf8\"},\"displayName\":\"CMake\"},{\"identifier\":{\"id\":\"wokwi.wokwi-vscode\",\"uuid\":\"51c34fa3-18ea-4f95-aae8-1dbe5438fe31\"},\"displayName\":\"Wokwi Simulator\"}]"}
59 changes: 59 additions & 0 deletions pico_extras_import_optional.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This is a copy of <PICO_EXTRAS_PATH>/external/pico_extras_import.cmake

# This can be dropped into an external project to help locate pico-extras
# It should be include()ed prior to project()

if (DEFINED ENV{PICO_EXTRAS_PATH} AND (NOT PICO_EXTRAS_PATH))
set(PICO_EXTRAS_PATH $ENV{PICO_EXTRAS_PATH})
message("Using PICO_EXTRAS_PATH from environment ('${PICO_EXTRAS_PATH}')")
endif ()

if (DEFINED ENV{PICO_EXTRAS_FETCH_FROM_GIT} AND (NOT PICO_EXTRAS_FETCH_FROM_GIT))
set(PICO_EXTRAS_FETCH_FROM_GIT $ENV{PICO_EXTRAS_FETCH_FROM_GIT})
message("Using PICO_EXTRAS_FETCH_FROM_GIT from environment ('${PICO_EXTRAS_FETCH_FROM_GIT}')")
endif ()

if (DEFINED ENV{PICO_EXTRAS_FETCH_FROM_GIT_PATH} AND (NOT PICO_EXTRAS_FETCH_FROM_GIT_PATH))
set(PICO_EXTRAS_FETCH_FROM_GIT_PATH $ENV{PICO_EXTRAS_FETCH_FROM_GIT_PATH})
message("Using PICO_EXTRAS_FETCH_FROM_GIT_PATH from environment ('${PICO_EXTRAS_FETCH_FROM_GIT_PATH}')")
endif ()

if (NOT PICO_EXTRAS_PATH)
if (PICO_EXTRAS_FETCH_FROM_GIT)
include(FetchContent)
set(FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR})
if (PICO_EXTRAS_FETCH_FROM_GIT_PATH)
get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_EXTRAS_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
endif ()
FetchContent_Declare(
pico_extras
GIT_REPOSITORY https://github.com/raspberrypi/pico-extras
GIT_TAG master
)
if (NOT pico_extras)
message("Downloading Raspberry Pi Pico Extras")
FetchContent_Populate(pico_extras)
set(PICO_EXTRAS_PATH ${pico_extras_SOURCE_DIR})
endif ()
set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE})
else ()
if (PICO_SDK_PATH AND EXISTS "${PICO_SDK_PATH}/../pico-extras")
set(PICO_EXTRAS_PATH ${PICO_SDK_PATH}/../pico-extras)
message("Defaulting PICO_EXTRAS_PATH as sibling of PICO_SDK_PATH: ${PICO_EXTRAS_PATH}")
endif()
endif ()
endif ()

if (PICO_EXTRAS_PATH)
set(PICO_EXTRAS_PATH "${PICO_EXTRAS_PATH}" CACHE PATH "Path to the PICO EXTRAS")
set(PICO_EXTRAS_FETCH_FROM_GIT "${PICO_EXTRAS_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of PICO EXTRAS from git if not otherwise locatable")
set(PICO_EXTRAS_FETCH_FROM_GIT_PATH "${PICO_EXTRAS_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download EXTRAS")

get_filename_component(PICO_EXTRAS_PATH "${PICO_EXTRAS_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")
if (NOT EXISTS ${PICO_EXTRAS_PATH})
message(FATAL_ERROR "Directory '${PICO_EXTRAS_PATH}' not found")
endif ()

set(PICO_EXTRAS_PATH ${PICO_EXTRAS_PATH} CACHE PATH "Path to the PICO EXTRAS" FORCE)
add_subdirectory(${PICO_EXTRAS_PATH} pico_extras)
endif()
Loading

0 comments on commit d996d41

Please sign in to comment.