Skip to content

Commit 8d119cc

Browse files
committed
Add sample C project
1 parent 47521b8 commit 8d119cc

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
cmake_minimum_required(VERSION 3.13)
2+
3+
include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake)
4+
5+
project(sample C CXX ASM)
6+
7+
set(CMAKE_C_STANDARD 11)
8+
set(CMAKE_CXX_STANDARD 17)
9+
10+
pico_sdk_init()
11+
12+
add_executable(sample main.c)
13+
14+
pico_enable_stdio_usb(sample 1)
15+
pico_enable_stdio_uart(sample 1)
16+
pico_add_extra_outputs(sample)
17+
18+
target_link_libraries(sample pico_stdlib)

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Raspberry Pi Pico Docker
1+
# Raspberry Pi Pico Docker SDK
22

33
## Run Docker container
44

@@ -9,3 +9,17 @@ docker run -d -it --name pico-sdk --mount type=bind,source=${PWD},target=/home/d
99
1010
docker exec -it pico-sdk /bin/sh
1111
```
12+
13+
## Project build
14+
15+
After attaching to SDK container run the following command to build the project:
16+
```
17+
cd /home/dev
18+
19+
mkdir build
20+
21+
cd build
22+
23+
cmake .. && make -j4
24+
25+
```

main.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <stdio.h>
2+
#include "pico/stdlib.h"
3+
#include "hardware/gpio.h"
4+
#include "pico/binary_info.h"
5+
6+
int LED_PIN = 25;
7+
8+
int main ()
9+
{
10+
bi_decl(bi_program_description("Sample binary"));
11+
bi_decl(bi_1pin_with_name(LED_PIN, "on-board PIN"));
12+
13+
stdio_init_all();
14+
15+
gpio_init();
16+
gpio_set_dir(LED_PIN, GPIO_OUT);
17+
18+
while(1)
19+
{
20+
gpio_put(LED_PIN, 0);
21+
sleep_ms(250);
22+
gpio_put(LED_PIN, 1);
23+
puts("Hello Word\n");
24+
sleep_ms(1000);
25+
}
26+
}
27+

0 commit comments

Comments
 (0)