Compare commits
No commits in common. "1561b1285795948a77a13133f1432da00a01ae1d" and "5e832a478116f556e10366faac1bc7e82840dc82" have entirely different histories.
1561b12857
...
5e832a4781
17
.devcontainer/Dockerfile
Normal file
17
.devcontainer/Dockerfile
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
FROM mcr.microsoft.com/devcontainers/base:dev-ubuntu-20.04
|
||||||
|
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
# 安装基础依赖
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
python3 python3-pip python3-venv \
|
||||||
|
git curl build-essential && \
|
||||||
|
apt-get autoremove -y && \
|
||||||
|
apt-get clean && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
|
||||||
|
# 安装 PlatformIO Core
|
||||||
|
RUN python3 -m pip install --upgrade platformio
|
||||||
|
|
||||||
|
WORKDIR /workspace
|
20
.devcontainer/devcontainer.json
Normal file
20
.devcontainer/devcontainer.json
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"name": "Embedded DevContainer",
|
||||||
|
"build": {
|
||||||
|
"dockerfile": "Dockerfile",
|
||||||
|
"context": ".."
|
||||||
|
},
|
||||||
|
"remoteUser": "vscode",
|
||||||
|
"customizations": {
|
||||||
|
"vscode": {
|
||||||
|
"extensions": [
|
||||||
|
"ms-vscode.cpptools" // C/C++ 调试支持
|
||||||
|
],
|
||||||
|
"settings": {
|
||||||
|
"platformio-ide.useBuiltinPython": false, // 使用容器内 Python
|
||||||
|
"platformio-ide.customPATH": "/usr/local/bin"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"postCreateCommand": "platformio upgrade --dev && pio init && echo '环境初始化完成'" // 初始化 PlatformIO
|
||||||
|
}
|
21
.gitea/workflows/ci.yaml
Normal file
21
.gitea/workflows/ci.yaml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
name: CI Pipeline
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: 🔍 Check out repository code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: 🔧 Test Codes
|
||||||
|
run: |
|
||||||
|
set -e # 任何命令失败都停止执行
|
||||||
|
|
||||||
|
echo "Building repository code ${{ gitea.repository }}:${{ gitea.ref }}."
|
37
include/README
Normal file
37
include/README
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
This directory is intended for project header files.
|
||||||
|
|
||||||
|
A header file is a file containing C declarations and macro definitions
|
||||||
|
to be shared between several project source files. You request the use of a
|
||||||
|
header file in your project source file (C, C++, etc) located in `src` folder
|
||||||
|
by including it, with the C preprocessing directive `#include'.
|
||||||
|
|
||||||
|
```src/main.c
|
||||||
|
|
||||||
|
#include "header.h"
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
{
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Including a header file produces the same results as copying the header file
|
||||||
|
into each source file that needs it. Such copying would be time-consuming
|
||||||
|
and error-prone. With a header file, the related declarations appear
|
||||||
|
in only one place. If they need to be changed, they can be changed in one
|
||||||
|
place, and programs that include the header file will automatically use the
|
||||||
|
new version when next recompiled. The header file eliminates the labor of
|
||||||
|
finding and changing all the copies as well as the risk that a failure to
|
||||||
|
find one copy will result in inconsistencies within a program.
|
||||||
|
|
||||||
|
In C, the convention is to give header files names that end with `.h'.
|
||||||
|
|
||||||
|
Read more about using header files in official GCC documentation:
|
||||||
|
|
||||||
|
* Include Syntax
|
||||||
|
* Include Operation
|
||||||
|
* Once-Only Headers
|
||||||
|
* Computed Includes
|
||||||
|
|
||||||
|
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
46
lib/README
Normal file
46
lib/README
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
|
||||||
|
This directory is intended for project specific (private) libraries.
|
||||||
|
PlatformIO will compile them to static libraries and link into the executable file.
|
||||||
|
|
||||||
|
The source code of each library should be placed in a separate directory
|
||||||
|
("lib/your_library_name/[Code]").
|
||||||
|
|
||||||
|
For example, see the structure of the following example libraries `Foo` and `Bar`:
|
||||||
|
|
||||||
|
|--lib
|
||||||
|
| |
|
||||||
|
| |--Bar
|
||||||
|
| | |--docs
|
||||||
|
| | |--examples
|
||||||
|
| | |--src
|
||||||
|
| | |- Bar.c
|
||||||
|
| | |- Bar.h
|
||||||
|
| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
||||||
|
| |
|
||||||
|
| |--Foo
|
||||||
|
| | |- Foo.c
|
||||||
|
| | |- Foo.h
|
||||||
|
| |
|
||||||
|
| |- README --> THIS FILE
|
||||||
|
|
|
||||||
|
|- platformio.ini
|
||||||
|
|--src
|
||||||
|
|- main.c
|
||||||
|
|
||||||
|
Example contents of `src/main.c` using Foo and Bar:
|
||||||
|
```
|
||||||
|
#include <Foo.h>
|
||||||
|
#include <Bar.h>
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
{
|
||||||
|
...
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
The PlatformIO Library Dependency Finder will find automatically dependent
|
||||||
|
libraries by scanning project source files.
|
||||||
|
|
||||||
|
More information about PlatformIO Library Dependency Finder
|
||||||
|
- https://docs.platformio.org/page/librarymanager/ldf.html
|
64
src/main.c
Normal file
64
src/main.c
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/* Copyright 2018 Canaan Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#include <devices.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <FreeRTOS.h>
|
||||||
|
#include <task.h>
|
||||||
|
#include "project_cfg.h"
|
||||||
|
|
||||||
|
handle_t gio;
|
||||||
|
|
||||||
|
void vTask1()
|
||||||
|
{
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
int val = gpio_get_pin_value(gio, 2);
|
||||||
|
|
||||||
|
printf("The PIN is %d\n", val);
|
||||||
|
vTaskDelay(500 / portTICK_RATE_MS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void vTask2()
|
||||||
|
{
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
static int val = 0;
|
||||||
|
|
||||||
|
gpio_set_pin_value(gio, 3, val = !val);
|
||||||
|
vTaskDelay(1000 / portTICK_RATE_MS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
gio = io_open("/dev/gpio0");
|
||||||
|
configASSERT(gio);
|
||||||
|
|
||||||
|
gpio_set_drive_mode(gio, 2, GPIO_DM_INPUT);
|
||||||
|
gpio_set_drive_mode(gio, 3, GPIO_DM_OUTPUT);
|
||||||
|
gpio_set_pin_value(gio, 3, GPIO_PV_HIGH);
|
||||||
|
|
||||||
|
vTaskSuspendAll();
|
||||||
|
xTaskCreate(vTask1, "vTask1", 512, NULL, 3, NULL);
|
||||||
|
xTaskCreate(vTask2, "vTask2", 128, NULL, 2, NULL);
|
||||||
|
if (!xTaskResumeAll())
|
||||||
|
{
|
||||||
|
taskYIELD();
|
||||||
|
}
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
;
|
||||||
|
}
|
28
src/project_cfg.h
Normal file
28
src/project_cfg.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/* Copyright 2018 Canaan Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#ifndef _PROJECT_CFG_H_
|
||||||
|
#define _PROJECT_CFG_H_
|
||||||
|
#include <pin_cfg.h>
|
||||||
|
|
||||||
|
const fpioa_cfg_t g_fpioa_cfg =
|
||||||
|
{
|
||||||
|
.version = PIN_CFG_VERSION,
|
||||||
|
.functions_count = 2,
|
||||||
|
.functions =
|
||||||
|
{
|
||||||
|
{14, FUNC_GPIOHS2},
|
||||||
|
{14, FUNC_GPIOHS3}}};
|
||||||
|
|
||||||
|
#endif
|
11
test/README
Normal file
11
test/README
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
This directory is intended for PlatformIO Test Runner and project tests.
|
||||||
|
|
||||||
|
Unit Testing is a software testing method by which individual units of
|
||||||
|
source code, sets of one or more MCU program modules together with associated
|
||||||
|
control data, usage procedures, and operating procedures, are tested to
|
||||||
|
determine whether they are fit for use. Unit testing finds problems early
|
||||||
|
in the development cycle.
|
||||||
|
|
||||||
|
More information about PlatformIO Unit Testing:
|
||||||
|
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html
|
Loading…
Reference in New Issue
Block a user